2019-06-11 07:05:05 +02:00
|
|
|
package de.steamwar.bausystem;
|
|
|
|
|
|
|
|
import de.steamwar.bausystem.commands.*;
|
2019-06-13 10:22:07 +02:00
|
|
|
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;
|
2019-06-11 07:05:05 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2019-06-13 10:22:07 +02:00
|
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
2019-06-11 07:05:05 +02:00
|
|
|
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;
|
2019-06-13 10:22:07 +02:00
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
2019-06-11 07:05:05 +02:00
|
|
|
import org.bukkit.permissions.PermissionAttachment;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2019-06-13 10:22:07 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.List;
|
2019-06-11 07:05:05 +02:00
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
public class BauSystem extends JavaPlugin implements Listener {
|
|
|
|
private static BauSystem plugin;
|
|
|
|
private static UUID owner;
|
|
|
|
private static Bauwelt welt;
|
|
|
|
private static TNTTracer tracer;
|
2019-06-13 10:22:07 +02:00
|
|
|
private static List<ArenaSection> sections;
|
2019-06-11 07:05:05 +02:00
|
|
|
public static final String PREFIX = "§eBauSystem§8» §7";
|
2019-06-13 10:22:07 +02:00
|
|
|
public static final String SECTION_PATH = "";
|
2019-06-11 07:05:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
plugin = this;
|
|
|
|
|
|
|
|
try{
|
|
|
|
owner = UUID.fromString(Bukkit.getWorlds().get(0).getName());
|
|
|
|
}catch(IllegalArgumentException e){
|
|
|
|
e.printStackTrace();
|
|
|
|
Bukkit.shutdown();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
welt = Bauwelt.getBauwelt(owner);
|
|
|
|
tracer = new TNTTracer();
|
|
|
|
|
|
|
|
try {
|
|
|
|
CommandRemover.removeCommand("tp");
|
|
|
|
CommandRemover.injectCommand(new CommandTeleport());
|
|
|
|
CommandRemover.removeCommand("gamemode");
|
|
|
|
CommandRemover.injectCommand(new CommandGamemode());
|
|
|
|
CommandRemover.removeCommand("time");
|
|
|
|
CommandRemover.injectCommand(new CommandTime());
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
Bukkit.shutdown();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-13 10:22:07 +02:00
|
|
|
try {
|
|
|
|
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + owner.toString() + "/sections.yml"));
|
|
|
|
} catch (IOException | InvalidConfigurationException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
Bukkit.shutdown();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-11 07:05:05 +02:00
|
|
|
getCommand("trace").setExecutor(new CommandTrace());
|
|
|
|
getCommand("nightvision").setExecutor(new CommandNV());
|
|
|
|
getCommand("reset").setExecutor(new CommandReset());
|
|
|
|
getCommand("speed").setExecutor(new CommandSpeed());
|
|
|
|
getCommand("tnt").setExecutor(new CommandTNT());
|
|
|
|
getCommand("fire").setExecutor(new CommandFire());
|
|
|
|
getCommand("testblock").setExecutor(new CommandTestblock());
|
2019-06-13 10:22:07 +02:00
|
|
|
getCommand("bau").setExecutor(new CommandBau());
|
2019-06-11 07:05:05 +02:00
|
|
|
|
|
|
|
Bukkit.getPluginManager().registerEvents(this, this);
|
|
|
|
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BauSystem getPlugin(){
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
public static UUID getOwner(){
|
|
|
|
return owner;
|
|
|
|
}
|
|
|
|
public static Bauwelt getWelt(){
|
|
|
|
return welt;
|
|
|
|
}
|
|
|
|
public static TNTTracer getTracer(){
|
|
|
|
return tracer;
|
|
|
|
}
|
2019-06-13 10:22:07 +02:00
|
|
|
public static List<ArenaSection> getSections(){
|
|
|
|
return sections;
|
|
|
|
}
|
|
|
|
public static int getOwnerID(){
|
|
|
|
return WarkingUser.get(owner).getId();
|
|
|
|
}
|
2019-06-11 07:05:05 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onDeath(PlayerDeathEvent e) {
|
|
|
|
e.setDeathMessage(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onJoin(PlayerJoinEvent e) {
|
|
|
|
Player p = e.getPlayer();
|
|
|
|
PermissionAttachment attachment = p.addAttachment(this);
|
|
|
|
attachment.setPermission("F3NPerm.use", true);
|
|
|
|
attachment.setPermission("fawe.permpack.basic", true);
|
|
|
|
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
|
|
|
|
attachment.setPermission("worldedit.navigation.thru.tool", true);
|
|
|
|
}
|
2019-06-13 10:22:07 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onLeave(PlayerQuitEvent e){
|
2019-06-13 21:06:59 +02:00
|
|
|
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(e.getPlayer())))
|
2019-06-13 10:22:07 +02:00
|
|
|
Bukkit.shutdown();
|
|
|
|
}
|
2019-06-11 07:05:05 +02:00
|
|
|
}
|