Changing TNT/Fire startup behavior + refactoring
Dieser Commit ist enthalten in:
Ursprung
308ecd90e6
Commit
8e91113f3d
@ -1,7 +1,6 @@
|
|||||||
package de.steamwar.bausystem;
|
package de.steamwar.bausystem;
|
||||||
|
|
||||||
import de.steamwar.bausystem.commands.*;
|
import de.steamwar.bausystem.commands.*;
|
||||||
import de.steamwar.bausystem.sql.Bauwelt;
|
|
||||||
import de.steamwar.bausystem.world.ArenaSection;
|
import de.steamwar.bausystem.world.ArenaSection;
|
||||||
import de.steamwar.bausystem.world.RegionListener;
|
import de.steamwar.bausystem.world.RegionListener;
|
||||||
import de.steamwar.bausystem.world.TNTListener;
|
import de.steamwar.bausystem.world.TNTListener;
|
||||||
@ -26,7 +25,6 @@ import java.util.logging.Level;
|
|||||||
public class BauSystem extends JavaPlugin implements Listener {
|
public class BauSystem extends JavaPlugin implements Listener {
|
||||||
private static BauSystem plugin;
|
private static BauSystem plugin;
|
||||||
private static UUID owner;
|
private static UUID owner;
|
||||||
private static Bauwelt welt;
|
|
||||||
private static List<ArenaSection> sections;
|
private static List<ArenaSection> sections;
|
||||||
public static final String PREFIX = "§eBauSystem§8» §7";
|
public static final String PREFIX = "§eBauSystem§8» §7";
|
||||||
public static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/";
|
public static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/";
|
||||||
@ -42,14 +40,11 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
welt = Bauwelt.getBauwelt(owner);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommandRemover.removeCommand("tp");
|
CommandRemover.removeAll("tp", "gamemode", "time");
|
||||||
CommandRemover.injectCommand(new CommandTeleport());
|
CommandRemover.injectCommand(new CommandTeleport());
|
||||||
CommandRemover.removeCommand("gamemode");
|
|
||||||
CommandRemover.injectCommand(new CommandGamemode());
|
CommandRemover.injectCommand(new CommandGamemode());
|
||||||
CommandRemover.removeCommand("time");
|
|
||||||
CommandRemover.injectCommand(new CommandTime());
|
CommandRemover.injectCommand(new CommandTime());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||||
@ -71,12 +66,12 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
getCommand("speed").setExecutor(new CommandSpeed());
|
getCommand("speed").setExecutor(new CommandSpeed());
|
||||||
getCommand("tnt").setExecutor(new CommandTNT());
|
getCommand("tnt").setExecutor(new CommandTNT());
|
||||||
getCommand("fire").setExecutor(new CommandFire());
|
getCommand("fire").setExecutor(new CommandFire());
|
||||||
|
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||||
getCommand("testblock").setExecutor(new CommandTestblock());
|
getCommand("testblock").setExecutor(new CommandTestblock());
|
||||||
getCommand("bau").setExecutor(new CommandBau());
|
getCommand("bau").setExecutor(new CommandBau());
|
||||||
getCommand("bauinfo").setExecutor(new CommandInfo());
|
getCommand("bauinfo").setExecutor(new CommandInfo());
|
||||||
getCommand("protect").setExecutor(new CommandProtect());
|
getCommand("protect").setExecutor(new CommandProtect());
|
||||||
getCommand("skull").setExecutor(new CommandSkull());
|
getCommand("skull").setExecutor(new CommandSkull());
|
||||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
|
||||||
getCommand("loader").setExecutor(new CommandLoader());
|
getCommand("loader").setExecutor(new CommandLoader());
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
@ -90,9 +85,6 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
public static UUID getOwner(){
|
public static UUID getOwner(){
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
public static Bauwelt getWelt(){
|
|
||||||
return welt;
|
|
||||||
}
|
|
||||||
public static List<ArenaSection> getSections(){
|
public static List<ArenaSection> getSections(){
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class CommandBau implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BauweltMember target = BauweltMember.getBauMember(id);
|
BauweltMember target = BauweltMember.getBauMember(id);
|
||||||
Welt.toggleTestblock(p, target);
|
Welt.toggleWorld(p, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean negativeToggleCheck(Player p, UUID id){
|
private boolean negativeToggleCheck(Player p, UUID id){
|
||||||
|
@ -1,20 +1,40 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CommandFire implements CommandExecutor {
|
public class CommandFire extends ToggleCommand {
|
||||||
|
|
||||||
|
public CommandFire(){
|
||||||
|
super(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToggleCommand getInstance(){
|
||||||
|
return getInstance(CommandFire.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
String getNoPermMessage() {
|
||||||
if(!(sender instanceof Player))
|
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";
|
||||||
return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
Welt.switchFire(player);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
String getEnableMessage(){
|
||||||
|
return "§cFeuerschaden deaktiviert";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
String getDisableMessage(){
|
||||||
|
return "§aFeuerschaden aktiviert";
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFireDamage(BlockBurnEvent e) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFireSpread(BlockSpreadEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +1,29 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
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.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
public class CommandFreeze implements CommandExecutor, Listener {
|
public class CommandFreeze extends ToggleCommand {
|
||||||
|
|
||||||
private boolean frozen = false;
|
public CommandFreeze(){
|
||||||
|
super(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToggleCommand getInstance(){
|
||||||
|
return getInstance(CommandFreeze.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
String getNoPermMessage() {
|
||||||
if(!(sender instanceof Player))
|
return "§cDu darfst diese Welt nicht einfrieren";
|
||||||
return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (Welt.noPermission(player, Permission.world)){
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst diese Welt nicht einfrieren");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
if(frozen){
|
String getEnableMessage(){
|
||||||
HandlerList.unregisterAll(this);
|
return "§cWelt eingefroren";
|
||||||
Bukkit.broadcastMessage(BauSystem.PREFIX + "§aDie Welt wurde aufgetaut");
|
|
||||||
}else{
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
|
||||||
Bukkit.broadcastMessage(BauSystem.PREFIX + "§cDie Welt wurde eingefroren");
|
|
||||||
}
|
}
|
||||||
frozen = !frozen;
|
@Override
|
||||||
return false;
|
String getDisableMessage(){
|
||||||
|
return "§aWelt aufgetaut";
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.sql.Bauwelt;
|
|
||||||
import de.steamwar.bausystem.sql.BauweltMember;
|
import de.steamwar.bausystem.sql.BauweltMember;
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
import net.minecraft.server.v1_12_R1.MinecraftServer;
|
import net.minecraft.server.v1_12_R1.MinecraftServer;
|
||||||
@ -15,12 +14,12 @@ public class CommandInfo implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
Bauwelt welt = BauSystem.getWelt();
|
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + WarkingUser.get(BauSystem.getOwnerID()).getUserName());
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + WarkingUser.get(welt.getUserID()).getUserName());
|
sender.sendMessage(BauSystem.PREFIX + "TNT-Schaden: " + (CommandTNT.getInstance().isOn() ? "§aAUS" : "§cAN"));
|
||||||
sender.sendMessage(BauSystem.PREFIX + "TNT-Schaden: " + (welt.isTNTDmg() ? "§aAN" : "§cAUS"));
|
sender.sendMessage(BauSystem.PREFIX + "Feuerschaden: " + (CommandFire.getInstance().isOn() ? "§aAUS" : "§cAN"));
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Feuerschaden: " + (welt.isFireDmg() ? "§aAN" : "§cAUS"));
|
sender.sendMessage(BauSystem.PREFIX + "Eingefroren: " + (CommandFreeze.getInstance().isOn() ? "§aJA" : "§cNEIN"));
|
||||||
|
|
||||||
List<BauweltMember> members = BauweltMember.getMembers(welt.getUserID());
|
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
|
||||||
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
|
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
|
||||||
|
|
||||||
for (BauweltMember member : members) {
|
for (BauweltMember member : members) {
|
||||||
|
@ -18,14 +18,7 @@ public class CommandRemover {
|
|||||||
for (String cmd : cmds) removeCommand(cmd);
|
for (String cmd : cmds) removeCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static void removeCommand(String command) throws Exception {
|
||||||
* Removes command from bukkit CommandMap
|
|
||||||
*
|
|
||||||
* @param command Command to remove
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static void removeCommand(String command) throws Exception {
|
|
||||||
Class<?> serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer");
|
Class<?> serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer");
|
||||||
|
|
||||||
Field f1 = serverClass.getDeclaredField("commandMap");
|
Field f1 = serverClass.getDeclaredField("commandMap");
|
||||||
|
@ -1,20 +1,33 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CommandTNT implements CommandExecutor {
|
public class CommandTNT extends ToggleCommand {
|
||||||
|
|
||||||
|
public CommandTNT(){
|
||||||
|
super(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToggleCommand getInstance(){
|
||||||
|
return getInstance(CommandTNT.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
String getNoPermMessage() {
|
||||||
if(!(sender instanceof Player))
|
return "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren";
|
||||||
return false;
|
}
|
||||||
Player player = (Player) sender;
|
@Override
|
||||||
|
String getEnableMessage(){
|
||||||
|
return "§cTNT-Schaden deaktiviert";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
String getDisableMessage(){
|
||||||
|
return "§aTNT-Schaden aktiviert";
|
||||||
|
}
|
||||||
|
|
||||||
Welt.switchTNT(player);
|
@EventHandler
|
||||||
return false;
|
public void onExplode(EntityExplodeEvent e) {
|
||||||
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
68
src/de/steamwar/bausystem/commands/ToggleCommand.java
Normale Datei
68
src/de/steamwar/bausystem/commands/ToggleCommand.java
Normale Datei
@ -0,0 +1,68 @@
|
|||||||
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class ToggleCommand implements CommandExecutor, Listener {
|
||||||
|
|
||||||
|
private static Map<Class<? extends ToggleCommand>, Boolean> enabled = new HashMap<>();
|
||||||
|
private static Map<Class<? extends ToggleCommand>, ToggleCommand> instance = new HashMap<>();
|
||||||
|
|
||||||
|
ToggleCommand(boolean on){
|
||||||
|
enabled.put(getClass(), false);
|
||||||
|
if(on)
|
||||||
|
toggle();
|
||||||
|
instance.put(getClass(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player))
|
||||||
|
return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (Welt.noPermission(player, Permission.world)){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ToggleCommand getInstance(Class<? extends ToggleCommand> clazz){
|
||||||
|
return instance.get(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract String getNoPermMessage();
|
||||||
|
abstract String getEnableMessage();
|
||||||
|
abstract String getDisableMessage();
|
||||||
|
|
||||||
|
public boolean isOn(){
|
||||||
|
return enabled.get(getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggle(){
|
||||||
|
enabled.compute(getClass(), (clazz, value) -> !value);
|
||||||
|
if(enabled.get(getClass())){
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getEnableMessage())));
|
||||||
|
}else{
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getDisableMessage())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,87 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -162,7 +162,6 @@ public class AutoLoader implements Listener {
|
|||||||
}
|
}
|
||||||
}else if(event.getAction() == Action.PHYSICAL){
|
}else if(event.getAction() == Action.PHYSICAL){
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
System.out.println(block);
|
|
||||||
Material material = block.getType();
|
Material material = block.getType();
|
||||||
if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){
|
if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){
|
||||||
new TemporaryActivation(block.getLocation(), 20);
|
new TemporaryActivation(block.getLocation(), 20);
|
||||||
@ -207,6 +206,7 @@ public class AutoLoader implements Listener {
|
|||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private boolean setRedstone(Location location, boolean active){
|
private boolean setRedstone(Location location, boolean active){
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
Material material = block.getType();
|
Material material = block.getType();
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
public class RegionListener implements Listener {
|
public class RegionListener implements Listener {
|
||||||
@ -58,24 +57,6 @@ public class RegionListener implements Listener {
|
|||||||
.getCommandManager().getDispatcher().get(command) != null;
|
.getCommandManager().getDispatcher().get(command) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onExplode(EntityExplodeEvent e) {
|
|
||||||
if(!BauSystem.getWelt().isTNTDmg())
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onFireDamage(BlockBurnEvent e) {
|
|
||||||
if(!BauSystem.getWelt().isFireDmg())
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onFireSpread(BlockSpreadEvent e){
|
|
||||||
if(!BauSystem.getWelt().isFireDmg())
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSignChange(SignChangeEvent event) {
|
public void onSignChange(SignChangeEvent event) {
|
||||||
for(int i = 0; i <= 3; ++i) {
|
for(int i = 0; i <= 3; ++i) {
|
||||||
|
@ -2,7 +2,6 @@ package de.steamwar.bausystem.world;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.sql.Bauwelt;
|
|
||||||
import de.steamwar.bausystem.sql.BauweltMember;
|
import de.steamwar.bausystem.sql.BauweltMember;
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -34,83 +33,34 @@ public class Welt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void switchTNT(Player p){
|
private static void sendMessages(Player p, boolean ableTo, BauweltMember target, String what){
|
||||||
if (noPermission(p, Permission.world)){
|
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de)aktivieren");
|
if (z != null) {
|
||||||
return;
|
if (ableTo) {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a " + what);
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c " + what);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bauwelt welt = BauSystem.getWelt();
|
|
||||||
welt.setTNTDmg(!welt.isTNTDmg());
|
|
||||||
if (welt.isTNTDmg())
|
|
||||||
Bukkit.broadcastMessage(BauSystem.PREFIX + "§aTNT-Schaden erlaubt");
|
|
||||||
else
|
|
||||||
Bukkit.broadcastMessage(BauSystem.PREFIX + "§cTNT-Schaden verboten");
|
|
||||||
}
|
}
|
||||||
|
if (ableTo) {
|
||||||
public static void switchFire(Player p){
|
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun " + what);
|
||||||
if (noPermission(p, Permission.world)){
|
} else {
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht Feuerschaden (de)aktivieren");
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr " + what);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bauwelt welt = BauSystem.getWelt();
|
|
||||||
welt.setFireDmg(!welt.isFireDmg());
|
|
||||||
if (welt.isFireDmg())
|
|
||||||
Bukkit.broadcastMessage(BauSystem.PREFIX + "§aFeuer-Schaden erlaubt");
|
|
||||||
else
|
|
||||||
Bukkit.broadcastMessage(BauSystem.PREFIX + "§cFeuer-Schaden verboten");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void toggleBuild(Player p, BauweltMember target){
|
public static void toggleBuild(Player p, BauweltMember target){
|
||||||
target.setBuild(!target.isBuild());
|
target.setBuild(!target.isBuild());
|
||||||
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
sendMessages(p, target.isBuild(), target, "bauen");
|
||||||
if (z != null) {
|
|
||||||
if (target.isBuild()) {
|
|
||||||
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a bauen");
|
|
||||||
}else {
|
|
||||||
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c bauen");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (target.isBuild()) {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun bauen");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr bauen");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleWE(Player p, BauweltMember target){
|
public static void toggleWE(Player p, BauweltMember target){
|
||||||
target.setWorldEdit(!target.isWorldEdit());
|
target.setWorldEdit(!target.isWorldEdit());
|
||||||
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
sendMessages(p, target.isWorldEdit(), target, "WorldEdit verwenden");
|
||||||
if (z != null) {
|
|
||||||
if (target.isWorldEdit()) {
|
|
||||||
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a WorldEdit verwenden");
|
|
||||||
}else {
|
|
||||||
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c WorldEdit verwenden");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (target.isWorldEdit()) {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun WorldEdit verwenden");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun kein WorldEdit mehr verwenden");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleTestblock(Player p, BauweltMember target){
|
public static void toggleWorld(Player p, BauweltMember target){
|
||||||
target.setWorld(!target.isWorld());
|
target.setWorld(!target.isWorld());
|
||||||
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
sendMessages(p, target.isWorld(), target, "Einstellungen vornehmen");
|
||||||
if (z != null) {
|
|
||||||
if (target.isWorld()) {
|
|
||||||
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a Einstellungen vornehmen");
|
|
||||||
}else {
|
|
||||||
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c Einstellungen vornehmen");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (target.isWorld()) {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun Einstellungen vornehmen");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr Einstellungen vornehmen");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren