added schematic check system; extended config; fixed bugs; not stable version
Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
bd21fd9ac3
Commit
14238f621c
@ -6,6 +6,7 @@ Schematics:
|
|||||||
Obsidian:
|
Obsidian:
|
||||||
Bedrock:
|
Bedrock:
|
||||||
ForbiddenIds:
|
ForbiddenIds:
|
||||||
|
CheckList:
|
||||||
MiniWarGear:
|
MiniWarGear:
|
||||||
Breite:
|
Breite:
|
||||||
Höhe:
|
Höhe:
|
||||||
@ -13,6 +14,7 @@ Schematics:
|
|||||||
Obsidian:
|
Obsidian:
|
||||||
Bedrock:
|
Bedrock:
|
||||||
ForbiddenIds:
|
ForbiddenIds:
|
||||||
|
CheckList:
|
||||||
WarShip:
|
WarShip:
|
||||||
Breite:
|
Breite:
|
||||||
Höhe:
|
Höhe:
|
||||||
@ -20,6 +22,7 @@ Schematics:
|
|||||||
Obsidian:
|
Obsidian:
|
||||||
Bedrock:
|
Bedrock:
|
||||||
ForbiddenIds:
|
ForbiddenIds:
|
||||||
|
CheckList:
|
||||||
AirShip:
|
AirShip:
|
||||||
Breite:
|
Breite:
|
||||||
Höhe:
|
Höhe:
|
||||||
@ -27,3 +30,4 @@ Schematics:
|
|||||||
Obsidian:
|
Obsidian:
|
||||||
Bedrock:
|
Bedrock:
|
||||||
ForbiddenIds:
|
ForbiddenIds:
|
||||||
|
CheckList:
|
@ -1,9 +1,8 @@
|
|||||||
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.schematicsystem.check.CheckUtils;
|
||||||
import de.warking.hunjy.MySQL.SchematicType;
|
import de.warking.schematicsystem.commands.CheckCommand;
|
||||||
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;
|
||||||
@ -13,9 +12,6 @@ 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/";
|
||||||
@ -23,8 +19,6 @@ 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;
|
||||||
|
|
||||||
@ -40,14 +34,15 @@ public class SchematicSystem extends JavaPlugin {
|
|||||||
getCommand("/schematic").setExecutor(new SchematicCommand());
|
getCommand("/schematic").setExecutor(new SchematicCommand());
|
||||||
getCommand("schem").setExecutor(new SchematicCommand());
|
getCommand("schem").setExecutor(new SchematicCommand());
|
||||||
getCommand("/schem").setExecutor(new SchematicCommand());
|
getCommand("/schem").setExecutor(new SchematicCommand());
|
||||||
|
getCommand("check").setExecutor(new CheckCommand());
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(instance, new Runnable() {
|
Bukkit.getScheduler().scheduleAsyncRepeatingTask(instance, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if(CheckUtils.getCSchematicsSize() > 0)
|
||||||
Check.sendTeamMembersCSchematics(Check.sendTeamMembersCSchematicsInfo());
|
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
|
||||||
}
|
}
|
||||||
}, 0, 20*60*10);
|
}, 0, 20*60*10);
|
||||||
}
|
}
|
||||||
@ -70,8 +65,4 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
194
src/de/warking/schematicsystem/check/CheckSession.java
Normale Datei
194
src/de/warking/schematicsystem/check/CheckSession.java
Normale Datei
@ -0,0 +1,194 @@
|
|||||||
|
package de.warking.schematicsystem.check;
|
||||||
|
|
||||||
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
|
import de.warking.hunjy.MySQL.SchematicType;
|
||||||
|
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.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class CheckSession {
|
||||||
|
|
||||||
|
public static ArrayList<CheckSession> checkSessions = new ArrayList<>();
|
||||||
|
|
||||||
|
private UUID uuid; //player
|
||||||
|
private Schematic schematic;
|
||||||
|
private int position; //position in checklist
|
||||||
|
private HashMap<Integer, Integer> checkTimes = new HashMap<>(); //position, time
|
||||||
|
|
||||||
|
private long startTime;
|
||||||
|
private long stopTime;
|
||||||
|
|
||||||
|
public CheckSession(UUID uuid, Schematic schematic, int position) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.schematic = schematic;
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
checkSessions.add(this);
|
||||||
|
setStartTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean doesPlayerCheck(Player player) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
|
for(CheckSession checkSession : checkSessions) {
|
||||||
|
return checkSession.equals(uuid);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckSession getCheckSession(Player player) {
|
||||||
|
for(CheckSession checkSession : checkSessions) {
|
||||||
|
if(checkSession.getUuid().equals(player.getUniqueId()))
|
||||||
|
return checkSession;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calculatePositionTime() {
|
||||||
|
return Math.round((stopTime - startTime) / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calculateTotalTime() {
|
||||||
|
int totalTime = 0;
|
||||||
|
for(Map.Entry<Integer, Integer> entry : this.checkTimes.entrySet()) {
|
||||||
|
totalTime += entry.getValue();
|
||||||
|
}
|
||||||
|
return totalTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendNextCheck() {
|
||||||
|
setStopTime();
|
||||||
|
this.position++;
|
||||||
|
setStartTime();
|
||||||
|
if(getChecklist().size() > (this.position + 1)) {
|
||||||
|
Bukkit.getPlayer(uuid).sendMessage(getCheckListEntry(this.position));
|
||||||
|
|
||||||
|
TextComponent next = new TextComponent("next ");
|
||||||
|
next.setColor(ChatColor.GREEN);
|
||||||
|
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check next"));
|
||||||
|
|
||||||
|
TextComponent decline = new TextComponent("decline");
|
||||||
|
decline.setColor(ChatColor.DARK_RED);
|
||||||
|
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
|
||||||
|
|
||||||
|
next.addExtra(decline);
|
||||||
|
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
|
||||||
|
return;
|
||||||
|
} else if(getChecklist().size() == (this.position + 1)) {
|
||||||
|
Bukkit.getPlayer(uuid).sendMessage(getCheckListEntry(this.position));
|
||||||
|
|
||||||
|
TextComponent accept = new TextComponent("accept ");
|
||||||
|
accept.setColor(ChatColor.GREEN);
|
||||||
|
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
|
||||||
|
|
||||||
|
TextComponent decline = new TextComponent("decline");
|
||||||
|
decline.setColor(ChatColor.DARK_RED);
|
||||||
|
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
|
||||||
|
|
||||||
|
accept.addExtra(decline);
|
||||||
|
Bukkit.getPlayer(uuid).spigot().sendMessage(accept);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getChecklist() {
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cwargear)
|
||||||
|
return Config.WarGearCheckList;
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cminiwargear)
|
||||||
|
return Config.MiniWarGearCheckList;
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cwarship)
|
||||||
|
return Config.WarShipCheckList;
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cairship)
|
||||||
|
return Config.AirShipCheckList;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCheckListEntry(int position) {
|
||||||
|
return getChecklist().get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void allowSchematic() {
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cwargear) {
|
||||||
|
schematic.setSchemType(SchematicType.wargear);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cminiwargear) {
|
||||||
|
schematic.setSchemType(SchematicType.miniwargear);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cwarship) {
|
||||||
|
schematic.setSchemType(SchematicType.warship);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(schematic.getSchemType() == SchematicType.Cairship) {
|
||||||
|
schematic.setSchemType(SchematicType.airship);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//TODO: save position times and total time to file
|
||||||
|
//calculateTotalTime();
|
||||||
|
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void declineSchematic() {
|
||||||
|
this.schematic.setSchemType(SchematicType.normal);
|
||||||
|
//TODO: save position times and total time to file
|
||||||
|
//calculateTotalTime();
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
checkSessions.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Schematic getSchematic() {
|
||||||
|
return schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSchematic(Schematic schematic) {
|
||||||
|
this.schematic = schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(int position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Integer, Integer> getCheckTimes() {
|
||||||
|
return checkTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime() {
|
||||||
|
this.startTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStopTime() {
|
||||||
|
return stopTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStopTime() {
|
||||||
|
this.stopTime = System.currentTimeMillis();
|
||||||
|
checkTimes.put(this.position, calculatePositionTime());
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package de.warking.schematicsystem.check;
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import de.warking.hunjy.MySQL.Schematic;
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
@ -22,7 +23,7 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Check {
|
public class CheckUtils {
|
||||||
|
|
||||||
public static boolean isSchematicNameAllowed(String schematicName) {
|
public static boolean isSchematicNameAllowed(String schematicName) {
|
||||||
if(schematicName.contains("/") ||
|
if(schematicName.contains("/") ||
|
||||||
@ -39,6 +40,7 @@ public class Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkSchematic(Clipboard clipboard, List<Integer> forbiddenBlocks, boolean obsidianToTnt, boolean slimeToBedrock, String modus) {
|
public static boolean checkSchematic(Clipboard clipboard, List<Integer> forbiddenBlocks, boolean obsidianToTnt, boolean slimeToBedrock, String modus) {
|
||||||
|
|
||||||
Region region = clipboard.getRegion();
|
Region region = clipboard.getRegion();
|
||||||
Vector min = region.getMinimumPoint();
|
Vector min = region.getMinimumPoint();
|
||||||
Vector max = region.getMaximumPoint();
|
Vector max = region.getMaximumPoint();
|
||||||
@ -136,6 +138,15 @@ public class Check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getCSchematicsSize() {
|
||||||
|
int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
|
||||||
|
Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
|
||||||
|
Schematic.getAllSchemsOfType(SchematicType.Cwargear).size() +
|
||||||
|
Schematic.getAllSchemsOfType(SchematicType.Cwarship).size();
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
public static String sendTeamMembersCSchematicsInfo() {
|
public static String sendTeamMembersCSchematicsInfo() {
|
||||||
int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
|
int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
|
||||||
Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
|
Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
|
||||||
@ -155,29 +166,7 @@ public class Check {
|
|||||||
|
|
||||||
public static void sendTeammemberSchematicList(Player player, int filesPerPage, int currentPage) {
|
public static void sendTeammemberSchematicList(Player player, int filesPerPage, int currentPage) {
|
||||||
|
|
||||||
List<Schematic> wargears = Schematic.getAllSchemsOfType(SchematicType.Cwargear);
|
List<Schematic> schematicList = getAllCSchems();
|
||||||
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()) {
|
if(schematicList.isEmpty()) {
|
||||||
@ -224,7 +213,7 @@ public class Check {
|
|||||||
schematics.setBold(true);
|
schematics.setBold(true);
|
||||||
|
|
||||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen...").create()));
|
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()));
|
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + WarkingUser.get(schematic.getSchemOwner()).getUserName()));
|
||||||
|
|
||||||
player.spigot().sendMessage(schematics);
|
player.spigot().sendMessage(schematics);
|
||||||
}
|
}
|
||||||
@ -235,28 +224,49 @@ public class Check {
|
|||||||
TextComponent nextPage = new TextComponent("Nächste Seite >>");
|
TextComponent nextPage = new TextComponent("Nächste Seite >>");
|
||||||
nextPage.setColor(ChatColor.RED);
|
nextPage.setColor(ChatColor.RED);
|
||||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
|
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"));
|
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist 1"));
|
||||||
player.spigot().sendMessage(nextPage);
|
player.spigot().sendMessage(nextPage);
|
||||||
} else if((currPage + 1) == pages) {
|
} else if((currPage + 1) == pages) {
|
||||||
TextComponent beforePage = new TextComponent("<< Vorherige Seite");
|
TextComponent beforePage = new TextComponent("<< Vorherige Seite");
|
||||||
beforePage.setColor(ChatColor.RED);
|
beforePage.setColor(ChatColor.RED);
|
||||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
|
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)));
|
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist " + (currPage - 1)));
|
||||||
player.spigot().sendMessage(beforePage);
|
player.spigot().sendMessage(beforePage);
|
||||||
} else {
|
} else {
|
||||||
TextComponent beforePage = new TextComponent("<< Seite ");
|
TextComponent beforePage = new TextComponent("<< Seite ");
|
||||||
beforePage.setColor(ChatColor.RED);
|
beforePage.setColor(ChatColor.RED);
|
||||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
|
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)));
|
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist " + (currPage - 1)));
|
||||||
|
|
||||||
TextComponent nextPage = new TextComponent(">>");
|
TextComponent nextPage = new TextComponent(">>");
|
||||||
nextPage.setColor(ChatColor.RED);
|
nextPage.setColor(ChatColor.RED);
|
||||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
|
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)));
|
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist " + (currPage + 1)));
|
||||||
|
|
||||||
beforePage.addExtra(nextPage);
|
beforePage.addExtra(nextPage);
|
||||||
player.spigot().sendMessage(beforePage);
|
player.spigot().sendMessage(beforePage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Schematic> getAllCSchems() {
|
||||||
|
|
||||||
|
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)
|
||||||
|
schematicList.add(schematic);
|
||||||
|
for(Schematic schematic : miniwargears)
|
||||||
|
schematicList.add(schematic);
|
||||||
|
for(Schematic schematic : warships)
|
||||||
|
schematicList.add(schematic);
|
||||||
|
for(Schematic schematic : airships)
|
||||||
|
schematicList.add(schematic);
|
||||||
|
|
||||||
|
return schematicList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
204
src/de/warking/schematicsystem/commands/CheckCommand.java
Normale Datei
204
src/de/warking/schematicsystem/commands/CheckCommand.java
Normale Datei
@ -0,0 +1,204 @@
|
|||||||
|
package de.warking.schematicsystem.commands;
|
||||||
|
|
||||||
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
|
import de.warking.hunjy.MySQL.SchematicType;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import de.warking.schematicsystem.SchematicSystem;
|
||||||
|
import de.warking.schematicsystem.check.CheckSession;
|
||||||
|
import de.warking.schematicsystem.check.CheckUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CheckCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(CheckUtils.allowedToCheck(player)) {
|
||||||
|
|
||||||
|
if(args.length == 0) {
|
||||||
|
sendHelp(player);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.length == 1) {
|
||||||
|
if(args[0].equalsIgnoreCase("checklist")) {
|
||||||
|
CheckUtils.sendTeammemberSchematicList(player, 15, 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[0].equalsIgnoreCase("next")) {
|
||||||
|
CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||||
|
if(checkSession != null) {
|
||||||
|
checkSession.sendNextCheck();
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[0].equalsIgnoreCase("allow")) {
|
||||||
|
CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||||
|
if(checkSession != null) {
|
||||||
|
if(checkSession.getPosition() == (checkSession.getChecklist().size() - 1)) {
|
||||||
|
|
||||||
|
String schemType = "";
|
||||||
|
if(checkSession.getSchematic().getSchemType() == SchematicType.Cwargear)
|
||||||
|
schemType = SchematicType.wargear.name();
|
||||||
|
if(checkSession.getSchematic().getSchemType() == SchematicType.Cminiwargear)
|
||||||
|
schemType = SchematicType.miniwargear.name();
|
||||||
|
if(checkSession.getSchematic().getSchemType() == SchematicType.Cwarship)
|
||||||
|
schemType = SchematicType.warship.name();
|
||||||
|
if(checkSession.getSchematic().getSchemType() == SchematicType.Cairship)
|
||||||
|
schemType = SchematicType.airship.name();
|
||||||
|
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + WarkingUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §aist nun als §6" + schemType + " §afreigegeben!");
|
||||||
|
checkSession.allowSchematic();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu hast noch nicht alles überprüft!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.length == 2) {
|
||||||
|
if(args[0].equalsIgnoreCase("checklist")) {
|
||||||
|
int currentPage;
|
||||||
|
try {
|
||||||
|
currentPage = Integer.parseInt(args[1]);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Zahl angeben!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CheckUtils.sendTeammemberSchematicList(player, 15, currentPage);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.length == 3) {
|
||||||
|
|
||||||
|
if(args[0].equalsIgnoreCase("schematic")) {
|
||||||
|
String schemName = args[1];
|
||||||
|
String owner = args[2];
|
||||||
|
|
||||||
|
if(!CheckUtils.isSchematicNameAllowed(schemName)) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarkingUser warkingUser = WarkingUser.get(owner);
|
||||||
|
if(warkingUser != null) {
|
||||||
|
|
||||||
|
Schematic schematic = Schematic.getSchemFromDB(schemName, warkingUser.getUUID());
|
||||||
|
if(schematic != null) {
|
||||||
|
for(CheckSession checkSession : CheckSession.checkSessions) {
|
||||||
|
if(checkSession.getSchematic().equals(schematic)) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX +"§cDiese Schematic wird bereits geprüft!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, UUID> schematicList = new HashMap<>();
|
||||||
|
for(Schematic schematics : CheckUtils.getAllCSchems()) {
|
||||||
|
schematicList.put(schematics.getSchemName(), WarkingUser.get(schematics.getSchemOwner()).getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Map.Entry<String, UUID> entry : schematicList.entrySet()) {
|
||||||
|
if(!(entry.getKey().equals(schematic.getSchemName()) && entry.getValue().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID()))) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! CONTAINS");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/" + schemName + ".schematic");
|
||||||
|
if(!file.exists()) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NO SUCH FILE");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
com.boydti.fawe.object.schematic.Schematic schematicFAWE = FaweAPI.load(file);
|
||||||
|
Location playerLocation = player.getLocation();
|
||||||
|
|
||||||
|
World weWorld = new BukkitWorld(player.getWorld());
|
||||||
|
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
|
||||||
|
schematicFAWE.paste(weWorld, vector);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! PASTE");
|
||||||
|
ex.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckSession checkSession = new CheckSession(player.getUniqueId(), schematic, -1);
|
||||||
|
checkSession.sendNextCheck();
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NULL");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! USER");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.length >= 3) {
|
||||||
|
if(args[0].equalsIgnoreCase("decline")) {
|
||||||
|
|
||||||
|
CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||||
|
if(checkSession != null) {
|
||||||
|
|
||||||
|
String message = "";
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
message = message + args[i] + " ";
|
||||||
|
}
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + WarkingUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §awurde aufgrund von §6" + message + " §anicht freigegeben!");
|
||||||
|
checkSession.declineSchematic();
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendHelp(Player player) {
|
||||||
|
if(CheckUtils.allowedToCheck(player)) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
|
||||||
|
player.sendMessage("§8/ckeck checklist - §6Zeigt die Liste der ungeprüften Schematics");
|
||||||
|
player.sendMessage("§8/ckeck schematic <SchematicName> <Besitzer> - §6Zum Checken einer Schematic");
|
||||||
|
player.sendMessage("§8/ckeck allow - §6Schematic freigeben");
|
||||||
|
player.sendMessage("§8/ckeck decline <Grund> - §6Schematic nicht freigeben");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
|||||||
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.check.CheckUtils;
|
||||||
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;
|
||||||
@ -57,11 +57,6 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
sendHelp(player);
|
sendHelp(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("checklist") && Check.allowedToCheck(player)) {
|
|
||||||
Check.sendTeammemberSchematicList(player, 15, 0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@ -76,7 +71,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("load")) {
|
if(args[0].equalsIgnoreCase("load")) {
|
||||||
if(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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) {
|
||||||
|
|
||||||
@ -108,7 +103,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("delete")) {
|
if(args[0].equalsIgnoreCase("delete")) {
|
||||||
if(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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())) {
|
||||||
@ -140,7 +135,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("savedelete")) {
|
if(args[0].equalsIgnoreCase("savedelete")) {
|
||||||
if(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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())) {
|
||||||
@ -165,7 +160,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if(args[0].equalsIgnoreCase("save")) {
|
if(args[0].equalsIgnoreCase("save")) {
|
||||||
|
|
||||||
if(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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) {
|
||||||
@ -180,7 +175,12 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
} else
|
} else
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gespeichert!");
|
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gespeichert!");
|
||||||
|
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId().toString() + "/", args[1] + ".schematic");
|
|
||||||
|
File folder = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId().toString() + "/");
|
||||||
|
if(!folder.exists())
|
||||||
|
folder.mkdir();
|
||||||
|
|
||||||
|
File file = new File(folder, args[1] + ".schematic");
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
Files.setPosixFilePermissions(file.toPath(),
|
Files.setPosixFilePermissions(file.toPath(),
|
||||||
EnumSet.of(PosixFilePermission.OWNER_READ,
|
EnumSet.of(PosixFilePermission.OWNER_READ,
|
||||||
@ -207,7 +207,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("info")) {
|
if(args[0].equalsIgnoreCase("info")) {
|
||||||
if(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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) {
|
||||||
|
|
||||||
@ -249,18 +249,6 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("checklist") && Check.allowedToCheck(player)) {
|
|
||||||
int currentPage;
|
|
||||||
try {
|
|
||||||
currentPage = Integer.parseInt(args[1]);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Zahl angeben!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Check.sendTeammemberSchematicList(player, 15, currentPage);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@ -268,7 +256,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(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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 {
|
||||||
@ -323,52 +311,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(!Check.checkSchematic(clipboard, Config.AirShipForbiddenIds, true, true, "AirShip")) {
|
if(!CheckUtils.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!");
|
||||||
Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6AirShip§8]");
|
CheckUtils.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(!Check.checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, true, true, "MiniWarGear")) {
|
if(!CheckUtils.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!");
|
||||||
Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6MiniWarGear§8]");
|
CheckUtils.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(!Check.checkSchematic(clipboard, Config.WarGearForbiddenIds, true, true, "WarGear")) {
|
if(!CheckUtils.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!");
|
||||||
Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarGear§8]");
|
CheckUtils.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(!Check.checkSchematic(clipboard, Config.WarShipForbiddenIds, true, true, "WarShip")) {
|
if(!CheckUtils.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!");
|
||||||
Check.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarShip§8]");
|
CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarShip§8]");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -383,7 +371,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("addmember")) {
|
if(args[0].equalsIgnoreCase("addmember")) {
|
||||||
if(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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()) {
|
||||||
@ -426,7 +414,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("delmember")) {
|
if(args[0].equalsIgnoreCase("delmember")) {
|
||||||
if(Check.isSchematicNameAllowed(args[1])) {
|
if(CheckUtils.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()) {
|
||||||
@ -469,14 +457,6 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("lock")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("unlock")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -494,13 +474,6 @@ 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(Check.allowedToCheck(player)) {
|
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
|
|
||||||
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 allow / decline - §6Schematic (nicht) freigeben");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player) {
|
public static void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player) {
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package de.warking.schematicsystem.listener;
|
||||||
|
|
||||||
|
import de.warking.schematicsystem.SchematicSystem;
|
||||||
|
import de.warking.schematicsystem.check.CheckSession;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class PlayerCommandPreProcessListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void handlePlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if(!event.getMessage().contains("copy"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(CheckSession.doesPlayerCheck(player)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nichts kopieren während du eine Schematic prüfst!");
|
||||||
|
//eventuell Admin Benachrichtigen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -4,8 +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.check.CheckUtils;
|
||||||
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;
|
||||||
@ -40,8 +39,8 @@ public class PlayerJoinListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Check.allowedToCheck(player))
|
if(CheckUtils.allowedToCheck(player))
|
||||||
player.sendMessage(Check.sendTeamMembersCSchematicsInfo());
|
player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,29 +1,18 @@
|
|||||||
package de.warking.schematicsystem.listener;
|
package de.warking.schematicsystem.listener;
|
||||||
|
|
||||||
import de.warking.hunjy.MySQL.Schematic;
|
import de.warking.schematicsystem.check.CheckSession;
|
||||||
import de.warking.schematicsystem.SchematicSystem;
|
|
||||||
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;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class PlayerQuitListener implements Listener {
|
public class PlayerQuitListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(SchematicSystem.getCurrCheckSchems().containsKey(player.getUniqueId())) {
|
if(CheckSession.doesPlayerCheck(player))
|
||||||
Iterator itr = SchematicSystem.getCurrCheckSchems().entrySet().iterator();
|
CheckSession.getCheckSession(player).remove();
|
||||||
while (itr.hasNext()) {
|
|
||||||
Map.Entry<UUID, Schematic> pair = (Map.Entry) itr.next();
|
|
||||||
if(pair.getKey().equals(player.getUniqueId()))
|
|
||||||
itr.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ public class Config {
|
|||||||
public static int WarGearObsidianBedrock;
|
public static int WarGearObsidianBedrock;
|
||||||
public static int WarGearMaxDispenser;
|
public static int WarGearMaxDispenser;
|
||||||
public static List<Integer> WarGearForbiddenIds;
|
public static List<Integer> WarGearForbiddenIds;
|
||||||
|
public static List<String> WarGearCheckList;
|
||||||
|
|
||||||
public static double MiniWarGearBreite;
|
public static double MiniWarGearBreite;
|
||||||
public static double MiniWarGearHöhe;
|
public static double MiniWarGearHöhe;
|
||||||
@ -26,6 +27,7 @@ public class Config {
|
|||||||
public static int MiniWarGearObsidianBedrock;
|
public static int MiniWarGearObsidianBedrock;
|
||||||
public static int MiniWarGearMaxDispenser;
|
public static int MiniWarGearMaxDispenser;
|
||||||
public static List<Integer> MiniWarGearForbiddenIds;
|
public static List<Integer> MiniWarGearForbiddenIds;
|
||||||
|
public static List<String> MiniWarGearCheckList;
|
||||||
|
|
||||||
public static double WarShipBreite;
|
public static double WarShipBreite;
|
||||||
public static double WarShipHöhe;
|
public static double WarShipHöhe;
|
||||||
@ -35,6 +37,7 @@ public class Config {
|
|||||||
public static int WarShipObsidianBedrock;
|
public static int WarShipObsidianBedrock;
|
||||||
public static int WarShipMaxDispenser;
|
public static int WarShipMaxDispenser;
|
||||||
public static List<Integer> WarShipForbiddenIds;
|
public static List<Integer> WarShipForbiddenIds;
|
||||||
|
public static List<String> WarShipCheckList;
|
||||||
|
|
||||||
public static double AirShipBreite;
|
public static double AirShipBreite;
|
||||||
public static double AirShipHöhe;
|
public static double AirShipHöhe;
|
||||||
@ -44,6 +47,7 @@ public class Config {
|
|||||||
public static int AirShipObsidianBedrock;
|
public static int AirShipObsidianBedrock;
|
||||||
public static int AirShipMaxDispenser;
|
public static int AirShipMaxDispenser;
|
||||||
public static List<Integer> AirShipForbiddenIds;
|
public static List<Integer> AirShipForbiddenIds;
|
||||||
|
public static List<String> AirShipCheckList;
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
if (!new File("plugins/" + SchematicSystem.getInstance().getName() + "/config.yml").exists()) {
|
if (!new File("plugins/" + SchematicSystem.getInstance().getName() + "/config.yml").exists()) {
|
||||||
@ -61,6 +65,7 @@ public class Config {
|
|||||||
WarGearObsidianBedrock = config.getInt("Schematics.WarGear.ObsidianBedrock");
|
WarGearObsidianBedrock = config.getInt("Schematics.WarGear.ObsidianBedrock");
|
||||||
WarGearMaxDispenser = config.getInt("Schematics.WarGear.Dispenser");
|
WarGearMaxDispenser = config.getInt("Schematics.WarGear.Dispenser");
|
||||||
WarGearForbiddenIds = config.getIntegerList("Schematics.WarGear.ForbiddenIds");
|
WarGearForbiddenIds = config.getIntegerList("Schematics.WarGear.ForbiddenIds");
|
||||||
|
WarGearCheckList = config.getStringList("Schematics.WarGear.CheckList");
|
||||||
|
|
||||||
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");
|
||||||
@ -70,6 +75,7 @@ public class Config {
|
|||||||
MiniWarGearObsidianBedrock = config.getInt("Schematics.MiniWarGear.ObsidianBedrock");
|
MiniWarGearObsidianBedrock = config.getInt("Schematics.MiniWarGear.ObsidianBedrock");
|
||||||
MiniWarGearMaxDispenser = config.getInt("Schematics.MiniWarGear.Dispenser");
|
MiniWarGearMaxDispenser = config.getInt("Schematics.MiniWarGear.Dispenser");
|
||||||
MiniWarGearForbiddenIds = config.getIntegerList("Schematics.MiniWarGear.ForbiddenIds");
|
MiniWarGearForbiddenIds = config.getIntegerList("Schematics.MiniWarGear.ForbiddenIds");
|
||||||
|
MiniWarGearCheckList = config.getStringList("Schematics.MiniWarGear.CheckList");
|
||||||
|
|
||||||
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");
|
||||||
@ -79,6 +85,7 @@ public class Config {
|
|||||||
WarShipObsidianBedrock = config.getInt("Schematics.WarShip.ObsidianBedrock");
|
WarShipObsidianBedrock = config.getInt("Schematics.WarShip.ObsidianBedrock");
|
||||||
WarShipMaxDispenser = config.getInt("Schematics.WarShip.Dispenser");
|
WarShipMaxDispenser = config.getInt("Schematics.WarShip.Dispenser");
|
||||||
WarShipForbiddenIds = config.getIntegerList("Schematics.WarShip.ForbiddenIds");
|
WarShipForbiddenIds = config.getIntegerList("Schematics.WarShip.ForbiddenIds");
|
||||||
|
WarShipCheckList = config.getStringList("Schematics.WarShip.CheckList");
|
||||||
|
|
||||||
AirShipBreite = config.getDouble("Schematics.AirShip.Breite");
|
AirShipBreite = config.getDouble("Schematics.AirShip.Breite");
|
||||||
AirShipHöhe = config.getDouble("Schematics.AirShip.Höhe");
|
AirShipHöhe = config.getDouble("Schematics.AirShip.Höhe");
|
||||||
@ -88,5 +95,6 @@ public class Config {
|
|||||||
AirShipObsidianBedrock = config.getInt("Schematics.AirShip.ObsidianBedrock");
|
AirShipObsidianBedrock = config.getInt("Schematics.AirShip.ObsidianBedrock");
|
||||||
AirShipMaxDispenser = config.getInt("Schematics.AirShip.Dispenser");
|
AirShipMaxDispenser = config.getInt("Schematics.AirShip.Dispenser");
|
||||||
AirShipForbiddenIds = config.getIntegerList("Schematics.AirShip.ForbiddenIds");
|
AirShipForbiddenIds = config.getIntegerList("Schematics.AirShip.ForbiddenIds");
|
||||||
|
AirShipCheckList = config.getStringList("Schematics.AirShip.CheckList");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,3 +9,4 @@ commands:
|
|||||||
/schematic:
|
/schematic:
|
||||||
schem:
|
schem:
|
||||||
/schem:
|
/schem:
|
||||||
|
check:
|
In neuem Issue referenzieren
Einen Benutzer sperren