Merge branch 'master' into NamingAndFormating
# Conflicts: # BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java # BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java # BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java # BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java
Dieser Commit ist enthalten in:
Commit
a26d816f12
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.PlayerUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -28,7 +28,7 @@ class CommandDebugStick_15 {
|
|||||||
private CommandDebugStick_15() {
|
private CommandDebugStick_15() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void giveStick(Player player) {
|
static void giveStick(Player player){
|
||||||
PlayerUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK));
|
SWUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,10 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class PlayerUtils {
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SWUtils {
|
||||||
|
|
||||||
public static void giveItemToPlayer(Player player, ItemStack itemStack) {
|
public static void giveItemToPlayer(Player player, ItemStack itemStack) {
|
||||||
ItemStack current = player.getInventory().getItemInMainHand();
|
ItemStack current = player.getInventory().getItemInMainHand();
|
||||||
@ -33,4 +36,18 @@ public class PlayerUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> manageList(List<String> strings, String[] args, int index) {
|
||||||
|
strings = new ArrayList<>(strings);
|
||||||
|
for (int i = strings.size() - 1; i >= 0; i--) {
|
||||||
|
if (!strings.get(i).startsWith(args[index])) {
|
||||||
|
strings.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> manageList(List<String> strings, String[] args) {
|
||||||
|
return manageList(strings, args, args.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -21,7 +21,7 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.PlayerUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.world.Detonator;
|
import de.steamwar.bausystem.world.Detonator;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -63,7 +63,7 @@ public class CommandDetonator implements CommandExecutor {
|
|||||||
case "wand":
|
case "wand":
|
||||||
case "detonator":
|
case "detonator":
|
||||||
case "item":
|
case "item":
|
||||||
PlayerUtils.giveItemToPlayer(player, Detonator.WAND);
|
SWUtils.giveItemToPlayer(player, Detonator.WAND);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
break;
|
break;
|
||||||
case "remove":
|
case "remove":
|
||||||
|
@ -19,41 +19,26 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandDetonatorTabCompleter implements TabCompleter {
|
public class CommandDetonatorTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
private List<String> arguments = new ArrayList<>(Arrays.asList("wand", "reset", "detonate", "remove"));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player)) return new ArrayList<>();
|
if(!(sender instanceof Player)) return new ArrayList<>();
|
||||||
return detonaterTabComplete((Player) sender, args);
|
if (args.length != 1) {
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> detonaterTabComplete(Player player, String[] args) {
|
|
||||||
List<String> tabComplete = new ArrayList<>();
|
|
||||||
tabComplete.add("wand");
|
|
||||||
tabComplete.add("reset");
|
|
||||||
tabComplete.add("detonate");
|
|
||||||
tabComplete.add("remove");
|
|
||||||
|
|
||||||
if (args.length >= 2) {
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return manageList(tabComplete, args, 0);
|
return SWUtils.manageList(arguments, args);
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> manageList(List<String> strings, String[] args, int index) {
|
|
||||||
for (int i = strings.size() - 1; i >= 0; i--) {
|
|
||||||
if (!strings.get(i).startsWith(args[index])) {
|
|
||||||
strings.remove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strings;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.PlayerUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||||
import de.steamwar.bausystem.world.*;
|
import de.steamwar.bausystem.world.*;
|
||||||
@ -587,7 +587,7 @@ public class CommandGUI implements CommandExecutor, Listener {
|
|||||||
openBauGui(player);
|
openBauGui(player);
|
||||||
OPEN_INVS.add(player);
|
OPEN_INVS.add(player);
|
||||||
} else if ("item".equalsIgnoreCase(strings[0])) {
|
} else if ("item".equalsIgnoreCase(strings[0])) {
|
||||||
PlayerUtils.giveItemToPlayer(player, new ItemStack(Material.NETHER_STAR));
|
SWUtils.giveItemToPlayer(player, new ItemStack(Material.NETHER_STAR));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.PlayerUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -68,7 +68,7 @@ public class CommandScript implements CommandExecutor {
|
|||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlayerUtils.giveItemToPlayer((Player) sender, BOOK);
|
SWUtils.giveItemToPlayer((Player) sender, BOOK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.PlayerUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.world.TNTSimulator;
|
import de.steamwar.bausystem.world.TNTSimulator;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -59,7 +59,7 @@ public class CommandSimulator implements CommandExecutor {
|
|||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "wand":
|
case "wand":
|
||||||
PlayerUtils.giveItemToPlayer(player, TNTSimulator.WAND);
|
SWUtils.giveItemToPlayer(player, TNTSimulator.WAND);
|
||||||
break;
|
break;
|
||||||
case "start":
|
case "start":
|
||||||
TNTSimulator.get(player).start();
|
TNTSimulator.get(player).start();
|
||||||
|
@ -20,41 +20,27 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandSimulatorTabCompleter implements TabCompleter {
|
public class CommandSimulatorTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
private List<String> arguments = new ArrayList<>(Arrays.asList("wand", "start", "delete"));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player)) return new ArrayList<>();
|
if(!(sender instanceof Player)) return new ArrayList<>();
|
||||||
return simulatorTabComplete((Player) sender, args);
|
if (args.length != 1) {
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> simulatorTabComplete(Player player, String[] args) {
|
|
||||||
List<String> tabComplete = new ArrayList<>();
|
|
||||||
tabComplete.add("wand");
|
|
||||||
tabComplete.add("start");
|
|
||||||
tabComplete.add("delete");
|
|
||||||
|
|
||||||
if (args.length >= 2) {
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return manageList(tabComplete, args, 0);
|
return SWUtils.manageList(arguments, args);
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> manageList(List<String> strings, String[] args, int index) {
|
|
||||||
for (int i = strings.size() - 1; i >= 0; i--) {
|
|
||||||
if (!strings.get(i).startsWith(args[index])) {
|
|
||||||
strings.remove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.PlayerUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -47,7 +47,7 @@ public class CommandSkull implements CommandExecutor {
|
|||||||
assert sm != null;
|
assert sm != null;
|
||||||
sm.setDisplayName("§e" + args[0] + "§8s Kopf");
|
sm.setDisplayName("§e" + args[0] + "§8s Kopf");
|
||||||
is.setItemMeta(sm);
|
is.setItemMeta(sm);
|
||||||
PlayerUtils.giveItemToPlayer(p, is);
|
SWUtils.giveItemToPlayer(p, is);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.world.Region;
|
import de.steamwar.bausystem.world.Region;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -28,40 +29,24 @@ import org.bukkit.command.TabCompleter;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandTNTTabComplete implements TabCompleter {
|
public class CommandTNTTabComplete implements TabCompleter {
|
||||||
|
|
||||||
|
private List<String> arguments = new ArrayList<>(Arrays.asList("an", "on", "aus", "off"));
|
||||||
|
|
||||||
|
public CommandTNTTabComplete() {
|
||||||
|
if (Region.buildAreaEnabled()) arguments.addAll(Arrays.asList("testblock", "tb"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player)) return new ArrayList<>();
|
if(!(sender instanceof Player)) return new ArrayList<>();
|
||||||
return tntTabComplete(args);
|
if (args.length != 1) {
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> tntTabComplete(String[] args) {
|
|
||||||
List<String> tabComplete = new ArrayList<>();
|
|
||||||
tabComplete.add("an");
|
|
||||||
tabComplete.add("on");
|
|
||||||
tabComplete.add("aus");
|
|
||||||
tabComplete.add("off");
|
|
||||||
if (Region.buildAreaEnabled()) {
|
|
||||||
tabComplete.add("testblock");
|
|
||||||
tabComplete.add("tb");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length >= 2) {
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return manageList(tabComplete, args, 0);
|
return SWUtils.manageList(arguments, args);
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> manageList(List<String> strings, String[] args, int index) {
|
|
||||||
for (int i = strings.size() - 1; i >= 0; i--) {
|
|
||||||
if (!strings.get(i).startsWith(args[index])) {
|
|
||||||
strings.remove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.world.TPSUtils;
|
import de.steamwar.bausystem.world.TPSUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -39,16 +41,11 @@ public class CommandTPSLimiterTabComplete implements TabCompleter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)) return new ArrayList<>();
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
List<String> validArguments = new ArrayList<>(arguments.size());
|
return SWUtils.manageList(arguments, args);
|
||||||
for (String s : arguments) {
|
|
||||||
if (s.startsWith(args[0])) {
|
|
||||||
validArguments.add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return validArguments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStatus;
|
import de.steamwar.bausystem.tracer.record.RecordStatus;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -49,19 +50,12 @@ public class CommandTraceTabCompleter implements TabCompleter {
|
|||||||
return tracerTabComplete((Player) sender, args);
|
return tracerTabComplete((Player) sender, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> tracerTabComplete(Player player, String[] args) {
|
private List<String> tracerTabComplete(Player player, java.lang.String[] args) {
|
||||||
List<String> tabComplete = new ArrayList<>();
|
List<java.lang.String> tabComplete = new ArrayList<>();
|
||||||
for (TabComplete tab : tabCompletes) {
|
for (TabComplete tab : tabCompletes) {
|
||||||
if (tab.test(player, args)) tabComplete.addAll(Arrays.asList(tab.getTabCompletes()));
|
if (tab.test(player, args)) tabComplete.addAll(Arrays.asList(tab.getTabCompletes()));
|
||||||
}
|
}
|
||||||
return manageList(tabComplete, args);
|
return SWUtils.manageList(tabComplete, args);
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> manageList(List<String> strings, String[] args) {
|
|
||||||
for (int i = strings.size() - 1; i >= 0; i--) {
|
|
||||||
if (!strings.get(i).startsWith(args[args.length - 1])) strings.remove(i);
|
|
||||||
}
|
|
||||||
return strings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TabComplete {
|
private static class TabComplete {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren