13
0

added schematic check system; added commands(not finished); extended config

Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-04-22 13:14:32 +02:00 committet von yaruma3341
Ursprung e5fdc2a047
Commit 6a1ca71f2d
5 geänderte Dateien mit 335 neuen und 49 gelöschten Zeilen

Datei anzeigen

@ -1,14 +1,20 @@
package de.warking.schematicsystem; package de.warking.schematicsystem;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.schematicsystem.commands.SchematicCommand; import de.warking.schematicsystem.commands.SchematicCommand;
import de.warking.schematicsystem.listener.PlayerJoinListener; import de.warking.schematicsystem.listener.PlayerJoinListener;
import de.warking.schematicsystem.listener.PlayerQuitListener;
import de.warking.schematicsystem.utils.CommandRemover; import de.warking.schematicsystem.utils.CommandRemover;
import de.warking.schematicsystem.utils.Config; import de.warking.schematicsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.UUID;
public class SchematicSystem extends JavaPlugin { public class SchematicSystem extends JavaPlugin {
public static String SCHEM_DIR = "/home/netuser/schematics/"; public static String SCHEM_DIR = "/home/netuser/schematics/";
@ -16,6 +22,8 @@ public class SchematicSystem extends JavaPlugin {
private static SchematicSystem instance; private static SchematicSystem instance;
public static HashMap<UUID, Schematic> currCheckSchems = new HashMap<>();
public void onEnable() { public void onEnable() {
instance = this; instance = this;
@ -33,6 +41,14 @@ public class SchematicSystem extends JavaPlugin {
getCommand("/schem").setExecutor(new SchematicCommand()); getCommand("/schem").setExecutor(new SchematicCommand());
init(); init();
Bukkit.getScheduler().scheduleAsyncRepeatingTask(instance, new Runnable() {
@Override
public void run() {
SchematicCommand.sendTeamMembersCSchematics(SchematicCommand.sendTeamMembersCSchematicsInfo());
}
}, 0, 20*60*10);
} }
public void onDisable() { public void onDisable() {
@ -42,6 +58,7 @@ public class SchematicSystem extends JavaPlugin {
public void init() { public void init() {
PluginManager pm = Bukkit.getPluginManager(); PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(), instance); pm.registerEvents(new PlayerJoinListener(), instance);
pm.registerEvents(new PlayerQuitListener(), instance);
} }
@ -52,4 +69,8 @@ public class SchematicSystem extends JavaPlugin {
public static WorldEditPlugin getWorldEditPlugin() { public static WorldEditPlugin getWorldEditPlugin() {
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
} }
public static HashMap<UUID, Schematic> getCurrCheckSchems() {
return currCheckSchems;
}
} }

Datei anzeigen

@ -10,10 +10,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import de.warking.hunjy.MySQL.Schematic; import de.warking.hunjy.MySQL.*;
import de.warking.hunjy.MySQL.SchematicMember;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
import de.warking.schematicsystem.SchematicSystem; import de.warking.schematicsystem.SchematicSystem;
import de.warking.schematicsystem.utils.Config; import de.warking.schematicsystem.utils.Config;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -22,7 +19,6 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -63,6 +59,11 @@ public class SchematicCommand implements CommandExecutor {
sendHelp(player); sendHelp(player);
return false; return false;
} }
if(args[0].equalsIgnoreCase("checklist") && allowedToCheck(player)) {
sendTeammemberSchematicList(player, 15, 0);
return false;
}
return false; return false;
case 2: case 2:
@ -171,11 +172,8 @@ public class SchematicCommand implements CommandExecutor {
if(FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard() != null) { if(FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard() != null) {
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) { if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()).getSchemType() != SchematicType.normal) { if(Schematic.getSchemFromDB(args[1], player.getUniqueId()).getSchemType() != SchematicType.normal) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst dieses Schematic Typ nicht überschreiben!"); player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diesen Schematic Typ nicht überschreiben!");
return false; return false;
} else {
Schematic.getSchemFromDB(args[1], player.getUniqueId()).remove();
} }
} }
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) { if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
@ -253,6 +251,18 @@ public class SchematicCommand implements CommandExecutor {
return false; return false;
} }
} }
if(args[0].equalsIgnoreCase("checklist") && allowedToCheck(player)) {
int currentPage;
try {
currentPage = Integer.parseInt(args[1]);
} catch (NumberFormatException ex) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Zahl angeben!");
return false;
}
sendTeammemberSchematicList(player, 15, currentPage);
return false;
}
return false; return false;
case 3: case 3:
@ -298,43 +308,75 @@ public class SchematicCommand implements CommandExecutor {
Vector origin = clipboard.getOrigin(); Vector origin = clipboard.getOrigin();
Vector dimensions = clipboard.getDimensions(); Vector dimensions = clipboard.getDimensions();
if(args[2].equalsIgnoreCase("airship")) { if(schematic.getSchemType() != SchematicType.normal) {
if(dimensions.getBlockX() <= Config.AirShipBreite && dimensions.getBlockY() <= Config.AirShipHöhe && dimensions.getBlockZ() <= Config.AirShipTiefe && checkSchematic(clipboard, Config.AirShipForbiddenIds, true, true, "AirShip")) {
schematic.setSchemType(SchematicType.airship);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6airship §7angefordert!");
}
return false;
}
if(args[2].equalsIgnoreCase("miniwargear")) {
if(dimensions.getBlockX() <= Config.MiniWarGearBreite && dimensions.getBlockY() <= Config.MiniWarGearHöhe && dimensions.getBlockZ() <= Config.MiniWarGearTiefe && checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, true, true, "MiniWarGear")) {
schematic.setSchemType(SchematicType.miniwargear);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6miniwargear §7angefordert!");
}
return false;
}
if(args[2].equalsIgnoreCase("wargear")) {
if(dimensions.getBlockX() <= Config.WarGearBreite && dimensions.getBlockY() <= Config.WarGearHöhe && dimensions.getBlockZ() <= Config.WarGearTiefe && checkSchematic(clipboard, Config.WarGearForbiddenIds, true, true, "WarGear")) {
schematic.setSchemType(SchematicType.wargear);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6wargear §7angefordert!");
}
return false;
}
if(args[2].equalsIgnoreCase("warship")) {
if(dimensions.getBlockX() <= Config.WarShipBreite && dimensions.getBlockY() <= Config.WarShipHöhe && dimensions.getBlockZ() <= Config.WarShipTiefe && checkSchematic(clipboard, Config.WarShipForbiddenIds, true, true, "WarShip")) {
schematic.setSchemType(SchematicType.warship);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6warship §7angefordert!");
}
return false;
}
if(args[2].equalsIgnoreCase("normal")) { if(args[2].equalsIgnoreCase("normal")) {
schematic.setSchemType(SchematicType.normal); schematic.setSchemType(SchematicType.normal);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6normal §7gesetzt!"); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6normal §7gesetzt!");
return false; return false;
} else if(args[2].equalsIgnoreCase("airship") ||
args[2].equalsIgnoreCase("miniwargear") ||
args[2].equalsIgnoreCase("wargear") ||
args[2].equalsIgnoreCase("warship")) {
player.sendMessage(SchematicSystem.PREFIX + "Diese Schematic ist entweder schon freigegeben oder du versuchst eine bereits zum Prüfen gesendete Schematic erneut einzusenden!");
return false;
} }
} else {
if(args[2].equalsIgnoreCase("airship")) {
if(dimensions.getBlockX() <= Config.AirShipBreite && dimensions.getBlockY() <= Config.AirShipHöhe && dimensions.getBlockZ() <= Config.AirShipTiefe) {
if(!checkSchematic(clipboard, Config.AirShipForbiddenIds, true, true, "AirShip")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein AirShip ist nicht regelkonform!");
return false;
}
schematic.setSchemType(SchematicType.Cairship);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6airship §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6AirShip§8]");
}
return false;
}
if(args[2].equalsIgnoreCase("miniwargear")) {
if(dimensions.getBlockX() <= Config.MiniWarGearBreite && dimensions.getBlockY() <= Config.MiniWarGearHöhe && dimensions.getBlockZ() <= Config.MiniWarGearTiefe) {
if(!checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, true, true, "MiniWarGear")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear ist nicht regelkonform!");
return false;
}
schematic.setSchemType(SchematicType.Cminiwargear);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6miniwargear §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6MiniWarGear§8]");
}
return false;
}
if(args[2].equalsIgnoreCase("wargear")) {
if(dimensions.getBlockX() <= Config.WarGearBreite && dimensions.getBlockY() <= Config.WarGearHöhe && dimensions.getBlockZ() <= Config.WarGearTiefe) {
if(!checkSchematic(clipboard, Config.WarGearForbiddenIds, true, true, "WarGear")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear ist nicht regelkonform!");
return false;
}
schematic.setSchemType(SchematicType.Cwargear);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6wargear §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarGear§8]");
}
return false;
}
if(args[2].equalsIgnoreCase("warship")) {
if(dimensions.getBlockX() <= Config.WarShipBreite && dimensions.getBlockY() <= Config.WarShipHöhe && dimensions.getBlockZ() <= Config.WarShipTiefe) {
if(!checkSchematic(clipboard, Config.WarShipForbiddenIds, true, true, "WarShip")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip ist nicht regelkonform!");
return false;
}
schematic.setSchemType(SchematicType.Cwarship);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6warship §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarShip§8]");
}
return false;
}
}
player.sendMessage("§8/schem changetype <Name> <airship/warship/miniwargear/wargear/normal>");
} else { } else {
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!"); player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
return false; return false;
@ -448,16 +490,17 @@ public class SchematicCommand implements CommandExecutor {
player.sendMessage("§8/schem list - §6Listet deine Schematics auf"); player.sendMessage("§8/schem list - §6Listet deine Schematics auf");
player.sendMessage("§8/schem load <Name> [Besitzer] - §6Du lädst eine Schematic"); player.sendMessage("§8/schem load <Name> [Besitzer] - §6Du lädst eine Schematic");
player.sendMessage("§8/schem save <Name> - §6Du speicherst dein Clipboard als Datei"); player.sendMessage("§8/schem save <Name> - §6Du speicherst dein Clipboard als Datei");
player.sendMessage("§8/schem changetype <Name> <airship/miniwargear/wargear/normal> - §6Ändert den Typ deiner Schematic"); player.sendMessage("§8/schem changetype <Name> <airship/warship/miniwargear/wargear/normal> - §6Ändert den Typ deiner Schematic");
player.sendMessage("§8/schem info <Name> - §6Zeigt dir Informationen zu der Schematic"); player.sendMessage("§8/schem info <Name> - §6Zeigt dir Informationen zu der Schematic");
player.sendMessage("§8/schem delete <Name> - §6Löscht eine Schematic"); player.sendMessage("§8/schem delete <Name> - §6Löscht eine Schematic");
player.sendMessage("§8/schem addmember <Schematic> <Spieler> - §6Fügt einen Spieler zu einer Schematic hinzu"); player.sendMessage("§8/schem addmember <Schematic> <Spieler> - §6Fügt einen Spieler zu einer Schematic hinzu");
player.sendMessage("§8/schem delmember <Schematic> <Spieler> - §6Entfernt einen Spieler von einer Schematic"); player.sendMessage("§8/schem delmember <Schematic> <Spieler> - §6Entfernt einen Spieler von einer Schematic");
if (player.hasPermission("bau.team")) { if(allowedToCheck(player)) {
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:"); player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
player.sendMessage("§8/schem lock <Name> <Besitzer/Team> - §6Sperrt eine Schematic"); player.sendMessage("§8/schem checklist <Seite> - §6Zeigt die Liste der ungeprüften Schematics");
player.sendMessage("§8/schem unlock <Name> <Besitzer/Team> - §6Entsperrt eine Schematic"); player.sendMessage("§8/schem check <SchematicName> - §6Zum Checken einer Schematic");
player.sendMessage("§8/schem allow / decline - §6Schematic (nicht) freigeben");
} }
} }
@ -504,6 +547,14 @@ public class SchematicCommand implements CommandExecutor {
schematicType = "§7[§8WG§7] "; schematicType = "§7[§8WG§7] ";
if(schematic.getSchemType() == SchematicType.warship) if(schematic.getSchemType() == SchematicType.warship)
schematicType = "§7[§8WS§7] "; schematicType = "§7[§8WS§7] ";
if(schematic.getSchemType() == SchematicType.Cairship)
schematicType = "§7[§8CAS§7] ";
if(schematic.getSchemType() == SchematicType.Cminiwargear)
schematicType = "§7[§8CMWG§7] ";
if(schematic.getSchemType() == SchematicType.Cwargear)
schematicType = "§7[§8CWG§7] ";
if(schematic.getSchemType() == SchematicType.Cwarship)
schematicType = "§7[§8CWS§7] ";
String schematicPlayer; String schematicPlayer;
if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
@ -571,14 +622,12 @@ public class SchematicCommand implements CommandExecutor {
int obsidian = 0; int obsidian = 0;
int bedrock = 0; int bedrock = 0;
int dispenser = 0;
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
Vector vector = new Vector(x, y, z); Vector vector = new Vector(x, y, z);
if (forbiddenBlocks.contains(clipboard.getBlock(vector).getId())) {
return false;
}
try { try {
if(obsidianToTnt && clipboard.getBlock(vector).getId() == 46) { if(obsidianToTnt && clipboard.getBlock(vector).getId() == 46) {
@ -586,39 +635,204 @@ public class SchematicCommand implements CommandExecutor {
obsidian++; obsidian++;
} }
if(slimeToBedrock && clipboard.getBlock(vector).getId() == 165) { if(slimeToBedrock && clipboard.getBlock(vector).getId() == 165) {
if(modus.equals("WarShip") ||
modus.equals("AirShip"))
clipboard.setBlock(vector, new BaseBlock(7)); clipboard.setBlock(vector, new BaseBlock(7));
bedrock++; bedrock++;
} }
if(clipboard.getBlock(vector).getId() == 23)
dispenser++;
} catch (WorldEditException ex) { } catch (WorldEditException ex) {
return false; return false;
} }
if (forbiddenBlocks.contains(clipboard.getBlock(vector).getId()))
return false;
}
} }
} }
}
int obsidianBedrock = obsidian + bedrock;
if(modus.equalsIgnoreCase("WarGear")) { if(modus.equalsIgnoreCase("WarGear")) {
if(Config.WarGearMaxObsidian < obsidian) if(Config.WarGearMaxObsidian < obsidian)
return false; return false;
if(Config.WarGearMaxBedrock < bedrock) if(Config.WarGearMaxBedrock < bedrock)
return false; return false;
if(Config.WarGearMaxDispenser < dispenser)
return false;
if(Config.WarGearObsidianBedrock < obsidianBedrock)
return false;
} }
if(modus.equalsIgnoreCase("MiniWarGear")) { if(modus.equalsIgnoreCase("MiniWarGear")) {
if(Config.MiniWarGearMaxObsidian < obsidian) if(Config.MiniWarGearMaxObsidian < obsidian)
return false; return false;
if(Config.MiniWarGearMaxBedrock < bedrock) if(Config.MiniWarGearMaxBedrock < bedrock)
return false; return false;
if(Config.MiniWarGearMaxDispenser < dispenser)
return false;
if(Config.MiniWarGearObsidianBedrock < obsidianBedrock)
return false;
} }
if(modus.equalsIgnoreCase("WarShip")) { if(modus.equalsIgnoreCase("WarShip")) {
if(Config.WarShipMaxObsidian < obsidian) if(Config.WarShipMaxObsidian < obsidian)
return false; return false;
if(Config.MiniWarGearMaxBedrock < bedrock) if(Config.WarShipMaxBedrock < bedrock)
return false;
if(Config.WarShipMaxDispenser < dispenser)
return false;
if(Config.WarShipObsidianBedrock < obsidianBedrock)
return false; return false;
} }
if(modus.equalsIgnoreCase("AirShip")) { if(modus.equalsIgnoreCase("AirShip")) {
if(Config.AirShipMaxObsidian < obsidian) if(Config.AirShipMaxObsidian < obsidian)
return false; return false;
if(Config.MiniWarGearMaxBedrock < bedrock) if(Config.AirShipMaxBedrock < bedrock)
return false;
if(Config.AirShipMaxDispenser < dispenser)
return false;
if(Config.AirShipObsidianBedrock < obsidianBedrock)
return false; return false;
} }
return true; return true;
} }
public static void sendTeamMembersCSchematics(String message) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
if(allowedToCheck(player))
player.sendMessage(message);
}
}
public static boolean allowedToCheck(Player player) {
WarkingUser warkingUser = WarkingUser.get(player.getUniqueId());
if(warkingUser.getUserGroup() == UserGroup.Supporter ||
warkingUser.getUserGroup() == UserGroup.Developer ||
warkingUser.getUserGroup() == UserGroup.Moderator ||
warkingUser.getUserGroup() == UserGroup.Admin)
return true;
return false;
}
public static String sendTeamMembersCSchematicsInfo() {
int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
Schematic.getAllSchemsOfType(SchematicType.Cwargear).size() +
Schematic.getAllSchemsOfType(SchematicType.Cwarship).size();
String message = "";
if(size == 0)
message = SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!";
if(size == 1)
message = SchematicSystem.PREFIX + "§aEs gibt noch §6eine §aungeprüfte Schematic!";
if(size > 1)
message = SchematicSystem.PREFIX + "§aEs gibt noch §6" + size + " §aungeprüfte Schematics!";
return message;
}
private void sendTeammemberSchematicList(Player player, int filesPerPage, int currentPage) {
List<Schematic> wargears = Schematic.getAllSchemsOfType(SchematicType.Cwargear);
List<Schematic> miniwargears = Schematic.getAllSchemsOfType(SchematicType.Cminiwargear);
List<Schematic> warships = Schematic.getAllSchemsOfType(SchematicType.Cwarship);
List<Schematic> airships = Schematic.getAllSchemsOfType(SchematicType.Cairship);
List<Schematic> schematicList = new ArrayList<>();
for(Schematic schematic : wargears) {
if(!SchematicSystem.getCurrCheckSchems().containsValue(schematic))
schematicList.add(schematic);
}
for(Schematic schematic : miniwargears) {
if(!SchematicSystem.getCurrCheckSchems().containsValue(schematic))
schematicList.add(schematic);
}
for(Schematic schematic : warships) {
if(!SchematicSystem.getCurrCheckSchems().containsValue(schematic))
schematicList.add(schematic);
}
for(Schematic schematic : airships) {
if(!SchematicSystem.getCurrCheckSchems().containsValue(schematic))
schematicList.add(schematic);
}
if(schematicList.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!");
return;
}
int pages;
double doublePages = (Double.valueOf(schematicList.size()) / Double.valueOf(filesPerPage));
int intPages = schematicList.size() / filesPerPage;
if(schematicList.size() <= filesPerPage) {
pages = 1;
} else if(doublePages > intPages) {
pages = (intPages + 1);
} else
pages = intPages;
int currPage = currentPage;
if(currPage >= pages) return;
player.sendMessage("§5======§8[§dSeite " + (currentPage + 1) + " §7/ §d" + pages + " §7| §d" + schematicList.size() + " ungeprüfte Schematic(s)§8]§5======");
for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
if(schematicList.size() <= i) break;
Schematic schematic = schematicList.get(i);
String schematicType = "";
if(schematic.getSchemType() == SchematicType.Cairship)
schematicType = "§7[§8CAS§7] ";
if(schematic.getSchemType() == SchematicType.Cminiwargear)
schematicType = "§7[§8CMWG§7] ";
if(schematic.getSchemType() == SchematicType.Cwargear)
schematicType = "§7[§8CWG§7] ";
if(schematic.getSchemType() == SchematicType.Cwarship)
schematicType = "§7[§8CWS§7] ";
String schematicPlayer = "§7[§a" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + "§7] ";
TextComponent schematics = new TextComponent(schematicType + schematicPlayer + "§b" + schematic.getSchemName());
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen...").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem check " + schematic.getSchemName()));
player.spigot().sendMessage(schematics);
}
if(pages <= 1) return;
if(currPage == 0) {
TextComponent nextPage = new TextComponent("Nächste Seite >>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem checklist 1"));
player.spigot().sendMessage(nextPage);
} else if((currPage + 1) == pages) {
TextComponent beforePage = new TextComponent("<< Vorherige Seite");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem checklist " + (currPage - 1)));
player.spigot().sendMessage(beforePage);
} else {
TextComponent beforePage = new TextComponent("<< Seite ");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem checklist " + (currPage - 1)));
TextComponent nextPage = new TextComponent(">>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem checklist " + (currPage + 1)));
beforePage.addExtra(nextPage);
player.spigot().sendMessage(beforePage);
}
}
} }

Datei anzeigen

@ -4,6 +4,7 @@ import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType; import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser; import de.warking.hunjy.MySQL.WarkingUser;
import de.warking.schematicsystem.SchematicSystem; import de.warking.schematicsystem.SchematicSystem;
import de.warking.schematicsystem.commands.SchematicCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -37,6 +38,9 @@ public class PlayerJoinListener implements Listener {
Schematic schematic = new Schematic(fileName.substring(0, fileName.lastIndexOf(".")), player.getUniqueId(), "", SchematicType.normal); Schematic schematic = new Schematic(fileName.substring(0, fileName.lastIndexOf(".")), player.getUniqueId(), "", SchematicType.normal);
} }
} }
if(SchematicCommand.allowedToCheck(player))
player.sendMessage(SchematicCommand.sendTeamMembersCSchematicsInfo());
} }

Datei anzeigen

@ -0,0 +1,30 @@
package de.warking.schematicsystem.listener;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.schematicsystem.SchematicSystem;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
public class PlayerQuitListener implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if(SchematicSystem.getCurrCheckSchems().containsKey(player.getUniqueId())) {
Iterator itr = SchematicSystem.getCurrCheckSchems().entrySet().iterator();
while (itr.hasNext()) {
Map.Entry<UUID, Schematic> pair = (Map.Entry) itr.next();
if(pair.getKey().equals(player.getUniqueId()))
itr.remove();
}
}
}
}

Datei anzeigen

@ -14,6 +14,8 @@ public class Config {
public static double WarGearTiefe; public static double WarGearTiefe;
public static int WarGearMaxObsidian; public static int WarGearMaxObsidian;
public static int WarGearMaxBedrock; public static int WarGearMaxBedrock;
public static int WarGearObsidianBedrock;
public static int WarGearMaxDispenser;
public static List<Integer> WarGearForbiddenIds; public static List<Integer> WarGearForbiddenIds;
public static double MiniWarGearBreite; public static double MiniWarGearBreite;
@ -21,6 +23,8 @@ public class Config {
public static double MiniWarGearTiefe; public static double MiniWarGearTiefe;
public static int MiniWarGearMaxObsidian; public static int MiniWarGearMaxObsidian;
public static int MiniWarGearMaxBedrock; public static int MiniWarGearMaxBedrock;
public static int MiniWarGearObsidianBedrock;
public static int MiniWarGearMaxDispenser;
public static List<Integer> MiniWarGearForbiddenIds; public static List<Integer> MiniWarGearForbiddenIds;
public static double WarShipBreite; public static double WarShipBreite;
@ -28,6 +32,8 @@ public class Config {
public static double WarShipTiefe; public static double WarShipTiefe;
public static int WarShipMaxObsidian; public static int WarShipMaxObsidian;
public static int WarShipMaxBedrock; public static int WarShipMaxBedrock;
public static int WarShipObsidianBedrock;
public static int WarShipMaxDispenser;
public static List<Integer> WarShipForbiddenIds; public static List<Integer> WarShipForbiddenIds;
public static double AirShipBreite; public static double AirShipBreite;
@ -35,6 +41,8 @@ public class Config {
public static double AirShipTiefe; public static double AirShipTiefe;
public static int AirShipMaxObsidian; public static int AirShipMaxObsidian;
public static int AirShipMaxBedrock; public static int AirShipMaxBedrock;
public static int AirShipObsidianBedrock;
public static int AirShipMaxDispenser;
public static List<Integer> AirShipForbiddenIds; public static List<Integer> AirShipForbiddenIds;
public static void load() { public static void load() {
@ -50,19 +58,26 @@ public class Config {
WarGearTiefe = config.getDouble("Schematics.WarGear.Tiefe"); WarGearTiefe = config.getDouble("Schematics.WarGear.Tiefe");
WarGearMaxObsidian = config.getInt("Schematics.WarGear.Obsidian"); WarGearMaxObsidian = config.getInt("Schematics.WarGear.Obsidian");
WarGearMaxBedrock = config.getInt("Schematics.WarGear.Bedrock"); WarGearMaxBedrock = config.getInt("Schematics.WarGear.Bedrock");
WarGearObsidianBedrock = config.getInt("Schematics.WarGear.ObsidianBedrock");
WarGearMaxDispenser = config.getInt("Schematics.WarGear.Dispenser");
WarGearForbiddenIds = config.getIntegerList("Schematics.WarGear.ForbiddenIds"); WarGearForbiddenIds = config.getIntegerList("Schematics.WarGear.ForbiddenIds");
MiniWarGearBreite = config.getDouble("Schematics.MiniWarGear.Breite"); MiniWarGearBreite = config.getDouble("Schematics.MiniWarGear.Breite");
MiniWarGearHöhe = config.getDouble("Schematics.MiniWarGear.Höhe"); MiniWarGearHöhe = config.getDouble("Schematics.MiniWarGear.Höhe");
MiniWarGearTiefe = config.getDouble("Schematics.MiniWarGear.Tiefe"); MiniWarGearTiefe = config.getDouble("Schematics.MiniWarGear.Tiefe");
MiniWarGearMaxObsidian = config.getInt("Schematics.MiniWarGear.Obsidian"); MiniWarGearMaxObsidian = config.getInt("Schematics.MiniWarGear.Obsidian");
MiniWarGearForbiddenIds = config.getIntegerList("Schematics.MiniWarGear.Bedrock"); MiniWarGearMaxBedrock = config.getInt("Schematics.MiniWarGear.Bedrock");
MiniWarGearObsidianBedrock = config.getInt("Schematics.MiniWarGear.ObsidianBedrock");
MiniWarGearMaxDispenser = config.getInt("Schematics.MiniWarGear.Dispenser");
MiniWarGearForbiddenIds = config.getIntegerList("Schematics.MiniWarGear.ForbiddenIds");
WarShipBreite = config.getDouble("Schematics.WarShip.Breite"); WarShipBreite = config.getDouble("Schematics.WarShip.Breite");
WarShipHöhe = config.getDouble("Schematics.WarShip.Höhe"); WarShipHöhe = config.getDouble("Schematics.WarShip.Höhe");
WarShipTiefe = config.getDouble("Schematics.WarShip.Tiefe"); WarShipTiefe = config.getDouble("Schematics.WarShip.Tiefe");
WarShipMaxObsidian = config.getInt("Schematics.WarShip.Obsidian"); WarShipMaxObsidian = config.getInt("Schematics.WarShip.Obsidian");
WarShipMaxBedrock = config.getInt("Schematics.WarShip.Bedrock"); WarShipMaxBedrock = config.getInt("Schematics.WarShip.Bedrock");
WarShipObsidianBedrock = config.getInt("Schematics.WarShip.ObsidianBedrock");
WarShipMaxDispenser = config.getInt("Schematics.WarShip.Dispenser");
WarShipForbiddenIds = config.getIntegerList("Schematics.WarShip.ForbiddenIds"); WarShipForbiddenIds = config.getIntegerList("Schematics.WarShip.ForbiddenIds");
AirShipBreite = config.getDouble("Schematics.AirShip.Breite"); AirShipBreite = config.getDouble("Schematics.AirShip.Breite");
@ -70,6 +85,8 @@ public class Config {
AirShipTiefe = config.getDouble("Schematics.AirShip.Tiefe"); AirShipTiefe = config.getDouble("Schematics.AirShip.Tiefe");
AirShipMaxObsidian = config.getInt("Schematics.AirShip.Obsidian"); AirShipMaxObsidian = config.getInt("Schematics.AirShip.Obsidian");
AirShipMaxBedrock = config.getInt("Schematics.AirShip.Bedrock"); AirShipMaxBedrock = config.getInt("Schematics.AirShip.Bedrock");
AirShipObsidianBedrock = config.getInt("Schematics.AirShip.ObsidianBedrock");
AirShipMaxDispenser = config.getInt("Schematics.AirShip.Dispenser");
AirShipForbiddenIds = config.getIntegerList("Schematics.AirShip.ForbiddenIds"); AirShipForbiddenIds = config.getIntegerList("Schematics.AirShip.ForbiddenIds");
} }
} }