From 607ff10250c7d8129dbcafd511407910edaafb6a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 6 Sep 2020 21:04:07 +0200 Subject: [PATCH 1/2] Move Copy-Schematic to BauSystem due to arena implications --- .../src/de/steamwar/bausystem/BauSystem.java | 133 +----------------- .../bausystem/world/ClipboardListener.java | 65 +++++++++ 2 files changed, 66 insertions(+), 132 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index b1201c3..c54c742 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -122,6 +122,7 @@ public class BauSystem extends JavaPlugin implements Listener { Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); Bukkit.getPluginManager().registerEvents(new TraceListener(), this); Bukkit.getPluginManager().registerEvents(new Detonator(), this); + Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this); new AFKStopper(); TNTTracer.init(); @@ -155,138 +156,6 @@ public class BauSystem extends JavaPlugin implements Listener { Player p = e.getPlayer(); p.setOp(true); - /*PermissionAttachment attachment = p.addAttachment(this); - attachment.setPermission("F3NPerm.use", true); - attachment.setPermission("fawe.tips", false); - attachment.setPermission("fawe.admin", true); - attachment.setPermission("fawe.permpack.basic", true); - attachment.setPermission("worldedit.navigation.jumpto.tool", true); - attachment.setPermission("worldedit.navigation.thru.tool", true); - attachment.setPermission("worldedit.biome.info", true); - attachment.setPermission("worldedit.biome.set", true); - attachment.setPermission("worldedit.biome.list", true); - attachment.setPermission("worldedit.chunkinfo", true); - attachment.setPermission("worldedit.listchunks", true); - attachment.setPermission("worldedit.clipboard.cut", true); - attachment.setPermission("worldedit.clipboard.paste", true); - attachment.setPermission("worldedit.schematic.formats", true); - attachment.setPermission("worldedit.schematic.load", true); - attachment.setPermission("worldedit.schematic.list", true); - attachment.setPermission("worldedit.schematic.save", true); - attachment.setPermission("worldedit.clipboard.clear", true); - attachment.setPermission("worldedit.clipboard.copy", true); - attachment.setPermission("worldedit.clipboard.lazycopy", true); - attachment.setPermission("worldedit.clipboard.place", true); - attachment.setPermission("worldedit.clipboard.download", true); - attachment.setPermission("worldedit.clipboard.flip", true); - attachment.setPermission("worldedit.clipboard.rotate", true); - attachment.setPermission("worldedit.help", true); - attachment.setPermission("worldedit.global-mask", true); - attachment.setPermission("worldedit.global-transform", true); - attachment.setPermission("worldedit.generation.cylinder", true); - attachment.setPermission("worldedit.generation.sphere", true); - attachment.setPermission("worldedit.generation.forest", true); - attachment.setPermission("worldedit.generation.pumpkins", true); - attachment.setPermission("worldedit.generation.pyramid", true); - attachment.setPermission("worldedit.generation.shape", true); - attachment.setPermission("worldedit.biome.set", true); - attachment.setPermission("worldedit.history.undo", true); - attachment.setPermission("worldedit.history.redo", true); - attachment.setPermission("worldedit.history.rollback", true); - attachment.setPermission("worldedit.navigation.unstuck", true); - attachment.setPermission("worldedit.navigation.ascend", true); - attachment.setPermission("worldedit.navigation.descend", true); - attachment.setPermission("worldedit.navigation.ceiling", true); - attachment.setPermission("worldedit.navigation.thru.command", true); - attachment.setPermission("worldedit.navigation.jumpto.command", true); - attachment.setPermission("worldedit.navigation.up", true); - attachment.setPermission("worldedit.region.hollow", true); - attachment.setPermission("worldedit.region.line", true); - attachment.setPermission("worldedit.region.curve", true); - attachment.setPermission("worldedit.region.overlay", true); - attachment.setPermission("worldedit.region.center", true); - attachment.setPermission("worldedit.region.naturalize", true); - attachment.setPermission("worldedit.region.walls", true); - attachment.setPermission("worldedit.region.faces", true); - attachment.setPermission("worldedit.region.smooth", true); - attachment.setPermission("worldedit.region.move", true); - attachment.setPermission("worldedit.region.forest", true); - attachment.setPermission("worldedit.region.replace", true); - attachment.setPermission("worldedit.region.stack", true); - attachment.setPermission("worldedit.region.set", true); - attachment.setPermission("worldedit.selection.pos", true); - attachment.setPermission("worldedit.selection.chunk", true); - attachment.setPermission("worldedit.selection.hpos", true); - attachment.setPermission("worldedit.wand", true); - attachment.setPermission("worldedit.wand.toggle", true); - attachment.setPermission("worldedit.selection.contract", true); - attachment.setPermission("worldedit.selection.outset", true); - attachment.setPermission("worldedit.selection.inset", true); - attachment.setPermission("worldedit.analysis.distr", true); - attachment.setPermission("worldedit.analysis.count", true); - attachment.setPermission("worldedit.selection.size", true); - attachment.setPermission("worldedit.selection.expand", true); - attachment.setPermission("worldedit.selection.shift", true); - attachment.setPermission("worldedit.snapshots.list", true); - attachment.setPermission("worldedit.superpickaxe", true); - attachment.setPermission("worldedit.superpickaxe.area", true); - attachment.setPermission("worldedit.superpickaxe.recursive", true); - attachment.setPermission("worldedit.brush.blendball", true); - attachment.setPermission("worldedit.brush.erode", true); - attachment.setPermission("worldedit.brush.pull", true); - attachment.setPermission("worldedit.brush.circle", true); - attachment.setPermission("worldedit.brush.recursive", true); - attachment.setPermission("worldedit.brush.line", true); - attachment.setPermission("worldedit.brush.spline", true); - attachment.setPermission("worldedit.brush.surfacespline", true); - attachment.setPermission("worldedit.brush.shatter", true); - attachment.setPermission("worldedit.brush.stencil", true); - attachment.setPermission("worldedit.brush.height", true); - attachment.setPermission("worldedit.brush.layer", true); - attachment.setPermission("worldedit.brush.populateschematic", true); - attachment.setPermission("worldedit.brush.scatter", true); - attachment.setPermission("worldedit.brush.splatter", true); - attachment.setPermission("worldedit.brush.scattercommand", true); - attachment.setPermission("worldedit.brush.copy", true); - attachment.setPermission("worldedit.brush.command", true); - attachment.setPermission("worldedit.brush.apply", true); - attachment.setPermission("worldedit.brush.sphere", true); - attachment.setPermission("worldedit.brush.cylinder", true); - attachment.setPermission("worldedit.brush.clipboard", true); - attachment.setPermission("worldedit.brush.smooth", true); - attachment.setPermission("worldedit.brush.ex", true); - attachment.setPermission("worldedit.brush.gravity", true); - attachment.setPermission("worldedit.brush.options.range", true); - attachment.setPermission("worldedit.brush.options.material", true); - attachment.setPermission("worldedit.brush.options.size", true); - attachment.setPermission("worldedit.brush.options.mask", true); - attachment.setPermission("worldedit.brush.options.smask", true); - attachment.setPermission("worldedit.brush.options.transform", true); - attachment.setPermission("worldedit.brush.options.scroll", true); - attachment.setPermission("worldedit.brush.options.visualize", true); - attachment.setPermission("worldedit.tool.deltree", true); - attachment.setPermission("worldedit.tool.farwand", true); - attachment.setPermission("worldedit.tool.lrbuild", true); - attachment.setPermission("worldedit.tool.info", true); - attachment.setPermission("worldedit.tool.tree", true); - attachment.setPermission("worldedit.tool.replacer", true); - attachment.setPermission("worldedit.tool.data-cycler", true); - attachment.setPermission("worldedit.tool.flood-fill", true); - attachment.setPermission("worldedit.tool.inspect", true); - attachment.setPermission("worldedit.fill.recursive", true); - attachment.setPermission("worldedit.drain", true); - attachment.setPermission("worldedit.fixlava", true); - attachment.setPermission("worldedit.fixwater", true); - attachment.setPermission("worldedit.removeabove", true); - attachment.setPermission("worldedit.removebelow", true); - attachment.setPermission("worldedit.removenear", true); - attachment.setPermission("worldedit.replacenear", true); - attachment.setPermission("worldedit.snow", true); - attachment.setPermission("worldedit.thaw", true); - attachment.setPermission("worldedit.green", true); - attachment.setPermission("worldedit.extinguish", true); - attachment.setPermission("worldedit.calc", true); - attachment.setPermission("worldedit.fill", true);*/ ShowManager.add(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java new file mode 100644 index 0000000..b587d40 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java @@ -0,0 +1,65 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.bausystem.world; + +import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.UUID; + +public class ClipboardListener implements Listener { + + private static final String CLIPBOARD_SCHEMNAME = "//copy"; + + @EventHandler + public void onLogin(PlayerJoinEvent e){ + Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, e.getPlayer().getUniqueId()); + if(schematic != null){ + try { + schematic.loadToPlayer(e.getPlayer()); + } catch (Exception ex) { + //ignore + } + } + } + + @EventHandler + public void onLogout(PlayerQuitEvent e){ + UUID playerUUID = e.getPlayer().getUniqueId(); + Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID); + boolean newSchem = false; + if(schematic == null){ + Schematic.createSchem(CLIPBOARD_SCHEMNAME, playerUUID, "", SchematicType.Normal); + schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID); + newSchem = true; + } + + try{ + schematic.saveFromPlayer(e.getPlayer()); + } catch (Exception ex) { + if(newSchem) + schematic.remove(); + } + } +} -- 2.39.5 From f5c34db39e74535145c54c1e1cc2996f2b50c124 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 6 Sep 2020 21:05:39 +0200 Subject: [PATCH 2/2] Refactor for "better" error handling --- .../de/steamwar/bausystem/world/ClipboardListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java index b587d40..f31f51a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java @@ -34,13 +34,13 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogin(PlayerJoinEvent e){ - Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, e.getPlayer().getUniqueId()); - if(schematic != null){ - try { + try { + Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, e.getPlayer().getUniqueId()); + if(schematic != null){ schematic.loadToPlayer(e.getPlayer()); - } catch (Exception ex) { - //ignore } + } catch (Exception ex) { + //ignore cause players do all kind of stuff with schematics.... like massively oversized schems } } -- 2.39.5