Merge branch 'new-checksystem'
# Conflicts: # src/de/steamwar/bungeecore/BungeeCore.java # src/de/steamwar/bungeecore/commands/FightCommand.java
Dieser Commit ist enthalten in:
Commit
3260bc4581
@ -8,6 +8,7 @@ public class ArenaMode {
|
||||
|
||||
private static Map<String, ArenaMode> byChat = new HashMap<>();
|
||||
private static Map<String, ArenaMode> byInternal = new HashMap<>();
|
||||
private static Map<String, ArenaMode> byCheckSchemType = new HashMap<>();
|
||||
private static List<ArenaMode> allModes = new LinkedList<>();
|
||||
private static Random random = new Random();
|
||||
|
||||
@ -33,6 +34,10 @@ public class ArenaMode {
|
||||
return chatNames;
|
||||
}
|
||||
|
||||
public static ArenaMode getByCheckSchemType(String checkSchemType){
|
||||
return byCheckSchemType.get(checkSchemType);
|
||||
}
|
||||
|
||||
public static List<ArenaMode> getAllModes(){
|
||||
return allModes;
|
||||
}
|
||||
@ -57,6 +62,9 @@ public class ArenaMode {
|
||||
for(String name : chatNames){
|
||||
byChat.put(name.toLowerCase(), this);
|
||||
}
|
||||
|
||||
if(config.contains("checkSchemType"))
|
||||
byCheckSchemType.put(config.getString("checkSchemType").toLowerCase(), this);
|
||||
}
|
||||
|
||||
public String getInternalName() {
|
||||
|
@ -58,6 +58,7 @@ public class BungeeCore extends Plugin {
|
||||
new LabyMod();
|
||||
new ChatListener();
|
||||
new BanListener();
|
||||
new CheckListener();
|
||||
|
||||
commands.put("/b", null);
|
||||
commands.put("/gs", null);
|
||||
@ -93,6 +94,7 @@ public class BungeeCore extends Plugin {
|
||||
new WhoisCommand();
|
||||
new RegelnCommand();
|
||||
new HistoricCommand();
|
||||
new CheckCommand();
|
||||
|
||||
new EventStarter();
|
||||
new Broadcaster();
|
||||
@ -196,6 +198,7 @@ public class BungeeCore extends Plugin {
|
||||
BAUWELT15 = config.getString("bauwelt15");
|
||||
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
|
||||
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
|
||||
CheckCommand.loadCheckQuestions(config.getSection("checkquestions"));
|
||||
Persistent.setChatPrefix(CHAT_PREFIX);
|
||||
Persistent.setLobbyServer(LOBBY_SERVER);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class SubserverSystem {
|
||||
* @return
|
||||
* The new started subserver.
|
||||
*/
|
||||
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, String serverName, String mapName, UUID player1, UUID player2){
|
||||
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2){
|
||||
//Generate missing parameters
|
||||
int port = freePort(2500);
|
||||
|
||||
@ -96,6 +96,8 @@ public class SubserverSystem {
|
||||
cmd.add("-DblueLeader=" + player1.toString());
|
||||
if(player2 != null)
|
||||
cmd.add("-DredLeader=" + player2.toString());
|
||||
if(checkSchemID != 0)
|
||||
cmd.add("-DcheckSchemID=" + checkSchemID);
|
||||
cmd.add("-Xmx2G");
|
||||
cmd.addAll(JVM_ARGS);
|
||||
cmd.add("-jar");
|
||||
@ -135,7 +137,7 @@ public class SubserverSystem {
|
||||
}
|
||||
|
||||
public static Subserver startArena(ArenaMode modus, String map){
|
||||
return startArena(modus, map, 0, null, null, null, null);
|
||||
return startArena(modus, map, 0, 0, null, null, null, null);
|
||||
}
|
||||
|
||||
public static Subserver startEventArena(EventFight eventFight, String serverName){
|
||||
@ -143,14 +145,15 @@ public class SubserverSystem {
|
||||
eventFight.getSpielmodus(),
|
||||
eventFight.getMap(),
|
||||
eventFight.getFightID(),
|
||||
0,
|
||||
serverName,
|
||||
serverName.replace(' ', '_') + eventFight.getStartTime().toLocalDateTime().format(EventCommand.TIME_FORMAT),
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
public static void sendToTestServer(ProxiedPlayer p, ArenaMode m, String map){
|
||||
startArena(m, map, -1, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null).sendPlayer(p);
|
||||
public static void sendToTestServer(ProxiedPlayer p, ArenaMode m, String map, int checkSchemId){
|
||||
startArena(m, map, -1, checkSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null).sendPlayer(p);
|
||||
}
|
||||
|
||||
public static void sendToBauServer(ProxiedPlayer p, UUID owner){
|
||||
|
@ -213,7 +213,7 @@ public class BauCommand {
|
||||
break;
|
||||
}
|
||||
}
|
||||
SubserverSystem.sendToTestServer(p, mode, map);
|
||||
SubserverSystem.sendToTestServer(p, mode, map, 0);
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ChallengeCommand extends BasicCommand {
|
||||
challenges.remove(target);
|
||||
challenges.remove(player);
|
||||
|
||||
Subserver arena = SubserverSystem.startArena(mode, map, 0, null, null, player.getUniqueId(), target.getUniqueId());
|
||||
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), target.getUniqueId());
|
||||
|
||||
arena.sendPlayer(player);
|
||||
arena.sendPlayer(target);
|
||||
|
265
src/de/steamwar/bungeecore/commands/CheckCommand.java
Normale Datei
265
src/de/steamwar/bungeecore/commands/CheckCommand.java
Normale Datei
@ -0,0 +1,265 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.bungeecore.sql.CheckedSchematic;
|
||||
import de.steamwar.bungeecore.sql.Schematic;
|
||||
import de.steamwar.bungeecore.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CheckCommand extends BasicCommand {
|
||||
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
|
||||
|
||||
private static Map<ProxiedPlayer, CheckSession> currentCheckers = new HashMap<>();
|
||||
private static Map<Integer, CheckSession> currentSchems = new HashMap<>();
|
||||
|
||||
public static void loadCheckQuestions(Configuration config){
|
||||
for(String schemType : config.getKeys()){
|
||||
checkQuestions.put(SchematicType.fromDB(schemType), config.getStringList(schemType));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isChecking(ProxiedPlayer player){
|
||||
return currentCheckers.containsKey(player);
|
||||
}
|
||||
|
||||
public CheckCommand() {
|
||||
super("check", ConnectionListener.CHECK_PERMISSION);
|
||||
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
List<Schematic> schematics = getSchemsToCheck();
|
||||
if(schematics.size() > 0)
|
||||
ServerTeamchatCommand.sendToTeam("§7Es sind §e" + schematics.size() + " §7Schematics zu prüfen§8!");
|
||||
}, 10, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
|
||||
if(args.length == 0){
|
||||
help(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(args[0].toLowerCase()){
|
||||
case "list":
|
||||
list(player);
|
||||
break;
|
||||
case "schematic":
|
||||
schematic(player, args[1]);
|
||||
break;
|
||||
case "next":
|
||||
case "allow":
|
||||
next(player);
|
||||
break;
|
||||
case "cancel":
|
||||
abort(player);
|
||||
break;
|
||||
case "decline":
|
||||
decline(player, args);
|
||||
break;
|
||||
default:
|
||||
help(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Schematic> getSchemsToCheck(){
|
||||
List<Schematic> schematicList = new LinkedList<>();
|
||||
|
||||
for (SchematicType type : SchematicType.values()) {
|
||||
if (type.check())
|
||||
schematicList.addAll(Schematic.getAllSchemsOfType(type));
|
||||
}
|
||||
return schematicList;
|
||||
}
|
||||
|
||||
private void list(ProxiedPlayer player) {
|
||||
List<Schematic> schematicList = getSchemsToCheck();
|
||||
|
||||
BungeeCore.send(player, "§e§lZu prüfen sind " + schematicList.size() + " Schematics");
|
||||
|
||||
for (Schematic schematic : schematicList) {
|
||||
CheckSession current = currentSchems.get(schematic.getSchemID());
|
||||
if (current == null) {
|
||||
BungeeCore.send(player,
|
||||
"§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName(),
|
||||
"§eSchematic prüfen",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemID()));
|
||||
} else {
|
||||
BungeeCore.send(player,
|
||||
"§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName() + " §7wird geprüft von §e" + current.checker.getName(),
|
||||
"§eZum Prüfer",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + current.checker.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void schematic(ProxiedPlayer player, String schemID){
|
||||
if(currentCheckers.containsKey(player)){
|
||||
BungeeCore.send(player, "§cDu prüfst schon eine Schematic!");
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schem = Schematic.getSchemFromDB(Integer.parseInt(schemID));
|
||||
if(!schem.getSchemType().check()){
|
||||
ProxyServer.getInstance().getLogger().log(Level.SEVERE, player.getName() + " tried to check an uncheckable schematic!");
|
||||
return;
|
||||
}else if(schem.getSchemOwner() == SteamwarUser.get(player.getUniqueId()).getId()) {
|
||||
BungeeCore.send(player, "§cDu kannst nicht deine eigenen Schematics prüfen");
|
||||
return;
|
||||
}
|
||||
|
||||
new CheckSession(player, schem);
|
||||
}
|
||||
|
||||
private static boolean notChecking(ProxiedPlayer player){
|
||||
if(!currentCheckers.containsKey(player)){
|
||||
BungeeCore.send(player, "§cDu prüfst derzeit nicht.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void next(ProxiedPlayer player){
|
||||
if(notChecking(player))
|
||||
return;
|
||||
|
||||
currentCheckers.get(player).next();
|
||||
}
|
||||
|
||||
public static void abort(ProxiedPlayer player){
|
||||
if(notChecking(player))
|
||||
return;
|
||||
|
||||
BungeeCore.send(player, "§aDer Prüfvorgang wurde abgebrochen!");
|
||||
currentCheckers.get(player).abort();
|
||||
}
|
||||
|
||||
private void decline(ProxiedPlayer player, String[] args){
|
||||
if(notChecking(player))
|
||||
return;
|
||||
|
||||
if(args.length < 2) {
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++)
|
||||
message.append(args[i]).append(" ");
|
||||
|
||||
currentCheckers.get(player).decline(message.toString());
|
||||
}
|
||||
|
||||
private void help(CommandSender sender){
|
||||
BungeeCore.send(sender, "§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics");
|
||||
BungeeCore.send(sender, "§8/§echeck next §8- §7Nächste Prüffrage");
|
||||
BungeeCore.send(sender, "§8/§echeck allow §8- §7Schematic freigeben");
|
||||
BungeeCore.send(sender, "§8/§echeck decline [Grund] §8- §7Schematic nicht freigeben");
|
||||
BungeeCore.send(sender, "§8/§echeck cancel §8- §7Bricht das Prüfen ab");
|
||||
}
|
||||
|
||||
private static class CheckSession{
|
||||
private final ProxiedPlayer checker;
|
||||
private final Schematic schematic;
|
||||
private final Timestamp startTime;
|
||||
private final ListIterator<String> checkList;
|
||||
|
||||
private CheckSession(ProxiedPlayer checker, Schematic schematic){
|
||||
this.checker = checker;
|
||||
this.schematic = schematic;
|
||||
this.startTime = Timestamp.from(Instant.now());
|
||||
this.checkList = checkQuestions.get(schematic.getSchemType()).listIterator();
|
||||
|
||||
currentCheckers.put(checker, this);
|
||||
currentSchems.put(schematic.getSchemID(), this);
|
||||
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(checker.getUniqueId())) {
|
||||
subserver.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ArenaMode mode = ArenaMode.getByCheckSchemType(schematic.getSchemType().toDB());
|
||||
SubserverSystem.sendToTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID());
|
||||
});
|
||||
}
|
||||
|
||||
private void next() {
|
||||
if(!checkList.hasNext()){
|
||||
accept();
|
||||
return;
|
||||
}
|
||||
|
||||
BungeeCore.send(checker, checkList.next());
|
||||
|
||||
TextComponent next;
|
||||
if(checkList.hasNext()){
|
||||
next = new TextComponent("next ");
|
||||
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check next"));
|
||||
}else{
|
||||
next = new TextComponent("accept ");
|
||||
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
|
||||
}
|
||||
next.setColor(ChatColor.GREEN);
|
||||
|
||||
TextComponent decline = new TextComponent("decline");
|
||||
decline.setColor(ChatColor.RED);
|
||||
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline "));
|
||||
|
||||
next.addExtra(decline);
|
||||
checker.sendMessage(next);
|
||||
}
|
||||
|
||||
private void accept(){
|
||||
schematic.setSchemType(schematic.getSchemType().fightType());
|
||||
CheckedSchematic.create(schematic.getSchemName(), schematic.getSchemOwner(), SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "freigegeben");
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid());
|
||||
if(player != null)
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aDein §e" + schematic.getSchemType().name() + " " + schematic.getSchemName() + " §ewurde freigegeben§8!");
|
||||
ServerTeamchatCommand.sendToTeam("§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
|
||||
abort();
|
||||
}
|
||||
|
||||
private void decline(String reason){
|
||||
schematic.setSchemType(SchematicType.Normal);
|
||||
CheckedSchematic.create(schematic.getSchemName(), schematic.getSchemOwner(), SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason);
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid());
|
||||
if(player != null)
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDein §e" + schematic.getSchemType().name() + " " + schematic.getSchemName() + " §cwurde abgelehnt§8: §c" + reason);
|
||||
ServerTeamchatCommand.sendToTeam("§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §awurde aufgrund von §e" + reason + " §aabgelehnt!");
|
||||
abort();
|
||||
}
|
||||
|
||||
private void abort(){
|
||||
currentCheckers.remove(checker);
|
||||
currentSchems.remove(schematic.getSchemID());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(checker.getUniqueId())) {
|
||||
subserver.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ public class FightCommand extends BasicCommand {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getMap(CommandSender sender, ArenaMode mode, String arg){
|
||||
static String getMap(CommandSender sender, ArenaMode mode, String arg){
|
||||
String realMap = mode.hasMap(arg.toLowerCase());
|
||||
if(realMap != null)
|
||||
return realMap;
|
||||
@ -140,7 +140,7 @@ public class FightCommand extends BasicCommand {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
createArena(sender, "/fight ", args, 0, false, (player, mode, map) -> {
|
||||
Subserver arena = SubserverSystem.startArena(mode, map, 0, null, null, player.getUniqueId(), null);
|
||||
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), null);
|
||||
arena.sendPlayer(player);
|
||||
TextComponent tc = new TextComponent(BungeeCore.CHAT_PREFIX + "§7Klicke §ehier§7, um §e" + mode.getDisplayName() + " §7gegen §e" + player.getName() + " §7zu §7kämpfen!");
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aGegen §7" + player.getName() + " §ekämpfen").create()));
|
||||
|
@ -39,6 +39,9 @@ public class JoinmeCommand extends BasicCommand {
|
||||
}else if(target.equals(player)){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cSei eins mit dir selbst!");
|
||||
return;
|
||||
}else if(CheckCommand.isChecking(player)){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu prüfst gerade eine Schematic!");
|
||||
return;
|
||||
}
|
||||
ServerInfo server = target.getServer().getInfo();
|
||||
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||
|
@ -30,11 +30,15 @@ public class ServerTeamchatCommand extends BasicCommand {
|
||||
String msg = msgBuilder.toString();
|
||||
msg = ChatColor.translateAlternateColorCodes('&', msg);
|
||||
|
||||
sendToTeam(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendToTeam(String message){
|
||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||
if ((target.hasPermission("bungeecore.teamchat"))
|
||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
||||
target.sendMessage(msg);
|
||||
}
|
||||
BungeeCore.send(target, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
47
src/de/steamwar/bungeecore/listeners/CheckListener.java
Normale Datei
47
src/de/steamwar/bungeecore/listeners/CheckListener.java
Normale Datei
@ -0,0 +1,47 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.sql.Schematic;
|
||||
import de.steamwar.bungeecore.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class CheckListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PostLoginEvent e){
|
||||
ProxiedPlayer player = e.getPlayer();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
|
||||
List<Schematic> uncheckedSchematics = new LinkedList<>();
|
||||
for(SchematicType type : SchematicType.values()){
|
||||
if(type.check())
|
||||
uncheckedSchematics.addAll(Schematic.getSchemsOfType(user.getId(), type));
|
||||
}
|
||||
|
||||
if(!uncheckedSchematics.isEmpty())
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du hast noch §e" + uncheckedSchematics.size() + " §7ungeprüfte Schematic§8(§7s§8)!");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerSwitch(ServerSwitchEvent e){
|
||||
ProxiedPlayer player = e.getPlayer();
|
||||
if(CheckCommand.isChecking(player))
|
||||
CheckCommand.abort(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDisconnect(PlayerDisconnectEvent e){
|
||||
ProxiedPlayer player = e.getPlayer();
|
||||
if(CheckCommand.isChecking(player))
|
||||
CheckCommand.abort(player);
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ public class ConnectionListener extends BasicListener {
|
||||
|
||||
private static final String ADMIN_GROUP = "admin";
|
||||
public static final String TEAM_GROUP = "team";
|
||||
public static final String CHECK_PERMISSION = "bungeecore.check";
|
||||
private static final String YOUTUBER_MODS = "bungeecore.youtubermods";
|
||||
|
||||
@EventHandler
|
||||
@ -37,24 +38,28 @@ public class ConnectionListener extends BasicListener {
|
||||
case "Admin":
|
||||
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
|
||||
player.setPermission("bungeecore.group.admin", true);
|
||||
player.setPermission("bungeecore.check", true);
|
||||
player.setPermission(YOUTUBER_MODS, true);
|
||||
player.setDisplayName("§4Admin " + player.getName() + "§r");
|
||||
break;
|
||||
case "Developer":
|
||||
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
|
||||
player.setPermission("bungeecore.group.developer", true);
|
||||
player.setPermission("bungeecore.check", true);
|
||||
player.setPermission(YOUTUBER_MODS, true);
|
||||
player.setDisplayName("§3Developer " + player.getName() + "§r");
|
||||
break;
|
||||
case "Moderator":
|
||||
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
|
||||
player.setPermission("bungeecore.group.moderator", true);
|
||||
player.setPermission("bungeecore.check", true);
|
||||
player.setPermission(YOUTUBER_MODS, true);
|
||||
player.setDisplayName("§bModerator " + player.getName() + "§r");
|
||||
break;
|
||||
case "Supporter":
|
||||
player.addGroups(TEAM_GROUP);
|
||||
player.setPermission("bungeecore.group.supporter", true);
|
||||
player.setPermission("bungeecore.check", true);
|
||||
player.setPermission(YOUTUBER_MODS, true);
|
||||
player.setDisplayName("§1Supporter " + player.getName() + "§r");
|
||||
break;
|
||||
|
12
src/de/steamwar/bungeecore/sql/CheckedSchematic.java
Normale Datei
12
src/de/steamwar/bungeecore/sql/CheckedSchematic.java
Normale Datei
@ -0,0 +1,12 @@
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class CheckedSchematic {
|
||||
private CheckedSchematic(){}
|
||||
|
||||
public static void create(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
||||
SQL.update("INSERT INTO CheckedSchematic (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
schemName, schemOwner, validator, startTime, endTime, reason);
|
||||
}
|
||||
}
|
95
src/de/steamwar/bungeecore/sql/Schematic.java
Normale Datei
95
src/de/steamwar/bungeecore/sql/Schematic.java
Normale Datei
@ -0,0 +1,95 @@
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Schematic {
|
||||
private final int schemID;
|
||||
private final String schemName;
|
||||
private final int schemOwner;
|
||||
private SchematicType schemType;
|
||||
|
||||
private Schematic(ResultSet rs) throws SQLException {
|
||||
this.schemID = rs.getInt("SchemID");
|
||||
this.schemName = rs.getString("SchemName");
|
||||
this.schemOwner = rs.getInt("SchemOwner");
|
||||
this.schemType = SchematicType.fromDB(rs.getString("SchemType"));
|
||||
}
|
||||
|
||||
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
|
||||
return getSchemFromDB(schemName, SteamwarUser.get(schemOwner).getId());
|
||||
}
|
||||
|
||||
public static Schematic getSchemFromDB(String schemName, int schemOwner){
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemName = ? AND SchemOwner = ?", schemName, schemOwner);
|
||||
try {
|
||||
if(schematic == null || !schematic.next()){
|
||||
return null;
|
||||
}
|
||||
return new Schematic(schematic);
|
||||
} catch (SQLException e) {
|
||||
throw new SecurityException("Failed loading schematic", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Schematic getSchemFromDB(int schemID){
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemID = ?", schemID);
|
||||
try {
|
||||
if(!schematic.next())
|
||||
throw new SecurityException("Failed loading schematic " + schemID);
|
||||
return new Schematic(schematic);
|
||||
} catch (SQLException e) {
|
||||
throw new SecurityException("Failed loading schematic", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
|
||||
try{
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemType = ?", schemType.toDB());
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
while(schematic.next()){
|
||||
schematics.add(new Schematic(schematic));
|
||||
}
|
||||
return schematics;
|
||||
}catch(SQLException e){
|
||||
throw new SecurityException("Failed loading all schems of type", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Schematic> getSchemsOfType(int userId, SchematicType schemType){
|
||||
try{
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemType = ? AND SchemOwner = ?", schemType.toDB(), userId);
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
while(schematic.next()){
|
||||
schematics.add(new Schematic(schematic));
|
||||
}
|
||||
return schematics;
|
||||
}catch(SQLException e){
|
||||
throw new SecurityException("Failed loading schems of type", e);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSchemID() {
|
||||
return schemID;
|
||||
}
|
||||
|
||||
public String getSchemName() {
|
||||
return schemName;
|
||||
}
|
||||
|
||||
public int getSchemOwner() {
|
||||
return schemOwner;
|
||||
}
|
||||
|
||||
public SchematicType getSchemType() {
|
||||
return schemType;
|
||||
}
|
||||
|
||||
public void setSchemType(SchematicType schemType) {
|
||||
this.schemType = schemType;
|
||||
SQL.update("UPDATE Schematic SET SchemType = ? WHERE SchemID = ?", schemType, schemID);
|
||||
}
|
||||
}
|
115
src/de/steamwar/bungeecore/sql/SchematicType.java
Normale Datei
115
src/de/steamwar/bungeecore/sql/SchematicType.java
Normale Datei
@ -0,0 +1,115 @@
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class SchematicType {
|
||||
public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null); //Has to stay publicly availible
|
||||
|
||||
private static final Map<String, SchematicType> fromDB;
|
||||
private static final Map<SchematicType, SchematicType> fightType;
|
||||
private static final List<SchematicType> types;
|
||||
|
||||
static{
|
||||
File file = new File(BungeeCore.get().getDataFolder(), "SchematicTypes.yml");
|
||||
|
||||
if(!file.exists())
|
||||
throw new SecurityException("SchematicType-ConfigFile not found!");
|
||||
|
||||
Configuration config;
|
||||
try {
|
||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not load SchematicTypes", e);
|
||||
}
|
||||
|
||||
List<SchematicType> tmpTypes = new LinkedList<>();
|
||||
Map<String, SchematicType> tmpFromDB = new HashMap<>();
|
||||
Map<SchematicType, SchematicType> tmpFightType = new HashMap<>();
|
||||
|
||||
tmpTypes.add(Normal);
|
||||
tmpFromDB.put(Normal.name().toLowerCase(), Normal);
|
||||
|
||||
for(String type : config.getKeys()){
|
||||
Configuration section = config.getSection(type);
|
||||
assert section != null;
|
||||
String checktype = section.getString("checktype");
|
||||
SchematicType current = new SchematicType(type, section.getString("kuerzel"), Type.valueOf(section.getString("type")), checktype != null ? tmpFromDB.get(checktype.toLowerCase()) : null);
|
||||
tmpTypes.add(current);
|
||||
tmpFightType.put(current, current.checkType);
|
||||
tmpFromDB.put(type.toLowerCase(), current);
|
||||
}
|
||||
|
||||
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
||||
fightType = Collections.unmodifiableMap(tmpFightType);
|
||||
types = Collections.unmodifiableList(tmpTypes);
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final String kuerzel;
|
||||
private final Type type;
|
||||
private SchematicType checkType;
|
||||
|
||||
private SchematicType(String name, String kuerzel, Type type, SchematicType checkType){
|
||||
this.name = name;
|
||||
this.kuerzel = kuerzel;
|
||||
this.type = type;
|
||||
this.checkType = checkType;
|
||||
}
|
||||
|
||||
public boolean isAssignable(){
|
||||
return type == Type.NORMAL || (type == Type.FIGHT_TYPE && checkType != null);
|
||||
}
|
||||
|
||||
public SchematicType checkType(){
|
||||
return checkType;
|
||||
}
|
||||
|
||||
public SchematicType fightType(){
|
||||
return fightType.get(this);
|
||||
}
|
||||
|
||||
public boolean check(){
|
||||
return type == Type.CHECK_TYPE;
|
||||
}
|
||||
|
||||
public boolean fight(){
|
||||
return type == Type.FIGHT_TYPE;
|
||||
}
|
||||
|
||||
public boolean writeable(){
|
||||
return type == Type.NORMAL;
|
||||
}
|
||||
|
||||
public String name(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getKuerzel() {
|
||||
return kuerzel;
|
||||
}
|
||||
|
||||
public String toDB(){
|
||||
return name.toLowerCase();
|
||||
}
|
||||
|
||||
public static SchematicType fromDB(String input){
|
||||
return fromDB.getOrDefault(input.toLowerCase(), null);
|
||||
}
|
||||
|
||||
public static List<SchematicType> values(){
|
||||
return types;
|
||||
}
|
||||
|
||||
enum Type{
|
||||
NORMAL,
|
||||
CHECK_TYPE,
|
||||
FIGHT_TYPE
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren