SteamWar/BauSystem
Archiviert
13
0

Refactoring, adding local affecting /bau subcommands

Dieser Commit ist enthalten in:
Travis CI 2019-06-13 10:22:07 +02:00
Ursprung 52c2a93f3e
Commit 59ab68ad6b
19 geänderte Dateien mit 543 neuen und 333 gelöschten Zeilen

18
pom.xml
Datei anzeigen

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.warking</groupId>
<groupId>de.steamwar</groupId>
<artifactId>BauSystem</artifactId>
<version>1.0</version>
@ -34,10 +34,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
@ -62,22 +61,11 @@
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldGuard</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,16 +1,25 @@
package de.steamwar.bausystem;
import de.steamwar.bausystem.commands.*;
import de.warking.hunjy.MySQL.Bauwelt;
import de.steamwar.bausystem.sql.Bauwelt;
import de.steamwar.bausystem.world.ArenaSection;
import de.steamwar.bausystem.world.RegionListener;
import de.steamwar.bausystem.world.TNTTracer;
import de.warking.hunjy.MySQL.WarkingUser;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
public class BauSystem extends JavaPlugin implements Listener {
@ -18,7 +27,9 @@ public class BauSystem extends JavaPlugin implements Listener {
private static UUID owner;
private static Bauwelt welt;
private static TNTTracer tracer;
private static List<ArenaSection> sections;
public static final String PREFIX = "§eBauSystem§8» §7";
public static final String SECTION_PATH = "";
@Override
public void onEnable() {
@ -47,6 +58,14 @@ public class BauSystem extends JavaPlugin implements Listener {
return;
}
try {
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + owner.toString() + "/sections.yml"));
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
Bukkit.shutdown();
return;
}
getCommand("trace").setExecutor(new CommandTrace());
getCommand("nightvision").setExecutor(new CommandNV());
getCommand("reset").setExecutor(new CommandReset());
@ -54,6 +73,7 @@ public class BauSystem extends JavaPlugin implements Listener {
getCommand("tnt").setExecutor(new CommandTNT());
getCommand("fire").setExecutor(new CommandFire());
getCommand("testblock").setExecutor(new CommandTestblock());
getCommand("bau").setExecutor(new CommandBau());
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
@ -71,6 +91,12 @@ public class BauSystem extends JavaPlugin implements Listener {
public static TNTTracer getTracer(){
return tracer;
}
public static List<ArenaSection> getSections(){
return sections;
}
public static int getOwnerID(){
return WarkingUser.get(owner).getId();
}
@EventHandler
public void onDeath(PlayerDeathEvent e) {
@ -86,4 +112,10 @@ public class BauSystem extends JavaPlugin implements Listener {
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
attachment.setPermission("worldedit.navigation.thru.tool", true);
}
@EventHandler
public void onLeave(PlayerQuitEvent e){
if(Bukkit.getOnlinePlayers().isEmpty())
Bukkit.shutdown();
}
}

Datei anzeigen

@ -1,20 +0,0 @@
package de.steamwar.bausystem;
public class Region {
int SchemsizeX;
int SchemsizeY;
int SchemsizeZ;
int MinX;
int MinY;
int MinZ;
int MaxX;
int MaxY;
int MaxZ;
boolean TestblockSouth;
//TODO: ADD MORE
}

Datei anzeigen

@ -1,11 +1,21 @@
package de.steamwar.bausystem.commands;
public class CommandBau {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.sql.BauweltMember;
import de.steamwar.bausystem.world.Welt;
import de.warking.hunjy.MySQL.WarkingUser;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.UUID;
public class CommandBau implements CommandExecutor {
//TODO: Move to BungeeCore
/*
@Command(name = "bau", aliases = {"bau.help", "gs", "gs.help"}, inGameOnly = true)
/*@Command(name = "bau", aliases = {"bau.help", "gs", "gs.help"}, inGameOnly = true)
public void onHelp(CommandArgs args) {
Player p = args.getPlayer();
p.sendMessage(BauSystem.PREFIX + "Hilfeseite 1 von 2:");
@ -43,7 +53,7 @@ public class CommandBau {
if (Bukkit.getWorld(p.getUniqueId().toString()) == null){
p.sendMessage(BauSystem.PREFIX + "§aEinen Moment bitte... Deine Welt wird vorbereitet");
try {
BauWorld.loadWorld(p.getUniqueId());
Welt.loadWorld(p.getUniqueId());
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten");
e.printStackTrace();
@ -64,7 +74,7 @@ public class CommandBau {
}
UUID worldOwner = WarkingUser.get(args.getArgs(0)).getUUID();
if (!BauWorld.hasPermission(worldOwner, p, Permission.member)){
if (!Welt.hasPermission(worldOwner, p, Permission.member)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich nicht auf diese Welt teleportieren");
return;
}
@ -72,7 +82,7 @@ public class CommandBau {
if (Bukkit.getWorld(worldOwner.toString()) == null){
p.sendMessage(BauSystem.PREFIX + "§aEinen Moment bitte... Die Welt wird vorbereitet");
try {
BauWorld.loadWorld(worldOwner);
Welt.loadWorld(worldOwner);
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten");
e.printStackTrace();
@ -109,136 +119,72 @@ public class CommandBau {
Player z = Bukkit.getPlayer(id);
if(z != null)
z.sendMessage(BauSystem.PREFIX + "§aDu wurdest zu der Welt von §6" + p.getName() + " §ahinzugefügt");
}
}*/
@Command(name = "bau.delmember", aliases = "gs.delmember", inGameOnly = true)
public void onDel(CommandArgs args) {
Player p = args.getPlayer();
if (args.length() == 0) {
private void onDel(Player p, String arg) {
/*if (args.length() == 0) {
p.sendMessage(BauSystem.PREFIX + "/bau delmember <Spieler>");
return;
}
}*/
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
if(!toggleCheck(args, p, id)){
UUID id = WarkingUser.get(arg).getUUID();
if(!toggleCheck(p, id)){
return;
}
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
BauWorld.removePlayer(p, target);
BauweltMember target = BauweltMember.getBauMember(id);
Welt.removePlayer(p, target);
}
@Command(name = "bau.togglebuild", aliases = "gs.togglebuild", inGameOnly = true)
public void onToggleBD(CommandArgs args) {
Player p = args.getPlayer();
if (args.length() == 0) {
private void onToggleBD(Player p, String arg) {
/*if (args.length() == 0) {
p.sendMessage(BauSystem.PREFIX + "/bau togglebuild <Spieler>");
return;
}
}*/
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
if(!toggleCheck(args, p, id)){
UUID id = WarkingUser.get(arg).getUUID();
if(!toggleCheck(p, id)){
return;
}
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
BauWorld.toggleBuild(p, target);
BauweltMember target = BauweltMember.getBauMember(id);
Welt.toggleBuild(p, target);
}
@Command(name = "bau.togglewe", aliases = "gs.togglewe", inGameOnly = true)
public void onToggleWE(CommandArgs args) {
Player p = args.getPlayer();
if (args.length() == 0) {
private void onToggleWE(Player p, String arg) {
/*if (args.length() == 0) {
p.sendMessage(BauSystem.PREFIX + "/bau togglewe <Spieler>");
return;
}
}*/
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
if(!toggleCheck(args, p, id)){
UUID id = WarkingUser.get(arg).getUUID();
if(!toggleCheck(p, id)){
return;
}
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
BauWorld.toggleWE(p, target);
BauweltMember target = BauweltMember.getBauMember(id);
Welt.toggleWE(p, target);
}
@Command(name = "bau.toggleworld", aliases = "gs.toggleworld", inGameOnly = true)
public void onToggleTestblock(CommandArgs args) {
Player p = args.getPlayer();
if (args.length() == 0) {
private void onToggleWorld(Player p, String arg) {
/*if (args.length() == 0) {
p.sendMessage(BauSystem.PREFIX + "/bau toggleworld <Spieler>");
return;
}
}*/
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
if(!toggleCheck(args, p, id)){
UUID id = WarkingUser.get(arg).getUUID();
if(!toggleCheck(p, id)){
return;
}
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
BauWorld.toggleTestblock(p, target);
BauweltMember target = BauweltMember.getBauMember(id);
Welt.toggleTestblock(p, target);
}
@Command(name = "bau.testblock", aliases = {"gs.testblock", "testblock"}, inGameOnly = true)
public void onTestblock(CommandArgs args) {
final Player p = args.getPlayer();
UUID worldOwner = BauWorld.getWorldUUID(p.getWorld());
if (!BauWorld.hasPermission(worldOwner, p, Permission.worldedit)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock erneuern");
return;
}
Location playerLocation = p.getLocation();
World playerWorld = p.getWorld();
for (ProtectedRegion rg : BauSystem.getWorldGuard().getRegionManager(playerWorld).getApplicableRegions(playerLocation)) {
String rgID = rg.getId();
if(rgID.equalsIgnoreCase("resetall"))
continue;
Vector position = new Vector(Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.X")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Y")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Z")));
File file = new File(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".schematic.testblock"));
pasteSchematic(p, file, position);
p.sendMessage(BauSystem.PREFIX + "§aTestblock erneuert");
}
}
@Command(name = "bau.reset", aliases = {"gs.reset", "reset"}, inGameOnly = true)
public void onReset(CommandArgs args) {
final Player p = args.getPlayer();
UUID worldOwner = BauWorld.getWorldUUID(p.getWorld());
if (!BauWorld.hasPermission(worldOwner, p, Permission.world)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Regionen erneuern");
return;
}
Location playerLocation = p.getLocation();
World playerWorld = p.getWorld();
for (ProtectedRegion rg : BauSystem.getWorldGuard().getRegionManager(playerWorld).getApplicableRegions(playerLocation)) {
String rgID = rg.getId();
if(rgID.equalsIgnoreCase("resetall"))
continue;
Vector position = new Vector(Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.X")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Y")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Z")));
File file = new File(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".schematic.reset"));
pasteSchematic(p, file, position);
p.sendMessage(BauSystem.PREFIX + "§aRegion " + rgID + " wurde erneuert");
}
}
@Command(name = "bau.resetall", aliases = "gs.resetall", inGameOnly = true)
public void onResetAll(CommandArgs args) {
/*public void onResetAll(CommandArgs args) {
final Player p = args.getPlayer();
p.sendMessage(BauSystem.PREFIX + "§aDeine Welt wird zurückgesetzt. Einen Moment bitte");
BauWorld.unloadWorld(p.getUniqueId());
Welt.unloadWorld(p.getUniqueId());
File directory = new File("plugins/BauSystem/worlds/" + p.getUniqueId().toString());
del(directory);
File directory1 = new File("plugins/WorldGuard/worlds/" + p.getUniqueId().toString());
@ -246,171 +192,6 @@ public class CommandBau {
Bukkit.getScheduler().scheduleSyncDelayedTask(BauSystem.getInstance(), () -> onHome(args),20L);
}
@Command(name = "bau.replace", aliases = "gs.replace", inGameOnly = true)
public void onReplace(CommandArgs args) {
final Player p = args.getPlayer();
UUID worldOwner = BauWorld.getWorldUUID(p.getWorld());
if (!BauWorld.hasPermission(worldOwner, p, Permission.worldedit)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht Obsidian und Grundgestein ersetzen");
return;
}
World world = p.getWorld();
for(ProtectedRegion rg : BauSystem.getWorldGuard().getRegionManager(world).getApplicableRegions(p.getLocation())) {
String rgID = rg.getId();
if(rgID.equalsIgnoreCase("resetall"))
continue;
EditSession editSession = BauSystem.getWorldEdit().getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(p.getWorld()), Integer.MAX_VALUE);
CuboidSelection selection = new CuboidSelection(p.getWorld(), new Location(p.getWorld(), rg.getMinimumPoint().getBlockX(), rg.getMinimumPoint().getBlockY(), rg.getMinimumPoint().getBlockZ()), new Location(p.getWorld(), rg.getMaximumPoint().getBlockX(), rg.getMaximumPoint().getBlockY(), rg.getMaximumPoint().getBlockZ()));
Set<BaseBlock> targetObsidian = new HashSet<>();
targetObsidian.add(new BaseBlock(49));
Set<BaseBlock> targetBedrock = new HashSet<>();
targetBedrock.add(new BaseBlock(7));
try {
int tnt = editSession.replaceBlocks(selection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(46));
int slime = editSession.replaceBlocks(selection.getRegionSelector().getRegion(), targetBedrock, new BaseBlock(165));
editSession.flushQueue();
p.sendMessage(BauSystem.PREFIX + "§aEs wurden " + (tnt + slime) + " Obsidian und Grundgestein ersetzt");
} catch(Exception ex) { ex.printStackTrace(); }
}
}
@Command(name = "bau.info", aliases = "gs.info", inGameOnly = true)
public void onInfo(CommandArgs args) {
final Player p = args.getPlayer();
UUID worldOwner = BauWorld.getWorldUUID(p.getWorld());
if(worldOwner == null){
p.sendMessage(BauSystem.PREFIX + "§cDu bist auf keiner Bauwelt");
return;
}
Bukkit.getScheduler().runTaskAsynchronously(BauSystem.getInstance(), () -> {
Bauwelt welt = Bauwelt.getBauwelt(worldOwner);
p.sendMessage("§6Besitzer§8: §6" + WarkingUser.get(welt.getUserID()).getUserName());
if(welt.isTNTDmg())
p.sendMessage("§6TNT-Schaden§8: §aerlaubt");
else
p.sendMessage("§6TNT-Schaden§8: §cverboten");
if(welt.isFireDmg())
p.sendMessage("§6Feuer-Schaden§8: §aerlaubt");
else
p.sendMessage("§6Feuer-Schaden§8: §cverboten");
List<BauweltMember> memberList = BauweltMember.getMembers(worldOwner);
if(!memberList.isEmpty()){
StringBuilder members = new StringBuilder();
members.append("Mitglieder§8: ");
for(BauweltMember member : memberList){
members.append("§6");
members.append(WarkingUser.get(member.getMemberID()).getUserName());
members.append("§8, ");
}
p.sendMessage(members.toString());
}
});
}
@Command(name = "bau.tntdmg", aliases = {"gs.tntdmg", "bau.tnt", "gs.tnt", "tnt"}, inGameOnly = true)
public void onTntdmg(CommandArgs args){
BauWorld.switchTNT(args.getPlayer());
}
@Command(name = "bau.firedmg", aliases = {"gs.firedmg", "bau.fire", "gs.fire", "fire"}, inGameOnly = true)
public void onFiredmg(CommandArgs args) {
BauWorld.switchFire(args.getPlayer());
}
@Command(name = "bau.speed", aliases = {"gs.speed", "speed"}, inGameOnly = true)
public void onSpeed(CommandArgs args){
final Player player = args.getPlayer();
if (args.length() == 0){
player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]");
return;
}
float speed;
try{
speed = Float.valueOf(args.getArgs(0));
}catch(NumberFormatException e){
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
return;
}
if (speed < 0 || speed > 10) {
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
return;
}
player.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
if(speed == 1.0f){
speed = 1.25f;
}
player.setFlySpeed(speed / 10);
player.setWalkSpeed(speed / 10);
}
@Command(name = "bau.time", inGameOnly = true)
public void onTime(CommandArgs args){
Player p = args.getPlayer();
if(args.length() == 0){
p.sendMessage(BauSystem.PREFIX + "/time <Zeit 0=Morgen, 6000=Mittag, 18000=Mitternacht>");
return;
}
UUID worldOwner = BauWorld.getWorldUUID(p.getWorld());
if (!BauWorld.hasPermission(worldOwner, p, Permission.world)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
return;
}
int time;
try{
time = Integer.valueOf(args.getArgs(0));
}catch(NumberFormatException e){
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
return;
}
if (time < 0 || time > 24000) {
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
return;
}
p.getWorld().setTime(time);
}
private void pasteSchematic(Player player, File schematic, Vector position) {
int count = 0;
World world = player.getWorld();
for(ProtectedRegion rg: BauSystem.getWorldGuard().getRegionManager(world).getApplicableRegions(player.getLocation())) {
count++;
if(count != 0) {
EditSession session = BauSystem.getWorldEdit().getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(world), Integer.MAX_VALUE);
try {
CuboidClipboard format = MCEditSchematicFormat.getFormat(schematic).load(schematic);
format.paste(session, position, false);
} catch (Exception ex) {
player.sendMessage(ex.getMessage());
ex.printStackTrace();
}
}
}
}
private void del(File dir){
if (dir.isDirectory()){
String[] entries = dir.list();
@ -431,24 +212,37 @@ public class CommandBau {
return false;
}
return true;
}
private boolean toggleCheck(CommandArgs args, Player p, UUID id){
if (!hasWorld(p)) {
//p.sendMessage(BauSystem.PREFIX + "§cDu hast noch keine Bauwelt");
return false;
}
}*/
private boolean toggleCheck(Player p, UUID id){
if (id == null) {
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
return false;
}
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
BauweltMember target = BauweltMember.getBauMember(id);
if (target == null) {
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt!");
return false;
}
return true;
}*/
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(args[0].equalsIgnoreCase("delmember")){
onDel(player, args[1]);
}else if(args[0].equalsIgnoreCase("togglebuild")){
onToggleBD(player, args[1]);
}else if(args[0].equalsIgnoreCase("togglewe")){
onToggleWE(player, args[1]);
}else if(args[0].equalsIgnoreCase("toggleworld")){
onToggleWorld(player, args[1]);
}
return false;
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

Datei anzeigen

@ -1,4 +1,4 @@
package de.steamwar.bausystem;
package de.steamwar.bausystem.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@ -7,7 +7,7 @@ import org.bukkit.command.SimpleCommandMap;
import java.lang.reflect.Field;
import java.util.Map;
class CommandRemover {
public class CommandRemover {
private CommandRemover(){}

Datei anzeigen

@ -1,5 +1,9 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.ArenaSection;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -13,7 +17,19 @@ public class CommandReset implements CommandExecutor {
return false;
Player player = (Player) sender;
if(!Welt.hasPermission(player, Permission.world)){
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
return false;
}
for(ArenaSection section : BauSystem.getSections()){
if(section.inRegion(player.getLocation())){
section.reset();
return false;
}
}
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return false;
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

Datei anzeigen

@ -1,5 +1,9 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.ArenaSection;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -13,7 +17,19 @@ public class CommandTestblock implements CommandExecutor {
return false;
Player player = (Player) sender;
if(!Welt.hasPermission(player, Permission.worldedit)){
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen");
return false;
}
for(ArenaSection section : BauSystem.getSections()){
if(section.inRegion(player.getLocation())){
section.getTestblock().reset();
return false;
}
}
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return false;
}
}

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;

Datei anzeigen

@ -2,7 +2,7 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.TNTTracer;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
public class CommandTrace implements CommandExecutor {
private static final String DENY_MESSAGE = "§cDu darfst hier nicht den TNT-Tracer nutzen";
private void help(Player player){
player.sendMessage("§8/§etrace start §7- Startet die Aufnahme aller TNT-Positionen");
player.sendMessage("§8/§etrace show §7- Zeigt alle TNT-Positionen");
@ -19,7 +21,7 @@ public class CommandTrace implements CommandExecutor {
private void start(Player p){
if(!Welt.hasPermission(p, Permission.world)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
p.sendMessage(BauSystem.PREFIX + DENY_MESSAGE);
return;
}
@ -29,7 +31,7 @@ public class CommandTrace implements CommandExecutor {
private void stop(Player p){
if(!Welt.hasPermission(p, Permission.world)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
p.sendMessage(BauSystem.PREFIX + DENY_MESSAGE);
return;
}
@ -44,7 +46,7 @@ public class CommandTrace implements CommandExecutor {
private void show(Player p){
if(!Welt.hasPermission(p, Permission.world)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
p.sendMessage(BauSystem.PREFIX + DENY_MESSAGE);
return;
}
@ -59,7 +61,7 @@ public class CommandTrace implements CommandExecutor {
private void hide(Player p){
if(!Welt.hasPermission(p, Permission.world)){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
p.sendMessage(BauSystem.PREFIX + DENY_MESSAGE);
return;
}

Datei anzeigen

@ -0,0 +1,87 @@
package de.steamwar.bausystem.sql;
import de.warking.hunjy.MySQL.MySQL;
import de.warking.hunjy.MySQL.WarkingUser;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
import static de.warking.hunjy.Core.sql;
public class Bauwelt {
private final int UserID;
private boolean TNTDmg;
private boolean FireDmg;
private Bauwelt(int userID, boolean tntDmg, boolean fireDmg, boolean updateDB){
UserID = userID;
TNTDmg = tntDmg;
FireDmg = fireDmg;
if(updateDB)
updateDB();
}
public Bauwelt(int userID, boolean tntDmg, boolean fireDmg){
this(userID, tntDmg, fireDmg, true);
}
public Bauwelt(UUID userID, boolean tntDmg, boolean fireDmg){
this(WarkingUser.get(userID).getId(), tntDmg, fireDmg, true);
}
private void updateDB(){
sql.update("INSERT INTO Bauwelt" +
" (UserID, TNTDmg, FireDmg)" +
" VALUES" +
" ('" + UserID + "', '" + MySQL.booleanToInt(TNTDmg) + "', '" + MySQL.booleanToInt(FireDmg) + "')" +
" ON DUPLICATE KEY UPDATE" +
" TNTDmg = VALUES(TNTDmg), FireDmg = VALUES(FireDmg)");
}
public static Bauwelt getBauwelt(UUID user){
return getBauwelt(WarkingUser.get(user).getId());
}
public static Bauwelt getBauwelt(int userId){
ResultSet bauwelt = sql.select("SELECT * FROM Bauwelt WHERE UserID = '" + userId + "'");
try {
if(bauwelt == null || !bauwelt.next()){
return null;
}
boolean tntDmg = bauwelt.getBoolean("TNTDmg");
boolean fireDmg = bauwelt.getBoolean("FireDmg");
return new Bauwelt(userId, tntDmg, fireDmg, false);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public int getUserID() {
return UserID;
}
public UUID getUUID(){
return WarkingUser.get(UserID).getUUID();
}
public boolean isTNTDmg() {
return TNTDmg;
}
public void setTNTDmg(boolean TNTDmg) {
this.TNTDmg = TNTDmg;
updateDB();
}
public boolean isFireDmg() {
return FireDmg;
}
public void setFireDmg(boolean fireDmg) {
FireDmg = fireDmg;
updateDB();
}
}

Datei anzeigen

@ -0,0 +1,162 @@
package de.steamwar.bausystem.sql;
import de.steamwar.bausystem.BauSystem;
import de.warking.hunjy.MySQL.MySQL;
import de.warking.hunjy.MySQL.WarkingUser;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static de.warking.hunjy.Core.sql;
public class BauweltMember{
private final int BauweltID;
private final int MemberID;
private boolean Build;
private boolean ChangeGM;
private boolean Teleport;
private boolean WorldEdit;
private boolean Testblock;
private static final List<BauweltMember> members = new ArrayList<>();
private BauweltMember(int memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock, boolean updateDB){
BauweltID = BauSystem.getOwnerID();
MemberID = memberID;
Build = build;
ChangeGM = changeGM;
Teleport = teleport;
WorldEdit = worldEdit;
Testblock = testblock;
if(updateDB)
updateDB();
members.add(this);
}
public BauweltMember(int memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock){
this(memberID, build, changeGM, teleport, worldEdit, testblock, true);
}
public BauweltMember(UUID memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock){
this(WarkingUser.get(memberID).getId(), build, changeGM, teleport, worldEdit, testblock, true);
}
public void remove(){
sql.update("DELETE FROM BauweltMember WHERE BauweltID = " + BauweltID + " AND MemberID = " + MemberID);
members.remove(this);
}
private void updateDB(){
sql.update("INSERT INTO BauweltMember" +
" (BauweltID, MemberID, Build, ChangeGM, Teleport, WorldEdit, Testblock)" +
" VALUES" +
" ('" + BauweltID + "', '" + MemberID + "', '" + MySQL.booleanToInt(Build) + "', '" + MySQL.booleanToInt(ChangeGM) + "', '" + sql.booleanToInt(Teleport) + "', '" + sql.booleanToInt(WorldEdit) + "', '" + sql.booleanToInt(Testblock) + "')" +
" ON DUPLICATE KEY UPDATE" +
" Build = VALUES(Build), ChangeGM = VALUES(ChangeGM), Teleport = VALUES(Teleport), WorldEdit = VALUES(WorldEdit), Testblock = VALUES(Testblock)");
}
public static BauweltMember getBauMember(UUID memberID){
return getBauMember(WarkingUser.get(memberID).getId());
}
public static BauweltMember getBauMember(int memberID){
for(BauweltMember member : members)
if(member.MemberID == memberID)
return member;
ResultSet member = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + BauSystem.getOwnerID() + "' AND MemberID = '" + memberID + "'");
try {
if(member == null || !member.next()){
return null;
}
boolean build = member.getBoolean("Build");
boolean changeGM = member.getBoolean("ChangeGM");
boolean teleport = member.getBoolean("Teleport");
boolean worldEdit = member.getBoolean("WorldEdit");
boolean testblock = member.getBoolean("Testblock");
return new BauweltMember(memberID, build, changeGM, teleport, worldEdit, testblock, false);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public static List<BauweltMember> getMembers(UUID bauweltID){
return getMembers(WarkingUser.get(bauweltID).getId());
}
public static List<BauweltMember> getMembers(int bauweltID){
try{
ResultSet memberlist = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + bauweltID + "'");
List<BauweltMember> members = new ArrayList<>();
while(memberlist.next()){
int memberID = memberlist.getInt("MemberID");
boolean build = memberlist.getBoolean("Build");
boolean changeGM = memberlist.getBoolean("ChangeGM");
boolean teleport = memberlist.getBoolean("Teleport");
boolean worldEdit = memberlist.getBoolean("WorldEdit");
boolean testblock = memberlist.getBoolean("Testblock");
members.add(new BauweltMember(memberID, build, changeGM, teleport, worldEdit, testblock, false));
}
return members;
}catch(SQLException e){
e.printStackTrace();
}
return new ArrayList<>();
}
public int getBauweltID() {
return BauweltID;
}
public int getMemberID() {
return MemberID;
}
public boolean isBuild() {
return Build;
}
public void setBuild(boolean build) {
Build = build;
updateDB();
}
public boolean isChangeGM() {
return ChangeGM;
}
public void setChangeGM(boolean changeGM) {
ChangeGM = changeGM;
updateDB();
}
public boolean isTeleport() {
return Teleport;
}
public void setTeleport(boolean teleport) {
Teleport = teleport;
updateDB();
}
public boolean isWorldEdit() {
return WorldEdit;
}
public void setWorldEdit(boolean worldEdit) {
WorldEdit = worldEdit;
updateDB();
}
public boolean isTestblock() {
return Testblock;
}
public void setTestblock(boolean testblock) {
Testblock = testblock;
updateDB();
}
}

Datei anzeigen

@ -0,0 +1,42 @@
package de.steamwar.bausystem.world;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ArenaSection extends Region {
private final Region testblock;
private ArenaSection(ConfigurationSection config) {
super(config);
testblock = new Region(config.getConfigurationSection("testblock"));
}
public Region getTestblock(){
return testblock;
}
@Override
public Map<String, Object> serialize() {
Map<String, Object> section = super.serialize();
for(Map.Entry<String, Object> subsection : testblock.serialize().entrySet())
section.put("testblock." + subsection.getKey(), subsection.getValue());
return section;
}
public static List<ArenaSection> loadFromFile(File file) throws IOException, InvalidConfigurationException {
YamlConfiguration config = new YamlConfiguration();
config.load(file);
List<ArenaSection> list = new ArrayList<>();
for(String section : config.getKeys(false))
list.add(new ArenaSection(config.getConfigurationSection(section)));
return list;
}
}

Datei anzeigen

@ -0,0 +1,86 @@
package de.steamwar.bausystem.world;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class Region implements ConfigurationSerializable {
private final int sizeX;
private final int sizeY;
private final int sizeZ;
private final int minX;
private final int minY;
private final int minZ;
private final String schematic;
private final boolean rotate;
Region(ConfigurationSection config){
Region rg = config.getSerializable("region", this.getClass());
sizeX = rg.sizeX;
sizeY = rg.sizeY;
sizeZ = rg.sizeZ;
minX = rg.minX;
minY = rg.minY;
minZ = rg.minZ;
schematic = rg.schematic;
rotate = rg.rotate;
}
public boolean inRegion(Location l){
return inRange(l.getX(), minX, sizeX) && inRange(l.getY(), minY, sizeY) && inRange(l.getZ(), minZ, sizeZ);
}
private boolean inRange(double l, int min, int size){
return min <= l && l <= min + size;
}
public void reset(){
File file = new File(BauSystem.SECTION_PATH + schematic);
com.boydti.fawe.object.schematic.Schematic schem;
try {
schem = FaweAPI.load(file);
}catch(IOException e){
e.printStackTrace();
return;
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v = new Vector(minX + sizeX/2, minY, minZ + sizeZ/2);
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
aT = aT.rotateY(180);
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
}else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
schem.paste(w, v, false, true, aT).flushQueue();
}
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("sizeX", sizeX);
map.put("sizeY", sizeY);
map.put("sizeZ", sizeZ);
map.put("minX", minX);
map.put("minY", minY);
map.put("minZ", minZ);
map.put("schematic", schematic);
map.put("rotate", rotate);
return map;
}
}

Datei anzeigen

@ -1,8 +1,9 @@
package de.steamwar.bausystem;
package de.steamwar.bausystem.world;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import de.steamwar.bausystem.commands.Welt;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.bausystem;
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -20,8 +21,8 @@ public class TNTTracer implements Runnable {
private boolean printed;
private boolean active;
TNTTracer(){
this.locations = new HashSet<>();
public TNTTracer(){
this.locations = new HashSet<Location>();
this.printed = false;
this.active = false;
}
@ -53,7 +54,7 @@ public class TNTTracer implements Runnable {
public void show(){
end();
printed = true;
Set<Location> unsetLoc = new HashSet<>();
Set<Location> unsetLoc = new HashSet<Location>();
World world = Bukkit.getWorlds().get(0);
for(Location l : locations){
Block b = world.getBlockAt(l);
@ -81,7 +82,6 @@ public class TNTTracer implements Runnable {
stop();
}
@Override
public void run() {
if(locations.size() < 20000){
World world = Bukkit.getWorlds().get(0);

Datei anzeigen

@ -1,9 +1,10 @@
package de.steamwar.bausystem.commands;
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.warking.hunjy.MySQL.Bauwelt;
import de.warking.hunjy.MySQL.BauweltMember;
import de.steamwar.bausystem.sql.Bauwelt;
import de.steamwar.bausystem.sql.BauweltMember;
import de.warking.hunjy.MySQL.WarkingUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -15,7 +16,7 @@ public class Welt {
if(member.getUniqueId().equals(BauSystem.getOwner()))
return true;
BauweltMember member1 = BauweltMember.getBauMember(BauSystem.getOwner(), member.getUniqueId());
BauweltMember member1 = BauweltMember.getBauMember(member.getUniqueId());
if(member1 == null)
return false;
@ -61,9 +62,8 @@ public class Welt {
Bukkit.broadcastMessage(BauSystem.PREFIX + "§cFeuer-Schaden verboten");
}
//TODO: To BungeeCore
/*public static void toggleBuild(Player p, BauweltMember target){
public static void toggleBuild(Player p, BauweltMember target){
target.setBuild(!target.isBuild());
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
if (z != null) {
@ -121,5 +121,5 @@ public class Welt {
z.kickPlayer(BauSystem.PREFIX + "§cDu wurdest von der Welt von §6" + p.getName() + " §centfernt");
}
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler wurde entfernt");
}*/
}
}

Datei anzeigen

@ -10,6 +10,7 @@ commands:
trace:
testblock:
reset:
bau:
speed:
nightvision:
aliases: nv