Added Corner Command, Spam Prevent System, Members Upgrade Redone
This commit is contained in:
64
src/main/java/com/massivecraft/factions/cmd/CmdCorner.java
Normal file
64
src/main/java/com/massivecraft/factions/cmd/CmdCorner.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.CornerTask;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class CmdCorner extends FCommand {
|
||||
|
||||
public CmdCorner() {
|
||||
this.aliases.add("corner");
|
||||
|
||||
this.permission = Permission.CLAIM_RADIUS.node;
|
||||
|
||||
this.senderMustBePlayer = true;
|
||||
this.senderMustBeMember = true;
|
||||
this.senderMustBeModerator = false;
|
||||
this.senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FLocation to = new FLocation(me.getLocation());
|
||||
if (SavageFactions.plugin.getFactionsPlayerListener().getCorners().contains(to)) {
|
||||
Faction cornerAt = Board.getInstance().getFactionAt(to);
|
||||
if (cornerAt != null && cornerAt.isNormal() && !cornerAt.equals(fme.getFaction())) {
|
||||
msg(TL.COMMAND_CORNER_CANT_CLAIM);
|
||||
} else {
|
||||
msg(TL.COMMAND_CORNER_ATTEMPTING_CLAIM);
|
||||
List<FLocation> surrounding = new ArrayList<>(400);
|
||||
for (int x = 0; x < Conf.factionBufferSize; ++x) {
|
||||
for (int z = 0; z < Conf.factionBufferSize; ++z) {
|
||||
int newX = (int) ((to.getX() > 0L) ? (to.getX() - x) : (to.getX() + x));
|
||||
int newZ = (int) ((to.getZ() > 0L) ? (to.getZ() - z) : (to.getZ() + z));
|
||||
FLocation location = new FLocation(me.getWorld().getName(), newX, newZ);
|
||||
Faction at = Board.getInstance().getFactionAt(location);
|
||||
if (at == null || !at.isNormal()) {
|
||||
surrounding.add(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
surrounding.sort(Comparator.comparingInt(fLocation -> (int) fLocation.getDistanceTo(to)));
|
||||
if (surrounding.isEmpty()) {
|
||||
msg(TL.COMMAND_CORNER_CANT_CLAIM);
|
||||
} else {
|
||||
new CornerTask(fme, surrounding).runTaskTimer(SavageFactions.plugin, 1L, 1L);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msg(TL.COMMAND_CORNER_NOT_CORNER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_CORNER_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdStrikeSet cmdStrikeSet = new CmdStrikeSet();
|
||||
public CmdAlts cmdAlts = new CmdAlts();
|
||||
public CmdSpam cmdSpam = new CmdSpam();
|
||||
public CmdCorner cmdCorner = new CmdCorner();
|
||||
|
||||
|
||||
|
||||
@@ -224,6 +225,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdSetBanner);
|
||||
this.addSubCommand(this.cmdStrikeSet);
|
||||
this.addSubCommand(this.cmdSpam);
|
||||
this.addSubCommand(this.cmdCorner);
|
||||
|
||||
|
||||
if(SavageFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){
|
||||
|
||||
Reference in New Issue
Block a user