13
0
Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-04-22 16:41:03 +02:00 committet von yaruma3341
Ursprung 6a1ca71f2d
Commit bd21fd9ac3
4 geänderte Dateien mit 289 neuen und 261 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ 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.Schematic;
import de.warking.hunjy.MySQL.SchematicType; import de.warking.hunjy.MySQL.SchematicType;
import de.warking.schematicsystem.check.Check;
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.listener.PlayerQuitListener;
@ -46,7 +47,7 @@ public class SchematicSystem extends JavaPlugin {
@Override @Override
public void run() { public void run() {
SchematicCommand.sendTeamMembersCSchematics(SchematicCommand.sendTeamMembersCSchematicsInfo()); Check.sendTeamMembersCSchematics(Check.sendTeamMembersCSchematicsInfo());
} }
}, 0, 20*60*10); }, 0, 20*60*10);
} }

Datei anzeigen

@ -0,0 +1,262 @@
package de.warking.schematicsystem.check;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.regions.Region;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.UserGroup;
import de.warking.hunjy.MySQL.WarkingUser;
import de.warking.schematicsystem.SchematicSystem;
import de.warking.schematicsystem.utils.Config;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class Check {
public static boolean isSchematicNameAllowed(String schematicName) {
if(schematicName.contains("/") ||
schematicName.contains("\\") ||
schematicName.contains("<") ||
schematicName.contains(">") ||
schematicName.contains("^") ||
schematicName.contains("°") ||
schematicName.contains("'") ||
schematicName.contains("\"")) {
return false;
} else
return true;
}
public static boolean checkSchematic(Clipboard clipboard, List<Integer> forbiddenBlocks, boolean obsidianToTnt, boolean slimeToBedrock, String modus) {
Region region = clipboard.getRegion();
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int obsidian = 0;
int bedrock = 0;
int dispenser = 0;
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
Vector vector = new Vector(x, y, z);
try {
if(obsidianToTnt && clipboard.getBlock(vector).getId() == 46) {
clipboard.setBlock(vector, new BaseBlock(49));
obsidian++;
}
if(slimeToBedrock && clipboard.getBlock(vector).getId() == 165) {
if(modus.equals("WarShip") ||
modus.equals("AirShip"))
clipboard.setBlock(vector, new BaseBlock(7));
bedrock++;
}
if(clipboard.getBlock(vector).getId() == 23)
dispenser++;
} catch (WorldEditException ex) {
return false;
}
if (forbiddenBlocks.contains(clipboard.getBlock(vector).getId()))
return false;
}
}
}
int obsidianBedrock = obsidian + bedrock;
if(modus.equalsIgnoreCase("WarGear")) {
if(Config.WarGearMaxObsidian < obsidian)
return false;
if(Config.WarGearMaxBedrock < bedrock)
return false;
if(Config.WarGearMaxDispenser < dispenser)
return false;
if(Config.WarGearObsidianBedrock < obsidianBedrock)
return false;
}
if(modus.equalsIgnoreCase("MiniWarGear")) {
if(Config.MiniWarGearMaxObsidian < obsidian)
return false;
if(Config.MiniWarGearMaxBedrock < bedrock)
return false;
if(Config.MiniWarGearMaxDispenser < dispenser)
return false;
if(Config.MiniWarGearObsidianBedrock < obsidianBedrock)
return false;
}
if(modus.equalsIgnoreCase("WarShip")) {
if(Config.WarShipMaxObsidian < obsidian)
return false;
if(Config.WarShipMaxBedrock < bedrock)
return false;
if(Config.WarShipMaxDispenser < dispenser)
return false;
if(Config.WarShipObsidianBedrock < obsidianBedrock)
return false;
}
if(modus.equalsIgnoreCase("AirShip")) {
if(Config.AirShipMaxObsidian < obsidian)
return false;
if(Config.AirShipMaxBedrock < bedrock)
return false;
if(Config.AirShipMaxDispenser < dispenser)
return false;
if(Config.AirShipObsidianBedrock < obsidianBedrock)
return false;
}
return true;
}
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 void sendTeamMembersCSchematics(String message) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
if(allowedToCheck(player))
player.sendMessage(message);
}
}
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;
}
public static 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

@ -3,15 +3,13 @@ package de.warking.schematicsystem.commands;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard; 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.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import de.warking.hunjy.MySQL.*; import de.warking.hunjy.MySQL.*;
import de.warking.schematicsystem.SchematicSystem; import de.warking.schematicsystem.SchematicSystem;
import de.warking.schematicsystem.check.Check;
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;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
@ -60,8 +58,8 @@ public class SchematicCommand implements CommandExecutor {
return false; return false;
} }
if(args[0].equalsIgnoreCase("checklist") && allowedToCheck(player)) { if(args[0].equalsIgnoreCase("checklist") && Check.allowedToCheck(player)) {
sendTeammemberSchematicList(player, 15, 0); Check.sendTeammemberSchematicList(player, 15, 0);
return false; return false;
} }
return false; return false;
@ -78,7 +76,7 @@ public class SchematicCommand implements CommandExecutor {
} }
if(args[0].equalsIgnoreCase("load")) { if(args[0].equalsIgnoreCase("load")) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if (schematic != null) { if (schematic != null) {
@ -110,7 +108,7 @@ public class SchematicCommand implements CommandExecutor {
} }
if(args[0].equalsIgnoreCase("delete")) { if(args[0].equalsIgnoreCase("delete")) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if(schematic != null) { if(schematic != null) {
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
@ -142,7 +140,7 @@ public class SchematicCommand implements CommandExecutor {
} }
if(args[0].equalsIgnoreCase("savedelete")) { if(args[0].equalsIgnoreCase("savedelete")) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if(schematic != null) { if(schematic != null) {
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
@ -167,7 +165,7 @@ public class SchematicCommand implements CommandExecutor {
if(args[0].equalsIgnoreCase("save")) { if(args[0].equalsIgnoreCase("save")) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
try { try {
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) {
@ -209,7 +207,7 @@ public class SchematicCommand implements CommandExecutor {
} }
if(args[0].equalsIgnoreCase("info")) { if(args[0].equalsIgnoreCase("info")) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if(schematic != null) { if(schematic != null) {
@ -252,7 +250,7 @@ public class SchematicCommand implements CommandExecutor {
} }
} }
if(args[0].equalsIgnoreCase("checklist") && allowedToCheck(player)) { if(args[0].equalsIgnoreCase("checklist") && Check.allowedToCheck(player)) {
int currentPage; int currentPage;
try { try {
currentPage = Integer.parseInt(args[1]); currentPage = Integer.parseInt(args[1]);
@ -260,7 +258,7 @@ public class SchematicCommand implements CommandExecutor {
player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Zahl angeben!"); player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Zahl angeben!");
return false; return false;
} }
sendTeammemberSchematicList(player, 15, currentPage); Check.sendTeammemberSchematicList(player, 15, currentPage);
return false; return false;
} }
return false; return false;
@ -270,7 +268,7 @@ public class SchematicCommand implements CommandExecutor {
if(!player.hasPermission("bau.team")) return false; if(!player.hasPermission("bau.team")) return false;
WarkingUser warkingUser = WarkingUser.get(args[2]); WarkingUser warkingUser = WarkingUser.get(args[2]);
if(warkingUser != null) { if(warkingUser != null) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], warkingUser.getUUID()); Schematic schematic = Schematic.getSchemFromDB(args[1], warkingUser.getUUID());
if(schematic != null) { if(schematic != null) {
try { try {
@ -325,52 +323,52 @@ public class SchematicCommand implements CommandExecutor {
if(args[2].equalsIgnoreCase("airship")) { if(args[2].equalsIgnoreCase("airship")) {
if(dimensions.getBlockX() <= Config.AirShipBreite && dimensions.getBlockY() <= Config.AirShipHöhe && dimensions.getBlockZ() <= Config.AirShipTiefe) { if(dimensions.getBlockX() <= Config.AirShipBreite && dimensions.getBlockY() <= Config.AirShipHöhe && dimensions.getBlockZ() <= Config.AirShipTiefe) {
if(!checkSchematic(clipboard, Config.AirShipForbiddenIds, true, true, "AirShip")) { if(!Check.checkSchematic(clipboard, Config.AirShipForbiddenIds, true, true, "AirShip")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein AirShip ist nicht regelkonform!"); player.sendMessage(SchematicSystem.PREFIX + "§cDein AirShip ist nicht regelkonform!");
return false; return false;
} }
schematic.setSchemType(SchematicType.Cairship); schematic.setSchemType(SchematicType.Cairship);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6airship §7angefordert!"); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6airship §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6AirShip§8]"); Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6AirShip§8]");
} }
return false; return false;
} }
if(args[2].equalsIgnoreCase("miniwargear")) { if(args[2].equalsIgnoreCase("miniwargear")) {
if(dimensions.getBlockX() <= Config.MiniWarGearBreite && dimensions.getBlockY() <= Config.MiniWarGearHöhe && dimensions.getBlockZ() <= Config.MiniWarGearTiefe) { if(dimensions.getBlockX() <= Config.MiniWarGearBreite && dimensions.getBlockY() <= Config.MiniWarGearHöhe && dimensions.getBlockZ() <= Config.MiniWarGearTiefe) {
if(!checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, true, true, "MiniWarGear")) { if(!Check.checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, true, true, "MiniWarGear")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear ist nicht regelkonform!"); player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear ist nicht regelkonform!");
return false; return false;
} }
schematic.setSchemType(SchematicType.Cminiwargear); schematic.setSchemType(SchematicType.Cminiwargear);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6miniwargear §7angefordert!"); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6miniwargear §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6MiniWarGear§8]"); Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6MiniWarGear§8]");
} }
return false; return false;
} }
if(args[2].equalsIgnoreCase("wargear")) { if(args[2].equalsIgnoreCase("wargear")) {
if(dimensions.getBlockX() <= Config.WarGearBreite && dimensions.getBlockY() <= Config.WarGearHöhe && dimensions.getBlockZ() <= Config.WarGearTiefe) { if(dimensions.getBlockX() <= Config.WarGearBreite && dimensions.getBlockY() <= Config.WarGearHöhe && dimensions.getBlockZ() <= Config.WarGearTiefe) {
if(!checkSchematic(clipboard, Config.WarGearForbiddenIds, true, true, "WarGear")) { if(!Check.checkSchematic(clipboard, Config.WarGearForbiddenIds, true, true, "WarGear")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear ist nicht regelkonform!"); player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear ist nicht regelkonform!");
return false; return false;
} }
schematic.setSchemType(SchematicType.Cwargear); schematic.setSchemType(SchematicType.Cwargear);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6wargear §7angefordert!"); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6wargear §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarGear§8]"); Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarGear§8]");
} }
return false; return false;
} }
if(args[2].equalsIgnoreCase("warship")) { if(args[2].equalsIgnoreCase("warship")) {
if(dimensions.getBlockX() <= Config.WarShipBreite && dimensions.getBlockY() <= Config.WarShipHöhe && dimensions.getBlockZ() <= Config.WarShipTiefe) { if(dimensions.getBlockX() <= Config.WarShipBreite && dimensions.getBlockY() <= Config.WarShipHöhe && dimensions.getBlockZ() <= Config.WarShipTiefe) {
if(!checkSchematic(clipboard, Config.WarShipForbiddenIds, true, true, "WarShip")) { if(!Check.checkSchematic(clipboard, Config.WarShipForbiddenIds, true, true, "WarShip")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip ist nicht regelkonform!"); player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip ist nicht regelkonform!");
return false; return false;
} }
schematic.setSchemType(SchematicType.Cwarship); schematic.setSchemType(SchematicType.Cwarship);
player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6warship §7angefordert!"); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6warship §7angefordert!");
sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarShip§8]"); Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarShip§8]");
} }
return false; return false;
} }
@ -385,7 +383,7 @@ public class SchematicCommand implements CommandExecutor {
} }
if(args[0].equalsIgnoreCase("addmember")) { if(args[0].equalsIgnoreCase("addmember")) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if(schematic != null) { if(schematic != null) {
if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) { if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
@ -428,7 +426,7 @@ public class SchematicCommand implements CommandExecutor {
} }
if(args[0].equalsIgnoreCase("delmember")) { if(args[0].equalsIgnoreCase("delmember")) {
if(isSchematicNameAllowed(args[1])) { if(Check.isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if(schematic != null) { if(schematic != null) {
if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) { if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
@ -496,7 +494,7 @@ public class SchematicCommand implements CommandExecutor {
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(allowedToCheck(player)) { if(Check.allowedToCheck(player)) {
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:"); player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
player.sendMessage("§8/schem checklist <Seite> - §6Zeigt die Liste der ungeprüften Schematics"); player.sendMessage("§8/schem checklist <Seite> - §6Zeigt die Liste der ungeprüften Schematics");
player.sendMessage("§8/schem check <SchematicName> - §6Zum Checken einer Schematic"); player.sendMessage("§8/schem check <SchematicName> - §6Zum Checken einer Schematic");
@ -601,238 +599,4 @@ public class SchematicCommand implements CommandExecutor {
} }
} }
private boolean isSchematicNameAllowed(String schematicName) {
if(schematicName.contains("/") ||
schematicName.contains("\\") ||
schematicName.contains("<") ||
schematicName.contains(">") ||
schematicName.contains("^") ||
schematicName.contains("°") ||
schematicName.contains("'") ||
schematicName.contains("\"")) {
return false;
} else
return true;
}
private boolean checkSchematic(Clipboard clipboard, List<Integer> forbiddenBlocks, boolean obsidianToTnt, boolean slimeToBedrock, String modus) {
Region region = clipboard.getRegion();
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int obsidian = 0;
int bedrock = 0;
int dispenser = 0;
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
Vector vector = new Vector(x, y, z);
try {
if(obsidianToTnt && clipboard.getBlock(vector).getId() == 46) {
clipboard.setBlock(vector, new BaseBlock(49));
obsidian++;
}
if(slimeToBedrock && clipboard.getBlock(vector).getId() == 165) {
if(modus.equals("WarShip") ||
modus.equals("AirShip"))
clipboard.setBlock(vector, new BaseBlock(7));
bedrock++;
}
if(clipboard.getBlock(vector).getId() == 23)
dispenser++;
} catch (WorldEditException ex) {
return false;
}
if (forbiddenBlocks.contains(clipboard.getBlock(vector).getId()))
return false;
}
}
}
int obsidianBedrock = obsidian + bedrock;
if(modus.equalsIgnoreCase("WarGear")) {
if(Config.WarGearMaxObsidian < obsidian)
return false;
if(Config.WarGearMaxBedrock < bedrock)
return false;
if(Config.WarGearMaxDispenser < dispenser)
return false;
if(Config.WarGearObsidianBedrock < obsidianBedrock)
return false;
}
if(modus.equalsIgnoreCase("MiniWarGear")) {
if(Config.MiniWarGearMaxObsidian < obsidian)
return false;
if(Config.MiniWarGearMaxBedrock < bedrock)
return false;
if(Config.MiniWarGearMaxDispenser < dispenser)
return false;
if(Config.MiniWarGearObsidianBedrock < obsidianBedrock)
return false;
}
if(modus.equalsIgnoreCase("WarShip")) {
if(Config.WarShipMaxObsidian < obsidian)
return false;
if(Config.WarShipMaxBedrock < bedrock)
return false;
if(Config.WarShipMaxDispenser < dispenser)
return false;
if(Config.WarShipObsidianBedrock < obsidianBedrock)
return false;
}
if(modus.equalsIgnoreCase("AirShip")) {
if(Config.AirShipMaxObsidian < obsidian)
return false;
if(Config.AirShipMaxBedrock < bedrock)
return false;
if(Config.AirShipMaxDispenser < dispenser)
return false;
if(Config.AirShipObsidianBedrock < obsidianBedrock)
return false;
}
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.check.Check;
import de.warking.schematicsystem.commands.SchematicCommand; 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;
@ -39,8 +40,8 @@ public class PlayerJoinListener implements Listener {
} }
} }
if(SchematicCommand.allowedToCheck(player)) if(Check.allowedToCheck(player))
player.sendMessage(SchematicCommand.sendTeamMembersCSchematicsInfo()); player.sendMessage(Check.sendTeamMembersCSchematicsInfo());
} }