removed the iterator in fly checks.
...
This commit is contained in:
parent
21587db74d
commit
12b9f94fe4
8
pom.xml
8
pom.xml
@ -47,6 +47,10 @@
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>com.massivecraft.factions.shade.com.google.gson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.darkblade12</pattern>
|
||||
<shadedPattern>com.massivecraft.factions.shade.com.darkblade12</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
@ -321,10 +325,6 @@
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>inventive-repo</id>
|
||||
<url>https://repo.inventivetalent.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>http://ci.ender.zone/plugin/repository/everything/</url>
|
||||
|
@ -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.
|
||||
@ -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, " ");
|
||||
|
||||
|
@ -18,9 +18,9 @@ import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
|
||||
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
import com.massivecraft.factions.zcore.util.particles.ParticleEffect;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -311,13 +311,14 @@ public class FactionsPlayerListener implements Listener {
|
||||
enableFly(me);
|
||||
}
|
||||
// bypass checks
|
||||
Relation relationTo = factionTo.getRelationTo(me);
|
||||
if ((factionTo.isWilderness() && me.canflyinWilderness()) ||
|
||||
(factionTo.isWarZone() && me.canflyinWarzone()) ||
|
||||
(factionTo.isSafeZone() && me.canflyinSafezone()) ||
|
||||
(factionTo.getRelationTo(me) == Relation.ENEMY && me.canflyinEnemy()) ||
|
||||
(factionTo.getRelationTo(me) == Relation.ALLY && me.canflyinAlly()) ||
|
||||
(factionTo.getRelationTo(me) == Relation.TRUCE && me.canflyinTruce()) ||
|
||||
(factionTo.getRelationTo(me) == Relation.NEUTRAL && me.canflyinNeutral())) {
|
||||
(relationTo == Relation.ENEMY && me.canflyinEnemy()) ||
|
||||
(relationTo == Relation.ALLY && me.canflyinAlly()) ||
|
||||
(relationTo == Relation.TRUCE && me.canflyinTruce()) ||
|
||||
(relationTo == Relation.NEUTRAL && me.canflyinNeutral())) {
|
||||
enableFly(me);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
||||
package com.massivecraft.factions.zcore.util.particles;
|
||||
|
||||
package com.massivecraft.factions.util.Particles;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -11,7 +10,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <b>com.prosavage.savagecore.particle.ReflectionUtils</b>
|
||||
* <b>ReflectionUtils</b>
|
||||
* <p>
|
||||
* This class provides useful methods which makes dealing with reflection much easier, especially when working with Bukkit
|
||||
* <p>
|
||||
@ -23,7 +22,7 @@ import java.util.Map;
|
||||
* <p>
|
||||
* <i>It would be nice if you provide credit to me if you use this class in a published project</i>
|
||||
*
|
||||
* @author Araos
|
||||
* @author DarkBlade12
|
||||
* @version 1.1
|
||||
*/
|
||||
public final class ReflectionUtils {
|
||||
@ -62,6 +61,7 @@ public final class ReflectionUtils {
|
||||
* @return The constructor of the desired target class with the specified parameter types
|
||||
* @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found
|
||||
* @throws ClassNotFoundException ClassNotFoundException If the desired target class with the specified name and package cannot be found
|
||||
* @see #getClass(String, PackageType)
|
||||
* @see #getConstructor(Class, Class...)
|
||||
*/
|
||||
public static Constructor<?> getConstructor(String className, PackageType packageType, Class<?>... parameterTypes) throws NoSuchMethodException, ClassNotFoundException {
|
||||
@ -97,6 +97,7 @@ public final class ReflectionUtils {
|
||||
* @throws InvocationTargetException If the desired constructor cannot be invoked
|
||||
* @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found
|
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found
|
||||
* @see #getClass(String, PackageType)
|
||||
* @see #instantiateObject(Class, Object...)
|
||||
*/
|
||||
public static Object instantiateObject(String className, PackageType packageType, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
|
||||
@ -135,6 +136,7 @@ public final class ReflectionUtils {
|
||||
* @return The method of the desired target class with the specified name and parameter types
|
||||
* @throws NoSuchMethodException If the desired method of the desired target class with the specified name and parameter types cannot be found
|
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found
|
||||
* @see #getClass(String, PackageType)
|
||||
* @see #getMethod(Class, String, Class...)
|
||||
*/
|
||||
public static Method getMethod(String className, PackageType packageType, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException, ClassNotFoundException {
|
||||
@ -192,6 +194,7 @@ public final class ReflectionUtils {
|
||||
* @throws InvocationTargetException If the desired method cannot be invoked on the target object
|
||||
* @throws NoSuchMethodException If the desired method of the desired target class with the specified name and arguments cannot be found
|
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found
|
||||
* @see #getClass(String, PackageType)
|
||||
* @see #invokeMethod(Object, Class, String, Object...)
|
||||
*/
|
||||
public static Object invokeMethod(Object instance, String className, PackageType packageType, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
|
||||
@ -344,7 +347,7 @@ public final class ReflectionUtils {
|
||||
/**
|
||||
* Represents an enumeration of dynamic packages of NMS and CraftBukkit
|
||||
* <p>
|
||||
* This class is part of the <b>com.prosavage.savagecore.particle.ReflectionUtils</b> and follows the same usage conditions
|
||||
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions
|
||||
*
|
||||
* @author DarkBlade12
|
||||
* @since 1.0
|
||||
@ -398,7 +401,7 @@ public final class ReflectionUtils {
|
||||
* @return The server version
|
||||
*/
|
||||
public static String getServerVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().substring(23);
|
||||
return Bukkit.getServer().getClass().getName().split("\\.")[3];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,7 +434,7 @@ public final class ReflectionUtils {
|
||||
/**
|
||||
* Represents an enumeration of Java data types with corresponding classes
|
||||
* <p>
|
||||
* This class is part of the <b>com.prosavage.savagecore.particle.ReflectionUtils</b> and follows the same usage conditions
|
||||
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions
|
||||
*
|
||||
* @author DarkBlade12
|
||||
* @since 1.0
|
||||
@ -535,7 +538,7 @@ public final class ReflectionUtils {
|
||||
/**
|
||||
* Returns the primitive class array of the given object array
|
||||
*
|
||||
* @param objects Given object array
|
||||
* @param object Given object array
|
||||
* @return The primitive class array
|
||||
*/
|
||||
public static Class<?>[] getPrimitive(Object[] objects) {
|
||||
@ -550,7 +553,7 @@ public final class ReflectionUtils {
|
||||
/**
|
||||
* Returns the reference class array of the given object array
|
||||
*
|
||||
* @param objects Given object array
|
||||
* @param object Given object array
|
||||
* @return The reference class array
|
||||
*/
|
||||
public static Class<?>[] getReference(Object[] objects) {
|
@ -147,6 +147,7 @@ public enum TL {
|
||||
COMMAND_BAN_BANNED("&e%1$s &cbanned &7%2$s"),
|
||||
COMMAND_BAN_SELF("&cYou may not ban yourself"),
|
||||
COMMAND_BAN_INSUFFICIENTRANK("&cYour rank is too low to ban &7%1$s"),
|
||||
COMMAND_BAN_ALREADYBANNED("&cThis player is already banned!"),
|
||||
|
||||
COMMAND_BANLIST_DESCRIPTION("View a Faction's ban list"),
|
||||
COMMAND_BANLIST_HEADER("&6There are &c%d&6 bans for %s"),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -61,7 +61,6 @@ warp-cost:
|
||||
# Faction Fly
|
||||
# Enable Faction Fly:
|
||||
enable-faction-flight: true
|
||||
fly-falldamage-cooldown: 10
|
||||
ffly:
|
||||
Particles:
|
||||
Enabled: true
|
||||
@ -72,7 +71,7 @@ ffly:
|
||||
# If a player leaves fly (out of territory or took damage)
|
||||
# how long should they not take fall damage for?
|
||||
# Set to 0 to have them always take fall damage.
|
||||
fly-falldamage-cooldown: 3
|
||||
fly-falldamage-cooldown: 10
|
||||
|
||||
# Pistons
|
||||
# Should we disable pistons in Faction territory? This will prevent people from doing something like:
|
||||
|
Loading…
Reference in New Issue
Block a user