mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-23 18:55:25 +01:00
Merge branch 'hintss-1.6.x' into 1.6.x
This commit is contained in:
commit
846cd71583
@ -131,10 +131,18 @@ public class FLocation {
|
||||
return Math.sqrt(dx * dx + dz * dz);
|
||||
}
|
||||
|
||||
public double getDistanceSquaredTo(FLocation that) {
|
||||
double dx = that.x - this.x;
|
||||
double dz = that.z - this.z;
|
||||
return dx * dx + dz * dz;
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Some Geometry
|
||||
//----------------------------------------------//
|
||||
public Set<FLocation> getCircle(double radius) {
|
||||
double radiusSquared = radius * radius;
|
||||
|
||||
Set<FLocation> ret = new LinkedHashSet<FLocation>();
|
||||
if (radius <= 0) {
|
||||
return ret;
|
||||
@ -148,7 +156,7 @@ public class FLocation {
|
||||
for (int x = xfrom; x <= xto; x++) {
|
||||
for (int z = zfrom; z <= zto; z++) {
|
||||
FLocation potential = new FLocation(this.worldName, x, z);
|
||||
if (this.getDistanceTo(potential) <= radius) {
|
||||
if (this.getDistanceSquaredTo(potential) <= radiusSquared) {
|
||||
ret.add(potential);
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
this.autoClaimFor = null;
|
||||
this.autoSafeZoneEnabled = false;
|
||||
this.autoWarZoneEnabled = false;
|
||||
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
|
||||
this.loginPvpDisabled = Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0;
|
||||
this.deleteMe = false;
|
||||
this.powerBoost = 0.0;
|
||||
|
||||
@ -634,15 +634,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
public boolean canClaimForFaction(Faction forFaction) {
|
||||
if (forFaction.isNone()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isAdminBypassing() || (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR)) || (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) || (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return !forFaction.isNone() && (this.isAdminBypassing() || (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR)) || (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) || (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())));
|
||||
}
|
||||
|
||||
public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure) {
|
||||
|
@ -391,25 +391,18 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
protected boolean addFPlayer(FPlayer fplayer) {
|
||||
if (this.isPlayerFreeType()) {
|
||||
return false;
|
||||
}
|
||||
return !this.isPlayerFreeType() && fplayers.add(fplayer);
|
||||
|
||||
return fplayers.add(fplayer);
|
||||
}
|
||||
|
||||
protected boolean removeFPlayer(FPlayer fplayer) {
|
||||
if (this.isPlayerFreeType()) {
|
||||
return false;
|
||||
}
|
||||
return !this.isPlayerFreeType() && fplayers.remove(fplayer);
|
||||
|
||||
return fplayers.remove(fplayer);
|
||||
}
|
||||
|
||||
public Set<FPlayer> getFPlayers() {
|
||||
// return a shallow copy of the FPlayer list, to prevent tampering and concurrency issues
|
||||
Set<FPlayer> ret = new HashSet<FPlayer>(fplayers);
|
||||
return ret;
|
||||
return new HashSet<FPlayer>(fplayers);
|
||||
}
|
||||
|
||||
public Set<FPlayer> getFPlayersWhereOnline(boolean online) {
|
||||
@ -483,10 +476,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
// even if all players are technically logged off, maybe someone was on recently enough to not consider them officially offline yet
|
||||
if (Conf.considerFactionsReallyOfflineAfterXMinutes > 0 && System.currentTimeMillis() < lastPlayerLoggedOffTime + (Conf.considerFactionsReallyOfflineAfterXMinutes * 60000)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Conf.considerFactionsReallyOfflineAfterXMinutes > 0 && System.currentTimeMillis() < lastPlayerLoggedOffTime + (Conf.considerFactionsReallyOfflineAfterXMinutes * 60000);
|
||||
}
|
||||
|
||||
public void memberLoggedOff() {
|
||||
@ -628,11 +618,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
if (ownerData == null) {
|
||||
return false;
|
||||
}
|
||||
if (ownerData.contains(player.getId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return ownerData.contains(player.getId());
|
||||
}
|
||||
|
||||
public void setPlayerAsOwner(FPlayer player, FLocation loc) {
|
||||
@ -691,11 +677,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
|
||||
// if no owner list, owner list is empty, or player is in owner list, they're allowed
|
||||
if (ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId());
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,11 +168,8 @@ public class P extends MPlugin {
|
||||
|
||||
@Override
|
||||
public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) {
|
||||
if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender)) {
|
||||
return true;
|
||||
}
|
||||
return sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender) || super.handleCommand(sender, commandString, testOnly);
|
||||
|
||||
return super.handleCommand(sender, commandString, testOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -206,10 +203,7 @@ public class P extends MPlugin {
|
||||
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
|
||||
|
||||
public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) {
|
||||
if (event == null) {
|
||||
return false;
|
||||
}
|
||||
return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
|
||||
return event != null && (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
|
||||
}
|
||||
|
||||
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
|
||||
@ -220,10 +214,7 @@ public class P extends MPlugin {
|
||||
}
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
|
||||
if (me == null) {
|
||||
return false;
|
||||
}
|
||||
return me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
||||
return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
||||
}
|
||||
|
||||
// Is this chat message actually a Factions command, and thus should be left alone by other plugins?
|
||||
@ -231,10 +222,7 @@ public class P extends MPlugin {
|
||||
// TODO: GET THIS BACK AND WORKING
|
||||
|
||||
public boolean isFactionsCommand(String check) {
|
||||
if (check == null || check.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return this.handleCommand(null, check, true);
|
||||
return !(check == null || check.isEmpty()) && this.handleCommand(null, check, true);
|
||||
}
|
||||
|
||||
// Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat
|
||||
|
@ -138,19 +138,8 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
*/
|
||||
// TODO: There should be a boolean for silence
|
||||
public boolean validCall(CommandSender sender, List<String> args) {
|
||||
if (!validSenderType(sender, true)) {
|
||||
return false;
|
||||
}
|
||||
return validSenderType(sender, true) && validSenderPermissions(sender, true) && validArgs(args, sender);
|
||||
|
||||
if (!validSenderPermissions(sender, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!validArgs(args, sender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
@ -168,10 +157,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
}
|
||||
|
||||
public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) {
|
||||
if (this.permission == null) {
|
||||
return true;
|
||||
}
|
||||
return p.perm.has(sender, this.permission, informSenderIfNot);
|
||||
return this.permission == null || p.perm.has(sender, this.permission, informSenderIfNot);
|
||||
}
|
||||
|
||||
public boolean validArgs(List<String> args, CommandSender sender) {
|
||||
@ -276,10 +262,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
|
||||
// Is set? ======================
|
||||
public boolean argIsSet(int idx) {
|
||||
if (this.args.size() < idx + 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return this.args.size() >= idx + 1;
|
||||
}
|
||||
|
||||
// STRING ======================
|
||||
@ -300,8 +283,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
return def;
|
||||
}
|
||||
try {
|
||||
Integer ret = Integer.parseInt(str);
|
||||
return ret;
|
||||
return Integer.parseInt(str);
|
||||
} catch (Exception e) {
|
||||
return def;
|
||||
}
|
||||
@ -321,8 +303,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
return def;
|
||||
}
|
||||
try {
|
||||
Double ret = Double.parseDouble(str);
|
||||
return ret;
|
||||
return Double.parseDouble(str);
|
||||
} catch (Exception e) {
|
||||
return def;
|
||||
}
|
||||
@ -340,10 +321,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
// Boolean ======================
|
||||
public Boolean strAsBool(String str) {
|
||||
str = str.toLowerCase();
|
||||
if (str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1");
|
||||
}
|
||||
|
||||
public Boolean argAsBool(int idx, boolean def) {
|
||||
|
@ -46,5 +46,4 @@ public class PlayerEntity extends Entity {
|
||||
this.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user