New Shop Config Format With Help, Removed Useless Code FactionsBlockListener Block Break Revamp, F Wild Revamp (DroppingAnvil) & Alot I can't remember xD
This commit is contained in:
@@ -10,6 +10,7 @@ import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.wait.WaitedTask;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -23,51 +24,31 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class CmdWild extends FCommand {
|
||||
public static HashMap<Player, Integer> waitingTeleport;
|
||||
public class CmdWild extends FCommand implements WaitedTask {
|
||||
public static HashMap<Player, String> teleportRange;
|
||||
public static HashSet<Player> teleporting;
|
||||
public static CmdWild instance;
|
||||
|
||||
public CmdWild() {
|
||||
super();
|
||||
if (instance == null) instance = this;
|
||||
this.aliases.addAll(Aliases.wild);
|
||||
this.requirements = new CommandRequirements.Builder(Permission.WILD)
|
||||
.playerOnly()
|
||||
.build();
|
||||
waitingTeleport = new HashMap<>();
|
||||
teleporting = new HashSet<>();
|
||||
teleportRange = new HashMap<>();
|
||||
startWild();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!waitingTeleport.containsKey(context.player)) {
|
||||
if (!teleportRange.containsKey(context.player)) {
|
||||
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
||||
} else {
|
||||
context.fPlayer.msg(TL.COMMAND_WILD_WAIT);
|
||||
}
|
||||
}
|
||||
|
||||
public void startWild() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () -> {
|
||||
for (Player p : waitingTeleport.keySet()) {
|
||||
int i = waitingTeleport.get(p) - 1;
|
||||
if (i > 0) {
|
||||
if (i != 1) {
|
||||
p.sendMessage(TL.COMMAND_WILD_WAIT.format((i + " Seconds")));
|
||||
} else {
|
||||
p.sendMessage(TL.COMMAND_WILD_WAIT.format((i + " Second")));
|
||||
}
|
||||
waitingTeleport.replace(p, i);
|
||||
} else {
|
||||
p.sendMessage(TL.COMMAND_WILD_SUCCESS.toString());
|
||||
waitingTeleport.remove(p);
|
||||
attemptTeleport(p);
|
||||
}
|
||||
}
|
||||
}, 0L, 20L);
|
||||
}
|
||||
|
||||
public void attemptTeleport(Player p) {
|
||||
boolean success = false;
|
||||
@@ -121,4 +102,15 @@ public class CmdWild extends FCommand {
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_WILD_DESCRIPTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSuccess(Player player) {
|
||||
attemptTeleport(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleFailure(Player player) {
|
||||
player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user