mirror of
https://github.com/xoo0524tw/OpenHBedwars.git
synced 2026-12-05 22:16:02 +02:00
108 lines
4.0 KiB
Java
108 lines
4.0 KiB
Java
package com.axeelheaven.hbedwars.commands.setup;
|
|
|
|
import com.axeelheaven.hbedwars.BedWars;
|
|
import com.axeelheaven.hbedwars.commands.interfaces.CommandArgument;
|
|
import com.axeelheaven.hbedwars.configuration.HConfiguration;
|
|
import com.axeelheaven.hbedwars.cuboid.CuboidBetweenLocations;
|
|
import com.axeelheaven.hbedwars.listeners.SetupListener;
|
|
import com.axeelheaven.hbedwars.util.CenterMessage;
|
|
import java.util.HashMap;
|
|
import java.util.UUID;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
public class IslandTopperArg implements CommandArgument {
|
|
private String cosmeticId;
|
|
private static IslandTopperArg instance;
|
|
private final BedWars plugin;
|
|
private final HashMap<UUID, CuboidBetweenLocations> editing = new HashMap<>();
|
|
|
|
public String name() {
|
|
return "islandtopper";
|
|
}
|
|
|
|
public IslandTopperArg(BedWars var1) {
|
|
this.plugin = var1;
|
|
instance = this;
|
|
}
|
|
|
|
public String usage() {
|
|
return "<id> <price> <permission>";
|
|
}
|
|
|
|
public static IslandTopperArg getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
public String permission() {
|
|
return null;
|
|
}
|
|
|
|
public int minArgs() {
|
|
return 3;
|
|
}
|
|
|
|
public boolean handle(Player var1, String[] var2) {
|
|
if (this.editing.containsKey(var1.getUniqueId())) {
|
|
this.editing.remove(var1.getUniqueId());
|
|
this.cosmeticId = null;
|
|
var1.teleport(this.plugin.getGameManager().getSpawn());
|
|
this.plugin.getGameManager().getData(var1.getUniqueId()).getInventoryData().load();
|
|
var1.sendMessage(this.c("&cYou have exited the Island Topper setup."));
|
|
return true;
|
|
} else if (this.plugin.getIslandTopperManager().getIslandTopper(var2[0]) != null) {
|
|
var1.sendMessage(this.c("&cThere is already an island topper with that name!"));
|
|
return true;
|
|
} else if (!this.editing.isEmpty()) {
|
|
var1.sendMessage(this.c("&cSomeone is already setup Island Topper."));
|
|
return true;
|
|
} else if (!this.plugin.getUtil().isNumeric(var2[1])) {
|
|
var1.sendMessage(String.valueOf(new StringBuilder().append(ChatColor.RED).append("You must put a number as price.")));
|
|
return true;
|
|
} else {
|
|
HConfiguration var3 = this.plugin.getIslandtoppers();
|
|
var3.set(String.valueOf(new StringBuilder().append("islandtoppers.").append(var2[0]).append(".id")), var2[0]);
|
|
var3.set(String.valueOf(new StringBuilder().append("islandtoppers.").append(var2[0]).append(".price")), Integer.parseInt(var2[1]));
|
|
var3.set(String.valueOf(new StringBuilder().append("islandtoppers.").append(var2[0]).append(".permission")), Boolean.parseBoolean(var2[2]));
|
|
var3.save().reload();
|
|
this.plugin.getGameManager().getData(var1.getUniqueId()).getInventoryData().save();
|
|
this.editing.put(var1.getUniqueId(), new CuboidBetweenLocations());
|
|
this.setCosmeticId(var2[0]);
|
|
var1.getInventory().clear();
|
|
var1.getInventory().addItem((ItemStack[])SetupListener.getInstance().getIslandTopperItems().clone());
|
|
var1.setAllowFlight(true);
|
|
var1.setFlying(true);
|
|
var1.setGameMode(GameMode.CREATIVE);
|
|
var1.sendMessage(this.c(""));
|
|
var1.sendMessage(CenterMessage.centerMessage("&6&lISLAND TOPPER"));
|
|
var1.sendMessage(this.c(""));
|
|
var1.sendMessage(this.c(" • Left click for the first point and right for the second point."));
|
|
var1.sendMessage(this.c(" • Use the star to save the island topper cosmetic."));
|
|
var1.sendMessage(this.c(""));
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public HashMap<UUID, CuboidBetweenLocations> getEditing() {
|
|
return this.editing;
|
|
}
|
|
|
|
private String c(String var1) {
|
|
return ChatColor.translateAlternateColorCodes('&', var1);
|
|
}
|
|
|
|
public String description() {
|
|
return "Create new island topper cosmetic.";
|
|
}
|
|
|
|
public String getCosmeticId() {
|
|
return this.cosmeticId;
|
|
}
|
|
|
|
public void setCosmeticId(String var1) {
|
|
this.cosmeticId = var1;
|
|
}
|
|
}
|