removed the iterator in fly checks.
...
This commit is contained in:
@@ -3,10 +3,10 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||
import com.massivecraft.factions.struct.BanInfo;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -67,6 +67,15 @@ public class CmdBan extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
for (BanInfo banInfo : myFaction.getBannedPlayers()) {
|
||||
if (banInfo.getBanned().equals(target.getId())) {
|
||||
msg(TL.COMMAND_BAN_ALREADYBANNED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Ban the user.
|
||||
myFaction.ban(target, fme);
|
||||
myFaction.deinvite(target); // can't hurt
|
||||
|
||||
@@ -5,15 +5,14 @@ import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.particles.ParticleEffect;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class CmdFly extends FCommand {
|
||||
@@ -33,6 +32,81 @@ public class CmdFly extends FCommand {
|
||||
this.senderMustBeModerator = false;
|
||||
}
|
||||
|
||||
public static void startParticles() {
|
||||
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String name : flyMap.keySet()) {
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
if (!player.isFlying()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ParticleEffect.CLOUD.display(0, 0, 0, 0, 1, player.getLocation().add(0, -0.35, 0), 16);
|
||||
}
|
||||
if (flyMap.keySet().size() == 0) {
|
||||
Bukkit.getScheduler().cancelTask(id);
|
||||
id = -1;
|
||||
}
|
||||
}
|
||||
}, 10L, 10L);
|
||||
}
|
||||
|
||||
public static void startFlyCheck() {
|
||||
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String name : flyMap.keySet()) {
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
if (!player.isFlying()) {
|
||||
continue;
|
||||
}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
|
||||
if (fPlayer == null) {
|
||||
continue;
|
||||
}
|
||||
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) {
|
||||
continue;
|
||||
}
|
||||
Faction myFaction = fPlayer.getFaction();
|
||||
if (myFaction.isWilderness()) {
|
||||
fPlayer.setFlying(false);
|
||||
flyMap.remove(name);
|
||||
continue;
|
||||
}
|
||||
if (fPlayer.checkIfNearbyEnemies()) {
|
||||
continue;
|
||||
}
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
Faction toFac = Board.getInstance().getFactionAt(myFloc);
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!checkBypassPerms(fPlayer, player, toFac)) {
|
||||
fPlayer.setFlying(false);
|
||||
flyMap.remove(name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
checkTaskState();
|
||||
}
|
||||
}
|
||||
}, 20L, 20L);
|
||||
}
|
||||
|
||||
public boolean isInFlightChecker(Player player) {
|
||||
if (flyMap.containsKey(player.getName())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// Disabled by default.
|
||||
@@ -117,7 +191,7 @@ public class CmdFly extends FCommand {
|
||||
|
||||
}
|
||||
|
||||
toggleFlight(!fme.isFlying(),me);
|
||||
toggleFlight(!fme.isFlying(), me);
|
||||
} else if (args.size() == 1) {
|
||||
if (!fme.canFlyAtLocation() && argAsBool(0)) {
|
||||
if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness()) {
|
||||
@@ -148,82 +222,6 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInFlightChecker(Player player){
|
||||
if (flyMap.containsKey(player.getName())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void startParticles() {
|
||||
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Iterator<String> itr = flyMap.keySet().iterator();
|
||||
while (itr.hasNext()) {
|
||||
Player player = Bukkit.getPlayer(itr.next());
|
||||
if (player == null){
|
||||
continue;
|
||||
}
|
||||
if (!player.isFlying()){
|
||||
continue;
|
||||
}
|
||||
|
||||
ParticleEffect.CLOUD.display(0, 0, 0, 0, 1, player.getLocation().add(0, -0.35, 0), 16);
|
||||
}
|
||||
if (flyMap.keySet().size() == 0){
|
||||
Bukkit.getScheduler().cancelTask(id);
|
||||
id = -1;
|
||||
}
|
||||
}
|
||||
}, 10L, 10L);
|
||||
}
|
||||
|
||||
public static void startFlyCheck() {
|
||||
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Iterator itr = flyMap.keySet().iterator();
|
||||
while (itr.hasNext()) {
|
||||
Object nameObj = itr.next();
|
||||
String name = nameObj + "";
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player == null) { continue;}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
|
||||
if (fPlayer == null) { continue; }
|
||||
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR){
|
||||
continue;
|
||||
}
|
||||
Faction myFaction = fPlayer.getFaction();
|
||||
if (myFaction.isWilderness()){
|
||||
fPlayer.setFlying(false);
|
||||
flyMap.remove(name);
|
||||
continue;
|
||||
}
|
||||
if(fPlayer.checkIfNearbyEnemies()){
|
||||
continue;
|
||||
}
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
Faction toFac = Board.getInstance().getFactionAt(myFloc);
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!checkBypassPerms(fPlayer,player,toFac)){
|
||||
fPlayer.setFlying(false);
|
||||
itr.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
checkTaskState();
|
||||
}
|
||||
}
|
||||
},20L,20L);
|
||||
}
|
||||
|
||||
|
||||
private static boolean checkBypassPerms(FPlayer fplayer, Player player, Faction toFac) {
|
||||
if (player.hasPermission("factions.fly.wilderness") && toFac.isWilderness()){
|
||||
@@ -257,10 +255,10 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void toggleFlight(final boolean toggle, final Player player) {
|
||||
if (!toggle) {
|
||||
fme.setFlying(false);
|
||||
|
||||
flyMap.remove(player.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
|
||||
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.particles.ParticleEffect;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -23,6 +22,7 @@ public class CmdSeeChunk extends FCommand {
|
||||
|
||||
private boolean useParticles;
|
||||
private int length;
|
||||
|
||||
private ParticleEffect effect;
|
||||
//Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn.
|
||||
public static HashMap<String, Boolean> seeChunkMap = new HashMap<>();
|
||||
@@ -125,12 +125,8 @@ public class CmdSeeChunk extends FCommand {
|
||||
if (loc.getBlock().getType() != Material.AIR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (useParticles) {
|
||||
|
||||
this.effect.display(0, 0, 0, 0, 3, loc, player);
|
||||
|
||||
|
||||
this.effect.display(0, 0, 0, 0, 1, loc, player);
|
||||
} else {
|
||||
int typeId = blockY % 5 == 0 ? Material.REDSTONE_LAMP_ON.getId() : Material.STAINED_GLASS.getId();
|
||||
VisualizeUtil.addLocation(player, loc, typeId);
|
||||
|
||||
@@ -30,6 +30,7 @@ public class CmdTitle extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
args.remove(0);
|
||||
String title = TextUtil.implode(args, " ");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user