From 9c9033e47d8253fcf2472bc513342a67c3aa86a6 Mon Sep 17 00:00:00 2001 From: DefineOutside <49797025+MWHunter@users.noreply.github.com> Date: Mon, 29 Mar 2021 11:38:01 -0500 Subject: [PATCH 1/4] Convert to maven --- LockettePro/.classpath | 11 -- LockettePro/.gitignore | 1 - LockettePro/.project | 17 --- .../.settings/org.eclipse.jdt.core.prefs | 11 -- LockettePro/README.md | 22 ++++ LockettePro/pom.xml | 118 ++++++++++++++++++ .../mc/lockettepro/BlockDebugListener.java | 0 .../lockettepro/BlockEnvironmentListener.java | 0 .../BlockInventoryMoveListener.java | 2 +- .../mc/lockettepro/BlockPlayerListener.java | 0 .../me/crafter/mc/lockettepro/Config.java | 0 .../me/crafter/mc/lockettepro/Dependency.java | 0 .../mc/lockettepro/DependencyProtocolLib.java | 0 .../mc/lockettepro/DoorToggleTask.java | 0 .../crafter/mc/lockettepro/LockettePro.java | 0 .../mc/lockettepro/LocketteProAPI.java | 0 .../me/crafter/mc/lockettepro/Utils.java | 0 .../src/{ => main/resources}/config.yml | 0 LockettePro/src/{ => main/resources}/lang.yml | 0 .../src/{ => main/resources}/lang_de.yml | 0 .../src/{ => main/resources}/lang_es.yml | 0 .../src/{ => main/resources}/lang_fr.yml | 0 .../src/{ => main/resources}/lang_hu.yml | 0 .../src/{ => main/resources}/lang_it.yml | 0 .../src/{ => main/resources}/lang_pl.yml | 0 .../src/{ => main/resources}/lang_zh-cn.yml | 0 .../src/{ => main/resources}/plugin.yml | 0 27 files changed, 141 insertions(+), 41 deletions(-) delete mode 100644 LockettePro/.classpath delete mode 100644 LockettePro/.gitignore delete mode 100644 LockettePro/.project delete mode 100644 LockettePro/.settings/org.eclipse.jdt.core.prefs create mode 100644 LockettePro/README.md create mode 100644 LockettePro/pom.xml rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/BlockDebugListener.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/BlockEnvironmentListener.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java (98%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/BlockPlayerListener.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/Config.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/Dependency.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/DependencyProtocolLib.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/DoorToggleTask.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/LockettePro.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/LocketteProAPI.java (100%) rename LockettePro/src/{ => main/java}/me/crafter/mc/lockettepro/Utils.java (100%) rename LockettePro/src/{ => main/resources}/config.yml (100%) rename LockettePro/src/{ => main/resources}/lang.yml (100%) rename LockettePro/src/{ => main/resources}/lang_de.yml (100%) rename LockettePro/src/{ => main/resources}/lang_es.yml (100%) rename LockettePro/src/{ => main/resources}/lang_fr.yml (100%) rename LockettePro/src/{ => main/resources}/lang_hu.yml (100%) rename LockettePro/src/{ => main/resources}/lang_it.yml (100%) rename LockettePro/src/{ => main/resources}/lang_pl.yml (100%) rename LockettePro/src/{ => main/resources}/lang_zh-cn.yml (100%) rename LockettePro/src/{ => main/resources}/plugin.yml (100%) diff --git a/LockettePro/.classpath b/LockettePro/.classpath deleted file mode 100644 index 66e9dda..0000000 --- a/LockettePro/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/LockettePro/.gitignore b/LockettePro/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/LockettePro/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/LockettePro/.project b/LockettePro/.project deleted file mode 100644 index c209ca5..0000000 --- a/LockettePro/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - LockettePro - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/LockettePro/.settings/org.eclipse.jdt.core.prefs b/LockettePro/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index bb35fa0..0000000 --- a/LockettePro/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/LockettePro/README.md b/LockettePro/README.md new file mode 100644 index 0000000..8e2589c --- /dev/null +++ b/LockettePro/README.md @@ -0,0 +1,22 @@ +# LockettePro +### LockettePro - A much better Lockette plugin for Bukkit + +This fork is a continuation of the origial plugin: https://github.com/connection-lost/LockettePro +Also contains updates from: https://github.com/NyaaCat/LockettePro + +LockettePro is a block-protection plugin based on Lockette (https://github.com/Acru/Lockette), the code base is entirely re-written. It is 100% compatable with original Lockette, and the plugin behaviors are also 100% same. + +### LockettePro has a lot of enhancements compared to Lockette: + +1. Much better codebase and performance, fixed a lot of issues and glitches. +2. Real UUID support. +3. All blocks can be set to lockable or not. You can even prevent players from locking a chest. +4. Unlimited [Private], [More Users], [Timer:x] signs format. +5. Alert messages are editable, and UTF-8 characters are supported. +6. Lock expircy feature, locks can expire after a certain amount of time. + +### Links +Spigot release page: https://www.spigotmc.org/resources/lockettepro-for-1-14-1-15-1-16.74354/ +Bukkit release page: http://dev.bukkit.org/bukkit-plugins/lockettepro/ +MCBBS release page: http://www.mcbbs.net/thread-567962-1-1.html +MC 1.6~1.7 Port: https://github.com/connection-lost/LockettePro/releases/tag/v1.9.4 diff --git a/LockettePro/pom.xml b/LockettePro/pom.xml new file mode 100644 index 0000000..cbbfc6c --- /dev/null +++ b/LockettePro/pom.xml @@ -0,0 +1,118 @@ + + + 4.0.0 + groupId + LockettePro + 1.0-SNAPSHOT + jar + + 1.8 + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + com.comphenix + me.crafter.mc.shaded.com.comphenix + + + net.sf.cglib + me.crafter.mc.shaded.net.sf.cglib + + + net.bytebuddy + me.crafter.mc.shaded.net.bytebuddy + + + + + + + + + + src/main/resources + true + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + dmulloy2-repo + https://repo.dmulloy2.net/nexus/repository/public/ + + + coreprotect-repo + http://maven.playpro.com + + + sk89q-repo + https://maven.enginehub.org/repo/ + + + jitpack.io + https://jitpack.io + + + + + org.spigotmc + spigot-api + 1.16.5-R0.1-SNAPSHOT + provided + + + com.comphenix.protocol + ProtocolLib + 4.6.0 + provided + + + net.coreprotect + coreprotect + 19.5 + provided + + + com.sk89q.worldguard + worldguard-bukkit + 7.0.4-SNAPSHOT + provided + + + com.github.MilkBowl + VaultAPI + 1.7 + provided + + + \ No newline at end of file diff --git a/LockettePro/src/me/crafter/mc/lockettepro/BlockDebugListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/BlockDebugListener.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/BlockEnvironmentListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/BlockEnvironmentListener.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java similarity index 98% rename from LockettePro/src/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java index 3a2f183..01e0f95 100644 --- a/LockettePro/src/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java +++ b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java @@ -42,7 +42,7 @@ public void onInventoryMove(InventoryMoveItemEvent event){ String sourceOwner = LocketteProAPI.getOwner(sourceInventoryBlock); String destOwner = LocketteProAPI.getOwner(destinationInventoryBlock); if (destOwner != null && sourceOwner != null) { - if (sourceOwner.matches(destOwner)) { + if (sourceOwner.equalsIgnoreCase(destOwner)) { event.setCancelled(false); } } diff --git a/LockettePro/src/me/crafter/mc/lockettepro/BlockPlayerListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/BlockPlayerListener.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/Config.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/Config.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/Config.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/Config.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/Dependency.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/Dependency.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/Dependency.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/Dependency.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/DependencyProtocolLib.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/DependencyProtocolLib.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/DoorToggleTask.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/DoorToggleTask.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/LockettePro.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/LockettePro.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/LockettePro.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/LockettePro.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/LocketteProAPI.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/LocketteProAPI.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java diff --git a/LockettePro/src/me/crafter/mc/lockettepro/Utils.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/Utils.java similarity index 100% rename from LockettePro/src/me/crafter/mc/lockettepro/Utils.java rename to LockettePro/src/main/java/me/crafter/mc/lockettepro/Utils.java diff --git a/LockettePro/src/config.yml b/LockettePro/src/main/resources/config.yml similarity index 100% rename from LockettePro/src/config.yml rename to LockettePro/src/main/resources/config.yml diff --git a/LockettePro/src/lang.yml b/LockettePro/src/main/resources/lang.yml similarity index 100% rename from LockettePro/src/lang.yml rename to LockettePro/src/main/resources/lang.yml diff --git a/LockettePro/src/lang_de.yml b/LockettePro/src/main/resources/lang_de.yml similarity index 100% rename from LockettePro/src/lang_de.yml rename to LockettePro/src/main/resources/lang_de.yml diff --git a/LockettePro/src/lang_es.yml b/LockettePro/src/main/resources/lang_es.yml similarity index 100% rename from LockettePro/src/lang_es.yml rename to LockettePro/src/main/resources/lang_es.yml diff --git a/LockettePro/src/lang_fr.yml b/LockettePro/src/main/resources/lang_fr.yml similarity index 100% rename from LockettePro/src/lang_fr.yml rename to LockettePro/src/main/resources/lang_fr.yml diff --git a/LockettePro/src/lang_hu.yml b/LockettePro/src/main/resources/lang_hu.yml similarity index 100% rename from LockettePro/src/lang_hu.yml rename to LockettePro/src/main/resources/lang_hu.yml diff --git a/LockettePro/src/lang_it.yml b/LockettePro/src/main/resources/lang_it.yml similarity index 100% rename from LockettePro/src/lang_it.yml rename to LockettePro/src/main/resources/lang_it.yml diff --git a/LockettePro/src/lang_pl.yml b/LockettePro/src/main/resources/lang_pl.yml similarity index 100% rename from LockettePro/src/lang_pl.yml rename to LockettePro/src/main/resources/lang_pl.yml diff --git a/LockettePro/src/lang_zh-cn.yml b/LockettePro/src/main/resources/lang_zh-cn.yml similarity index 100% rename from LockettePro/src/lang_zh-cn.yml rename to LockettePro/src/main/resources/lang_zh-cn.yml diff --git a/LockettePro/src/plugin.yml b/LockettePro/src/main/resources/plugin.yml similarity index 100% rename from LockettePro/src/plugin.yml rename to LockettePro/src/main/resources/plugin.yml From b10c950c93b9ffbedfc22d512033fd47bf9a7109 Mon Sep 17 00:00:00 2001 From: DefineOutside <49797025+MWHunter@users.noreply.github.com> Date: Mon, 29 Mar 2021 11:43:25 -0500 Subject: [PATCH 2/4] Get rid of the unless double git repositories --- pom.xml | 118 +++ .../mc/lockettepro/BlockDebugListener.java | 58 ++ .../lockettepro/BlockEnvironmentListener.java | 118 +++ .../BlockInventoryMoveListener.java | 93 +++ .../mc/lockettepro/BlockPlayerListener.java | 379 +++++++++ .../me/crafter/mc/lockettepro/Config.java | 287 +++++++ .../me/crafter/mc/lockettepro/Dependency.java | 83 ++ .../mc/lockettepro/DependencyProtocolLib.java | 84 ++ .../mc/lockettepro/DoorToggleTask.java | 29 + .../crafter/mc/lockettepro/LockettePro.java | 281 +++++++ .../mc/lockettepro/LocketteProAPI.java | 742 ++++++++++++++++++ .../java/me/crafter/mc/lockettepro/Utils.java | 337 ++++++++ src/main/resources/config.yml | 70 ++ src/main/resources/lang.yml | 31 + src/main/resources/lang_de.yml | 33 + src/main/resources/lang_es.yml | 32 + src/main/resources/lang_fr.yml | 33 + src/main/resources/lang_hu.yml | 32 + src/main/resources/lang_it.yml | 32 + src/main/resources/lang_pl.yml | 32 + src/main/resources/lang_zh-cn.yml | 32 + src/main/resources/plugin.yml | 25 + 22 files changed, 2961 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/Config.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/Dependency.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/LockettePro.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java create mode 100644 src/main/java/me/crafter/mc/lockettepro/Utils.java create mode 100644 src/main/resources/config.yml create mode 100644 src/main/resources/lang.yml create mode 100644 src/main/resources/lang_de.yml create mode 100644 src/main/resources/lang_es.yml create mode 100644 src/main/resources/lang_fr.yml create mode 100644 src/main/resources/lang_hu.yml create mode 100644 src/main/resources/lang_it.yml create mode 100644 src/main/resources/lang_pl.yml create mode 100644 src/main/resources/lang_zh-cn.yml create mode 100644 src/main/resources/plugin.yml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..cbbfc6c --- /dev/null +++ b/pom.xml @@ -0,0 +1,118 @@ + + + 4.0.0 + groupId + LockettePro + 1.0-SNAPSHOT + jar + + 1.8 + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + com.comphenix + me.crafter.mc.shaded.com.comphenix + + + net.sf.cglib + me.crafter.mc.shaded.net.sf.cglib + + + net.bytebuddy + me.crafter.mc.shaded.net.bytebuddy + + + + + + + + + + src/main/resources + true + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + dmulloy2-repo + https://repo.dmulloy2.net/nexus/repository/public/ + + + coreprotect-repo + http://maven.playpro.com + + + sk89q-repo + https://maven.enginehub.org/repo/ + + + jitpack.io + https://jitpack.io + + + + + org.spigotmc + spigot-api + 1.16.5-R0.1-SNAPSHOT + provided + + + com.comphenix.protocol + ProtocolLib + 4.6.0 + provided + + + net.coreprotect + coreprotect + 19.5 + provided + + + com.sk89q.worldguard + worldguard-bukkit + 7.0.4-SNAPSHOT + provided + + + com.github.MilkBowl + VaultAPI + 1.7 + provided + + + \ No newline at end of file diff --git a/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java b/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java new file mode 100644 index 0000000..41461c7 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java @@ -0,0 +1,58 @@ +package me.crafter.mc.lockettepro; + +import org.bukkit.ChatColor; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +public class BlockDebugListener implements Listener { + + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.MONITOR) + public void onDebugClick(PlayerInteractEvent event){ + Player p = event.getPlayer(); + if (p.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK){ + event.setCancelled(true); + Block b = event.getClickedBlock(); + p.sendMessage(ChatColor.GREEN + "==========================="); + p.sendMessage("isLockable: " + formatBoolean(LocketteProAPI.isLockable(b))); + p.sendMessage("isLocked: " + formatBoolean(LocketteProAPI.isLocked(b))); + p.sendMessage(" - isOwner/User: " + formatBoolean(LocketteProAPI.isOwner(b, p)) + ChatColor.RESET + "/" + formatBoolean(LocketteProAPI.isUser(b, p))); + p.sendMessage("isLockedSingle: " + formatBoolean(LocketteProAPI.isLockedSingleBlock(b, null))); + p.sendMessage(" - isOwner/UserSingle: " + formatBoolean(LocketteProAPI.isOwnerSingleBlock(b, null, p)) + ChatColor.RESET + "/" + formatBoolean(LocketteProAPI.isUserSingleBlock(b, null, p))); + p.sendMessage("isLockedUpDownLockedDoor: " + formatBoolean(LocketteProAPI.isUpDownLockedDoor(b))); + p.sendMessage(" - isOwner/UserSingle: " + formatBoolean(LocketteProAPI.isOwnerUpDownLockedDoor(b, p)) + ChatColor.RESET + "/" + formatBoolean(LocketteProAPI.isOwnerUpDownLockedDoor(b, p))); + if (LocketteProAPI.isLockSign(b)){ + p.sendMessage("isSignExpired: " + formatBoolean(LocketteProAPI.isSignExpired(b))); + p.sendMessage(" - created: " + Utils.getCreatedFromLine(((Sign)b.getState()).getLine(0))); + p.sendMessage(" - now : " + (int)(System.currentTimeMillis()/1000)); + } + + p.sendMessage("Block: " + b.getType().toString() + " " + b.getData()); + + if (Tag.WALL_SIGNS.isTagged(b.getType())){ + for (String line : ((Sign)b.getState()).getLines()){ + p.sendMessage(ChatColor.GREEN + line); + } + } + p.sendMessage(p.getUniqueId().toString()); + } + } + + public String formatBoolean(boolean tf){ + if (tf){ + return ChatColor.GREEN + "true"; + } else { + return ChatColor.RED + "false"; + } + } + +} + + diff --git a/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java b/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java new file mode 100644 index 0000000..2aa407c --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java @@ -0,0 +1,118 @@ +package me.crafter.mc.lockettepro; + +import java.util.Iterator; + +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.Silverfish; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Wither; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockExplodeEvent; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.event.block.BlockRedstoneEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.event.world.StructureGrowEvent; + +public class BlockEnvironmentListener implements Listener{ + + // Prevent explosion break block + @EventHandler(priority = EventPriority.HIGH) + public void onEntityExplode(EntityExplodeEvent event){ + if (Config.isProtectionExempted("explosion")) return; + Iterator it = event.blockList().iterator(); + while (it.hasNext()) { + Block block = it.next(); + if (LocketteProAPI.isProtected(block)) it.remove(); + } + } + + // Prevent bed break block + @EventHandler(priority = EventPriority.HIGH) + public void onBlockExplode(BlockExplodeEvent event){ + if (Config.isProtectionExempted("explosion")) return; + Iterator it = event.blockList().iterator(); + while (it.hasNext()) { + Block block = it.next(); + if (LocketteProAPI.isProtected(block)) it.remove(); + } + } + + // Prevent tree break block + @EventHandler(priority = EventPriority.HIGH) + public void onStructureGrow(StructureGrowEvent event){ + if (Config.isProtectionExempted("growth")) return; + for (BlockState blockstate : event.getBlocks()){ + if (LocketteProAPI.isProtected(blockstate.getBlock())){ + event.setCancelled(true); + return; + } + } + } + + // Prevent piston extend break lock + @EventHandler(priority = EventPriority.HIGH) + public void onPistonExtend(BlockPistonExtendEvent event){ + if (Config.isProtectionExempted("piston")) return; + for (Block block : event.getBlocks()){ + if (LocketteProAPI.isProtected(block)){ + event.setCancelled(true); + return; + } + } + } + + // Prevent piston retract break lock + @EventHandler(priority = EventPriority.HIGH) + public void onPistonRetract(BlockPistonRetractEvent event){ + if (Config.isProtectionExempted("piston")) return; + for (Block block : event.getBlocks()){ + if (LocketteProAPI.isProtected(block)){ + event.setCancelled(true); + return; + } + } + } + + // Prevent redstone current open doors + @EventHandler(priority = EventPriority.HIGH) + public void onBlockRedstoneChange(BlockRedstoneEvent event){ + if (Config.isProtectionExempted("redstone")) return; + if (LocketteProAPI.isProtected(event.getBlock())){ + event.setNewCurrent(event.getOldCurrent()); + } + } + + // Prevent villager open door + @EventHandler(priority = EventPriority.HIGH) + public void onVillagerOpenDoor(EntityInteractEvent event){ + if (Config.isProtectionExempted("villager")) return; + // Explicitly to villager vs all doors + if (event.getEntity() instanceof Villager && + (LocketteProAPI.isSingleDoorBlock(event.getBlock()) || LocketteProAPI.isDoubleDoorBlock(event.getBlock())) && + LocketteProAPI.isProtected(event.getBlock())){ + event.setCancelled(true); + } + } + + // Prevent mob change block + @EventHandler(priority = EventPriority.HIGH) + public void onMobChangeBlock(EntityChangeBlockEvent event) { + if ((event.getEntity() instanceof Enderman && !Config.isProtectionExempted("enderman")) ||// enderman pick up/place block + (event.getEntity() instanceof Wither && !Config.isProtectionExempted("wither")) ||// wither break block + (event.getEntity() instanceof Zombie && !Config.isProtectionExempted("zombie")) ||// zombie break door + (event.getEntity() instanceof Silverfish && !Config.isProtectionExempted("silverfish"))){ + if (LocketteProAPI.isProtected(event.getBlock())){ + event.setCancelled(true); + } + }// ignore other reason (boat break lily pad, arrow ignite tnt, etc) + } + +} diff --git a/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java b/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java new file mode 100644 index 0000000..01e0f95 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java @@ -0,0 +1,93 @@ +package me.crafter.mc.lockettepro; + +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.block.DoubleChest; +import org.bukkit.block.Hopper; +import org.bukkit.entity.minecart.HopperMinecart; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryMoveItemEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; + +public class BlockInventoryMoveListener implements Listener { + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) + public void onInventoryMove(InventoryMoveItemEvent event){ + if (Config.isItemTransferOutBlocked() || Config.getHopperMinecartAction() != (byte)0){ + if (isInventoryLocked(event.getSource())){ + if (Config.isItemTransferOutBlocked()){ + event.setCancelled(true); + } + // Additional Hopper Minecart Check + if (event.getDestination().getHolder() instanceof HopperMinecart) { + byte hopperminecartaction = Config.getHopperMinecartAction(); + switch (hopperminecartaction){ + // case 0 - Impossible + case (byte)1: // Cancel only, it is not called if !Config.isItemTransferOutBlocked() + event.setCancelled(true); + break; + case (byte)2: // Extra action - HopperMinecart removal + event.setCancelled(true); + ((HopperMinecart)event.getDestination().getHolder()).remove(); + break; + } + } else if (event.getDestination().getHolder() instanceof Hopper || event.getSource().getHolder() instanceof Hopper) { + if (isInventoryLocked(event.getDestination())) { + Block sourceInventoryBlock = event.getSource().getLocation().getBlock(); + Block destinationInventoryBlock = event.getDestination().getLocation().getBlock(); + if (sourceInventoryBlock != null && destinationInventoryBlock != null) { + String sourceOwner = LocketteProAPI.getOwner(sourceInventoryBlock); + String destOwner = LocketteProAPI.getOwner(destinationInventoryBlock); + if (destOwner != null && sourceOwner != null) { + if (sourceOwner.equalsIgnoreCase(destOwner)) { + event.setCancelled(false); + } + } + } + } + } + return; + } + } + if (Config.isItemTransferInBlocked()){ + if (isInventoryLocked(event.getDestination())){ + event.setCancelled(true); + return; + } + } + } + + public boolean isInventoryLocked(Inventory inventory){ + InventoryHolder inventoryholder = inventory.getHolder(); + if (inventoryholder instanceof DoubleChest){ + inventoryholder = ((DoubleChest)inventoryholder).getLeftSide(); + } + if (inventoryholder instanceof BlockState){ + Block block = ((BlockState)inventoryholder).getBlock(); + if (Config.isCacheEnabled()){ // Cache is enabled + if (Utils.hasValidCache(block)){ + return Utils.getAccess(block); + } else { + if (LocketteProAPI.isLocked(block)){ + Utils.setCache(block, true); + return true; + } else { + Utils.setCache(block, false); + return false; + } + } + } else { // Cache is disabled + if (LocketteProAPI.isLocked(block)){ + return true; + } else { + return false; + } + } + } + return false; + } + +} diff --git a/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java b/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java new file mode 100644 index 0000000..8d56b84 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java @@ -0,0 +1,379 @@ +package me.crafter.mc.lockettepro; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerTakeLecternBookEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.ArrayList; +import java.util.List; + +public class BlockPlayerListener implements Listener { + + // Quick protect for chests + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerQuickLockChest(PlayerInteractEvent event){ + // Check quick lock enabled + if (Config.getQuickProtectAction() == (byte)0) return; + // Get player and action info + Action action = event.getAction(); + Player player = event.getPlayer(); + // Check action correctness + if (action == Action.RIGHT_CLICK_BLOCK && Tag.SIGNS.isTagged(player.getInventory().getItemInMainHand().getType())) { + if (player.getGameMode().equals(GameMode.SPECTATOR)) { + return; + } + // Check quick lock action correctness + if (!((event.getPlayer().isSneaking() && Config.getQuickProtectAction() == (byte)2) || + (!event.getPlayer().isSneaking() && Config.getQuickProtectAction() == (byte)1))) return; + // Check permission + if (!player.hasPermission("lockettepro.lock")) return; + // Get target block to lock + BlockFace blockface = event.getBlockFace(); + if (blockface == BlockFace.NORTH || blockface == BlockFace.WEST || blockface == BlockFace.EAST || blockface == BlockFace.SOUTH){ + Block block = event.getClickedBlock(); + if (block == null) return; + // Check permission with external plugin + if (Dependency.isProtectedFrom(block, player)) return; // blockwise + if (Dependency.isProtectedFrom(block.getRelative(event.getBlockFace()), player)) return; // signwise + // Check whether locking location is obstructed + Block signLoc = block.getRelative(blockface); + if (!signLoc.isEmpty()) return; + // Check whether this block is lockable + if (LocketteProAPI.isLockable(block)){ + // Is this block already locked? + boolean locked = LocketteProAPI.isLocked(block); + // Cancel event here + event.setCancelled(true); + // Check lock info info + if (!locked && !LocketteProAPI.isUpDownLockedDoor(block)){ + Material signType = player.getInventory().getItemInMainHand().getType(); + // Not locked, not a locked door nearby + Utils.removeASign(player); + // Send message + Utils.sendMessages(player, Config.getLang("locked-quick")); + // Put sign on + Block newsign = Utils.putSignOn(block, blockface, Config.getDefaultPrivateString(), player.getName(), signType); + Utils.resetCache(block); + // Cleanups - UUID + if (Config.isUuidEnabled()){ + Utils.updateLineByPlayer(newsign, 1, player); + } + // Cleanups - Expiracy + if (Config.isLockExpire()) { + if (player.hasPermission("lockettepro.noexpire")) { + Utils.updateLineWithTime(newsign, true); // set created to -1 (no expire) + } else { + Utils.updateLineWithTime(newsign, false); // set created to now + } + } + Dependency.logPlacement(player, newsign); + } else if (!locked && LocketteProAPI.isOwnerUpDownLockedDoor(block, player)){ + // Not locked, (is locked door nearby), is owner of locked door nearby + Material signType = player.getInventory().getItemInMainHand().getType(); + Utils.removeASign(player); + Utils.sendMessages(player, Config.getLang("additional-sign-added-quick")); + Utils.putSignOn(block, blockface, Config.getDefaultAdditionalString(), "", signType); + Dependency.logPlacement(player, block.getRelative(blockface)); + } else if (LocketteProAPI.isOwner(block, player)) { + // Locked, (not locked door nearby), is owner of locked block + Material signType = player.getInventory().getItemInMainHand().getType(); + Utils.removeASign(player); + Utils.putSignOn(block, blockface, Config.getDefaultAdditionalString(), "", signType); + Utils.sendMessages(player, Config.getLang("additional-sign-added-quick")); + Dependency.logPlacement(player, block.getRelative(blockface)); + } else { + // Cannot lock this block + Utils.sendMessages(player, Config.getLang("cannot-lock-quick")); + } + } + } + } + } + + // Manual protection + @EventHandler(priority = EventPriority.NORMAL) + public void onManualLock(SignChangeEvent event){ + if (!Tag.WALL_SIGNS.isTagged(event.getBlock().getType())) return; + String topline = event.getLine(0); + if (topline == null) topline = ""; + Player player = event.getPlayer(); + /* Issue #46 - Old version of Minecraft trim signs in unexpected way. + * This is caused by Minecraft was doing: (unconfirmed but seemingly) + * Place Sign -> Event Fire -> Trim Sign + * The event.getLine() will be inaccurate if the line has white space to trim + * + * This will cause player without permission will be able to lock chests by + * adding a white space after the [private] word. + * Currently this is fixed by using trimmed line in checking permission. Trimmed + * line should not be used anywhere else. + */ + if (!player.hasPermission("lockettepro.lock")){ + String toplinetrimmed = topline.trim(); + if (LocketteProAPI.isLockString(toplinetrimmed) || LocketteProAPI.isAdditionalString(toplinetrimmed)){ + event.setLine(0, Config.getLang("sign-error")); + Utils.sendMessages(player, Config.getLang("cannot-lock-manual")); + return; + } + } + if (LocketteProAPI.isLockString(topline) || LocketteProAPI.isAdditionalString(topline)){ + Block block = LocketteProAPI.getAttachedBlock(event.getBlock()); + if (LocketteProAPI.isLockable(block)){ + if (Dependency.isProtectedFrom(block, player)){ // External check here + event.setLine(0, Config.getLang("sign-error")); + Utils.sendMessages(player, Config.getLang("cannot-lock-manual")); + return; + } + boolean locked = LocketteProAPI.isLocked(block); + if (!locked && !LocketteProAPI.isUpDownLockedDoor(block)){ + if (LocketteProAPI.isLockString(topline)){ + Utils.sendMessages(player, Config.getLang("locked-manual")); + if (!player.hasPermission("lockettepro.lockothers")){ // Player with permission can lock with another name + event.setLine(1, player.getName()); + } + Utils.resetCache(block); + } else { + Utils.sendMessages(player, Config.getLang("not-locked-yet-manual")); + event.setLine(0, Config.getLang("sign-error")); + } + } else if (!locked && LocketteProAPI.isOwnerUpDownLockedDoor(block, player)){ + if (LocketteProAPI.isLockString(topline)){ + Utils.sendMessages(player, Config.getLang("cannot-lock-door-nearby-manual")); + event.setLine(0, Config.getLang("sign-error")); + } else { + Utils.sendMessages(player, Config.getLang("additional-sign-added-manual")); + } + } else if (LocketteProAPI.isOwner(block, player)){ + if (LocketteProAPI.isLockString(topline)){ + Utils.sendMessages(player, Config.getLang("block-already-locked-manual")); + event.setLine(0, Config.getLang("sign-error")); + } else { + Utils.sendMessages(player, Config.getLang("additional-sign-added-manual")); + } + } else { // Not possible to fall here except override + Utils.sendMessages(player, Config.getLang("block-already-locked-manual")); + event.getBlock().breakNaturally(); + Utils.playAccessDenyEffect(player, block); + } + } else { + Utils.sendMessages(player, Config.getLang("block-is-not-lockable")); + event.setLine(0, Config.getLang("sign-error")); + Utils.playAccessDenyEffect(player, block); + } + } + } + + // Player select sign + @EventHandler(priority = EventPriority.LOW) + public void playerSelectSign(PlayerInteractEvent event){ + Block block = event.getClickedBlock(); + if (block == null) return; + if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasBlock() && Tag.WALL_SIGNS.isTagged(block.getType())) { + Player player = event.getPlayer(); + if (!player.hasPermission("lockettepro.edit")) return; + if (LocketteProAPI.isOwnerOfSign(block, player) || (LocketteProAPI.isLockSignOrAdditionalSign(block) && player.hasPermission("lockettepro.admin.edit"))){ + Utils.selectSign(player, block); + Utils.sendMessages(player, Config.getLang("sign-selected")); + Utils.playLockEffect(player, block); + } + } + } + + // Player break sign + @EventHandler(priority = EventPriority.HIGH) + public void onAttemptBreakSign(BlockBreakEvent event){ + if (event.isCancelled()) return; + Block block = event.getBlock(); + Player player = event.getPlayer(); + if (player.hasPermission("lockettepro.admin.break")) return; + if (LocketteProAPI.isLockSign(block)){ + if (LocketteProAPI.isOwnerOfSign(block, player)){ + Utils.sendMessages(player, Config.getLang("break-own-lock-sign")); + Utils.resetCache(LocketteProAPI.getAttachedBlock(block)); + // Remove additional signs? + } else { + Utils.sendMessages(player, Config.getLang("cannot-break-this-lock-sign")); + event.setCancelled(true); + Utils.playAccessDenyEffect(player, block); + } + } else if (LocketteProAPI.isAdditionalSign(block)){ + // TODO the next line is spaghetti + if (!LocketteProAPI.isLocked(LocketteProAPI.getAttachedBlock(block))){ + // phew, the locked block is expired! + // nothing + } else if (LocketteProAPI.isOwnerOfSign(block, player)){ + Utils.sendMessages(player, Config.getLang("break-own-additional-sign")); + } else if (!LocketteProAPI.isProtected(LocketteProAPI.getAttachedBlock(block))){ + Utils.sendMessages(player, Config.getLang("break-redundant-additional-sign")); + } else { + Utils.sendMessages(player, Config.getLang("cannot-break-this-additional-sign")); + event.setCancelled(true); + Utils.playAccessDenyEffect(player, block); + } + } + } + + // Protect block from being destroyed + @EventHandler(priority = EventPriority.HIGH) + public void onAttemptBreakLockedBlocks(BlockBreakEvent event){ + if (event.isCancelled()) return; + Block block = event.getBlock(); + Player player = event.getPlayer(); + if (LocketteProAPI.isLocked(block) || LocketteProAPI.isUpDownLockedDoor(block)){ + Utils.sendMessages(player, Config.getLang("block-is-locked")); + event.setCancelled(true); + Utils.playAccessDenyEffect(player, block); + } + } + + // Protect block from being used & handle double doors + @EventHandler(priority = EventPriority.HIGH) + public void onAttemptInteractLockedBlocks(PlayerInteractEvent event) { + if (event.hasBlock() == false) return; + Action action = event.getAction(); + Block block = event.getClickedBlock(); + if (LockettePro.needCheckHand() && LocketteProAPI.isChest(block)){ + if (event.getHand() != EquipmentSlot.HAND){ + if (action == Action.RIGHT_CLICK_BLOCK){ + /*if (LocketteProAPI.isChest(block)){ + // something not right + event.setCancelled(true); + }*/ + event.setCancelled(true); + return; + } + } + } + switch (action){ + case LEFT_CLICK_BLOCK: + case RIGHT_CLICK_BLOCK: + Player player = event.getPlayer(); + if (((LocketteProAPI.isLocked(block) && !LocketteProAPI.isUser(block, player)) || (LocketteProAPI.isUpDownLockedDoor(block) && !LocketteProAPI.isUserUpDownLockedDoor(block, player))) && !player.hasPermission("lockettepro.admin.use")){ + Utils.sendMessages(player, Config.getLang("block-is-locked")); + event.setCancelled(true); + Utils.playAccessDenyEffect(player, block); + } else { // Handle double doors + if (action == Action.RIGHT_CLICK_BLOCK) { + if ((LocketteProAPI.isDoubleDoorBlock(block) || LocketteProAPI.isSingleDoorBlock(block)) && LocketteProAPI.isLocked(block)){ + Block doorblock = LocketteProAPI.getBottomDoorBlock(block); + org.bukkit.block.data.Openable openablestate = (org.bukkit.block.data.Openable ) doorblock.getBlockData(); + boolean shouldopen = !openablestate.isOpen(); // Move to here + int closetime = LocketteProAPI.getTimerDoor(doorblock); + List doors = new ArrayList(); + doors.add(doorblock); + if (doorblock.getType() == Material.IRON_DOOR || doorblock.getType() == Material.IRON_TRAPDOOR){ + LocketteProAPI.toggleDoor(doorblock, shouldopen); + } + for (BlockFace blockface : LocketteProAPI.newsfaces){ + Block relative = doorblock.getRelative(blockface); + if (relative.getType() == doorblock.getType()){ + doors.add(relative); + LocketteProAPI.toggleDoor(relative, shouldopen); + } + } + if (closetime > 0) { + for (Block door : doors) { + if (door.hasMetadata("lockettepro.toggle")) { + return; + } + } + for (Block door : doors) { + door.setMetadata("lockettepro.toggle", new FixedMetadataValue(LockettePro.getPlugin(), true)); + } + Bukkit.getScheduler().runTaskLater(LockettePro.getPlugin(), new DoorToggleTask(doors), closetime*20); + } + } + } + } + break; + default: + break; + } + } + + // Protect block from interfere block + @EventHandler(priority = EventPriority.HIGH) + public void onAttemptPlaceInterfereBlocks(BlockPlaceEvent event){ + if (event.isCancelled()) return; + Block block = event.getBlock(); + Player player = event.getPlayer(); + if (player.hasPermission("lockettepro.admin.interfere")) return; + if (LocketteProAPI.mayInterfere(block, player)){ + Utils.sendMessages(player, Config.getLang("cannot-interfere-with-others")); + event.setCancelled(true); + Utils.playAccessDenyEffect(player, block); + } + } + + // Tell player about lockettepro + @EventHandler(priority = EventPriority.MONITOR) + public void onPlaceFirstBlockNotify(BlockPlaceEvent event){ + if (event.isCancelled()) return; + Block block = event.getBlock(); + Player player = event.getPlayer(); + if (!player.hasPermission("lockettepro.lock")) return; + if (Utils.shouldNotify(player) && Config.isLockable(block.getType())){ + switch (Config.getQuickProtectAction()){ + case (byte)0: + Utils.sendMessages(player, Config.getLang("you-can-manual-lock-it")); + break; + case (byte)1: + case (byte)2: + Utils.sendMessages(player, Config.getLang("you-can-quick-lock-it")); + break; + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onBucketEmpty(PlayerBucketEmptyEvent event) { + Player player = event.getPlayer(); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (LocketteProAPI.isProtected(block) && !(LocketteProAPI.isOwner(block, player) || LocketteProAPI.isOwnerOfSign(block, player))) { + event.setCancelled(true); + new BukkitRunnable() { + @Override + public void run() { + if (!player.isDead()) { + player.updateInventory(); + } + } + }.runTaskLater(LockettePro.getPlugin(), 1L); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onBucketUse(PlayerBucketFillEvent event) { + Player player = event.getPlayer(); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (LocketteProAPI.isProtected(block) && !(LocketteProAPI.isOwner(block, player) || LocketteProAPI.isOwnerOfSign(block, player))) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onLecternTake(PlayerTakeLecternBookEvent event){ + Player player = event.getPlayer(); + Block block = event.getLectern().getBlock(); + if(LocketteProAPI.isProtected(block) && !(LocketteProAPI.isOwner(block, player) || LocketteProAPI.isOwnerOfSign(block, player))){ + event.setCancelled(true); + } + } +} diff --git a/src/main/java/me/crafter/mc/lockettepro/Config.java b/src/main/java/me/crafter/mc/lockettepro/Config.java new file mode 100644 index 0000000..87a05e1 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/Config.java @@ -0,0 +1,287 @@ +package me.crafter.mc.lockettepro; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class Config { + + private static Plugin plugin; + private static FileConfiguration config; + private static FileConfiguration lang; + private static String langfilename = "lang.yml"; + private static boolean uuid = false; + private static Set lockables = new HashSet(); + private static Set privatestrings = new HashSet(); + private static Set additionalstrings = new HashSet(); + private static Set everyonestrings = new HashSet(); + private static Set timerstrings = new HashSet(); + private static String defaultprivatestring = "[Private]"; + private static String defaultadditionalstring = "[More Users]"; + private static byte enablequickprotect = (byte)1; + private static boolean blockinterfereplacement = true; + private static boolean blockitemtransferin = false; + private static boolean blockitemtransferout = false; + private static int cachetime = 0; + private static boolean cacheenabled = false; + private static byte blockhopperminecart = 0; + private static boolean lockexpire = false; + private static double lockexpiredays = 60D; + public static boolean protocollib = false; + public static boolean worldguard = false; + public static boolean coreprotect = false; + private static long lockdefaultcreatetime = -1L; + private static String lockexpirestring = ""; + private static Set protectionexempt = new HashSet(); + + public Config(Plugin _plugin){ + plugin = _plugin; + reload(); + } + + public static void reload(){ + initDefaultConfig(); + initAdditionalFiles(); + config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml")); + uuid = config.getBoolean("enable-uuid-support", false); + protocollib = config.getBoolean("protocollib", true); + worldguard = config.getBoolean("worldguard", true); + coreprotect = config.getBoolean("coreprotect", true); + langfilename = config.getString("language-file-name", "lang.yml"); + lang = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), langfilename)); + String enablequickprotectstring = config.getString("enable-quick-protect", "true"); + switch (enablequickprotectstring.toLowerCase()){ + case "true": + enablequickprotect = 1; + break; + case "false": + enablequickprotect = 0; + break; + case "sneak": + enablequickprotect = 2; + break; + default: + enablequickprotect = 1; + break; + } + blockinterfereplacement = config.getBoolean("block-interfere-placement", true); + blockitemtransferin = config.getBoolean("block-item-transfer-in", false); + blockitemtransferout = config.getBoolean("block-item-transfer-out", true); + + List privatestringlist = config.getStringList("private-signs"); + List additionalstringlist = config.getStringList("additional-signs"); + List everyonestringlist = config.getStringList("everyone-signs"); + List protectionexemptstringlist = config.getStringList("protection-exempt"); + privatestrings = new HashSet(privatestringlist); + additionalstrings = new HashSet(additionalstringlist); + everyonestrings = new HashSet(everyonestringlist); + protectionexempt = new HashSet(protectionexemptstringlist); + defaultprivatestring = privatestringlist.get(0); + defaultadditionalstring = additionalstringlist.get(0); + + List timerstringlist = config.getStringList("timer-signs"); + List timerstringlist2 = new ArrayList(); + for (String timerstring : timerstringlist){ + if (timerstring.contains("@")) timerstringlist2.add(timerstring); + } + timerstrings = new HashSet(timerstringlist2); + + cachetime = config.getInt("cache-time-seconds", 0) * 1000; + cacheenabled = (config.getInt("cache-time-seconds", 0) > 0); + if (cacheenabled){ + plugin.getLogger().info("Cache is enabled! In case of inconsistency, turn off immediately."); + } + + String blockhopperminecartstring = config.getString("block-hopper-minecart", "remove"); + switch (blockhopperminecartstring.toLowerCase()){ + case "true": + blockhopperminecart = 1; + break; + case "false": + blockhopperminecart = 0; + break; + case "remove": + blockhopperminecart = 2; + break; + default: + blockhopperminecart = 2; + break; + } + + lockexpire = config.getBoolean("lock-expire", false); + lockexpiredays = config.getDouble("lock-expire-days", 999.9D); + lockdefaultcreatetime = config.getLong("lock-default-create-time-unix", -1L); + if (lockdefaultcreatetime < -1L) lockdefaultcreatetime = -1L; + lockexpirestring = ChatColor.translateAlternateColorCodes('&', + config.getString("lock-expire-string", "&3[Expired]")); + List unprocesseditems = config.getStringList("lockables"); + lockables = new HashSet(); + for (String unprocesseditem : unprocesseditems){ + if (unprocesseditem.equals("*")){ + for (Material material : Material.values()){ + lockables.add(material); + } + plugin.getLogger().info("All blocks are default to be lockable!"); + plugin.getLogger().info("Add '-' to exempt a block, such as '-STONE'!"); + continue; + } + boolean add = true; + if (unprocesseditem.startsWith("-")){ + add = false; + unprocesseditem = unprocesseditem.substring(1); + } + Material material = Material.getMaterial(unprocesseditem); + if (material == null || !material.isBlock()) { + plugin.getLogger().warning(unprocesseditem + " is not a block!"); + } else { + if (add) { + lockables.add(material); + } else { + lockables.remove(material); + } + } + } + lockables.removeAll(Tag.SIGNS.getValues()); + lockables.remove(Material.SCAFFOLDING); + } + + public static void initDefaultConfig(){ + plugin.saveDefaultConfig(); + config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml")); + config.addDefault("language-file-name", "lang.yml"); + config.addDefault("enable-quick-protect", true); + config.addDefault("enable-uuid-support", false); + config.addDefault("block-interfere-placement", true); + config.addDefault("block-item-transfer-in", false); + config.addDefault("block-item-transfer-out", true); + config.addDefault("block-hopper-minecart", "remove"); + config.addDefault("cache-time-seconds", 0); + + String[] private_signs = {"[Private]", "[private]"}; + config.addDefault("private-signs", private_signs); + String[] additional_signs = {"[More Users]", "[more Users]"}; + config.addDefault("additional-signs", additional_signs); + String[] everyone_signs = {"[Everyone]", "[everyone]"}; + config.addDefault("everyone-signs", everyone_signs); + String[] timer_signs = {"[Timer:@]", "[timer:@]"}; + config.addDefault("timer-signs", timer_signs); + String[] lockables = {"CHEST","TRAPPED_CHEST","FURNACE","BURNING_FURNACE","HOPPER","BREWING_STAND","DIAMOND_BLOCK", + "OAK_DOOR","SPRUCE_DOOR","BIRCH_DOOR","JUNGLE_DOOR","ACACIA_DOOR","DARK_OAK_DOOR","IRON_DOOR", "LECTERN", "CRIMSON_DOOR", "WARPED_DOOR"}; + config.addDefault("lockables", lockables); + String[] protection_exempt = {"nothing"}; + config.addDefault("protection-exempt", protection_exempt); + + config.addDefault("lock-expire", false); + config.addDefault("lock-expire-days", 999.9D); + config.addDefault("lock-default-create-time-unix", -1L); + config.addDefault("lock-expire-string", "&3[Expired]"); + + config.options().copyDefaults(true); + try { + config.save(new File(plugin.getDataFolder(), "config.yml")); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void initAdditionalFiles(){ + String[] availablefiles = {"lang.yml", "lang_zh-cn.yml", "lang_es.yml", "lang_it.yml", "lang_de.yml", + "lang_hu.yml", "lang_pl.yml", "lang_fr.yml"}; + for (String filename : availablefiles){ + File langfile = new File(plugin.getDataFolder(), filename); + if (!langfile.exists()){ + plugin.saveResource(filename, false); + } + } + } + + public static byte getQuickProtectAction() {return enablequickprotect;} + public static boolean isInterferePlacementBlocked() {return blockinterfereplacement;} + public static boolean isItemTransferInBlocked() {return blockitemtransferin;} + public static boolean isItemTransferOutBlocked() {return blockitemtransferout;} + public static byte getHopperMinecartAction() {return blockhopperminecart;} + + public static boolean isLockExpire() {return lockexpire;} + public static Double getLockExpireDays() {return lockexpiredays;} + public static long getLockDefaultCreateTimeUnix() {return lockdefaultcreatetime;} + public static String getLockExpireString() {return lockexpirestring;} + + public static String getLang(String path){ + return ChatColor.translateAlternateColorCodes('&', lang.getString(path, "")); + } + + public static boolean isUuidEnabled(){ + return uuid; + } + + public static boolean isLockable(Material material){ + return lockables.contains(material); + } + + public static boolean isPrivateSignString(String message){ + return privatestrings.contains(message); + } + + public static boolean isAdditionalSignString(String message){ + return additionalstrings.contains(message); + } + + public static boolean isEveryoneSignString(String message){ + return everyonestrings.contains(message); + } + + public static boolean isTimerSignString(String message){ + for (String timerstring : timerstrings){ + String[] splitted = timerstring.split("@", 2); + if (message.startsWith(splitted[0]) && message.endsWith(splitted[1])){ + return true; + } + } + return false; + } + + public static int getTimer(String message){ + for (String timerstring : timerstrings){ + String[] splitted = timerstring.split("@", 2); + if (message.startsWith(splitted[0]) && message.endsWith(splitted[1])){ + String newmessage = message.replace(splitted[0], "").replace(splitted[1], ""); + try { + int seconds = Integer.parseInt(newmessage); + return Math.min(seconds, 20); + } catch (Exception ex){} + } + } + return 0; + } + + public static String getDefaultPrivateString(){ + return defaultprivatestring; + } + + public static String getDefaultAdditionalString(){ + return defaultadditionalstring; + } + + public static int getCacheTimeMillis(){ + return cachetime; + } + + public static boolean isCacheEnabled(){ + return cacheenabled; + } + + public static boolean isProtectionExempted(String against){ + return protectionexempt.contains(against); + } + +} diff --git a/src/main/java/me/crafter/mc/lockettepro/Dependency.java b/src/main/java/me/crafter/mc/lockettepro/Dependency.java new file mode 100644 index 0000000..59d4d61 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/Dependency.java @@ -0,0 +1,83 @@ +package me.crafter.mc.lockettepro; + +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import net.coreprotect.CoreProtect; +import net.coreprotect.CoreProtectAPI; +import net.milkbowl.vault.permission.Permission; +import org.bukkit.Bukkit; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.scoreboard.Team; + +public class Dependency { + + protected static WorldGuardPlugin worldguard = null; + protected static Plugin vault = null; + protected static Permission permission = null; + private static CoreProtectAPI coreProtectAPI; + + public Dependency(Plugin plugin) { + // WorldGuard + Plugin worldguardplugin = plugin.getServer().getPluginManager().getPlugin("WorldGuard"); + if (!Config.worldguard || !(worldguardplugin instanceof WorldGuardPlugin)) { + worldguard = null; + } else { + worldguard = (WorldGuardPlugin) worldguardplugin; + } + // Vault + vault = plugin.getServer().getPluginManager().getPlugin("Vault"); + if (vault != null) { + RegisteredServiceProvider rsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class); + permission = rsp.getProvider(); + } + //&& CoreProtect.getInstance().getAPI().APIVersion() == 6 + if (Config.coreprotect && Bukkit.getPluginManager().getPlugin("CoreProtect") != null) { + try { + coreProtectAPI = CoreProtect.getInstance().getAPI(); + if (!coreProtectAPI.isEnabled()) { + coreProtectAPI = null; + plugin.getLogger().warning("CoreProtect API is not enabled!"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public static boolean isProtectedFrom(Block block, Player player){ + if (worldguard != null) { + if (!worldguard.createProtectionQuery().testBlockPlace(player, block.getLocation(), block.getType())) { + return true; + } + } + return false; + } + + public static boolean isPermissionGroupOf(String line, Player player){ + if (vault != null){ + try { + String[] groups = permission.getPlayerGroups(player); + for (String group : groups){ + if (line.equals("[" + group + "]")) return true; + } + } catch (Exception e){} + } + return false; + } + + public static boolean isScoreboardTeamOf(String line, Player player){ + Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(player.getName()); + if (team != null){ + if (line.equals("[" + team.getName() + "]")) return true; + } + return false; + } + + public static void logPlacement(Player player, Block block) { + if (coreProtectAPI != null && coreProtectAPI.isEnabled()) { + coreProtectAPI.logPlacement(player.getName(), block.getLocation(), block.getType(), block.getBlockData()); + } + } +} diff --git a/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java b/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java new file mode 100644 index 0000000..27ef9b1 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java @@ -0,0 +1,84 @@ +package me.crafter.mc.lockettepro; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.ListenerPriority; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.WrappedChatComponent; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; +import com.comphenix.protocol.wrappers.nbt.NbtFactory; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import java.util.List; + +public class DependencyProtocolLib { + + public static void setUpProtocolLib(Plugin plugin){ + if (Config.protocollib) { + addTileEntityDataListener(plugin); + addMapChunkListener(plugin); + } + } + + public static void cleanUpProtocolLib(Plugin plugin){ + try { + if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")){ + ProtocolLibrary.getProtocolManager().removePacketListeners(plugin); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void addTileEntityDataListener(Plugin plugin){ + ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOW, PacketType.Play.Server.TILE_ENTITY_DATA) { + @Override + public void onPacketSending(PacketEvent event) { + PacketContainer packet = event.getPacket(); + if (packet.getIntegers().read(0) != 9) return; + NbtCompound nbtcompound = (NbtCompound) packet.getNbtModifier().read(0); + onSignSend(event.getPlayer(), nbtcompound); + } + }); + } + + public static void addMapChunkListener(Plugin plugin){ + ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOW, PacketType.Play.Server.MAP_CHUNK) { + @Override + public void onPacketSending(PacketEvent event) { + PacketContainer packet = event.getPacket(); + List tileentitydatas = packet.getSpecificModifier(List.class).read(0); + for (Object tileentitydata : tileentitydatas) { + NbtCompound nbtcompound = NbtFactory.fromNMSCompound(tileentitydata); + if (!"minecraft:sign".equals(nbtcompound.getString("id"))) continue; + onSignSend(event.getPlayer(), nbtcompound); + } + } + }); + } + + public static void onSignSend(Player player, NbtCompound nbtcompound) { + String raw_line1 = nbtcompound.getString("Text1"); + if (LocketteProAPI.isLockStringOrAdditionalString(Utils.getSignLineFromUnknown(raw_line1))) { + // Private line + String line1 = Utils.getSignLineFromUnknown(nbtcompound.getString("Text1")); + if (LocketteProAPI.isLineExpired(line1)) { + nbtcompound.put("Text1", WrappedChatComponent.fromText(Config.getLockExpireString()).getJson()); + } else { + nbtcompound.put("Text1", WrappedChatComponent.fromText(Utils.StripSharpSign(line1)).getJson()); + } + // Other line + for (int i = 2; i <= 4; i++) { + String line = Utils.getSignLineFromUnknown(nbtcompound.getString("Text" + i)); + if (Utils.isUsernameUuidLine(line)) { + nbtcompound.put("Text" + i, WrappedChatComponent.fromText(Utils.getUsernameFromLine(line)).getJson()); + } + } + } + } + +} diff --git a/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java b/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java new file mode 100644 index 0000000..347c438 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java @@ -0,0 +1,29 @@ +package me.crafter.mc.lockettepro; + +import org.bukkit.block.Block; + +import java.util.List; + +public class DoorToggleTask implements Runnable{ + + private List doors; + + public DoorToggleTask(List doors_){ + doors = doors_; + } + + @Override + public void run() { + for (Block door : doors) { + door.removeMetadata("lockettepro.toggle", LockettePro.getPlugin()); + } + for (Block door : doors){ + if (LocketteProAPI.isDoubleDoorBlock(door)){ + Block doorbottom = LocketteProAPI.getBottomDoorBlock(door); + //LocketteProAPI.toggleDoor(doorbottom, open); + LocketteProAPI.toggleDoor(doorbottom); + } + } + } + +} diff --git a/src/main/java/me/crafter/mc/lockettepro/LockettePro.java b/src/main/java/me/crafter/mc/lockettepro/LockettePro.java new file mode 100644 index 0000000..2b3f81c --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/LockettePro.java @@ -0,0 +1,281 @@ +package me.crafter.mc.lockettepro; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.ArrayList; +import java.util.List; + +public class LockettePro extends JavaPlugin { + + private static Plugin plugin; + private boolean debug = false; + private static boolean needcheckhand = true; + public static boolean is16version = true; + + public void onEnable(){ + plugin = this; + checkMcVersion(); + // Version + try { + Material.BARREL.isItem(); + } catch (Exception e) { + setEnabled(false); + getLogger().warning("This plugin is not compatible with your server version!"); + } + getLogger().info("==================================="); + if (!isEnabled()) { + return; + } + // Read config + new Config(this); + // Register Listeners + // If debug mode is not on, debug listener won't register + if (debug) getServer().getPluginManager().registerEvents(new BlockDebugListener(), this); + getServer().getPluginManager().registerEvents(new BlockPlayerListener(), this); + getServer().getPluginManager().registerEvents(new BlockEnvironmentListener(), this); + getServer().getPluginManager().registerEvents(new BlockInventoryMoveListener(), this); + // Dependency + new Dependency(this); + // If UUID is not enabled, UUID listener won't register + if (Config.isUuidEnabled() || Config.isLockExpire()){ + if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")){ + DependencyProtocolLib.setUpProtocolLib(this); + } else { + plugin.getLogger().info("ProtocolLib is not found!"); + plugin.getLogger().info("UUID & expiracy support requires ProtocolLib, or else signs will be ugly!"); + } + } + } + + public void onDisable(){ + if (Config.isUuidEnabled() && Bukkit.getPluginManager().getPlugin("ProtocolLib") != null){ + DependencyProtocolLib.cleanUpProtocolLib(this); + } + } + + private void checkMcVersion() { + String[] serverVersion = Bukkit.getBukkitVersion().split("-"); + String version = serverVersion[0]; + if (version.matches("1.16") || version.matches("1.16.1") || version.matches("1.16.2") || version.matches("1.16.3") || version.matches("1.16.4") || version.matches("1.16.5")) { + plugin.getLogger().info("Compatible server version detected: " + version); + is16version = true; + } else if (version.matches("1.15") || version.matches("1.15.1") || version.matches("1.15.2")) { + plugin.getLogger().info("Compatible server version detected: " + version); + is16version = false; + } else if (version.matches("1.14") || version.matches("1.14.1") || version.matches("1.14.2") || version.matches("1.14.3") || version.matches("1.14.4")) { + plugin.getLogger().info("Compatible server version detected: " + version); + is16version = false; + } else { + plugin.getLogger().info("Incompatible server version detected: " + version + " . Trying to run into 1.16 compatibility mode!"); + is16version = true; + } + } + + public static Plugin getPlugin(){ + return plugin; + } + + public static boolean needCheckHand(){ + return needcheckhand; + } + + @Override + public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + List commands = new ArrayList<>(); + commands.add("reload"); + commands.add("version"); + commands.add("1"); + commands.add("2"); + commands.add("3"); + commands.add("4"); + commands.add("uuid"); + commands.add("update"); + commands.add("debug"); + if (args != null && args.length == 1) { + List list = new ArrayList<>(); + for (String s : commands) { + if (s.startsWith(args[0])) { + list.add(s); + } + } + return list; + } + return null; + } + + public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, final String[] args){ + if (cmd.getName().equals("lockettepro")){ + if (args.length == 0){ + Utils.sendMessages(sender, Config.getLang("command-usage")); + } else { + // The following commands does not require player + switch (args[0]){ + case "reload": + if (sender.hasPermission("lockettepro.reload")){ + if(Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { + DependencyProtocolLib.cleanUpProtocolLib(this); + } + Config.reload(); + if (Config.isUuidEnabled() && Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { + DependencyProtocolLib.setUpProtocolLib(this); + } + Utils.sendMessages(sender, Config.getLang("config-reloaded")); + } else { + Utils.sendMessages(sender, Config.getLang("no-permission")); + } + return true; + case "version": + if (sender.hasPermission("lockettepro.version")){ + sender.sendMessage(plugin.getDescription().getFullName()); + } else { + Utils.sendMessages(sender, Config.getLang("no-permission")); + } + return true; + case "debug": + // This is not the author debug, this prints out info + if (sender.hasPermission("lockettepro.debug")) { + sender.sendMessage("LockettePro Debug Message"); + // Basic + sender.sendMessage("LockettePro: " + getDescription().getVersion()); + // Version + sender.sendMessage("Bukkit: " + "v" + Bukkit.getServer().getClass().getPackage().getName().split("v")[1]); + sender.sendMessage("Server version: " + Bukkit.getVersion()); + // Config + sender.sendMessage("UUID: " + Config.isUuidEnabled()); + sender.sendMessage("Expire: " + Config.isLockExpire() + " " + (Config.isLockExpire() ? Config.getLockExpireDays() : "")); + // ProtocolLib + sender.sendMessage("ProtocolLib info:"); + if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) { + sender.sendMessage(" - ProtocolLib missing"); + } else { + sender.sendMessage(" - ProtocolLib: " + Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion()); + } + // Other + sender.sendMessage("Linked plugins:"); + boolean linked = false; + if (Dependency.worldguard != null) { + linked = true; + sender.sendMessage(" - Worldguard: " + Dependency.worldguard.getDescription().getVersion()); + } + if (Dependency.vault != null) { + linked = true; + sender.sendMessage(" - Vault: " + Dependency.vault.getDescription().getVersion()); + } + if (Bukkit.getPluginManager().getPlugin("CoreProtect") != null) { + linked = true; + sender.sendMessage(" - CoreProtect: " + Bukkit.getPluginManager().getPlugin("CoreProtect").getDescription().getVersion()); + } + if (!linked) { + sender.sendMessage(" - none"); + } + } else { + Utils.sendMessages(sender, Config.getLang("no-permission")); + } + return true; + } + // The following commands requires player + if (!(sender instanceof Player)){ + Utils.sendMessages(sender, Config.getLang("command-usage")); + return false; + } + Player player = (Player)sender; + switch (args[0]){ + case "1": + case "2": + case "3": + case "4": + if (player.hasPermission("lockettepro.edit")){ + String message = ""; + Block block = Utils.getSelectedSign(player); + if (block == null){ + Utils.sendMessages(player, Config.getLang("no-sign-selected")); + } else if (!LocketteProAPI.isSign(block) || !(player.hasPermission("lockettepro.edit.admin") || LocketteProAPI.isOwnerOfSign(block, player))){ + Utils.sendMessages(player, Config.getLang("sign-need-reselect")); + } else { + for (int i = 1; i < args.length; i++){ + message += args[i]; + } + message = ChatColor.translateAlternateColorCodes('&', message); + if (!player.hasPermission("lockettepro.admin.edit") && !debug && message.length() > 18) { + Utils.sendMessages(player, Config.getLang("line-is-too-long")); + return true; + } + if (LocketteProAPI.isLockSign(block)){ + switch (args[0]){ + case "1": + if (!debug || !player.hasPermission("lockettepro.admin.edit")){ + Utils.sendMessages(player, Config.getLang("cannot-change-this-line")); + break; + } + case "2": + if (!player.hasPermission("lockettepro.admin.edit")){ + Utils.sendMessages(player, Config.getLang("cannot-change-this-line")); + break; + } + case "3": + case "4": + Utils.setSignLine(block, Integer.parseInt(args[0])-1, message); + Utils.sendMessages(player, Config.getLang("sign-changed")); + if (Config.isUuidEnabled()){ + Utils.updateUuidByUsername(Utils.getSelectedSign(player), Integer.parseInt(args[0])-1); + } + break; + } + } else if (LocketteProAPI.isAdditionalSign(block)){ + switch (args[0]){ + case "1": + if (!debug || !player.hasPermission("lockettepro.admin.edit")){ + Utils.sendMessages(player, Config.getLang("cannot-change-this-line")); + break; + } + case "2": + case "3": + case "4": + Utils.setSignLine(block, Integer.parseInt(args[0])-1, message); + Utils.sendMessages(player, Config.getLang("sign-changed")); + if (Config.isUuidEnabled()){ + Utils.updateUuidByUsername(Utils.getSelectedSign(player), Integer.parseInt(args[0])-1); + } + break; + } + } else { + Utils.sendMessages(player, Config.getLang("sign-need-reselect")); + } + } + } else { + Utils.sendMessages(player, Config.getLang("no-permission")); + } + break; + case "force": + if (debug && player.hasPermission("lockettepro.debug")){ + Utils.setSignLine(Utils.getSelectedSign(player), Integer.parseInt(args[1]), args[2]); + break; + } + case "update": + if (debug && player.hasPermission("lockettepro.debug")){ + Utils.updateSign(Utils.getSelectedSign(player)); + break; + } + case "uuid": + if (debug && player.hasPermission("lockettepro.debug")){ + Utils.updateUuidOnSign(Utils.getSelectedSign(player)); + break; + } + default: + Utils.sendMessages(player, Config.getLang("command-usage")); + break; + } + } + } + return true; + } + +} diff --git a/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java b/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java new file mode 100644 index 0000000..a95eeb5 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java @@ -0,0 +1,742 @@ +package me.crafter.mc.lockettepro; + +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Container; +import org.bukkit.block.Sign; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Directional; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.Chest; +import org.bukkit.entity.Player; + +import javax.annotation.Nullable; + +public class LocketteProAPI { + + public static BlockFace[] newsfaces = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}; + public static BlockFace[] allfaces = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN}; + + public static boolean isLocked(Block block){ + if (block == null) return false; + switch (block.getType()){ + // Double Doors + case OAK_DOOR: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case CRIMSON_DOOR: + case WARPED_DOOR: + case IRON_DOOR: + Block[] doors = getDoors(block); + if (doors == null) return false; + for (BlockFace doorface : newsfaces){ + Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); + if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ + if (isLockedSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace())) return true; + if (isLockedSingleBlock(relative1, doorface.getOppositeFace())) return true; + if (isLockedSingleBlock(relative0, doorface.getOppositeFace())) return true; + if (isLockedSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace())) return true; + } + } + if (isLockedSingleBlock(doors[1].getRelative(BlockFace.UP), null)) return true; + if (isLockedSingleBlock(doors[1], null)) return true; + if (isLockedSingleBlock(doors[0], null)) return true; + if (isLockedSingleBlock(doors[0].getRelative(BlockFace.DOWN), null)) return true; + break; + case LECTERN: + return isLockedSingleBlock(block, null); + // Chests (Second block only) + case CHEST: + case TRAPPED_CHEST: + // Check second chest sign + BlockFace chestface = getRelativeChestFace(block); + if (chestface != null) { + Block relativechest = block.getRelative(chestface); + if (isLockedSingleBlock(relativechest, chestface.getOppositeFace())) return true; + } + // Don't break here + // Everything else (First block of container check goes here) + default: + if (isLockedSingleBlock(block, null)) return true; + break; + } + return false; + } + + public static String getOwner(Block block){ + switch (block.getType()){ + // Double Doors + case OAK_DOOR: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case CRIMSON_DOOR: + case WARPED_DOOR: + case IRON_DOOR: + Block[] doors = getDoors(block); + if (doors == null) return null; + for (BlockFace doorface : newsfaces){ + Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); + if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ + String f1 = getLockOwnerSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace()); + String f2 = getLockOwnerSingleBlock(relative1, doorface.getOppositeFace()); + String f3 = getLockOwnerSingleBlock(relative0, doorface.getOppositeFace()); + String f4 = getLockOwnerSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace()); + if (f1 != null) { + return f1; + } else if (f2 != null) { + return f2; + } else if (f3 != null) { + return f3; + } else if (f4 != null) { + return f4; + } + } + } + String f1 = getLockOwnerSingleBlock(doors[1].getRelative(BlockFace.UP), null); + String f2 = getLockOwnerSingleBlock(doors[1], null); + String f3 = getLockOwnerSingleBlock(doors[0], null); + String f4 = getLockOwnerSingleBlock(doors[0].getRelative(BlockFace.DOWN), null); + if (f1 != null) { + return f1; + } else if (f2 != null) { + return f2; + } else if (f3 != null) { + return f3; + } else if (f4 != null) { + return f4; + } + break; + case LECTERN: + return getLockOwnerSingleBlock(block, null); + case CHEST: + case TRAPPED_CHEST: + // Check second chest sign + BlockFace chestface = getRelativeChestFace(block); + if (chestface != null) { + Block relativechest = block.getRelative(chestface); + return getLockOwnerSingleBlock(relativechest, chestface.getOppositeFace()); + } + // Don't break here + // Everything else (First block of container check goes here) + default: + return getLockOwnerSingleBlock(block, null); + } + return null; + } + + public static boolean isOwner(Block block, Player player){ + switch (block.getType()){ + // Double Doors + case OAK_DOOR: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case CRIMSON_DOOR: + case WARPED_DOOR: + case IRON_DOOR: + Block[] doors = getDoors(block); + if (doors == null) return false; + for (BlockFace doorface : newsfaces){ + Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); + if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ + if (isOwnerSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace(), player)) return true; + if (isOwnerSingleBlock(relative1, doorface.getOppositeFace(), player)) return true; + if (isOwnerSingleBlock(relative0, doorface.getOppositeFace(), player)) return true; + if (isOwnerSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace(), player)) return true; + } + } + if (isOwnerSingleBlock(doors[1].getRelative(BlockFace.UP), null, player)) return true; + if (isOwnerSingleBlock(doors[1], null, player)) return true; + if (isOwnerSingleBlock(doors[0], null, player)) return true; + if (isOwnerSingleBlock(doors[0].getRelative(BlockFace.DOWN), null, player)) return true; + break; + // Chests (Second block only) + case LECTERN: + return isOwnerSingleBlock(block, null, player); + case CHEST: + case TRAPPED_CHEST: + // Check second chest sign + BlockFace chestface = getRelativeChestFace(block); + if (chestface != null) { + Block relativechest = block.getRelative(chestface); + if (isOwnerSingleBlock(relativechest, chestface.getOppositeFace(), player)) return true; + } + // Don't break here + // Everything else (First block of container check goes here) + default: + if (isOwnerSingleBlock(block, null, player)) return true; + break; + } + return false; + } + + public static boolean isUser(Block block, Player player){ + switch (block.getType()){ + // Double Doors + case OAK_DOOR: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case CRIMSON_DOOR: + case WARPED_DOOR: + case IRON_DOOR: + Block[] doors = getDoors(block); + if (doors == null) return false; + for (BlockFace doorface : newsfaces){ + Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); + if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ + if (isUserSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace(), player)) return true; + if (isUserSingleBlock(relative1, doorface.getOppositeFace(), player)) return true; + if (isUserSingleBlock(relative0, doorface.getOppositeFace(), player)) return true; + if (isUserSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace(), player)) return true; + } + } + if (isUserSingleBlock(doors[1].getRelative(BlockFace.UP), null, player)) return true; + if (isUserSingleBlock(doors[1], null, player)) return true; + if (isUserSingleBlock(doors[0], null, player)) return true; + if (isUserSingleBlock(doors[0].getRelative(BlockFace.DOWN), null, player)) return true; + break; + // Lecterns + case LECTERN: + return isUserSingleBlock(block, null, player); + // Chests (Second block only) + case CHEST: + case TRAPPED_CHEST: + // Check second chest sign + BlockFace chestface = getRelativeChestFace(block); + if (chestface != null) { + Block relativechest = block.getRelative(chestface); + if (isUserSingleBlock(relativechest, chestface.getOppositeFace(), player)) return true; + } + // Don't break here + // Everything else (First block of container check goes here) + default: + if (isUserSingleBlock(block, null, player)) return true; + break; + } + return false; + } + + public static boolean isProtected(Block block){ + return (isLockSign(block) || isLocked(block) || isUpDownLockedDoor(block)); + } + + public static boolean isLockedSingleBlock(Block block, BlockFace exempt){ + for (BlockFace blockface : newsfaces){ + if (blockface == exempt) continue; + Block relativeblock = block.getRelative(blockface); + // Find [Private] sign? + if (isLockSign(relativeblock) && getFacing(relativeblock) == blockface){ + // Found [Private] sign, is expire turned on and expired? (relativeblock is now sign) + if (Config.isLockExpire() && LocketteProAPI.isSignExpired(relativeblock)) { + continue; // Private sign but expired... But impossible to have 2 [Private] signs anyway? + } + return true; + } + } + return false; + } + + public static boolean isOwnerSingleBlock(Block block, BlockFace exempt, Player player){ // Requires isLocked + for (BlockFace blockface : newsfaces){ + if (blockface == exempt) continue; + Block relativeblock = block.getRelative(blockface); + if (isLockSign(relativeblock) && getFacing(relativeblock) == blockface){ + if (isOwnerOnSign(relativeblock, player)){ + return true; + } + } + } + return false; + } + + public static String getLockOwnerSingleBlock(Block block, BlockFace exempt) { + for (BlockFace blockface : newsfaces){ + if (blockface == exempt) continue; + Block relativeblock = block.getRelative(blockface); + if (isLockSign(relativeblock) && getFacing(relativeblock) == blockface){ + return getOwnerOnSign(relativeblock); + } + } + return null; + } + + public static boolean isUserSingleBlock(Block block, BlockFace exempt, Player player){ // Requires isLocked + for (BlockFace blockface : newsfaces){ + if (blockface == exempt) continue; + Block relativeblock = block.getRelative(blockface); + if (isLockSignOrAdditionalSign(relativeblock) && getFacing(relativeblock) == blockface){ + if (isUserOnSign(relativeblock, player)){ + return true; + } + } + } + return false; + } + + public static boolean isOwnerOfSign(Block block, Player player){ // Requires isSign + Block protectedblock = getAttachedBlock(block); + // Normal situation, that block is just locked by an adjacent sign + if (isOwner(protectedblock, player)) return true; + // Situation where double door's block + if (isUpDownLockedDoor(protectedblock) && isOwnerUpDownLockedDoor(protectedblock, player)) return true; + // Otherwise... + return false; + } + + public static boolean isLockable(Block block){ + Material material = block.getType(); + //Bad blocks + if(Tag.SIGNS.isTagged(material)){ + return false; + } + if (Config.isLockable(material)){ // Directly lockable + return true; + } else { // Indirectly lockable + Block blockup = block.getRelative(BlockFace.UP); + if (blockup != null && isUpDownAlsoLockableBlock(blockup)) return true; + Block blockdown = block.getRelative(BlockFace.DOWN); + if (blockdown != null && isUpDownAlsoLockableBlock(blockdown)) return true; + return false; + } + } + + + public static boolean isChest(@Nullable Block block){ + if (block == null) { + return false; + } + switch (block.getType()){ + case CHEST: + case TRAPPED_CHEST: + return true; + default: + return false; + } + } + + public static boolean isUpDownAlsoLockableBlock(Block block){ + if (Config.isLockable(block.getType())){ + switch (block.getType()){ + case OAK_DOOR: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case CRIMSON_DOOR: + case WARPED_DOOR: + case IRON_DOOR: + return true; + default: + return false; + } + } + return false; + } + + public static boolean mayInterfere(Block block, Player player){ + if (block.getState() instanceof Container) { + for (BlockFace blockface : allfaces) { + Block newblock = block.getRelative(blockface); + if (isLocked(newblock) && !isOwner(newblock, player)) { + return true; + } + } + } + // if LEFT may interfere RIGHT + switch (block.getType()){ + case OAK_DOOR: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case CRIMSON_DOOR: + case WARPED_DOOR: + case IRON_DOOR: + for (BlockFace blockface : newsfaces){ + Block newblock = block.getRelative(blockface); + switch (newblock.getType()){ + case OAK_DOOR: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case CRIMSON_DOOR: + case WARPED_DOOR: + case IRON_DOOR: + if (isLocked(newblock) && !isOwner(newblock, player)){ + return true; + } + default: + break; + } + } + // Temp workaround bad code for checking up and down signs + Block newblock2 = block.getRelative(BlockFace.UP, 2); + switch (newblock2.getType()){ + default: + if (isLocked(newblock2) && !isOwner(newblock2, player)){ + return true; + } + break; + } + Block newblock3 = block.getRelative(BlockFace.DOWN, 1); + switch (newblock3.getType()){ + default: + if (isLocked(newblock3) && !isOwner(newblock3, player)){ + return true; + } + break; + } + break; + // End temp workaround bad code for checking up and down signs + case CHEST: + case TRAPPED_CHEST: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case BIRCH_SIGN: + case JUNGLE_SIGN: + case ACACIA_SIGN: + case DARK_OAK_SIGN: + for (BlockFace blockface : allfaces){ + Block newblock = block.getRelative(blockface); + switch (newblock.getType()){ + case CHEST: + case TRAPPED_CHEST: + if (isLockedSingleBlock(newblock, null) && !isOwnerSingleBlock(newblock, null, player)){ + return true; + } + default: + break; + } + } + break; + // This is extra interfere block + case HOPPER: + case DISPENSER: + case DROPPER: + if (!Config.isInterferePlacementBlocked()) return false; + for (BlockFace blockface : allfaces){ + Block newblock = block.getRelative(blockface); + switch (newblock.getType()){ + case CHEST: + case TRAPPED_CHEST: + case HOPPER: + case DISPENSER: + case DROPPER: + if (isLocked(newblock) && !isOwner(newblock, player)){ + return true; + } + default: + break; + } + } + break; + default: + break; + } + return false; + } + + public static boolean isSign(Block block){ + return Tag.WALL_SIGNS.isTagged(block.getType()); + } + + public static boolean isLockSign(Block block){ + return isSign(block) && isLockString(((Sign)block.getState()).getLine(0)); + } + + public static boolean isAdditionalSign(Block block){ + return isSign(block) && isAdditionalString(((Sign)block.getState()).getLine(0)); + } + + public static boolean isLockSignOrAdditionalSign(Block block){ + if (isSign(block)){ + String line = ((Sign)block.getState()).getLine(0); + return isLockStringOrAdditionalString(line); + } else { + return false; + } + } + + public static boolean isOwnerOnSign(Block block, Player player){ // Requires isLockSign + String[] lines = ((Sign)block.getState()).getLines(); + if (Utils.isPlayerOnLine(player, lines[1])){ + if (Config.isUuidEnabled()){ + Utils.updateLineByPlayer(block, 1, player); + } + return true; + } + return false; + } + + public static String getOwnerOnSign(Block block){ // Requires isLockSign + String[] lines = ((Sign)block.getState()).getLines(); + return lines[1]; + } + + public static boolean isUserOnSign(Block block, Player player){ // Requires (isLockSign or isAdditionalSign) + String[] lines = ((Sign)block.getState()).getLines(); + // Normal + for (int i = 1; i < 4; i ++){ + if (Utils.isPlayerOnLine(player, lines[i])){ + if (Config.isUuidEnabled()){ + Utils.updateLineByPlayer(block, i, player); + } + return true; + } else if (Config.isEveryoneSignString(lines[i])) { + return true; + } + } + // For Vault & Scoreboard + for (int i = 1; i < 4; i++) { + if (Dependency.isPermissionGroupOf(lines[i], player)) return true; + if (Dependency.isScoreboardTeamOf(lines[i], player)) return true; + } + return false; + } + + public static boolean isSignExpired(Block block){ + if (!isSign(block) || !isLockSign(block)) return false; + return isLineExpired(((Sign)block.getState()).getLine(0)); + } + + public static boolean isLineExpired(String line){ + long createdtime = Utils.getCreatedFromLine(line); + if (createdtime == -1L) return false; // No expire + long currenttime = (int)(System.currentTimeMillis()/1000); + return createdtime + Config.getLockExpireDays() * 86400L < currenttime; + } + + public static boolean isUpDownLockedDoor(@Nullable Block block){ + if (block == null) { + return false; + } + Block blockup = block.getRelative(BlockFace.UP); + if (blockup != null && isUpDownAlsoLockableBlock(blockup) && isLocked(blockup)) return true; + Block blockdown = block.getRelative(BlockFace.DOWN); + if (blockdown != null && isUpDownAlsoLockableBlock(blockdown) && isLocked(blockdown)) return true; + return false; + } + + public static boolean isOwnerUpDownLockedDoor(Block block, Player player){ + Block blockup = block.getRelative(BlockFace.UP); + if (blockup != null && isUpDownAlsoLockableBlock(blockup) && isOwner(blockup, player)) return true; + Block blockdown = block.getRelative(BlockFace.DOWN); + if (blockdown != null && isUpDownAlsoLockableBlock(blockdown) && isOwner(blockdown, player)) return true; + return false; + } + + public static boolean isUserUpDownLockedDoor(Block block, Player player){ + Block blockup = block.getRelative(BlockFace.UP); + if (blockup != null && isUpDownAlsoLockableBlock(blockup) && isUser(blockup, player)) return true; + Block blockdown = block.getRelative(BlockFace.DOWN); + if (blockdown != null && isUpDownAlsoLockableBlock(blockdown) && isUser(blockdown, player)) return true; + return false; + } + + public static boolean isLockString(String line){ + if (line.contains("#")) line = line.split("#", 2)[0]; + return Config.isPrivateSignString(line); + } + + public static boolean isAdditionalString(String line){ + if (line.contains("#")) line = line.split("#", 2)[0]; + return Config.isAdditionalSignString(line); + } + + public static boolean isLockStringOrAdditionalString(String line){ + return isLockString(line) || isAdditionalString(line); + } + + public static Block getAttachedBlock(Block sign){ // Requires isSign + BlockFace facing = getFacing(sign); + return sign.getRelative(facing.getOppositeFace()); + } + + public static int getTimerOnSigns(Block block){ + for (BlockFace blockface : newsfaces){ + Block relative = block.getRelative(blockface); + if (isSign(relative)){ + Sign sign = (Sign)relative.getState(); + for (String line : sign.getLines()){ + int linetime = Config.getTimer(line); + if (linetime > 0) return linetime; + } + } + } + return 0; + } + + public static int getTimerDoor(Block block){ + int timersingle = getTimerSingleDoor(block); + if (timersingle > 0) return timersingle; + for (BlockFace blockface : newsfaces){ + Block relative = block.getRelative(blockface); + timersingle = getTimerSingleDoor(relative); + if (timersingle > 0) return timersingle; + } + return 0; + } + + public static int getTimerSingleDoor(Block block){ + Block[] doors = getDoors(block); + if (doors == null) return 0; + Block relativeup = doors[1].getRelative(BlockFace.UP); + int relativeuptimer = getTimerOnSigns(relativeup); + if (relativeuptimer > 0) return relativeuptimer; + int doors0 = getTimerOnSigns(doors[0]); + if (doors0 > 0) return doors0; + int doors1 = getTimerOnSigns(doors[1]); + if (doors1 > 0) return doors1; + Block relativedown = doors[0].getRelative(BlockFace.DOWN); + int relativedowntimer = getTimerOnSigns(relativedown); + if (relativedowntimer > 0) return relativedowntimer; + return 0; + } + + public static Block[] getDoors(Block block){ + Block[] doors = new Block[2]; + boolean found = false; + Block up = block.getRelative(BlockFace.UP), down = block.getRelative(BlockFace.DOWN); + if (up.getType() == block.getType()){ + found = true; + doors[0] = block; doors[1] = up; + } + if (down.getType() == block.getType()){ + if (found == true){ // error 3 doors + return null; + } + doors[1] = block; doors[0] = down; + found = true; + } + if (!found){ // error 1 door + return null; + } + return doors; + } + + public static boolean isDoubleDoorBlock(@Nullable Block block){ + if (block == null) { + return false; + } + return Tag.DOORS.isTagged(block.getType()); + } + + public static boolean isSingleDoorBlock(@Nullable Block block){ + if (block == null) { + return false; + } + switch (block.getType()){ + case OAK_FENCE_GATE: + case SPRUCE_FENCE_GATE: + case BIRCH_FENCE_GATE: + case CRIMSON_FENCE_GATE: + case WARPED_FENCE_GATE: + case ACACIA_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case ACACIA_TRAPDOOR: + case DARK_OAK_TRAPDOOR: + case CRIMSON_TRAPDOOR: + case WARPED_TRAPDOOR: + case BIRCH_TRAPDOOR: + case OAK_TRAPDOOR: + case SPRUCE_TRAPDOOR: + case IRON_TRAPDOOR: + return true; + default: + return false; + } + } + + public static Block getBottomDoorBlock(Block block){ // Requires isDoubleDoorBlock || isSingleDoorBlock + if (isDoubleDoorBlock(block)){ + Block relative = block.getRelative(BlockFace.DOWN); + if (relative.getType() == block.getType()){ + return relative; + } else { + return block; + } + } else { + return block; + } + } + + public static void toggleDoor(Block block, boolean open) { + org.bukkit.block.data.Openable openablestate = (org.bukkit.block.data.Openable) block.getBlockData(); + openablestate.setOpen(open); + block.setBlockData(openablestate); + block.getWorld().playEffect(block.getLocation(), Effect.DOOR_TOGGLE, 0); + } + + public static void toggleDoor(Block block) { + org.bukkit.block.data.Openable openablestate = (org.bukkit.block.data.Openable) block.getBlockData(); + openablestate.setOpen(!openablestate.isOpen()); + block.setBlockData(openablestate); + block.getWorld().playEffect(block.getLocation(), Effect.DOOR_TOGGLE, 0); + } + + public static BlockFace getRelativeChestFace(Block block) { + Chest chest = (Chest) block.getBlockData(); + BlockFace face = getFacing(block); + BlockFace relativeFace = null; + if (chest.getType() == Chest.Type.LEFT) { + if (face == BlockFace.NORTH) { + relativeFace = BlockFace.EAST; + } else if (face == BlockFace.SOUTH) { + relativeFace = BlockFace.WEST; + } else if (face == BlockFace.WEST) { + relativeFace = BlockFace.NORTH; + } else if (face == BlockFace.EAST) { + relativeFace = BlockFace.SOUTH; + } + } else if (chest.getType() == Chest.Type.RIGHT) { + if (face == BlockFace.NORTH) { + relativeFace = BlockFace.WEST; + } else if (face == BlockFace.SOUTH) { + relativeFace = BlockFace.EAST; + } else if (face == BlockFace.WEST) { + relativeFace = BlockFace.SOUTH; + } else if (face == BlockFace.EAST) { + relativeFace = BlockFace.NORTH; + } + } + return relativeFace; + } + + public static BlockFace getFacing(Block block) { + BlockData data = block.getBlockData(); + BlockFace f = null; + if (data instanceof Directional && data instanceof Waterlogged && ((Waterlogged) data).isWaterlogged()) { + String str = ((Directional) data).toString(); + if (str.contains("facing=west")) { + f = BlockFace.WEST; + } else if (str.contains("facing=east")) { + f = BlockFace.EAST; + } else if (str.contains("facing=south")) { + f = BlockFace.SOUTH; + } else if (str.contains("facing=north")) { + f = BlockFace.NORTH; + } + } else if (data instanceof Directional) { + f = ((Directional) data).getFacing(); + } + return f; + } +} diff --git a/src/main/java/me/crafter/mc/lockettepro/Utils.java b/src/main/java/me/crafter/mc/lockettepro/Utils.java new file mode 100644 index 0000000..3446399 --- /dev/null +++ b/src/main/java/me/crafter/mc/lockettepro/Utils.java @@ -0,0 +1,337 @@ +package me.crafter.mc.lockettepro; + +import com.comphenix.protocol.wrappers.WrappedChatComponent; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Sign; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Directional; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.metadata.MetadataValue; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +public class Utils { + + public static final String usernamepattern = "^[a-zA-Z0-9_]*$"; + private static LoadingCache selectedsign = CacheBuilder.newBuilder() + .expireAfterAccess(30, TimeUnit.SECONDS) + .build(new CacheLoader() { + public Block load(UUID key) { + return null; + } + }); + private static Set notified = new HashSet<>(); + + // Helper functions + public static Block putSignOn(Block block, BlockFace blockface, String line1, String line2, Material material) { + Block newsign = block.getRelative(blockface); + Material blockType = Material.getMaterial(material.name().replace("_SIGN", "_WALL_SIGN")); + if (blockType != null && Tag.WALL_SIGNS.isTagged(blockType)) { + newsign.setType(blockType); + } else { + newsign.setType(Material.OAK_WALL_SIGN); + } + BlockData data = newsign.getBlockData(); + if(data instanceof Directional){ + ((Directional) data).setFacing(blockface); + newsign.setBlockData(data,true); + } + updateSign(newsign); + Sign sign = (Sign)newsign.getState(); + if (newsign.getType() == Material.DARK_OAK_WALL_SIGN || LockettePro.is16version && newsign.getType() == Material.CRIMSON_WALL_SIGN) { + sign.setColor(DyeColor.WHITE); + } + sign.setLine(0, line1); + sign.setLine(1, line2); + sign.update(); + return newsign; + } + + public static void setSignLine(Block block, int line, String text){ // Requires isSign + Sign sign = (Sign)block.getState(); + sign.setLine(line, text); + sign.update(); + } + + public static void removeASign(Player player){ + if (player.getGameMode() == GameMode.CREATIVE) return; + if (player.getInventory().getItemInMainHand().getAmount() == 1){ + player.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); + } else { + player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1); + } + } + + public static void updateSign(Block block){ + if (block.getState() instanceof Sign) { + ((Sign)block.getState()).update(); + } + } + + public static Block getSelectedSign(Player player) { + Block b = selectedsign.getIfPresent(player.getUniqueId()); + if (b != null && !player.getWorld().getName().equals(b.getWorld().getName())) { + selectedsign.invalidate(player.getUniqueId()); + return null; + } + return b; + } + + public static void selectSign(Player player, Block block){ + selectedsign.put(player.getUniqueId(), block); + } + + public static void playLockEffect(Player player, Block block){ +// player.playSound(block.getLocation(), Sound.DOOR_CLOSE, 0.3F, 1.4F); +// player.spigot().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.CRIT, 0, 0, 0.3F, 0.3F, 0.3F, 0.1F, 64, 64); + } + + public static void playAccessDenyEffect(Player player, Block block){ +// player.playSound(block.getLocation(), Sound.VILLAGER_NO, 0.3F, 0.9F); +// player.spigot().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.FLAME, 0, 0, 0.3F, 0.3F, 0.3F, 0.01F, 64, 64); + } + + public static void sendMessages(CommandSender sender, String messages){ + if (messages == null || messages.equals("")) return; + sender.sendMessage(messages); + } + + public static boolean shouldNotify(Player player){ + if (notified.contains(player.getUniqueId())){ + return false; + } else { + notified.add(player.getUniqueId()); + return true; + } + } + + public static boolean hasValidCache(Block block){ + List metadatas = block.getMetadata("expires"); + if (!metadatas.isEmpty()){ + long expires = metadatas.get(0).asLong(); + if (expires > System.currentTimeMillis()){ + return true; + } + } + return false; + } + + public static boolean getAccess(Block block){ // Requires hasValidCache() + List metadatas = block.getMetadata("locked"); + return metadatas.get(0).asBoolean(); + } + + public static void setCache(Block block, boolean access){ + block.removeMetadata("expires", LockettePro.getPlugin()); + block.removeMetadata("locked", LockettePro.getPlugin()); + block.setMetadata("expires", new FixedMetadataValue(LockettePro.getPlugin(), System.currentTimeMillis() + Config.getCacheTimeMillis())); + block.setMetadata("locked", new FixedMetadataValue(LockettePro.getPlugin(), access)); + } + + public static void resetCache(Block block){ + block.removeMetadata("expires", LockettePro.getPlugin()); + block.removeMetadata("locked", LockettePro.getPlugin()); + for (BlockFace blockface : LocketteProAPI.newsfaces){ + Block relative = block.getRelative(blockface); + if (relative.getType() == block.getType()){ + relative.removeMetadata("expires", LockettePro.getPlugin()); + relative.removeMetadata("locked", LockettePro.getPlugin()); + } + } + } + + public static void updateUuidOnSign(Block block){ + for (int line = 1; line < 4; line ++){ + updateUuidByUsername(block, line); + } + } + + public static void updateUuidByUsername(final Block block, final int line){ + Sign sign = (Sign)block.getState(); + final String original = sign.getLine(line); + Bukkit.getScheduler().runTaskAsynchronously(LockettePro.getPlugin(), new Runnable(){ + @Override + public void run() { + String username = original; + if (username.contains("#")){ + username = username.split("#")[0]; + } + if (!isUserName(username)) return; + String uuid = null; + Player user = Bukkit.getPlayerExact(username); + if (user != null){ // User is online + uuid = user.getUniqueId().toString(); + } else { // User is not online, fetch string + uuid = getUuidByUsernameFromMojang(username); + } + if (uuid != null){ + final String towrite = username + "#" + uuid; + Bukkit.getScheduler().runTask(LockettePro.getPlugin(), new Runnable(){ + @Override + public void run() { + setSignLine(block, line, towrite); + } + }); + } + } + }); + } + + public static void updateUsernameByUuid(Block block, int line){ + Sign sign = (Sign)block.getState(); + String original = sign.getLine(line); + if (isUsernameUuidLine(original)){ + String uuid = getUuidFromLine(original); + Player player = Bukkit.getPlayer(UUID.fromString(uuid)); + if (player != null){ + setSignLine(block, line, player.getName() + "#" + uuid); + } + } + } + + public static void updateLineByPlayer(Block block, int line, Player player){ + setSignLine(block, line, player.getName() + "#" + player.getUniqueId().toString()); + } + + public static void updateLineWithTime(Block block, boolean noexpire){ + Sign sign = (Sign)block.getState(); + if (noexpire){ + sign.setLine(0, sign.getLine(0) + "#created:" + -1); + } else { + sign.setLine(0, sign.getLine(0) + "#created:" + (int)(System.currentTimeMillis()/1000)); + } + sign.update(); + } + + public static boolean isUserName(String text){ + if (text.length() < 17 && text.length() > 2 && text.matches(usernamepattern)){ + return true; + } else { + return false; + } + } + + // Warning: don't use this in a sync way + public static String getUuidByUsernameFromMojang(String username){ + try { + URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + username); + URLConnection connection = url.openConnection(); + connection.setConnectTimeout(8000); + connection.setReadTimeout(8000); + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuffer response = new StringBuffer(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + String responsestring = response.toString(); + JsonObject json = new JsonParser().parse(responsestring).getAsJsonObject(); + String rawuuid = json.get("id").getAsString(); + return rawuuid.substring(0, 8) + "-" + rawuuid.substring(8, 12) + "-" + rawuuid.substring(12, 16) + "-" + rawuuid.substring(16, 20) + "-" + rawuuid.substring(20); + } catch (Exception ex){} + return null; + } + + public static boolean isUsernameUuidLine(String text){ + if (text.contains("#")){ + String[] splitted = text.split("#", 2); + if (splitted[1].length() == 36){ + return true; + } + } + return false; + } + + public static boolean isPrivateTimeLine(String text){ + if (text.contains("#")){ + String[] splitted = text.split("#", 2); + if (splitted[1].startsWith("created:")){ + return true; + } + } + return false; + } + + public static String StripSharpSign(String text){ + if (text.contains("#")){ + return text.split("#", 2)[0]; + } else { + return text; + } + } + + public static String getUsernameFromLine(String text){ + if (isUsernameUuidLine(text)){ + return text.split("#", 2)[0]; + } else { + return text; + } + } + + public static String getUuidFromLine(String text){ + if (isUsernameUuidLine(text)){ + return text.split("#", 2)[1]; + } else { + return null; + } + } + + public static long getCreatedFromLine(String text){ + if (isPrivateTimeLine(text)){ + return Long.parseLong(text.split("#created:", 2)[1]); + } else { + return Config.getLockDefaultCreateTimeUnix(); + } + } + + public static boolean isPlayerOnLine(Player player, String text){ + if (Utils.isUsernameUuidLine(text)){ + if (Config.isUuidEnabled()){ + return player.getUniqueId().toString().equals(getUuidFromLine(text)); + } else { + return player.getName().equals(getUsernameFromLine(text)); + } + } else { + return text.equals(player.getName()); + } + } + + public static String getSignLineFromUnknown(WrappedChatComponent rawline){ + String json = rawline.getJson(); + return getSignLineFromUnknown(json); + } + + public static String getSignLineFromUnknown(String json) { + try { // 1.9+ + if (json.length() > 33) { + JsonObject line = new JsonParser().parse(json).getAsJsonObject(); + if (line.has("extra")) { + return line.get("extra").getAsJsonArray().get(0).getAsJsonObject().get("text").getAsString(); + } + } + return ""; + } catch (Exception ex) { + ex.printStackTrace(); + } + return json; + } + +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..e5a4757 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,70 @@ +# Configuration file +# https://github.com/connection-lost/LockettePro/wiki/*-config.yml +# If there are missing entries, you can add them manually. + +language-file-name: 'lang.yml' +enable-quick-protect: true +enable-uuid-support: false +protocollib: true +worldguard: true +coreprotect: true +block-interfere-placement: true +block-item-transfer-in: false +block-item-transfer-out: true +block-hopper-minecart: remove +cache-time-seconds: 0 +lock-expire: false +lock-expire-days: 999.9 +lock-default-create-time-unix: -1 +lock-expire-string: '&3[Expired]' + +private-signs: +- '[Private]' +- '[private]' +additional-signs: +- '[More Users]' +- '[more users]' +everyone-signs: +- '[Everyone]' +- '[everyone]' +timer-signs: +- '[Timer:@]' +- '[timer:@]' +# material name see: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html +# legacy block name and block id are not supported! +lockables: +- CHEST +- TRAPPED_CHEST +- BARREL +- FURNACE +- SMOKER +- BLAST_FURNACE +- HOPPER +- BREWING_STAND +- DIAMOND_BLOCK +- OAK_DOOR +- SPRUCE_DOOR +- BIRCH_DOOR +- JUNGLE_DOOR +- ACACIA_DOOR +- DARK_OAK_DOOR +- IRON_DOOR +- LECTERN +- CRIMSON_DOOR +- WARPED_DOOR +- OAK_FENCE_GATE +- SPRUCE_FENCE_GATE +- BIRCH_FENCE_GATE +- CRIMSON_FENCE_GATE +- WARPED_FENCE_GATE +- ACACIA_FENCE_GATE +- JUNGLE_FENCE_GATE +- CRIMSON_TRAPDOOR +- WARPED_TRAPDOOR +- SPRUCE_TRAPDOOR +- OAK_TRAPDOOR +- BIRCH_TRAPDOOR +- DARK_OAK_TRAPDOOR +- ACACIA_TRAPDOOR +protection-exempt: +- nothing \ No newline at end of file diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml new file mode 100644 index 0000000..4f7b08d --- /dev/null +++ b/src/main/resources/lang.yml @@ -0,0 +1,31 @@ +command-usage: "&6[LockettePro] &bLockettePro plugin help\n&c1. In order to add a user to a sign, right click the sign, then enter /lock to change the line.\n&c2. To reload configuration, enter /lock reload.\nLockettePro by connection_lost" +you-can-quick-lock-it: '&6[LockettePro] &aRight click the block with a sign to lock.' +you-can-manual-lock-it: '&6[LockettePro] &aPlace a sign and write [Private] to lock it.' +config-reloaded: '&6[LockettePro] &aConfig reloaded.' +no-permission: '&6[LockettePro] &cYou don''t have permission to do that.' +no-sign-selected: '&6[LockettePro] &cSelect a sign by right-clicking on it first.' +sign-need-reselect: '&6[LockettePro] &cPlease re-select the sign.' +line-is-too-long: '&6[LockettePro] &cThis line is too long!' +cannot-change-this-line: '&6[LockettePro] &cYou cannot change this line.' +sign-changed: '&6[LockettePro] &aSign edited successfully.' +locked-quick: '&6[LockettePro] &aBlock locked successfully.' +additional-sign-added-quick: '&6[LockettePro] &aAdditional sign added successfully.' +cannot-lock-quick: '&6[LockettePro] &cYou cannot lock this.' +cannot-add-additional-sign-quick: '&6[LockettePro] &cYou cannot add a sign here' +locked-manual: '&6[LockettePro] &aBlock locked successfully.' +additional-sign-added-manual: '&6[LockettePro] &aAdditional sign added successfully.' +cannot-lock-manual: '&6[LockettePro] &cYou cannot lock this.' +cannot-add-additional-sign-manual: '&6[LockettePro] &cYou cannot add a sign here' +not-locked-yet-manual: '&6[LockettePro] &cThis block is not locked yet.' +cannot-lock-door-nearby-manual: '&6[LockettePro] &cThere is a door nearby.' +block-already-locked-manual: '&6[LockettePro] &cThis block is already locked.' +block-is-not-lockable: '&6[LockettePro] &cThis block is not lockable.' +sign-selected: '&6[LockettePro] &aSign Selected.' +break-own-lock-sign: '&6[LockettePro] &aYou broke your lock sign.' +cannot-break-this-lock-sign: '&6[LockettePro] &cYou cannot break this lock sign.' +break-own-additional-sign: '&6[LockettePro] &aYou broke your additional sign.' +break-redundant-additional-sign: '&6[LockettePro] &aYou broke a redundant additional sign.' +cannot-break-this-additional-sign: '&6[LockettePro] &cYou cannot break this additional sign.' +block-is-locked: '&6[LockettePro] &cThis block is locked.' +cannot-interfere-with-others: '&6[LockettePro] &cYou cannot place a block that may interfere others.' +sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/src/main/resources/lang_de.yml b/src/main/resources/lang_de.yml new file mode 100644 index 0000000..c264067 --- /dev/null +++ b/src/main/resources/lang_de.yml @@ -0,0 +1,33 @@ +# German translation by HeartCore + +command-usage: "&6[LockettePro] &bLockettePro Plugin-Hilfe\n&c1. Um einen User einem Schild hinzuzufügen, rechtsklicke das Schild und gib anschließend /lock ein, um den Text zu ändern\n&c2. Um die Konfiguration neu zu laden, gib /lock reload ein.\nLockettePro von connection_lost" +you-can-quick-lock-it: '&6[LockettePro] &aRechtsklicke den Block mit einem Schild, um ihn zu sichern.' +you-can-manual-lock-it: '&6[LockettePro] &aPlatziere ein Schild und schreibe [Private] darauf, um es zu sichern.' +config-reloaded: '&6[LockettePro] &aKonfiguratio neu geladen..' +no-permission: '&6[LockettePro] &cDu hast keine Rechte, um dies zu tun.' +no-sign-selected: '&6[LockettePro] &cWähle zuerst ein Schild aus, indem du es rechtsklickst.' +sign-need-reselect: '&6[LockettePro] &cBitte wähle das Schild erneut aus.' +line-is-too-long: '&6[LockettePro] &cDiese Zeile ist zu lang!' +cannot-change-this-line: '&6[LockettePro] &cDu kannst diese Zeile nicht verändern.' +sign-changed: '&6[LockettePro] &aSchild erfolgreich bearbeitet.' +locked-quick: '&6[LockettePro] &aBlock erfolgreich gesichert.' +additional-sign-added-quick: '&6[LockettePro] &aZusätzliches Schild erfolgreich hinzugefügt.' +cannot-lock-quick: '&6[LockettePro] &cDu kannst das nicht sichern.' +cannot-add-additional-sign-quick: '&6[LockettePro] &cDu kannst hier kein Schild hinzufügen' +locked-manual: '&6[LockettePro] &aBlock erfolgreich gesichert.' +additional-sign-added-manual: '&6[LockettePro] &aZusätzliches Schild erfolgreich hinzugefügt.' +cannot-lock-manual: '&6[LockettePro] &cDu kannst das nicht sichern.' +cannot-add-additional-sign-manual: '&6[LockettePro] &cDu kannst hier kein Schild hinzufügen' +not-locked-yet-manual: '&6[LockettePro] &cDieser Block ist noch nicht gesichert.' +cannot-lock-door-nearby-manual: '&6[LockettePro] &cHier ist eine Tür in der Nähe.' +block-already-locked-manual: '&6[LockettePro] &cDieser Block ist bereits gesichert.' +block-is-not-lockable: '&6[LockettePro] &cDieser Block kann nicht gesichert werden.' +sign-selected: '&6[LockettePro] &aSchild ausgewählt.' +break-own-lock-sign: '&6[LockettePro] &aDu hast dein Sicherungsschild zerstört.' +cannot-break-this-lock-sign: '&6[LockettePro] &cDu kannst dieses Sicherungsschild nicht zerstören.' +break-own-additional-sign: '&6[LockettePro] &aDu hast dein zusätzliches Schild zerstört.' +break-redundant-additional-sign: '&6[LockettePro] &aDu hast ein redundantes zusätzliches Schild zerstört.' +cannot-break-this-additional-sign: '&6[LockettePro] &cDu kansnt dieses zusätzliche Schild nicht zerstören.' +block-is-locked: '&6[LockettePro] &cDieser Block ist gesichert.' +cannot-interfere-with-others: '&6[LockettePro] &cDu kannst keinen Block platzieren, der in andere eingreifen könnte.' +sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/src/main/resources/lang_es.yml b/src/main/resources/lang_es.yml new file mode 100644 index 0000000..f061655 --- /dev/null +++ b/src/main/resources/lang_es.yml @@ -0,0 +1,32 @@ +# Spanish translation by Alarar +command-usage: "&6[Private] &bPrivate plugin ayuda\n&c1. Para a?adir un usuario al private, click derecho en el cartel, y escribe /lock para cambiar o a?adir l��nea.\n&c2. Para recargar la config, utiliza /lock reload.\nLockettepro by connection_lost" +you-can-quick-lock-it: '&6[Private] &aClick derecho con el cartel en lo que quieras proteger.' +you-can-manual-lock-it: '&6[Private] &aPon un cartel y escribe [Private] para privatizarlo.' +config-reloaded: '&6[Private] &aConfig recargada.' +no-permission: '&6[Private] &cNo tienes permisos para hacer esto.' +no-sign-selected: '&6[Private] &cPrimero selecciona un cartel con click derecho.' +sign-need-reselect: '&6[Private] &cPor favor selecciona otra vez el cartel.' +line-is-too-long: '&6[Private] &c?Esta l��nea es muy larga!' +cannot-change-this-line: '&6[Private] &cT�� no puedes cambiar esta l��nea.' +sign-changed: '&6[Private] &aCartel editado correctamente.' +locked-quick: '&6[Private] &aObjeto privatizado correctamente.' +additional-sign-added-quick: '&6[Private] &aCartel adicional agregado correctamente.' +cannot-lock-quick: '&6[Private] &cNo puedes privatizar eso.' +cannot-add-additional-sign-quick: '&6[Private] &cNo puedes colocar un cartel aqu��.' +locked-manual: '&6[Private] &aPrivatizado correctamente.' +additional-sign-added-manual: '&6[Private] &aCartel adicional a?adido correctamente.' +cannot-lock-manual: '&6[Private] &cNo puedes proteger esto.' +cannot-add-additional-sign-manual: '&6[Private] &cNo puedes a?adir un cartel aqu��.' +not-locked-yet-manual: '&6[Private] &cEste objeto no esta protegido todav��a.' +cannot-lock-door-nearby-manual: '&6[Private] &cHay una puerta cerca.' +block-already-locked-manual: '&6[Private] &cEste bloque esta ya privatizado.' +block-is-not-lockable: '&6[Private] &cEste bloque no se puede privatizar.' +sign-selected: '&6[Private] &aCartel seleccionado.' +break-own-lock-sign: '&6[Private] &a?Has roto t�� cartel private!.' +cannot-break-this-lock-sign: '&6[Private] &c?No puedes romper este cartel private!.' +break-own-additional-sign: '&6[Private] &aHas roto t�� cartel adicional private.' +break-redundant-additional-sign: '&6[Private] &aHas roto un cartel private que era redundante.' +cannot-break-this-additional-sign: '&6[Private] &cNo puedes romper este cartel adicional de private!.' +block-is-locked: '&6[Private] &c?Este bloque esta protegido!.' +cannot-interfere-with-others: '&6[Private] &c?No puedes poner un cartel interfiriendo con otros de private!.' +sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/src/main/resources/lang_fr.yml b/src/main/resources/lang_fr.yml new file mode 100644 index 0000000..f9fc7d9 --- /dev/null +++ b/src/main/resources/lang_fr.yml @@ -0,0 +1,33 @@ +# German translation by Morgan_vonBrylan + +command-usage: "&6[LockettePro] aide du plugin &bLockettePro\n&c1. Pour ajouter un joueur au panneau, faites clic droit dessus, puis entrez /lock pour changer la ligne.\n&c2. Pour recharger la configuration, entrez /lock reload.\nLockettePro par connection_lost" +you-can-quick-lock-it: '&6[LockettePro] &aClick droit sur un bloc avec un panneau pour le verrouiller.' +you-can-manual-lock-it: '&6[LockettePro] &aPlacez un panneau et crivez [Private] pour le verrouiller.' +config-reloaded: '&6[LockettePro] &aConfiguration recharge.' +no-permission: '&6[LockettePro] &cVous n''avez pas la permission de faire a.' +no-sign-selected: '&6[LockettePro] &cSlectionnez un panneau en faisant clic droit dessus.' +sign-need-reselect: '&6[LockettePro] &cVeuillez re-slectionner le panneau.' +line-is-too-long: '&6[LockettePro] &cCette ligne est trop longue !' +cannot-change-this-line: '&6[LockettePro] &cVous ne pouvez pas changer cette ligne.' +sign-changed: '&6[LockettePro] &aPanneau modifi avec succs.' +locked-quick: '&6[LockettePro] &aBloc verrouill avec succs.' +additional-sign-added-quick: '&6[LockettePro] &aPanneau supplmentaire ajout avec succs.' +cannot-lock-quick: '&6[LockettePro] &cVous ne pouvez pas verrouiller a.' +cannot-add-additional-sign-quick: '&6[LockettePro] &cVous ne pouvez pas mettre de panneau l.' +locked-manual: '&6[LockettePro] &aBloc verrouill avec succs.' +additional-sign-added-manual: '&6[LockettePro] &aPanneau supplmentaire ajout avec succs.' +cannot-lock-manual: '&6[LockettePro] &cVous ne pouvez pas verrouiller a.' +cannot-add-additional-sign-manual: '&6[LockettePro] &cVous ne pouvez pas mettre de panneau l.' +not-locked-yet-manual: '&6[LockettePro] &cCe bloc n''est pas envore verrouill.' +cannot-lock-door-nearby-manual: '&6[LockettePro] &cIl y a une porte proximit.' +block-already-locked-manual: '&6[LockettePro] &cCe bloc est dj verrouill.' +block-is-not-lockable: '&6[LockettePro] &cCe bloc n''est pas verrouillable.' +sign-selected: '&6[LockettePro] &aPanneau slectionn.' +break-own-lock-sign: '&6[LockettePro] &aVous avez cass votre panneau verrou.' +cannot-break-this-lock-sign: '&6[LockettePro] &cVous ne pouvez pas casser ce panneau verrou.' +break-own-additional-sign: '&6[LockettePro] &aVous avez cass votre panneau supplmentaire.' +break-redundant-additional-sign: '&6[LockettePro] &aVous avez cass un panneau supplmentaire redondant.' +cannot-break-this-additional-sign: '&6[LockettePro] &cVous ne pouvez pas cesser ce panneau supplmentaire.' +block-is-locked: '&6[LockettePro] &cCe bloc est verrouill.' +cannot-interfere-with-others: '&6[LockettePro] &cVous ne pouvez pas placer de bloc qui pourrait interfrer avec d''autres.' +sign-error: '&4[ERREUR]' \ No newline at end of file diff --git a/src/main/resources/lang_hu.yml b/src/main/resources/lang_hu.yml new file mode 100644 index 0000000..becc8cb --- /dev/null +++ b/src/main/resources/lang_hu.yml @@ -0,0 +1,32 @@ +# Hungarian translation by andris155 +command-usage: "&6[LockettePro] &bLockettePro plugin segítség\n&c1. Ha szeretnél valakit hozzáadni a védéshez, akkor jobb klikkelj a táblára és írd be /lock , hogy megváltoztasd a sort.\n&c2. Ha újra szeretnéd tölteni a plugin-t, akkor írd be /lock reload.\nLockettePro by connection_lost" +you-can-quick-lock-it: '&6[LockettePro] &aJobb klikkelj a blokkra egy táblával a levédéséhez.' +you-can-manual-lock-it: '&6[LockettePro] &aKérlek helyezz le egy táblát és írd rá, hogy [Lock] a levédéshez.' +config-reloaded: '&6[LockettePro] &aA konfig újratöltve.' +no-permission: '&6[LockettePro] &cEhhez nincs jogod.' +no-sign-selected: '&6[LockettePro] &cElőször válaszd ki a táblát jobb klikkel.' +sign-need-reselect: '&6[LockettePro] &cKérlek válaszd ki újra a táblát.' +line-is-too-long: '&6[LockettePro] &cA sor túl rövid!' +cannot-change-this-line: '&6[LockettePro] &cEzt a sort nem módosíthatod.' +sign-changed: '&6[LockettePro] &aA tábla sikeresen megváltoztatva.' +locked-quick: '&6[LockettePro] &aA blokk sikeresen levédve.' +additional-sign-added-quick: '&6[LockettePro] &aKiegészítő tábla sikeresen hozzáadva.' +cannot-lock-quick: '&6[LockettePro] &cEzt nem védheted le.' +cannot-add-additional-sign-quick: '&6[LockettePro] &cItt nem adhatsz hozzá táblát' +locked-manual: '&6[LockettePro] &aA blokk sikeresen levédve.' +additional-sign-added-manual: '&6[LockettePro] &aKiegészítő tábla sikeresen hozzáadva.' +cannot-lock-manual: '&6[LockettePro] &cEzt nem védheted le.' +cannot-add-additional-sign-manual: '&6[LockettePro] &cItt nem adhatsz hozzá táblát' +not-locked-yet-manual: '&6[LockettePro] &cEzt a blokkot még nem védted le.' +cannot-lock-door-nearby-manual: '&6[LockettePro] &cVan a közelben egy ajtó.' +block-already-locked-manual: '&6[LockettePro] &cEz a blokk már védett.' +block-is-not-lockable: '&6[LockettePro] &cEz a blokk nem levédhető.' +sign-selected: '&6[LockettePro] &aA Tábla kiválasztva.' +break-own-lock-sign: '&6[LockettePro] &aKiütötted a Lock táblád.' +cannot-break-this-lock-sign: '&6[LockettePro] &cNem ütheted ki ezt a levédés táblát.' +break-own-additional-sign: '&6[LockettePro] &aKiütötted a kiegészítő táblád.' +break-redundant-additional-sign: '&6[LockettePro] &aKiütöttél egy felesleges kiegészítő táblát.' +cannot-break-this-additional-sign: '&6[LockettePro] &cNem ütheted ki ezt a kiegészítő táblát.' +block-is-locked: '&6[LockettePro] &cEz a blokk védett.' +cannot-interfere-with-others: '&6[LockettePro] &cNem helyezhetsz blokkot oda, ahol ütközik más védésével.' +sign-error: '&4[HIBA]' diff --git a/src/main/resources/lang_it.yml b/src/main/resources/lang_it.yml new file mode 100644 index 0000000..fbea67d --- /dev/null +++ b/src/main/resources/lang_it.yml @@ -0,0 +1,32 @@ +# Lingua Italiana creata da Maxetto. +command-usage: "&6[LockettePro] &bAiuto LockettePro\n&c1. Per aggiungere un giocatore nel cartello, fai tasto destro sul cartello, poi scrivi /lock per modificare la linea indicata.\n&c2. Per ricaricare la configurazione, scrivi /lock reload.\nLockettePro di connection_lost" +you-can-quick-lock-it: '&6[LockettePro] &aFai tasto destro sul blocco con un cartello per privatizzarlo.' +you-can-manual-lock-it: '&6[LockettePro] &aPiazza un cartello e scrivi [Private] per privatizzarlo.' +config-reloaded: '&6[LockettePro] &aConfigurazione ricaricata correttamente.' +no-permission: '&6[LockettePro] &cNon hai il permesso di fare ciò.' +no-sign-selected: '&6[LockettePro] &cDevi selezionare un cartello facendo tasto destro su di esso prima di eseguire questo comando.' +sign-need-reselect: '&6[LockettePro] &cPer favore riseleziona il cartello.' +line-is-too-long: '&6[LockettePro] &cIl testo inserito è troppo lungo!' +cannot-change-this-line: '&6[LockettePro] &cNon puoi modificare questa linea.' +sign-changed: '&6[LockettePro] &aCartello modificato correttamente.' +locked-quick: '&6[LockettePro] &aBlocco privatizzato correttamente.' +additional-sign-added-quick: '&6[LockettePro] &aCartello aggiuntivo piazzato correttamente.' +cannot-lock-quick: '&6[LockettePro] &cNon puoi privatizzare questo blocco.' +cannot-add-additional-sign-quick: '&6[LockettePro] &cNon puoi piazzare un cartello qua.' +locked-manual: '&6[LockettePro] &aBlocco privatizzato correttamente.' +additional-sign-added-manual: '&6[LockettePro] &aCartello aggiuntivo piazzato correttamente.' +cannot-lock-manual: '&6[LockettePro] &cNon puoi privatizzare questo blocco.' +cannot-add-additional-sign-manual: '&6[LockettePro] &cNon puoi piazzare un cartello qua.' +not-locked-yet-manual: '&6[LockettePro] &cQuesto blocco non è stato ancora privatizzato.' +cannot-lock-door-nearby-manual: '&6[LockettePro] &cNon puoi privatizzare questo blocco perché c''è una porta nelle vicinanze.' +block-already-locked-manual: '&6[LockettePro] &cQuesto blocco è già privatizzato.' +block-is-not-lockable: '&6[LockettePro] &cQuesto blocco non è privatizzabile.' +sign-selected: '&6[LockettePro] &aCartello selezionato correttamente.' +break-own-lock-sign: '&6[LockettePro] &aHai rimosso il cartello di privatizzazione.' +cannot-break-this-lock-sign: '&6[LockettePro] &cNon puoi rimuovere questo cartello di privatizzazione.' +break-own-additional-sign: '&6[LockettePro] &aHai rimosso il cartello aggiuntivo.' +break-redundant-additional-sign: '&6[LockettePro] &aHai rimosso un cartello aggiuntivo.' +cannot-break-this-additional-sign: '&6[LockettePro] &cNon puoi rimuovere questo cartello aggiuntivo.' +block-is-locked: '&6[LockettePro] &cQuesto blocco è stato privatizzato da un giocatore.' +cannot-interfere-with-others: '&6[LockettePro] &cNon puoi piazzare un blocco che può interferire con altri.' +sign-error: '&4[ERRORE]' diff --git a/src/main/resources/lang_pl.yml b/src/main/resources/lang_pl.yml new file mode 100644 index 0000000..cfce093 --- /dev/null +++ b/src/main/resources/lang_pl.yml @@ -0,0 +1,32 @@ +#Polskie tłumaczenie od Szwendacz99 +command-usage: "&6[LockettePro] &bPomoc pluginu LockettePro\n&c1. W celu dodania gracza do tabliczki, kliknij prawym tabliczkę i wpisz /lock żeby zmienić daną linię.\n&c2. Żeby odświeżyć ustawienia, wpisz /lock reload.\nLockettePro od connection_lost" +you-can-quick-lock-it: '&6[LockettePro] &aKliknij prawym przycieskiem na blok, trzymając tabliczkę, aby zablokować.' +you-can-manual-lock-it: '&6[LockettePro] &aPostaw tabliczkę z napisem [Private] aby to zablokować.' +config-reloaded: '&6[LockettePro] &aUstawienia odświeżone.' +no-permission: '&6[LockettePro] &cNie masz uprawnień aby to zrobić.' +no-sign-selected: '&6[LockettePro] &cNajpierw wybierz tabliczkę klikając na nią prawym.' +sign-need-reselect: '&6[LockettePro] &cWybierz tabliczkę ponownie.' +line-is-too-long: '&6[LockettePro] &cTa linia jest za długa!' +cannot-change-this-line: '&6[LockettePro] &cNie możeszz zmienić tej linii.' +sign-changed: '&6[LockettePro] &aTabliczka edytowana pomyślnie.' +locked-quick: '&6[LockettePro] &aBlok zablokowany pomyślnie.' +additional-sign-added-quick: '&6[LockettePro] &aKolejna tabliczka dodana pomyślnie.' +cannot-lock-quick: '&6[LockettePro] &cNie możesz tego zablokować.' +cannot-add-additional-sign-quick: '&6[LockettePro] &cNie możesz tutaj postawić tabliczki' +locked-manual: '&6[LockettePro] &aBlok zablokowany pomyślnie.' +additional-sign-added-manual: '&6[LockettePro] &aKolejna tabliczka dodana pomyślnie.' +cannot-lock-manual: '&6[LockettePro] &cNie możesz tego zablokować.' +cannot-add-additional-sign-manual: '&6[LockettePro] &cNie możesz tutaj postawić tabliczki' +not-locked-yet-manual: '&6[LockettePro] &cTen blok nie jest jeszcze zablokowany.' +cannot-lock-door-nearby-manual: '&6[LockettePro] &cW pobliżu są drzwi.' +block-already-locked-manual: '&6[LockettePro] &cTen blok jest już zablokowany.' +block-is-not-lockable: '&6[LockettePro] &cTego bloku nie można zablokować.' +sign-selected: '&6[LockettePro] &aTabliczka wybrana.' +break-own-lock-sign: '&6[LockettePro] &aZniszczyłeś swoją bkokującą tabliczkę.' +cannot-break-this-lock-sign: '&6[LockettePro] &cNie możesz zniszczyć tej tabliczki blokującej.' +break-own-additional-sign: '&6[LockettePro] &aZniszczyłeś swoją dodatkową tabliczkę.' +break-redundant-additional-sign: '&6[LockettePro] &aZniszczyłeś niepotrzebną tabliczkę.' +cannot-break-this-additional-sign: '&6[LockettePro] &cNie możesz zniszczyć tej dodatkowej tabliczki.' +block-is-locked: '&6[LockettePro] &cTen blok jest zablokowany.' +cannot-interfere-with-others: '&6[LockettePro] &cNie możesz postawić bloku który może wpływać na inne.' +sign-error: '&4[BŁĄD]' \ No newline at end of file diff --git a/src/main/resources/lang_zh-cn.yml b/src/main/resources/lang_zh-cn.yml new file mode 100644 index 0000000..705ef12 --- /dev/null +++ b/src/main/resources/lang_zh-cn.yml @@ -0,0 +1,32 @@ +# Chinese (simplified) translation by connection_lost +command-usage: "&6[LockettePro] &bLockettePro 插件说明\n&c1. 为箱子添加或删除用户,首先右键选中一个牌子, 然后输入/lock 行号 玩家名 即可。\n&c2. 管理员重载插件配置,使用 /lock reload\nLockettePro by connection_lost" +you-can-quick-lock-it: '&6[LockettePro] 手持牌子右键箱子即可上锁。' +you-can-manual-lock-it: '&6[LockettePro] 贴上一个牌子并写上[Private]即可上锁。' +config-reloaded: '&6[LockettePro] &a配置已重新加载。' +no-permission: '&6[LockettePro] &c你没有使用这个指令的权限。' +no-sign-selected: '&6[LockettePro] &c请先右键选择一个牌子。' +sign-need-reselect: '&6[LockettePro] &c请重新选择一下牌子。' +line-is-too-long: '&6[LockettePro] &c你为牌子输入的文字太长了!' +cannot-change-this-line: '&6[LockettePro] &c你不可以修改这一行。' +sign-changed: '&6[LockettePro] &a牌子已修改。' +locked-quick: '&6[LockettePro] &a方块已上锁。' +additional-sign-added-quick: '&6[LockettePro] &a额外的用户牌子已添加。' +cannot-lock-quick: '&6[LockettePro] &c你不可以锁这个方块。' +cannot-add-additional-sign-quick: '&6[LockettePro] &c你不可以在这里添加牌子。' +locked-manual: '&6[LockettePro] &a方块已上锁。' +additional-sign-added-manual: '&6[LockettePro] &a额外的用户牌子已添加。' +cannot-lock-manual: '&6[LockettePro] &c你不可以锁这个方块。' +cannot-add-additional-sign-manual: '&6[LockettePro] &c你不可以在这里添加牌子。' +not-locked-yet-manual: '&6[LockettePro] &c这个方块还没有上锁。' +cannot-lock-door-nearby-manual: '&6[LockettePro] &c这附近有别人的门。' +block-already-locked-manual: '&6[LockettePro] &c这个方块已经被锁好了。' +block-is-not-lockable: '&6[LockettePro] &c这种方块不能上锁。' +sign-selected: '&6[LockettePro] &a你选中了一个牌子,输入/lock 行号 玩家名 来修改它。' +break-own-lock-sign: '&6[LockettePro] &a你拆掉了你的锁。' +cannot-break-this-lock-sign: '&6[LockettePro] &c你不可以拆掉别人的锁。' +break-own-additional-sign: '&6[LockettePro] &a你拆掉了你的额外用户牌子。' +break-redundant-additional-sign: '&6[LockettePro] &a你拆掉了废弃的额外用户牌子。' +cannot-break-this-additional-sign: '&6[LockettePro] &c你不可以拆掉别人的牌子。' +block-is-locked: '&6[LockettePro] &c这个方块已上锁。' +cannot-interfere-with-others: '&6[LockettePro] &c你不能在已上锁的方块附近放这个。' +sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..5eac849 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,25 @@ +name: LockettePro +main: me.crafter.mc.lockettepro.LockettePro +author: connection_lost +softdepend: [Vault, WorldGuard, ProtocolLib, CoreProtect] +loadbefore: [SignShop] +version: 2.10.10 +api-version: 1.13 +description: > + LockettePro is a chest protection plugin for Bukkit. It is 100% compatible with original Lockette, but delivers a lot of performance enhancements and feature options. +commands: + lockettepro: + permission: lockettepro.command + usage: | + /lock + aliases: [lock, lockette, lockit] +permissions: + lockettepro.command: + description: Command permission for LockettePro + default: true + lockettepro.lock: + description: Basic lock permission + default: true + lockettepro.edit: + description: Edit sign permission + default: true \ No newline at end of file From a5942b8a7c31dfa5146292587a52655fa05c18f2 Mon Sep 17 00:00:00 2001 From: DefineOutside <49797025+MWHunter@users.noreply.github.com> Date: Mon, 29 Mar 2021 11:46:01 -0500 Subject: [PATCH 3/4] Try and fix this git mess I made --- LockettePro/README.md | 22 - LockettePro/pom.xml | 118 --- .../mc/lockettepro/BlockDebugListener.java | 58 -- .../lockettepro/BlockEnvironmentListener.java | 118 --- .../BlockInventoryMoveListener.java | 93 --- .../mc/lockettepro/BlockPlayerListener.java | 379 --------- .../me/crafter/mc/lockettepro/Config.java | 287 ------- .../me/crafter/mc/lockettepro/Dependency.java | 83 -- .../mc/lockettepro/DependencyProtocolLib.java | 84 -- .../mc/lockettepro/DoorToggleTask.java | 29 - .../crafter/mc/lockettepro/LockettePro.java | 281 ------- .../mc/lockettepro/LocketteProAPI.java | 742 ------------------ .../java/me/crafter/mc/lockettepro/Utils.java | 337 -------- LockettePro/src/main/resources/config.yml | 70 -- LockettePro/src/main/resources/lang.yml | 31 - LockettePro/src/main/resources/lang_de.yml | 33 - LockettePro/src/main/resources/lang_es.yml | 32 - LockettePro/src/main/resources/lang_fr.yml | 33 - LockettePro/src/main/resources/lang_hu.yml | 32 - LockettePro/src/main/resources/lang_it.yml | 32 - LockettePro/src/main/resources/lang_pl.yml | 32 - LockettePro/src/main/resources/lang_zh-cn.yml | 32 - LockettePro/src/main/resources/plugin.yml | 25 - 23 files changed, 2983 deletions(-) delete mode 100644 LockettePro/README.md delete mode 100644 LockettePro/pom.xml delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/Config.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/Dependency.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/LockettePro.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java delete mode 100644 LockettePro/src/main/java/me/crafter/mc/lockettepro/Utils.java delete mode 100644 LockettePro/src/main/resources/config.yml delete mode 100644 LockettePro/src/main/resources/lang.yml delete mode 100644 LockettePro/src/main/resources/lang_de.yml delete mode 100644 LockettePro/src/main/resources/lang_es.yml delete mode 100644 LockettePro/src/main/resources/lang_fr.yml delete mode 100644 LockettePro/src/main/resources/lang_hu.yml delete mode 100644 LockettePro/src/main/resources/lang_it.yml delete mode 100644 LockettePro/src/main/resources/lang_pl.yml delete mode 100644 LockettePro/src/main/resources/lang_zh-cn.yml delete mode 100644 LockettePro/src/main/resources/plugin.yml diff --git a/LockettePro/README.md b/LockettePro/README.md deleted file mode 100644 index 8e2589c..0000000 --- a/LockettePro/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# LockettePro -### LockettePro - A much better Lockette plugin for Bukkit - -This fork is a continuation of the origial plugin: https://github.com/connection-lost/LockettePro -Also contains updates from: https://github.com/NyaaCat/LockettePro - -LockettePro is a block-protection plugin based on Lockette (https://github.com/Acru/Lockette), the code base is entirely re-written. It is 100% compatable with original Lockette, and the plugin behaviors are also 100% same. - -### LockettePro has a lot of enhancements compared to Lockette: - -1. Much better codebase and performance, fixed a lot of issues and glitches. -2. Real UUID support. -3. All blocks can be set to lockable or not. You can even prevent players from locking a chest. -4. Unlimited [Private], [More Users], [Timer:x] signs format. -5. Alert messages are editable, and UTF-8 characters are supported. -6. Lock expircy feature, locks can expire after a certain amount of time. - -### Links -Spigot release page: https://www.spigotmc.org/resources/lockettepro-for-1-14-1-15-1-16.74354/ -Bukkit release page: http://dev.bukkit.org/bukkit-plugins/lockettepro/ -MCBBS release page: http://www.mcbbs.net/thread-567962-1-1.html -MC 1.6~1.7 Port: https://github.com/connection-lost/LockettePro/releases/tag/v1.9.4 diff --git a/LockettePro/pom.xml b/LockettePro/pom.xml deleted file mode 100644 index cbbfc6c..0000000 --- a/LockettePro/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - 4.0.0 - groupId - LockettePro - 1.0-SNAPSHOT - jar - - 1.8 - 1.8 - 1.8 - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - ${java.version} - ${java.version} - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - com.comphenix - me.crafter.mc.shaded.com.comphenix - - - net.sf.cglib - me.crafter.mc.shaded.net.sf.cglib - - - net.bytebuddy - me.crafter.mc.shaded.net.bytebuddy - - - - - - - - - - src/main/resources - true - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - dmulloy2-repo - https://repo.dmulloy2.net/nexus/repository/public/ - - - coreprotect-repo - http://maven.playpro.com - - - sk89q-repo - https://maven.enginehub.org/repo/ - - - jitpack.io - https://jitpack.io - - - - - org.spigotmc - spigot-api - 1.16.5-R0.1-SNAPSHOT - provided - - - com.comphenix.protocol - ProtocolLib - 4.6.0 - provided - - - net.coreprotect - coreprotect - 19.5 - provided - - - com.sk89q.worldguard - worldguard-bukkit - 7.0.4-SNAPSHOT - provided - - - com.github.MilkBowl - VaultAPI - 1.7 - provided - - - \ No newline at end of file diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java deleted file mode 100644 index 41461c7..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockDebugListener.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.crafter.mc.lockettepro; - -import org.bukkit.ChatColor; -import org.bukkit.Tag; -import org.bukkit.block.Block; -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; - -public class BlockDebugListener implements Listener { - - @SuppressWarnings("deprecation") - @EventHandler(priority = EventPriority.MONITOR) - public void onDebugClick(PlayerInteractEvent event){ - Player p = event.getPlayer(); - if (p.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK){ - event.setCancelled(true); - Block b = event.getClickedBlock(); - p.sendMessage(ChatColor.GREEN + "==========================="); - p.sendMessage("isLockable: " + formatBoolean(LocketteProAPI.isLockable(b))); - p.sendMessage("isLocked: " + formatBoolean(LocketteProAPI.isLocked(b))); - p.sendMessage(" - isOwner/User: " + formatBoolean(LocketteProAPI.isOwner(b, p)) + ChatColor.RESET + "/" + formatBoolean(LocketteProAPI.isUser(b, p))); - p.sendMessage("isLockedSingle: " + formatBoolean(LocketteProAPI.isLockedSingleBlock(b, null))); - p.sendMessage(" - isOwner/UserSingle: " + formatBoolean(LocketteProAPI.isOwnerSingleBlock(b, null, p)) + ChatColor.RESET + "/" + formatBoolean(LocketteProAPI.isUserSingleBlock(b, null, p))); - p.sendMessage("isLockedUpDownLockedDoor: " + formatBoolean(LocketteProAPI.isUpDownLockedDoor(b))); - p.sendMessage(" - isOwner/UserSingle: " + formatBoolean(LocketteProAPI.isOwnerUpDownLockedDoor(b, p)) + ChatColor.RESET + "/" + formatBoolean(LocketteProAPI.isOwnerUpDownLockedDoor(b, p))); - if (LocketteProAPI.isLockSign(b)){ - p.sendMessage("isSignExpired: " + formatBoolean(LocketteProAPI.isSignExpired(b))); - p.sendMessage(" - created: " + Utils.getCreatedFromLine(((Sign)b.getState()).getLine(0))); - p.sendMessage(" - now : " + (int)(System.currentTimeMillis()/1000)); - } - - p.sendMessage("Block: " + b.getType().toString() + " " + b.getData()); - - if (Tag.WALL_SIGNS.isTagged(b.getType())){ - for (String line : ((Sign)b.getState()).getLines()){ - p.sendMessage(ChatColor.GREEN + line); - } - } - p.sendMessage(p.getUniqueId().toString()); - } - } - - public String formatBoolean(boolean tf){ - if (tf){ - return ChatColor.GREEN + "true"; - } else { - return ChatColor.RED + "false"; - } - } - -} - - diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java deleted file mode 100644 index 2aa407c..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockEnvironmentListener.java +++ /dev/null @@ -1,118 +0,0 @@ -package me.crafter.mc.lockettepro; - -import java.util.Iterator; - -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Enderman; -import org.bukkit.entity.Silverfish; -import org.bukkit.entity.Villager; -import org.bukkit.entity.Wither; -import org.bukkit.entity.Zombie; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockExplodeEvent; -import org.bukkit.event.block.BlockPistonExtendEvent; -import org.bukkit.event.block.BlockPistonRetractEvent; -import org.bukkit.event.block.BlockRedstoneEvent; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntityInteractEvent; -import org.bukkit.event.world.StructureGrowEvent; - -public class BlockEnvironmentListener implements Listener{ - - // Prevent explosion break block - @EventHandler(priority = EventPriority.HIGH) - public void onEntityExplode(EntityExplodeEvent event){ - if (Config.isProtectionExempted("explosion")) return; - Iterator it = event.blockList().iterator(); - while (it.hasNext()) { - Block block = it.next(); - if (LocketteProAPI.isProtected(block)) it.remove(); - } - } - - // Prevent bed break block - @EventHandler(priority = EventPriority.HIGH) - public void onBlockExplode(BlockExplodeEvent event){ - if (Config.isProtectionExempted("explosion")) return; - Iterator it = event.blockList().iterator(); - while (it.hasNext()) { - Block block = it.next(); - if (LocketteProAPI.isProtected(block)) it.remove(); - } - } - - // Prevent tree break block - @EventHandler(priority = EventPriority.HIGH) - public void onStructureGrow(StructureGrowEvent event){ - if (Config.isProtectionExempted("growth")) return; - for (BlockState blockstate : event.getBlocks()){ - if (LocketteProAPI.isProtected(blockstate.getBlock())){ - event.setCancelled(true); - return; - } - } - } - - // Prevent piston extend break lock - @EventHandler(priority = EventPriority.HIGH) - public void onPistonExtend(BlockPistonExtendEvent event){ - if (Config.isProtectionExempted("piston")) return; - for (Block block : event.getBlocks()){ - if (LocketteProAPI.isProtected(block)){ - event.setCancelled(true); - return; - } - } - } - - // Prevent piston retract break lock - @EventHandler(priority = EventPriority.HIGH) - public void onPistonRetract(BlockPistonRetractEvent event){ - if (Config.isProtectionExempted("piston")) return; - for (Block block : event.getBlocks()){ - if (LocketteProAPI.isProtected(block)){ - event.setCancelled(true); - return; - } - } - } - - // Prevent redstone current open doors - @EventHandler(priority = EventPriority.HIGH) - public void onBlockRedstoneChange(BlockRedstoneEvent event){ - if (Config.isProtectionExempted("redstone")) return; - if (LocketteProAPI.isProtected(event.getBlock())){ - event.setNewCurrent(event.getOldCurrent()); - } - } - - // Prevent villager open door - @EventHandler(priority = EventPriority.HIGH) - public void onVillagerOpenDoor(EntityInteractEvent event){ - if (Config.isProtectionExempted("villager")) return; - // Explicitly to villager vs all doors - if (event.getEntity() instanceof Villager && - (LocketteProAPI.isSingleDoorBlock(event.getBlock()) || LocketteProAPI.isDoubleDoorBlock(event.getBlock())) && - LocketteProAPI.isProtected(event.getBlock())){ - event.setCancelled(true); - } - } - - // Prevent mob change block - @EventHandler(priority = EventPriority.HIGH) - public void onMobChangeBlock(EntityChangeBlockEvent event) { - if ((event.getEntity() instanceof Enderman && !Config.isProtectionExempted("enderman")) ||// enderman pick up/place block - (event.getEntity() instanceof Wither && !Config.isProtectionExempted("wither")) ||// wither break block - (event.getEntity() instanceof Zombie && !Config.isProtectionExempted("zombie")) ||// zombie break door - (event.getEntity() instanceof Silverfish && !Config.isProtectionExempted("silverfish"))){ - if (LocketteProAPI.isProtected(event.getBlock())){ - event.setCancelled(true); - } - }// ignore other reason (boat break lily pad, arrow ignite tnt, etc) - } - -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java deleted file mode 100644 index 01e0f95..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockInventoryMoveListener.java +++ /dev/null @@ -1,93 +0,0 @@ -package me.crafter.mc.lockettepro; - -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.block.DoubleChest; -import org.bukkit.block.Hopper; -import org.bukkit.entity.minecart.HopperMinecart; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryMoveItemEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; - -public class BlockInventoryMoveListener implements Listener { - - @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) - public void onInventoryMove(InventoryMoveItemEvent event){ - if (Config.isItemTransferOutBlocked() || Config.getHopperMinecartAction() != (byte)0){ - if (isInventoryLocked(event.getSource())){ - if (Config.isItemTransferOutBlocked()){ - event.setCancelled(true); - } - // Additional Hopper Minecart Check - if (event.getDestination().getHolder() instanceof HopperMinecart) { - byte hopperminecartaction = Config.getHopperMinecartAction(); - switch (hopperminecartaction){ - // case 0 - Impossible - case (byte)1: // Cancel only, it is not called if !Config.isItemTransferOutBlocked() - event.setCancelled(true); - break; - case (byte)2: // Extra action - HopperMinecart removal - event.setCancelled(true); - ((HopperMinecart)event.getDestination().getHolder()).remove(); - break; - } - } else if (event.getDestination().getHolder() instanceof Hopper || event.getSource().getHolder() instanceof Hopper) { - if (isInventoryLocked(event.getDestination())) { - Block sourceInventoryBlock = event.getSource().getLocation().getBlock(); - Block destinationInventoryBlock = event.getDestination().getLocation().getBlock(); - if (sourceInventoryBlock != null && destinationInventoryBlock != null) { - String sourceOwner = LocketteProAPI.getOwner(sourceInventoryBlock); - String destOwner = LocketteProAPI.getOwner(destinationInventoryBlock); - if (destOwner != null && sourceOwner != null) { - if (sourceOwner.equalsIgnoreCase(destOwner)) { - event.setCancelled(false); - } - } - } - } - } - return; - } - } - if (Config.isItemTransferInBlocked()){ - if (isInventoryLocked(event.getDestination())){ - event.setCancelled(true); - return; - } - } - } - - public boolean isInventoryLocked(Inventory inventory){ - InventoryHolder inventoryholder = inventory.getHolder(); - if (inventoryholder instanceof DoubleChest){ - inventoryholder = ((DoubleChest)inventoryholder).getLeftSide(); - } - if (inventoryholder instanceof BlockState){ - Block block = ((BlockState)inventoryholder).getBlock(); - if (Config.isCacheEnabled()){ // Cache is enabled - if (Utils.hasValidCache(block)){ - return Utils.getAccess(block); - } else { - if (LocketteProAPI.isLocked(block)){ - Utils.setCache(block, true); - return true; - } else { - Utils.setCache(block, false); - return false; - } - } - } else { // Cache is disabled - if (LocketteProAPI.isLocked(block)){ - return true; - } else { - return false; - } - } - } - return false; - } - -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java deleted file mode 100644 index 8d56b84..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/BlockPlayerListener.java +++ /dev/null @@ -1,379 +0,0 @@ -package me.crafter.mc.lockettepro; - -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerBucketFillEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerTakeLecternBookEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.ArrayList; -import java.util.List; - -public class BlockPlayerListener implements Listener { - - // Quick protect for chests - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerQuickLockChest(PlayerInteractEvent event){ - // Check quick lock enabled - if (Config.getQuickProtectAction() == (byte)0) return; - // Get player and action info - Action action = event.getAction(); - Player player = event.getPlayer(); - // Check action correctness - if (action == Action.RIGHT_CLICK_BLOCK && Tag.SIGNS.isTagged(player.getInventory().getItemInMainHand().getType())) { - if (player.getGameMode().equals(GameMode.SPECTATOR)) { - return; - } - // Check quick lock action correctness - if (!((event.getPlayer().isSneaking() && Config.getQuickProtectAction() == (byte)2) || - (!event.getPlayer().isSneaking() && Config.getQuickProtectAction() == (byte)1))) return; - // Check permission - if (!player.hasPermission("lockettepro.lock")) return; - // Get target block to lock - BlockFace blockface = event.getBlockFace(); - if (blockface == BlockFace.NORTH || blockface == BlockFace.WEST || blockface == BlockFace.EAST || blockface == BlockFace.SOUTH){ - Block block = event.getClickedBlock(); - if (block == null) return; - // Check permission with external plugin - if (Dependency.isProtectedFrom(block, player)) return; // blockwise - if (Dependency.isProtectedFrom(block.getRelative(event.getBlockFace()), player)) return; // signwise - // Check whether locking location is obstructed - Block signLoc = block.getRelative(blockface); - if (!signLoc.isEmpty()) return; - // Check whether this block is lockable - if (LocketteProAPI.isLockable(block)){ - // Is this block already locked? - boolean locked = LocketteProAPI.isLocked(block); - // Cancel event here - event.setCancelled(true); - // Check lock info info - if (!locked && !LocketteProAPI.isUpDownLockedDoor(block)){ - Material signType = player.getInventory().getItemInMainHand().getType(); - // Not locked, not a locked door nearby - Utils.removeASign(player); - // Send message - Utils.sendMessages(player, Config.getLang("locked-quick")); - // Put sign on - Block newsign = Utils.putSignOn(block, blockface, Config.getDefaultPrivateString(), player.getName(), signType); - Utils.resetCache(block); - // Cleanups - UUID - if (Config.isUuidEnabled()){ - Utils.updateLineByPlayer(newsign, 1, player); - } - // Cleanups - Expiracy - if (Config.isLockExpire()) { - if (player.hasPermission("lockettepro.noexpire")) { - Utils.updateLineWithTime(newsign, true); // set created to -1 (no expire) - } else { - Utils.updateLineWithTime(newsign, false); // set created to now - } - } - Dependency.logPlacement(player, newsign); - } else if (!locked && LocketteProAPI.isOwnerUpDownLockedDoor(block, player)){ - // Not locked, (is locked door nearby), is owner of locked door nearby - Material signType = player.getInventory().getItemInMainHand().getType(); - Utils.removeASign(player); - Utils.sendMessages(player, Config.getLang("additional-sign-added-quick")); - Utils.putSignOn(block, blockface, Config.getDefaultAdditionalString(), "", signType); - Dependency.logPlacement(player, block.getRelative(blockface)); - } else if (LocketteProAPI.isOwner(block, player)) { - // Locked, (not locked door nearby), is owner of locked block - Material signType = player.getInventory().getItemInMainHand().getType(); - Utils.removeASign(player); - Utils.putSignOn(block, blockface, Config.getDefaultAdditionalString(), "", signType); - Utils.sendMessages(player, Config.getLang("additional-sign-added-quick")); - Dependency.logPlacement(player, block.getRelative(blockface)); - } else { - // Cannot lock this block - Utils.sendMessages(player, Config.getLang("cannot-lock-quick")); - } - } - } - } - } - - // Manual protection - @EventHandler(priority = EventPriority.NORMAL) - public void onManualLock(SignChangeEvent event){ - if (!Tag.WALL_SIGNS.isTagged(event.getBlock().getType())) return; - String topline = event.getLine(0); - if (topline == null) topline = ""; - Player player = event.getPlayer(); - /* Issue #46 - Old version of Minecraft trim signs in unexpected way. - * This is caused by Minecraft was doing: (unconfirmed but seemingly) - * Place Sign -> Event Fire -> Trim Sign - * The event.getLine() will be inaccurate if the line has white space to trim - * - * This will cause player without permission will be able to lock chests by - * adding a white space after the [private] word. - * Currently this is fixed by using trimmed line in checking permission. Trimmed - * line should not be used anywhere else. - */ - if (!player.hasPermission("lockettepro.lock")){ - String toplinetrimmed = topline.trim(); - if (LocketteProAPI.isLockString(toplinetrimmed) || LocketteProAPI.isAdditionalString(toplinetrimmed)){ - event.setLine(0, Config.getLang("sign-error")); - Utils.sendMessages(player, Config.getLang("cannot-lock-manual")); - return; - } - } - if (LocketteProAPI.isLockString(topline) || LocketteProAPI.isAdditionalString(topline)){ - Block block = LocketteProAPI.getAttachedBlock(event.getBlock()); - if (LocketteProAPI.isLockable(block)){ - if (Dependency.isProtectedFrom(block, player)){ // External check here - event.setLine(0, Config.getLang("sign-error")); - Utils.sendMessages(player, Config.getLang("cannot-lock-manual")); - return; - } - boolean locked = LocketteProAPI.isLocked(block); - if (!locked && !LocketteProAPI.isUpDownLockedDoor(block)){ - if (LocketteProAPI.isLockString(topline)){ - Utils.sendMessages(player, Config.getLang("locked-manual")); - if (!player.hasPermission("lockettepro.lockothers")){ // Player with permission can lock with another name - event.setLine(1, player.getName()); - } - Utils.resetCache(block); - } else { - Utils.sendMessages(player, Config.getLang("not-locked-yet-manual")); - event.setLine(0, Config.getLang("sign-error")); - } - } else if (!locked && LocketteProAPI.isOwnerUpDownLockedDoor(block, player)){ - if (LocketteProAPI.isLockString(topline)){ - Utils.sendMessages(player, Config.getLang("cannot-lock-door-nearby-manual")); - event.setLine(0, Config.getLang("sign-error")); - } else { - Utils.sendMessages(player, Config.getLang("additional-sign-added-manual")); - } - } else if (LocketteProAPI.isOwner(block, player)){ - if (LocketteProAPI.isLockString(topline)){ - Utils.sendMessages(player, Config.getLang("block-already-locked-manual")); - event.setLine(0, Config.getLang("sign-error")); - } else { - Utils.sendMessages(player, Config.getLang("additional-sign-added-manual")); - } - } else { // Not possible to fall here except override - Utils.sendMessages(player, Config.getLang("block-already-locked-manual")); - event.getBlock().breakNaturally(); - Utils.playAccessDenyEffect(player, block); - } - } else { - Utils.sendMessages(player, Config.getLang("block-is-not-lockable")); - event.setLine(0, Config.getLang("sign-error")); - Utils.playAccessDenyEffect(player, block); - } - } - } - - // Player select sign - @EventHandler(priority = EventPriority.LOW) - public void playerSelectSign(PlayerInteractEvent event){ - Block block = event.getClickedBlock(); - if (block == null) return; - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasBlock() && Tag.WALL_SIGNS.isTagged(block.getType())) { - Player player = event.getPlayer(); - if (!player.hasPermission("lockettepro.edit")) return; - if (LocketteProAPI.isOwnerOfSign(block, player) || (LocketteProAPI.isLockSignOrAdditionalSign(block) && player.hasPermission("lockettepro.admin.edit"))){ - Utils.selectSign(player, block); - Utils.sendMessages(player, Config.getLang("sign-selected")); - Utils.playLockEffect(player, block); - } - } - } - - // Player break sign - @EventHandler(priority = EventPriority.HIGH) - public void onAttemptBreakSign(BlockBreakEvent event){ - if (event.isCancelled()) return; - Block block = event.getBlock(); - Player player = event.getPlayer(); - if (player.hasPermission("lockettepro.admin.break")) return; - if (LocketteProAPI.isLockSign(block)){ - if (LocketteProAPI.isOwnerOfSign(block, player)){ - Utils.sendMessages(player, Config.getLang("break-own-lock-sign")); - Utils.resetCache(LocketteProAPI.getAttachedBlock(block)); - // Remove additional signs? - } else { - Utils.sendMessages(player, Config.getLang("cannot-break-this-lock-sign")); - event.setCancelled(true); - Utils.playAccessDenyEffect(player, block); - } - } else if (LocketteProAPI.isAdditionalSign(block)){ - // TODO the next line is spaghetti - if (!LocketteProAPI.isLocked(LocketteProAPI.getAttachedBlock(block))){ - // phew, the locked block is expired! - // nothing - } else if (LocketteProAPI.isOwnerOfSign(block, player)){ - Utils.sendMessages(player, Config.getLang("break-own-additional-sign")); - } else if (!LocketteProAPI.isProtected(LocketteProAPI.getAttachedBlock(block))){ - Utils.sendMessages(player, Config.getLang("break-redundant-additional-sign")); - } else { - Utils.sendMessages(player, Config.getLang("cannot-break-this-additional-sign")); - event.setCancelled(true); - Utils.playAccessDenyEffect(player, block); - } - } - } - - // Protect block from being destroyed - @EventHandler(priority = EventPriority.HIGH) - public void onAttemptBreakLockedBlocks(BlockBreakEvent event){ - if (event.isCancelled()) return; - Block block = event.getBlock(); - Player player = event.getPlayer(); - if (LocketteProAPI.isLocked(block) || LocketteProAPI.isUpDownLockedDoor(block)){ - Utils.sendMessages(player, Config.getLang("block-is-locked")); - event.setCancelled(true); - Utils.playAccessDenyEffect(player, block); - } - } - - // Protect block from being used & handle double doors - @EventHandler(priority = EventPriority.HIGH) - public void onAttemptInteractLockedBlocks(PlayerInteractEvent event) { - if (event.hasBlock() == false) return; - Action action = event.getAction(); - Block block = event.getClickedBlock(); - if (LockettePro.needCheckHand() && LocketteProAPI.isChest(block)){ - if (event.getHand() != EquipmentSlot.HAND){ - if (action == Action.RIGHT_CLICK_BLOCK){ - /*if (LocketteProAPI.isChest(block)){ - // something not right - event.setCancelled(true); - }*/ - event.setCancelled(true); - return; - } - } - } - switch (action){ - case LEFT_CLICK_BLOCK: - case RIGHT_CLICK_BLOCK: - Player player = event.getPlayer(); - if (((LocketteProAPI.isLocked(block) && !LocketteProAPI.isUser(block, player)) || (LocketteProAPI.isUpDownLockedDoor(block) && !LocketteProAPI.isUserUpDownLockedDoor(block, player))) && !player.hasPermission("lockettepro.admin.use")){ - Utils.sendMessages(player, Config.getLang("block-is-locked")); - event.setCancelled(true); - Utils.playAccessDenyEffect(player, block); - } else { // Handle double doors - if (action == Action.RIGHT_CLICK_BLOCK) { - if ((LocketteProAPI.isDoubleDoorBlock(block) || LocketteProAPI.isSingleDoorBlock(block)) && LocketteProAPI.isLocked(block)){ - Block doorblock = LocketteProAPI.getBottomDoorBlock(block); - org.bukkit.block.data.Openable openablestate = (org.bukkit.block.data.Openable ) doorblock.getBlockData(); - boolean shouldopen = !openablestate.isOpen(); // Move to here - int closetime = LocketteProAPI.getTimerDoor(doorblock); - List doors = new ArrayList(); - doors.add(doorblock); - if (doorblock.getType() == Material.IRON_DOOR || doorblock.getType() == Material.IRON_TRAPDOOR){ - LocketteProAPI.toggleDoor(doorblock, shouldopen); - } - for (BlockFace blockface : LocketteProAPI.newsfaces){ - Block relative = doorblock.getRelative(blockface); - if (relative.getType() == doorblock.getType()){ - doors.add(relative); - LocketteProAPI.toggleDoor(relative, shouldopen); - } - } - if (closetime > 0) { - for (Block door : doors) { - if (door.hasMetadata("lockettepro.toggle")) { - return; - } - } - for (Block door : doors) { - door.setMetadata("lockettepro.toggle", new FixedMetadataValue(LockettePro.getPlugin(), true)); - } - Bukkit.getScheduler().runTaskLater(LockettePro.getPlugin(), new DoorToggleTask(doors), closetime*20); - } - } - } - } - break; - default: - break; - } - } - - // Protect block from interfere block - @EventHandler(priority = EventPriority.HIGH) - public void onAttemptPlaceInterfereBlocks(BlockPlaceEvent event){ - if (event.isCancelled()) return; - Block block = event.getBlock(); - Player player = event.getPlayer(); - if (player.hasPermission("lockettepro.admin.interfere")) return; - if (LocketteProAPI.mayInterfere(block, player)){ - Utils.sendMessages(player, Config.getLang("cannot-interfere-with-others")); - event.setCancelled(true); - Utils.playAccessDenyEffect(player, block); - } - } - - // Tell player about lockettepro - @EventHandler(priority = EventPriority.MONITOR) - public void onPlaceFirstBlockNotify(BlockPlaceEvent event){ - if (event.isCancelled()) return; - Block block = event.getBlock(); - Player player = event.getPlayer(); - if (!player.hasPermission("lockettepro.lock")) return; - if (Utils.shouldNotify(player) && Config.isLockable(block.getType())){ - switch (Config.getQuickProtectAction()){ - case (byte)0: - Utils.sendMessages(player, Config.getLang("you-can-manual-lock-it")); - break; - case (byte)1: - case (byte)2: - Utils.sendMessages(player, Config.getLang("you-can-quick-lock-it")); - break; - } - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void onBucketEmpty(PlayerBucketEmptyEvent event) { - Player player = event.getPlayer(); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - if (LocketteProAPI.isProtected(block) && !(LocketteProAPI.isOwner(block, player) || LocketteProAPI.isOwnerOfSign(block, player))) { - event.setCancelled(true); - new BukkitRunnable() { - @Override - public void run() { - if (!player.isDead()) { - player.updateInventory(); - } - } - }.runTaskLater(LockettePro.getPlugin(), 1L); - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void onBucketUse(PlayerBucketFillEvent event) { - Player player = event.getPlayer(); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - if (LocketteProAPI.isProtected(block) && !(LocketteProAPI.isOwner(block, player) || LocketteProAPI.isOwnerOfSign(block, player))) { - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void onLecternTake(PlayerTakeLecternBookEvent event){ - Player player = event.getPlayer(); - Block block = event.getLectern().getBlock(); - if(LocketteProAPI.isProtected(block) && !(LocketteProAPI.isOwner(block, player) || LocketteProAPI.isOwnerOfSign(block, player))){ - event.setCancelled(true); - } - } -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/Config.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/Config.java deleted file mode 100644 index 87a05e1..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/Config.java +++ /dev/null @@ -1,287 +0,0 @@ -package me.crafter.mc.lockettepro; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.Plugin; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class Config { - - private static Plugin plugin; - private static FileConfiguration config; - private static FileConfiguration lang; - private static String langfilename = "lang.yml"; - private static boolean uuid = false; - private static Set lockables = new HashSet(); - private static Set privatestrings = new HashSet(); - private static Set additionalstrings = new HashSet(); - private static Set everyonestrings = new HashSet(); - private static Set timerstrings = new HashSet(); - private static String defaultprivatestring = "[Private]"; - private static String defaultadditionalstring = "[More Users]"; - private static byte enablequickprotect = (byte)1; - private static boolean blockinterfereplacement = true; - private static boolean blockitemtransferin = false; - private static boolean blockitemtransferout = false; - private static int cachetime = 0; - private static boolean cacheenabled = false; - private static byte blockhopperminecart = 0; - private static boolean lockexpire = false; - private static double lockexpiredays = 60D; - public static boolean protocollib = false; - public static boolean worldguard = false; - public static boolean coreprotect = false; - private static long lockdefaultcreatetime = -1L; - private static String lockexpirestring = ""; - private static Set protectionexempt = new HashSet(); - - public Config(Plugin _plugin){ - plugin = _plugin; - reload(); - } - - public static void reload(){ - initDefaultConfig(); - initAdditionalFiles(); - config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml")); - uuid = config.getBoolean("enable-uuid-support", false); - protocollib = config.getBoolean("protocollib", true); - worldguard = config.getBoolean("worldguard", true); - coreprotect = config.getBoolean("coreprotect", true); - langfilename = config.getString("language-file-name", "lang.yml"); - lang = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), langfilename)); - String enablequickprotectstring = config.getString("enable-quick-protect", "true"); - switch (enablequickprotectstring.toLowerCase()){ - case "true": - enablequickprotect = 1; - break; - case "false": - enablequickprotect = 0; - break; - case "sneak": - enablequickprotect = 2; - break; - default: - enablequickprotect = 1; - break; - } - blockinterfereplacement = config.getBoolean("block-interfere-placement", true); - blockitemtransferin = config.getBoolean("block-item-transfer-in", false); - blockitemtransferout = config.getBoolean("block-item-transfer-out", true); - - List privatestringlist = config.getStringList("private-signs"); - List additionalstringlist = config.getStringList("additional-signs"); - List everyonestringlist = config.getStringList("everyone-signs"); - List protectionexemptstringlist = config.getStringList("protection-exempt"); - privatestrings = new HashSet(privatestringlist); - additionalstrings = new HashSet(additionalstringlist); - everyonestrings = new HashSet(everyonestringlist); - protectionexempt = new HashSet(protectionexemptstringlist); - defaultprivatestring = privatestringlist.get(0); - defaultadditionalstring = additionalstringlist.get(0); - - List timerstringlist = config.getStringList("timer-signs"); - List timerstringlist2 = new ArrayList(); - for (String timerstring : timerstringlist){ - if (timerstring.contains("@")) timerstringlist2.add(timerstring); - } - timerstrings = new HashSet(timerstringlist2); - - cachetime = config.getInt("cache-time-seconds", 0) * 1000; - cacheenabled = (config.getInt("cache-time-seconds", 0) > 0); - if (cacheenabled){ - plugin.getLogger().info("Cache is enabled! In case of inconsistency, turn off immediately."); - } - - String blockhopperminecartstring = config.getString("block-hopper-minecart", "remove"); - switch (blockhopperminecartstring.toLowerCase()){ - case "true": - blockhopperminecart = 1; - break; - case "false": - blockhopperminecart = 0; - break; - case "remove": - blockhopperminecart = 2; - break; - default: - blockhopperminecart = 2; - break; - } - - lockexpire = config.getBoolean("lock-expire", false); - lockexpiredays = config.getDouble("lock-expire-days", 999.9D); - lockdefaultcreatetime = config.getLong("lock-default-create-time-unix", -1L); - if (lockdefaultcreatetime < -1L) lockdefaultcreatetime = -1L; - lockexpirestring = ChatColor.translateAlternateColorCodes('&', - config.getString("lock-expire-string", "&3[Expired]")); - List unprocesseditems = config.getStringList("lockables"); - lockables = new HashSet(); - for (String unprocesseditem : unprocesseditems){ - if (unprocesseditem.equals("*")){ - for (Material material : Material.values()){ - lockables.add(material); - } - plugin.getLogger().info("All blocks are default to be lockable!"); - plugin.getLogger().info("Add '-' to exempt a block, such as '-STONE'!"); - continue; - } - boolean add = true; - if (unprocesseditem.startsWith("-")){ - add = false; - unprocesseditem = unprocesseditem.substring(1); - } - Material material = Material.getMaterial(unprocesseditem); - if (material == null || !material.isBlock()) { - plugin.getLogger().warning(unprocesseditem + " is not a block!"); - } else { - if (add) { - lockables.add(material); - } else { - lockables.remove(material); - } - } - } - lockables.removeAll(Tag.SIGNS.getValues()); - lockables.remove(Material.SCAFFOLDING); - } - - public static void initDefaultConfig(){ - plugin.saveDefaultConfig(); - config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml")); - config.addDefault("language-file-name", "lang.yml"); - config.addDefault("enable-quick-protect", true); - config.addDefault("enable-uuid-support", false); - config.addDefault("block-interfere-placement", true); - config.addDefault("block-item-transfer-in", false); - config.addDefault("block-item-transfer-out", true); - config.addDefault("block-hopper-minecart", "remove"); - config.addDefault("cache-time-seconds", 0); - - String[] private_signs = {"[Private]", "[private]"}; - config.addDefault("private-signs", private_signs); - String[] additional_signs = {"[More Users]", "[more Users]"}; - config.addDefault("additional-signs", additional_signs); - String[] everyone_signs = {"[Everyone]", "[everyone]"}; - config.addDefault("everyone-signs", everyone_signs); - String[] timer_signs = {"[Timer:@]", "[timer:@]"}; - config.addDefault("timer-signs", timer_signs); - String[] lockables = {"CHEST","TRAPPED_CHEST","FURNACE","BURNING_FURNACE","HOPPER","BREWING_STAND","DIAMOND_BLOCK", - "OAK_DOOR","SPRUCE_DOOR","BIRCH_DOOR","JUNGLE_DOOR","ACACIA_DOOR","DARK_OAK_DOOR","IRON_DOOR", "LECTERN", "CRIMSON_DOOR", "WARPED_DOOR"}; - config.addDefault("lockables", lockables); - String[] protection_exempt = {"nothing"}; - config.addDefault("protection-exempt", protection_exempt); - - config.addDefault("lock-expire", false); - config.addDefault("lock-expire-days", 999.9D); - config.addDefault("lock-default-create-time-unix", -1L); - config.addDefault("lock-expire-string", "&3[Expired]"); - - config.options().copyDefaults(true); - try { - config.save(new File(plugin.getDataFolder(), "config.yml")); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void initAdditionalFiles(){ - String[] availablefiles = {"lang.yml", "lang_zh-cn.yml", "lang_es.yml", "lang_it.yml", "lang_de.yml", - "lang_hu.yml", "lang_pl.yml", "lang_fr.yml"}; - for (String filename : availablefiles){ - File langfile = new File(plugin.getDataFolder(), filename); - if (!langfile.exists()){ - plugin.saveResource(filename, false); - } - } - } - - public static byte getQuickProtectAction() {return enablequickprotect;} - public static boolean isInterferePlacementBlocked() {return blockinterfereplacement;} - public static boolean isItemTransferInBlocked() {return blockitemtransferin;} - public static boolean isItemTransferOutBlocked() {return blockitemtransferout;} - public static byte getHopperMinecartAction() {return blockhopperminecart;} - - public static boolean isLockExpire() {return lockexpire;} - public static Double getLockExpireDays() {return lockexpiredays;} - public static long getLockDefaultCreateTimeUnix() {return lockdefaultcreatetime;} - public static String getLockExpireString() {return lockexpirestring;} - - public static String getLang(String path){ - return ChatColor.translateAlternateColorCodes('&', lang.getString(path, "")); - } - - public static boolean isUuidEnabled(){ - return uuid; - } - - public static boolean isLockable(Material material){ - return lockables.contains(material); - } - - public static boolean isPrivateSignString(String message){ - return privatestrings.contains(message); - } - - public static boolean isAdditionalSignString(String message){ - return additionalstrings.contains(message); - } - - public static boolean isEveryoneSignString(String message){ - return everyonestrings.contains(message); - } - - public static boolean isTimerSignString(String message){ - for (String timerstring : timerstrings){ - String[] splitted = timerstring.split("@", 2); - if (message.startsWith(splitted[0]) && message.endsWith(splitted[1])){ - return true; - } - } - return false; - } - - public static int getTimer(String message){ - for (String timerstring : timerstrings){ - String[] splitted = timerstring.split("@", 2); - if (message.startsWith(splitted[0]) && message.endsWith(splitted[1])){ - String newmessage = message.replace(splitted[0], "").replace(splitted[1], ""); - try { - int seconds = Integer.parseInt(newmessage); - return Math.min(seconds, 20); - } catch (Exception ex){} - } - } - return 0; - } - - public static String getDefaultPrivateString(){ - return defaultprivatestring; - } - - public static String getDefaultAdditionalString(){ - return defaultadditionalstring; - } - - public static int getCacheTimeMillis(){ - return cachetime; - } - - public static boolean isCacheEnabled(){ - return cacheenabled; - } - - public static boolean isProtectionExempted(String against){ - return protectionexempt.contains(against); - } - -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/Dependency.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/Dependency.java deleted file mode 100644 index 59d4d61..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/Dependency.java +++ /dev/null @@ -1,83 +0,0 @@ -package me.crafter.mc.lockettepro; - -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import net.coreprotect.CoreProtect; -import net.coreprotect.CoreProtectAPI; -import net.milkbowl.vault.permission.Permission; -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.RegisteredServiceProvider; -import org.bukkit.scoreboard.Team; - -public class Dependency { - - protected static WorldGuardPlugin worldguard = null; - protected static Plugin vault = null; - protected static Permission permission = null; - private static CoreProtectAPI coreProtectAPI; - - public Dependency(Plugin plugin) { - // WorldGuard - Plugin worldguardplugin = plugin.getServer().getPluginManager().getPlugin("WorldGuard"); - if (!Config.worldguard || !(worldguardplugin instanceof WorldGuardPlugin)) { - worldguard = null; - } else { - worldguard = (WorldGuardPlugin) worldguardplugin; - } - // Vault - vault = plugin.getServer().getPluginManager().getPlugin("Vault"); - if (vault != null) { - RegisteredServiceProvider rsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class); - permission = rsp.getProvider(); - } - //&& CoreProtect.getInstance().getAPI().APIVersion() == 6 - if (Config.coreprotect && Bukkit.getPluginManager().getPlugin("CoreProtect") != null) { - try { - coreProtectAPI = CoreProtect.getInstance().getAPI(); - if (!coreProtectAPI.isEnabled()) { - coreProtectAPI = null; - plugin.getLogger().warning("CoreProtect API is not enabled!"); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - public static boolean isProtectedFrom(Block block, Player player){ - if (worldguard != null) { - if (!worldguard.createProtectionQuery().testBlockPlace(player, block.getLocation(), block.getType())) { - return true; - } - } - return false; - } - - public static boolean isPermissionGroupOf(String line, Player player){ - if (vault != null){ - try { - String[] groups = permission.getPlayerGroups(player); - for (String group : groups){ - if (line.equals("[" + group + "]")) return true; - } - } catch (Exception e){} - } - return false; - } - - public static boolean isScoreboardTeamOf(String line, Player player){ - Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(player.getName()); - if (team != null){ - if (line.equals("[" + team.getName() + "]")) return true; - } - return false; - } - - public static void logPlacement(Player player, Block block) { - if (coreProtectAPI != null && coreProtectAPI.isEnabled()) { - coreProtectAPI.logPlacement(player.getName(), block.getLocation(), block.getType(), block.getBlockData()); - } - } -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java deleted file mode 100644 index 27ef9b1..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/DependencyProtocolLib.java +++ /dev/null @@ -1,84 +0,0 @@ -package me.crafter.mc.lockettepro; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.wrappers.WrappedChatComponent; -import com.comphenix.protocol.wrappers.nbt.NbtCompound; -import com.comphenix.protocol.wrappers.nbt.NbtFactory; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import java.util.List; - -public class DependencyProtocolLib { - - public static void setUpProtocolLib(Plugin plugin){ - if (Config.protocollib) { - addTileEntityDataListener(plugin); - addMapChunkListener(plugin); - } - } - - public static void cleanUpProtocolLib(Plugin plugin){ - try { - if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")){ - ProtocolLibrary.getProtocolManager().removePacketListeners(plugin); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void addTileEntityDataListener(Plugin plugin){ - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOW, PacketType.Play.Server.TILE_ENTITY_DATA) { - @Override - public void onPacketSending(PacketEvent event) { - PacketContainer packet = event.getPacket(); - if (packet.getIntegers().read(0) != 9) return; - NbtCompound nbtcompound = (NbtCompound) packet.getNbtModifier().read(0); - onSignSend(event.getPlayer(), nbtcompound); - } - }); - } - - public static void addMapChunkListener(Plugin plugin){ - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOW, PacketType.Play.Server.MAP_CHUNK) { - @Override - public void onPacketSending(PacketEvent event) { - PacketContainer packet = event.getPacket(); - List tileentitydatas = packet.getSpecificModifier(List.class).read(0); - for (Object tileentitydata : tileentitydatas) { - NbtCompound nbtcompound = NbtFactory.fromNMSCompound(tileentitydata); - if (!"minecraft:sign".equals(nbtcompound.getString("id"))) continue; - onSignSend(event.getPlayer(), nbtcompound); - } - } - }); - } - - public static void onSignSend(Player player, NbtCompound nbtcompound) { - String raw_line1 = nbtcompound.getString("Text1"); - if (LocketteProAPI.isLockStringOrAdditionalString(Utils.getSignLineFromUnknown(raw_line1))) { - // Private line - String line1 = Utils.getSignLineFromUnknown(nbtcompound.getString("Text1")); - if (LocketteProAPI.isLineExpired(line1)) { - nbtcompound.put("Text1", WrappedChatComponent.fromText(Config.getLockExpireString()).getJson()); - } else { - nbtcompound.put("Text1", WrappedChatComponent.fromText(Utils.StripSharpSign(line1)).getJson()); - } - // Other line - for (int i = 2; i <= 4; i++) { - String line = Utils.getSignLineFromUnknown(nbtcompound.getString("Text" + i)); - if (Utils.isUsernameUuidLine(line)) { - nbtcompound.put("Text" + i, WrappedChatComponent.fromText(Utils.getUsernameFromLine(line)).getJson()); - } - } - } - } - -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java deleted file mode 100644 index 347c438..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/DoorToggleTask.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.crafter.mc.lockettepro; - -import org.bukkit.block.Block; - -import java.util.List; - -public class DoorToggleTask implements Runnable{ - - private List doors; - - public DoorToggleTask(List doors_){ - doors = doors_; - } - - @Override - public void run() { - for (Block door : doors) { - door.removeMetadata("lockettepro.toggle", LockettePro.getPlugin()); - } - for (Block door : doors){ - if (LocketteProAPI.isDoubleDoorBlock(door)){ - Block doorbottom = LocketteProAPI.getBottomDoorBlock(door); - //LocketteProAPI.toggleDoor(doorbottom, open); - LocketteProAPI.toggleDoor(doorbottom); - } - } - } - -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/LockettePro.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/LockettePro.java deleted file mode 100644 index 2b3f81c..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/LockettePro.java +++ /dev/null @@ -1,281 +0,0 @@ -package me.crafter.mc.lockettepro; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; - -import java.util.ArrayList; -import java.util.List; - -public class LockettePro extends JavaPlugin { - - private static Plugin plugin; - private boolean debug = false; - private static boolean needcheckhand = true; - public static boolean is16version = true; - - public void onEnable(){ - plugin = this; - checkMcVersion(); - // Version - try { - Material.BARREL.isItem(); - } catch (Exception e) { - setEnabled(false); - getLogger().warning("This plugin is not compatible with your server version!"); - } - getLogger().info("==================================="); - if (!isEnabled()) { - return; - } - // Read config - new Config(this); - // Register Listeners - // If debug mode is not on, debug listener won't register - if (debug) getServer().getPluginManager().registerEvents(new BlockDebugListener(), this); - getServer().getPluginManager().registerEvents(new BlockPlayerListener(), this); - getServer().getPluginManager().registerEvents(new BlockEnvironmentListener(), this); - getServer().getPluginManager().registerEvents(new BlockInventoryMoveListener(), this); - // Dependency - new Dependency(this); - // If UUID is not enabled, UUID listener won't register - if (Config.isUuidEnabled() || Config.isLockExpire()){ - if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")){ - DependencyProtocolLib.setUpProtocolLib(this); - } else { - plugin.getLogger().info("ProtocolLib is not found!"); - plugin.getLogger().info("UUID & expiracy support requires ProtocolLib, or else signs will be ugly!"); - } - } - } - - public void onDisable(){ - if (Config.isUuidEnabled() && Bukkit.getPluginManager().getPlugin("ProtocolLib") != null){ - DependencyProtocolLib.cleanUpProtocolLib(this); - } - } - - private void checkMcVersion() { - String[] serverVersion = Bukkit.getBukkitVersion().split("-"); - String version = serverVersion[0]; - if (version.matches("1.16") || version.matches("1.16.1") || version.matches("1.16.2") || version.matches("1.16.3") || version.matches("1.16.4") || version.matches("1.16.5")) { - plugin.getLogger().info("Compatible server version detected: " + version); - is16version = true; - } else if (version.matches("1.15") || version.matches("1.15.1") || version.matches("1.15.2")) { - plugin.getLogger().info("Compatible server version detected: " + version); - is16version = false; - } else if (version.matches("1.14") || version.matches("1.14.1") || version.matches("1.14.2") || version.matches("1.14.3") || version.matches("1.14.4")) { - plugin.getLogger().info("Compatible server version detected: " + version); - is16version = false; - } else { - plugin.getLogger().info("Incompatible server version detected: " + version + " . Trying to run into 1.16 compatibility mode!"); - is16version = true; - } - } - - public static Plugin getPlugin(){ - return plugin; - } - - public static boolean needCheckHand(){ - return needcheckhand; - } - - @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - List commands = new ArrayList<>(); - commands.add("reload"); - commands.add("version"); - commands.add("1"); - commands.add("2"); - commands.add("3"); - commands.add("4"); - commands.add("uuid"); - commands.add("update"); - commands.add("debug"); - if (args != null && args.length == 1) { - List list = new ArrayList<>(); - for (String s : commands) { - if (s.startsWith(args[0])) { - list.add(s); - } - } - return list; - } - return null; - } - - public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, final String[] args){ - if (cmd.getName().equals("lockettepro")){ - if (args.length == 0){ - Utils.sendMessages(sender, Config.getLang("command-usage")); - } else { - // The following commands does not require player - switch (args[0]){ - case "reload": - if (sender.hasPermission("lockettepro.reload")){ - if(Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { - DependencyProtocolLib.cleanUpProtocolLib(this); - } - Config.reload(); - if (Config.isUuidEnabled() && Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { - DependencyProtocolLib.setUpProtocolLib(this); - } - Utils.sendMessages(sender, Config.getLang("config-reloaded")); - } else { - Utils.sendMessages(sender, Config.getLang("no-permission")); - } - return true; - case "version": - if (sender.hasPermission("lockettepro.version")){ - sender.sendMessage(plugin.getDescription().getFullName()); - } else { - Utils.sendMessages(sender, Config.getLang("no-permission")); - } - return true; - case "debug": - // This is not the author debug, this prints out info - if (sender.hasPermission("lockettepro.debug")) { - sender.sendMessage("LockettePro Debug Message"); - // Basic - sender.sendMessage("LockettePro: " + getDescription().getVersion()); - // Version - sender.sendMessage("Bukkit: " + "v" + Bukkit.getServer().getClass().getPackage().getName().split("v")[1]); - sender.sendMessage("Server version: " + Bukkit.getVersion()); - // Config - sender.sendMessage("UUID: " + Config.isUuidEnabled()); - sender.sendMessage("Expire: " + Config.isLockExpire() + " " + (Config.isLockExpire() ? Config.getLockExpireDays() : "")); - // ProtocolLib - sender.sendMessage("ProtocolLib info:"); - if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) { - sender.sendMessage(" - ProtocolLib missing"); - } else { - sender.sendMessage(" - ProtocolLib: " + Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion()); - } - // Other - sender.sendMessage("Linked plugins:"); - boolean linked = false; - if (Dependency.worldguard != null) { - linked = true; - sender.sendMessage(" - Worldguard: " + Dependency.worldguard.getDescription().getVersion()); - } - if (Dependency.vault != null) { - linked = true; - sender.sendMessage(" - Vault: " + Dependency.vault.getDescription().getVersion()); - } - if (Bukkit.getPluginManager().getPlugin("CoreProtect") != null) { - linked = true; - sender.sendMessage(" - CoreProtect: " + Bukkit.getPluginManager().getPlugin("CoreProtect").getDescription().getVersion()); - } - if (!linked) { - sender.sendMessage(" - none"); - } - } else { - Utils.sendMessages(sender, Config.getLang("no-permission")); - } - return true; - } - // The following commands requires player - if (!(sender instanceof Player)){ - Utils.sendMessages(sender, Config.getLang("command-usage")); - return false; - } - Player player = (Player)sender; - switch (args[0]){ - case "1": - case "2": - case "3": - case "4": - if (player.hasPermission("lockettepro.edit")){ - String message = ""; - Block block = Utils.getSelectedSign(player); - if (block == null){ - Utils.sendMessages(player, Config.getLang("no-sign-selected")); - } else if (!LocketteProAPI.isSign(block) || !(player.hasPermission("lockettepro.edit.admin") || LocketteProAPI.isOwnerOfSign(block, player))){ - Utils.sendMessages(player, Config.getLang("sign-need-reselect")); - } else { - for (int i = 1; i < args.length; i++){ - message += args[i]; - } - message = ChatColor.translateAlternateColorCodes('&', message); - if (!player.hasPermission("lockettepro.admin.edit") && !debug && message.length() > 18) { - Utils.sendMessages(player, Config.getLang("line-is-too-long")); - return true; - } - if (LocketteProAPI.isLockSign(block)){ - switch (args[0]){ - case "1": - if (!debug || !player.hasPermission("lockettepro.admin.edit")){ - Utils.sendMessages(player, Config.getLang("cannot-change-this-line")); - break; - } - case "2": - if (!player.hasPermission("lockettepro.admin.edit")){ - Utils.sendMessages(player, Config.getLang("cannot-change-this-line")); - break; - } - case "3": - case "4": - Utils.setSignLine(block, Integer.parseInt(args[0])-1, message); - Utils.sendMessages(player, Config.getLang("sign-changed")); - if (Config.isUuidEnabled()){ - Utils.updateUuidByUsername(Utils.getSelectedSign(player), Integer.parseInt(args[0])-1); - } - break; - } - } else if (LocketteProAPI.isAdditionalSign(block)){ - switch (args[0]){ - case "1": - if (!debug || !player.hasPermission("lockettepro.admin.edit")){ - Utils.sendMessages(player, Config.getLang("cannot-change-this-line")); - break; - } - case "2": - case "3": - case "4": - Utils.setSignLine(block, Integer.parseInt(args[0])-1, message); - Utils.sendMessages(player, Config.getLang("sign-changed")); - if (Config.isUuidEnabled()){ - Utils.updateUuidByUsername(Utils.getSelectedSign(player), Integer.parseInt(args[0])-1); - } - break; - } - } else { - Utils.sendMessages(player, Config.getLang("sign-need-reselect")); - } - } - } else { - Utils.sendMessages(player, Config.getLang("no-permission")); - } - break; - case "force": - if (debug && player.hasPermission("lockettepro.debug")){ - Utils.setSignLine(Utils.getSelectedSign(player), Integer.parseInt(args[1]), args[2]); - break; - } - case "update": - if (debug && player.hasPermission("lockettepro.debug")){ - Utils.updateSign(Utils.getSelectedSign(player)); - break; - } - case "uuid": - if (debug && player.hasPermission("lockettepro.debug")){ - Utils.updateUuidOnSign(Utils.getSelectedSign(player)); - break; - } - default: - Utils.sendMessages(player, Config.getLang("command-usage")); - break; - } - } - } - return true; - } - -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java deleted file mode 100644 index a95eeb5..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/LocketteProAPI.java +++ /dev/null @@ -1,742 +0,0 @@ -package me.crafter.mc.lockettepro; - -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Container; -import org.bukkit.block.Sign; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Directional; -import org.bukkit.block.data.Waterlogged; -import org.bukkit.block.data.type.Chest; -import org.bukkit.entity.Player; - -import javax.annotation.Nullable; - -public class LocketteProAPI { - - public static BlockFace[] newsfaces = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}; - public static BlockFace[] allfaces = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN}; - - public static boolean isLocked(Block block){ - if (block == null) return false; - switch (block.getType()){ - // Double Doors - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case CRIMSON_DOOR: - case WARPED_DOOR: - case IRON_DOOR: - Block[] doors = getDoors(block); - if (doors == null) return false; - for (BlockFace doorface : newsfaces){ - Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); - if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ - if (isLockedSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace())) return true; - if (isLockedSingleBlock(relative1, doorface.getOppositeFace())) return true; - if (isLockedSingleBlock(relative0, doorface.getOppositeFace())) return true; - if (isLockedSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace())) return true; - } - } - if (isLockedSingleBlock(doors[1].getRelative(BlockFace.UP), null)) return true; - if (isLockedSingleBlock(doors[1], null)) return true; - if (isLockedSingleBlock(doors[0], null)) return true; - if (isLockedSingleBlock(doors[0].getRelative(BlockFace.DOWN), null)) return true; - break; - case LECTERN: - return isLockedSingleBlock(block, null); - // Chests (Second block only) - case CHEST: - case TRAPPED_CHEST: - // Check second chest sign - BlockFace chestface = getRelativeChestFace(block); - if (chestface != null) { - Block relativechest = block.getRelative(chestface); - if (isLockedSingleBlock(relativechest, chestface.getOppositeFace())) return true; - } - // Don't break here - // Everything else (First block of container check goes here) - default: - if (isLockedSingleBlock(block, null)) return true; - break; - } - return false; - } - - public static String getOwner(Block block){ - switch (block.getType()){ - // Double Doors - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case CRIMSON_DOOR: - case WARPED_DOOR: - case IRON_DOOR: - Block[] doors = getDoors(block); - if (doors == null) return null; - for (BlockFace doorface : newsfaces){ - Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); - if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ - String f1 = getLockOwnerSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace()); - String f2 = getLockOwnerSingleBlock(relative1, doorface.getOppositeFace()); - String f3 = getLockOwnerSingleBlock(relative0, doorface.getOppositeFace()); - String f4 = getLockOwnerSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace()); - if (f1 != null) { - return f1; - } else if (f2 != null) { - return f2; - } else if (f3 != null) { - return f3; - } else if (f4 != null) { - return f4; - } - } - } - String f1 = getLockOwnerSingleBlock(doors[1].getRelative(BlockFace.UP), null); - String f2 = getLockOwnerSingleBlock(doors[1], null); - String f3 = getLockOwnerSingleBlock(doors[0], null); - String f4 = getLockOwnerSingleBlock(doors[0].getRelative(BlockFace.DOWN), null); - if (f1 != null) { - return f1; - } else if (f2 != null) { - return f2; - } else if (f3 != null) { - return f3; - } else if (f4 != null) { - return f4; - } - break; - case LECTERN: - return getLockOwnerSingleBlock(block, null); - case CHEST: - case TRAPPED_CHEST: - // Check second chest sign - BlockFace chestface = getRelativeChestFace(block); - if (chestface != null) { - Block relativechest = block.getRelative(chestface); - return getLockOwnerSingleBlock(relativechest, chestface.getOppositeFace()); - } - // Don't break here - // Everything else (First block of container check goes here) - default: - return getLockOwnerSingleBlock(block, null); - } - return null; - } - - public static boolean isOwner(Block block, Player player){ - switch (block.getType()){ - // Double Doors - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case CRIMSON_DOOR: - case WARPED_DOOR: - case IRON_DOOR: - Block[] doors = getDoors(block); - if (doors == null) return false; - for (BlockFace doorface : newsfaces){ - Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); - if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ - if (isOwnerSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace(), player)) return true; - if (isOwnerSingleBlock(relative1, doorface.getOppositeFace(), player)) return true; - if (isOwnerSingleBlock(relative0, doorface.getOppositeFace(), player)) return true; - if (isOwnerSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace(), player)) return true; - } - } - if (isOwnerSingleBlock(doors[1].getRelative(BlockFace.UP), null, player)) return true; - if (isOwnerSingleBlock(doors[1], null, player)) return true; - if (isOwnerSingleBlock(doors[0], null, player)) return true; - if (isOwnerSingleBlock(doors[0].getRelative(BlockFace.DOWN), null, player)) return true; - break; - // Chests (Second block only) - case LECTERN: - return isOwnerSingleBlock(block, null, player); - case CHEST: - case TRAPPED_CHEST: - // Check second chest sign - BlockFace chestface = getRelativeChestFace(block); - if (chestface != null) { - Block relativechest = block.getRelative(chestface); - if (isOwnerSingleBlock(relativechest, chestface.getOppositeFace(), player)) return true; - } - // Don't break here - // Everything else (First block of container check goes here) - default: - if (isOwnerSingleBlock(block, null, player)) return true; - break; - } - return false; - } - - public static boolean isUser(Block block, Player player){ - switch (block.getType()){ - // Double Doors - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case CRIMSON_DOOR: - case WARPED_DOOR: - case IRON_DOOR: - Block[] doors = getDoors(block); - if (doors == null) return false; - for (BlockFace doorface : newsfaces){ - Block relative0 = doors[0].getRelative(doorface), relative1 = doors[1].getRelative(doorface); - if (relative0.getType() == doors[0].getType() && relative1.getType() == doors[1].getType()){ - if (isUserSingleBlock(relative1.getRelative(BlockFace.UP), doorface.getOppositeFace(), player)) return true; - if (isUserSingleBlock(relative1, doorface.getOppositeFace(), player)) return true; - if (isUserSingleBlock(relative0, doorface.getOppositeFace(), player)) return true; - if (isUserSingleBlock(relative0.getRelative(BlockFace.DOWN), doorface.getOppositeFace(), player)) return true; - } - } - if (isUserSingleBlock(doors[1].getRelative(BlockFace.UP), null, player)) return true; - if (isUserSingleBlock(doors[1], null, player)) return true; - if (isUserSingleBlock(doors[0], null, player)) return true; - if (isUserSingleBlock(doors[0].getRelative(BlockFace.DOWN), null, player)) return true; - break; - // Lecterns - case LECTERN: - return isUserSingleBlock(block, null, player); - // Chests (Second block only) - case CHEST: - case TRAPPED_CHEST: - // Check second chest sign - BlockFace chestface = getRelativeChestFace(block); - if (chestface != null) { - Block relativechest = block.getRelative(chestface); - if (isUserSingleBlock(relativechest, chestface.getOppositeFace(), player)) return true; - } - // Don't break here - // Everything else (First block of container check goes here) - default: - if (isUserSingleBlock(block, null, player)) return true; - break; - } - return false; - } - - public static boolean isProtected(Block block){ - return (isLockSign(block) || isLocked(block) || isUpDownLockedDoor(block)); - } - - public static boolean isLockedSingleBlock(Block block, BlockFace exempt){ - for (BlockFace blockface : newsfaces){ - if (blockface == exempt) continue; - Block relativeblock = block.getRelative(blockface); - // Find [Private] sign? - if (isLockSign(relativeblock) && getFacing(relativeblock) == blockface){ - // Found [Private] sign, is expire turned on and expired? (relativeblock is now sign) - if (Config.isLockExpire() && LocketteProAPI.isSignExpired(relativeblock)) { - continue; // Private sign but expired... But impossible to have 2 [Private] signs anyway? - } - return true; - } - } - return false; - } - - public static boolean isOwnerSingleBlock(Block block, BlockFace exempt, Player player){ // Requires isLocked - for (BlockFace blockface : newsfaces){ - if (blockface == exempt) continue; - Block relativeblock = block.getRelative(blockface); - if (isLockSign(relativeblock) && getFacing(relativeblock) == blockface){ - if (isOwnerOnSign(relativeblock, player)){ - return true; - } - } - } - return false; - } - - public static String getLockOwnerSingleBlock(Block block, BlockFace exempt) { - for (BlockFace blockface : newsfaces){ - if (blockface == exempt) continue; - Block relativeblock = block.getRelative(blockface); - if (isLockSign(relativeblock) && getFacing(relativeblock) == blockface){ - return getOwnerOnSign(relativeblock); - } - } - return null; - } - - public static boolean isUserSingleBlock(Block block, BlockFace exempt, Player player){ // Requires isLocked - for (BlockFace blockface : newsfaces){ - if (blockface == exempt) continue; - Block relativeblock = block.getRelative(blockface); - if (isLockSignOrAdditionalSign(relativeblock) && getFacing(relativeblock) == blockface){ - if (isUserOnSign(relativeblock, player)){ - return true; - } - } - } - return false; - } - - public static boolean isOwnerOfSign(Block block, Player player){ // Requires isSign - Block protectedblock = getAttachedBlock(block); - // Normal situation, that block is just locked by an adjacent sign - if (isOwner(protectedblock, player)) return true; - // Situation where double door's block - if (isUpDownLockedDoor(protectedblock) && isOwnerUpDownLockedDoor(protectedblock, player)) return true; - // Otherwise... - return false; - } - - public static boolean isLockable(Block block){ - Material material = block.getType(); - //Bad blocks - if(Tag.SIGNS.isTagged(material)){ - return false; - } - if (Config.isLockable(material)){ // Directly lockable - return true; - } else { // Indirectly lockable - Block blockup = block.getRelative(BlockFace.UP); - if (blockup != null && isUpDownAlsoLockableBlock(blockup)) return true; - Block blockdown = block.getRelative(BlockFace.DOWN); - if (blockdown != null && isUpDownAlsoLockableBlock(blockdown)) return true; - return false; - } - } - - - public static boolean isChest(@Nullable Block block){ - if (block == null) { - return false; - } - switch (block.getType()){ - case CHEST: - case TRAPPED_CHEST: - return true; - default: - return false; - } - } - - public static boolean isUpDownAlsoLockableBlock(Block block){ - if (Config.isLockable(block.getType())){ - switch (block.getType()){ - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case CRIMSON_DOOR: - case WARPED_DOOR: - case IRON_DOOR: - return true; - default: - return false; - } - } - return false; - } - - public static boolean mayInterfere(Block block, Player player){ - if (block.getState() instanceof Container) { - for (BlockFace blockface : allfaces) { - Block newblock = block.getRelative(blockface); - if (isLocked(newblock) && !isOwner(newblock, player)) { - return true; - } - } - } - // if LEFT may interfere RIGHT - switch (block.getType()){ - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case CRIMSON_DOOR: - case WARPED_DOOR: - case IRON_DOOR: - for (BlockFace blockface : newsfaces){ - Block newblock = block.getRelative(blockface); - switch (newblock.getType()){ - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case CRIMSON_DOOR: - case WARPED_DOOR: - case IRON_DOOR: - if (isLocked(newblock) && !isOwner(newblock, player)){ - return true; - } - default: - break; - } - } - // Temp workaround bad code for checking up and down signs - Block newblock2 = block.getRelative(BlockFace.UP, 2); - switch (newblock2.getType()){ - default: - if (isLocked(newblock2) && !isOwner(newblock2, player)){ - return true; - } - break; - } - Block newblock3 = block.getRelative(BlockFace.DOWN, 1); - switch (newblock3.getType()){ - default: - if (isLocked(newblock3) && !isOwner(newblock3, player)){ - return true; - } - break; - } - break; - // End temp workaround bad code for checking up and down signs - case CHEST: - case TRAPPED_CHEST: - case OAK_WALL_SIGN: - case SPRUCE_SIGN: - case BIRCH_SIGN: - case JUNGLE_SIGN: - case ACACIA_SIGN: - case DARK_OAK_SIGN: - for (BlockFace blockface : allfaces){ - Block newblock = block.getRelative(blockface); - switch (newblock.getType()){ - case CHEST: - case TRAPPED_CHEST: - if (isLockedSingleBlock(newblock, null) && !isOwnerSingleBlock(newblock, null, player)){ - return true; - } - default: - break; - } - } - break; - // This is extra interfere block - case HOPPER: - case DISPENSER: - case DROPPER: - if (!Config.isInterferePlacementBlocked()) return false; - for (BlockFace blockface : allfaces){ - Block newblock = block.getRelative(blockface); - switch (newblock.getType()){ - case CHEST: - case TRAPPED_CHEST: - case HOPPER: - case DISPENSER: - case DROPPER: - if (isLocked(newblock) && !isOwner(newblock, player)){ - return true; - } - default: - break; - } - } - break; - default: - break; - } - return false; - } - - public static boolean isSign(Block block){ - return Tag.WALL_SIGNS.isTagged(block.getType()); - } - - public static boolean isLockSign(Block block){ - return isSign(block) && isLockString(((Sign)block.getState()).getLine(0)); - } - - public static boolean isAdditionalSign(Block block){ - return isSign(block) && isAdditionalString(((Sign)block.getState()).getLine(0)); - } - - public static boolean isLockSignOrAdditionalSign(Block block){ - if (isSign(block)){ - String line = ((Sign)block.getState()).getLine(0); - return isLockStringOrAdditionalString(line); - } else { - return false; - } - } - - public static boolean isOwnerOnSign(Block block, Player player){ // Requires isLockSign - String[] lines = ((Sign)block.getState()).getLines(); - if (Utils.isPlayerOnLine(player, lines[1])){ - if (Config.isUuidEnabled()){ - Utils.updateLineByPlayer(block, 1, player); - } - return true; - } - return false; - } - - public static String getOwnerOnSign(Block block){ // Requires isLockSign - String[] lines = ((Sign)block.getState()).getLines(); - return lines[1]; - } - - public static boolean isUserOnSign(Block block, Player player){ // Requires (isLockSign or isAdditionalSign) - String[] lines = ((Sign)block.getState()).getLines(); - // Normal - for (int i = 1; i < 4; i ++){ - if (Utils.isPlayerOnLine(player, lines[i])){ - if (Config.isUuidEnabled()){ - Utils.updateLineByPlayer(block, i, player); - } - return true; - } else if (Config.isEveryoneSignString(lines[i])) { - return true; - } - } - // For Vault & Scoreboard - for (int i = 1; i < 4; i++) { - if (Dependency.isPermissionGroupOf(lines[i], player)) return true; - if (Dependency.isScoreboardTeamOf(lines[i], player)) return true; - } - return false; - } - - public static boolean isSignExpired(Block block){ - if (!isSign(block) || !isLockSign(block)) return false; - return isLineExpired(((Sign)block.getState()).getLine(0)); - } - - public static boolean isLineExpired(String line){ - long createdtime = Utils.getCreatedFromLine(line); - if (createdtime == -1L) return false; // No expire - long currenttime = (int)(System.currentTimeMillis()/1000); - return createdtime + Config.getLockExpireDays() * 86400L < currenttime; - } - - public static boolean isUpDownLockedDoor(@Nullable Block block){ - if (block == null) { - return false; - } - Block blockup = block.getRelative(BlockFace.UP); - if (blockup != null && isUpDownAlsoLockableBlock(blockup) && isLocked(blockup)) return true; - Block blockdown = block.getRelative(BlockFace.DOWN); - if (blockdown != null && isUpDownAlsoLockableBlock(blockdown) && isLocked(blockdown)) return true; - return false; - } - - public static boolean isOwnerUpDownLockedDoor(Block block, Player player){ - Block blockup = block.getRelative(BlockFace.UP); - if (blockup != null && isUpDownAlsoLockableBlock(blockup) && isOwner(blockup, player)) return true; - Block blockdown = block.getRelative(BlockFace.DOWN); - if (blockdown != null && isUpDownAlsoLockableBlock(blockdown) && isOwner(blockdown, player)) return true; - return false; - } - - public static boolean isUserUpDownLockedDoor(Block block, Player player){ - Block blockup = block.getRelative(BlockFace.UP); - if (blockup != null && isUpDownAlsoLockableBlock(blockup) && isUser(blockup, player)) return true; - Block blockdown = block.getRelative(BlockFace.DOWN); - if (blockdown != null && isUpDownAlsoLockableBlock(blockdown) && isUser(blockdown, player)) return true; - return false; - } - - public static boolean isLockString(String line){ - if (line.contains("#")) line = line.split("#", 2)[0]; - return Config.isPrivateSignString(line); - } - - public static boolean isAdditionalString(String line){ - if (line.contains("#")) line = line.split("#", 2)[0]; - return Config.isAdditionalSignString(line); - } - - public static boolean isLockStringOrAdditionalString(String line){ - return isLockString(line) || isAdditionalString(line); - } - - public static Block getAttachedBlock(Block sign){ // Requires isSign - BlockFace facing = getFacing(sign); - return sign.getRelative(facing.getOppositeFace()); - } - - public static int getTimerOnSigns(Block block){ - for (BlockFace blockface : newsfaces){ - Block relative = block.getRelative(blockface); - if (isSign(relative)){ - Sign sign = (Sign)relative.getState(); - for (String line : sign.getLines()){ - int linetime = Config.getTimer(line); - if (linetime > 0) return linetime; - } - } - } - return 0; - } - - public static int getTimerDoor(Block block){ - int timersingle = getTimerSingleDoor(block); - if (timersingle > 0) return timersingle; - for (BlockFace blockface : newsfaces){ - Block relative = block.getRelative(blockface); - timersingle = getTimerSingleDoor(relative); - if (timersingle > 0) return timersingle; - } - return 0; - } - - public static int getTimerSingleDoor(Block block){ - Block[] doors = getDoors(block); - if (doors == null) return 0; - Block relativeup = doors[1].getRelative(BlockFace.UP); - int relativeuptimer = getTimerOnSigns(relativeup); - if (relativeuptimer > 0) return relativeuptimer; - int doors0 = getTimerOnSigns(doors[0]); - if (doors0 > 0) return doors0; - int doors1 = getTimerOnSigns(doors[1]); - if (doors1 > 0) return doors1; - Block relativedown = doors[0].getRelative(BlockFace.DOWN); - int relativedowntimer = getTimerOnSigns(relativedown); - if (relativedowntimer > 0) return relativedowntimer; - return 0; - } - - public static Block[] getDoors(Block block){ - Block[] doors = new Block[2]; - boolean found = false; - Block up = block.getRelative(BlockFace.UP), down = block.getRelative(BlockFace.DOWN); - if (up.getType() == block.getType()){ - found = true; - doors[0] = block; doors[1] = up; - } - if (down.getType() == block.getType()){ - if (found == true){ // error 3 doors - return null; - } - doors[1] = block; doors[0] = down; - found = true; - } - if (!found){ // error 1 door - return null; - } - return doors; - } - - public static boolean isDoubleDoorBlock(@Nullable Block block){ - if (block == null) { - return false; - } - return Tag.DOORS.isTagged(block.getType()); - } - - public static boolean isSingleDoorBlock(@Nullable Block block){ - if (block == null) { - return false; - } - switch (block.getType()){ - case OAK_FENCE_GATE: - case SPRUCE_FENCE_GATE: - case BIRCH_FENCE_GATE: - case CRIMSON_FENCE_GATE: - case WARPED_FENCE_GATE: - case ACACIA_FENCE_GATE: - case JUNGLE_FENCE_GATE: - case ACACIA_TRAPDOOR: - case DARK_OAK_TRAPDOOR: - case CRIMSON_TRAPDOOR: - case WARPED_TRAPDOOR: - case BIRCH_TRAPDOOR: - case OAK_TRAPDOOR: - case SPRUCE_TRAPDOOR: - case IRON_TRAPDOOR: - return true; - default: - return false; - } - } - - public static Block getBottomDoorBlock(Block block){ // Requires isDoubleDoorBlock || isSingleDoorBlock - if (isDoubleDoorBlock(block)){ - Block relative = block.getRelative(BlockFace.DOWN); - if (relative.getType() == block.getType()){ - return relative; - } else { - return block; - } - } else { - return block; - } - } - - public static void toggleDoor(Block block, boolean open) { - org.bukkit.block.data.Openable openablestate = (org.bukkit.block.data.Openable) block.getBlockData(); - openablestate.setOpen(open); - block.setBlockData(openablestate); - block.getWorld().playEffect(block.getLocation(), Effect.DOOR_TOGGLE, 0); - } - - public static void toggleDoor(Block block) { - org.bukkit.block.data.Openable openablestate = (org.bukkit.block.data.Openable) block.getBlockData(); - openablestate.setOpen(!openablestate.isOpen()); - block.setBlockData(openablestate); - block.getWorld().playEffect(block.getLocation(), Effect.DOOR_TOGGLE, 0); - } - - public static BlockFace getRelativeChestFace(Block block) { - Chest chest = (Chest) block.getBlockData(); - BlockFace face = getFacing(block); - BlockFace relativeFace = null; - if (chest.getType() == Chest.Type.LEFT) { - if (face == BlockFace.NORTH) { - relativeFace = BlockFace.EAST; - } else if (face == BlockFace.SOUTH) { - relativeFace = BlockFace.WEST; - } else if (face == BlockFace.WEST) { - relativeFace = BlockFace.NORTH; - } else if (face == BlockFace.EAST) { - relativeFace = BlockFace.SOUTH; - } - } else if (chest.getType() == Chest.Type.RIGHT) { - if (face == BlockFace.NORTH) { - relativeFace = BlockFace.WEST; - } else if (face == BlockFace.SOUTH) { - relativeFace = BlockFace.EAST; - } else if (face == BlockFace.WEST) { - relativeFace = BlockFace.SOUTH; - } else if (face == BlockFace.EAST) { - relativeFace = BlockFace.NORTH; - } - } - return relativeFace; - } - - public static BlockFace getFacing(Block block) { - BlockData data = block.getBlockData(); - BlockFace f = null; - if (data instanceof Directional && data instanceof Waterlogged && ((Waterlogged) data).isWaterlogged()) { - String str = ((Directional) data).toString(); - if (str.contains("facing=west")) { - f = BlockFace.WEST; - } else if (str.contains("facing=east")) { - f = BlockFace.EAST; - } else if (str.contains("facing=south")) { - f = BlockFace.SOUTH; - } else if (str.contains("facing=north")) { - f = BlockFace.NORTH; - } - } else if (data instanceof Directional) { - f = ((Directional) data).getFacing(); - } - return f; - } -} diff --git a/LockettePro/src/main/java/me/crafter/mc/lockettepro/Utils.java b/LockettePro/src/main/java/me/crafter/mc/lockettepro/Utils.java deleted file mode 100644 index 3446399..0000000 --- a/LockettePro/src/main/java/me/crafter/mc/lockettepro/Utils.java +++ /dev/null @@ -1,337 +0,0 @@ -package me.crafter.mc.lockettepro; - -import com.comphenix.protocol.wrappers.WrappedChatComponent; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.bukkit.*; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Sign; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Directional; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -public class Utils { - - public static final String usernamepattern = "^[a-zA-Z0-9_]*$"; - private static LoadingCache selectedsign = CacheBuilder.newBuilder() - .expireAfterAccess(30, TimeUnit.SECONDS) - .build(new CacheLoader() { - public Block load(UUID key) { - return null; - } - }); - private static Set notified = new HashSet<>(); - - // Helper functions - public static Block putSignOn(Block block, BlockFace blockface, String line1, String line2, Material material) { - Block newsign = block.getRelative(blockface); - Material blockType = Material.getMaterial(material.name().replace("_SIGN", "_WALL_SIGN")); - if (blockType != null && Tag.WALL_SIGNS.isTagged(blockType)) { - newsign.setType(blockType); - } else { - newsign.setType(Material.OAK_WALL_SIGN); - } - BlockData data = newsign.getBlockData(); - if(data instanceof Directional){ - ((Directional) data).setFacing(blockface); - newsign.setBlockData(data,true); - } - updateSign(newsign); - Sign sign = (Sign)newsign.getState(); - if (newsign.getType() == Material.DARK_OAK_WALL_SIGN || LockettePro.is16version && newsign.getType() == Material.CRIMSON_WALL_SIGN) { - sign.setColor(DyeColor.WHITE); - } - sign.setLine(0, line1); - sign.setLine(1, line2); - sign.update(); - return newsign; - } - - public static void setSignLine(Block block, int line, String text){ // Requires isSign - Sign sign = (Sign)block.getState(); - sign.setLine(line, text); - sign.update(); - } - - public static void removeASign(Player player){ - if (player.getGameMode() == GameMode.CREATIVE) return; - if (player.getInventory().getItemInMainHand().getAmount() == 1){ - player.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); - } else { - player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1); - } - } - - public static void updateSign(Block block){ - if (block.getState() instanceof Sign) { - ((Sign)block.getState()).update(); - } - } - - public static Block getSelectedSign(Player player) { - Block b = selectedsign.getIfPresent(player.getUniqueId()); - if (b != null && !player.getWorld().getName().equals(b.getWorld().getName())) { - selectedsign.invalidate(player.getUniqueId()); - return null; - } - return b; - } - - public static void selectSign(Player player, Block block){ - selectedsign.put(player.getUniqueId(), block); - } - - public static void playLockEffect(Player player, Block block){ -// player.playSound(block.getLocation(), Sound.DOOR_CLOSE, 0.3F, 1.4F); -// player.spigot().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.CRIT, 0, 0, 0.3F, 0.3F, 0.3F, 0.1F, 64, 64); - } - - public static void playAccessDenyEffect(Player player, Block block){ -// player.playSound(block.getLocation(), Sound.VILLAGER_NO, 0.3F, 0.9F); -// player.spigot().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.FLAME, 0, 0, 0.3F, 0.3F, 0.3F, 0.01F, 64, 64); - } - - public static void sendMessages(CommandSender sender, String messages){ - if (messages == null || messages.equals("")) return; - sender.sendMessage(messages); - } - - public static boolean shouldNotify(Player player){ - if (notified.contains(player.getUniqueId())){ - return false; - } else { - notified.add(player.getUniqueId()); - return true; - } - } - - public static boolean hasValidCache(Block block){ - List metadatas = block.getMetadata("expires"); - if (!metadatas.isEmpty()){ - long expires = metadatas.get(0).asLong(); - if (expires > System.currentTimeMillis()){ - return true; - } - } - return false; - } - - public static boolean getAccess(Block block){ // Requires hasValidCache() - List metadatas = block.getMetadata("locked"); - return metadatas.get(0).asBoolean(); - } - - public static void setCache(Block block, boolean access){ - block.removeMetadata("expires", LockettePro.getPlugin()); - block.removeMetadata("locked", LockettePro.getPlugin()); - block.setMetadata("expires", new FixedMetadataValue(LockettePro.getPlugin(), System.currentTimeMillis() + Config.getCacheTimeMillis())); - block.setMetadata("locked", new FixedMetadataValue(LockettePro.getPlugin(), access)); - } - - public static void resetCache(Block block){ - block.removeMetadata("expires", LockettePro.getPlugin()); - block.removeMetadata("locked", LockettePro.getPlugin()); - for (BlockFace blockface : LocketteProAPI.newsfaces){ - Block relative = block.getRelative(blockface); - if (relative.getType() == block.getType()){ - relative.removeMetadata("expires", LockettePro.getPlugin()); - relative.removeMetadata("locked", LockettePro.getPlugin()); - } - } - } - - public static void updateUuidOnSign(Block block){ - for (int line = 1; line < 4; line ++){ - updateUuidByUsername(block, line); - } - } - - public static void updateUuidByUsername(final Block block, final int line){ - Sign sign = (Sign)block.getState(); - final String original = sign.getLine(line); - Bukkit.getScheduler().runTaskAsynchronously(LockettePro.getPlugin(), new Runnable(){ - @Override - public void run() { - String username = original; - if (username.contains("#")){ - username = username.split("#")[0]; - } - if (!isUserName(username)) return; - String uuid = null; - Player user = Bukkit.getPlayerExact(username); - if (user != null){ // User is online - uuid = user.getUniqueId().toString(); - } else { // User is not online, fetch string - uuid = getUuidByUsernameFromMojang(username); - } - if (uuid != null){ - final String towrite = username + "#" + uuid; - Bukkit.getScheduler().runTask(LockettePro.getPlugin(), new Runnable(){ - @Override - public void run() { - setSignLine(block, line, towrite); - } - }); - } - } - }); - } - - public static void updateUsernameByUuid(Block block, int line){ - Sign sign = (Sign)block.getState(); - String original = sign.getLine(line); - if (isUsernameUuidLine(original)){ - String uuid = getUuidFromLine(original); - Player player = Bukkit.getPlayer(UUID.fromString(uuid)); - if (player != null){ - setSignLine(block, line, player.getName() + "#" + uuid); - } - } - } - - public static void updateLineByPlayer(Block block, int line, Player player){ - setSignLine(block, line, player.getName() + "#" + player.getUniqueId().toString()); - } - - public static void updateLineWithTime(Block block, boolean noexpire){ - Sign sign = (Sign)block.getState(); - if (noexpire){ - sign.setLine(0, sign.getLine(0) + "#created:" + -1); - } else { - sign.setLine(0, sign.getLine(0) + "#created:" + (int)(System.currentTimeMillis()/1000)); - } - sign.update(); - } - - public static boolean isUserName(String text){ - if (text.length() < 17 && text.length() > 2 && text.matches(usernamepattern)){ - return true; - } else { - return false; - } - } - - // Warning: don't use this in a sync way - public static String getUuidByUsernameFromMojang(String username){ - try { - URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + username); - URLConnection connection = url.openConnection(); - connection.setConnectTimeout(8000); - connection.setReadTimeout(8000); - BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String inputLine; - StringBuffer response = new StringBuffer(); - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - String responsestring = response.toString(); - JsonObject json = new JsonParser().parse(responsestring).getAsJsonObject(); - String rawuuid = json.get("id").getAsString(); - return rawuuid.substring(0, 8) + "-" + rawuuid.substring(8, 12) + "-" + rawuuid.substring(12, 16) + "-" + rawuuid.substring(16, 20) + "-" + rawuuid.substring(20); - } catch (Exception ex){} - return null; - } - - public static boolean isUsernameUuidLine(String text){ - if (text.contains("#")){ - String[] splitted = text.split("#", 2); - if (splitted[1].length() == 36){ - return true; - } - } - return false; - } - - public static boolean isPrivateTimeLine(String text){ - if (text.contains("#")){ - String[] splitted = text.split("#", 2); - if (splitted[1].startsWith("created:")){ - return true; - } - } - return false; - } - - public static String StripSharpSign(String text){ - if (text.contains("#")){ - return text.split("#", 2)[0]; - } else { - return text; - } - } - - public static String getUsernameFromLine(String text){ - if (isUsernameUuidLine(text)){ - return text.split("#", 2)[0]; - } else { - return text; - } - } - - public static String getUuidFromLine(String text){ - if (isUsernameUuidLine(text)){ - return text.split("#", 2)[1]; - } else { - return null; - } - } - - public static long getCreatedFromLine(String text){ - if (isPrivateTimeLine(text)){ - return Long.parseLong(text.split("#created:", 2)[1]); - } else { - return Config.getLockDefaultCreateTimeUnix(); - } - } - - public static boolean isPlayerOnLine(Player player, String text){ - if (Utils.isUsernameUuidLine(text)){ - if (Config.isUuidEnabled()){ - return player.getUniqueId().toString().equals(getUuidFromLine(text)); - } else { - return player.getName().equals(getUsernameFromLine(text)); - } - } else { - return text.equals(player.getName()); - } - } - - public static String getSignLineFromUnknown(WrappedChatComponent rawline){ - String json = rawline.getJson(); - return getSignLineFromUnknown(json); - } - - public static String getSignLineFromUnknown(String json) { - try { // 1.9+ - if (json.length() > 33) { - JsonObject line = new JsonParser().parse(json).getAsJsonObject(); - if (line.has("extra")) { - return line.get("extra").getAsJsonArray().get(0).getAsJsonObject().get("text").getAsString(); - } - } - return ""; - } catch (Exception ex) { - ex.printStackTrace(); - } - return json; - } - -} diff --git a/LockettePro/src/main/resources/config.yml b/LockettePro/src/main/resources/config.yml deleted file mode 100644 index e5a4757..0000000 --- a/LockettePro/src/main/resources/config.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Configuration file -# https://github.com/connection-lost/LockettePro/wiki/*-config.yml -# If there are missing entries, you can add them manually. - -language-file-name: 'lang.yml' -enable-quick-protect: true -enable-uuid-support: false -protocollib: true -worldguard: true -coreprotect: true -block-interfere-placement: true -block-item-transfer-in: false -block-item-transfer-out: true -block-hopper-minecart: remove -cache-time-seconds: 0 -lock-expire: false -lock-expire-days: 999.9 -lock-default-create-time-unix: -1 -lock-expire-string: '&3[Expired]' - -private-signs: -- '[Private]' -- '[private]' -additional-signs: -- '[More Users]' -- '[more users]' -everyone-signs: -- '[Everyone]' -- '[everyone]' -timer-signs: -- '[Timer:@]' -- '[timer:@]' -# material name see: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html -# legacy block name and block id are not supported! -lockables: -- CHEST -- TRAPPED_CHEST -- BARREL -- FURNACE -- SMOKER -- BLAST_FURNACE -- HOPPER -- BREWING_STAND -- DIAMOND_BLOCK -- OAK_DOOR -- SPRUCE_DOOR -- BIRCH_DOOR -- JUNGLE_DOOR -- ACACIA_DOOR -- DARK_OAK_DOOR -- IRON_DOOR -- LECTERN -- CRIMSON_DOOR -- WARPED_DOOR -- OAK_FENCE_GATE -- SPRUCE_FENCE_GATE -- BIRCH_FENCE_GATE -- CRIMSON_FENCE_GATE -- WARPED_FENCE_GATE -- ACACIA_FENCE_GATE -- JUNGLE_FENCE_GATE -- CRIMSON_TRAPDOOR -- WARPED_TRAPDOOR -- SPRUCE_TRAPDOOR -- OAK_TRAPDOOR -- BIRCH_TRAPDOOR -- DARK_OAK_TRAPDOOR -- ACACIA_TRAPDOOR -protection-exempt: -- nothing \ No newline at end of file diff --git a/LockettePro/src/main/resources/lang.yml b/LockettePro/src/main/resources/lang.yml deleted file mode 100644 index 4f7b08d..0000000 --- a/LockettePro/src/main/resources/lang.yml +++ /dev/null @@ -1,31 +0,0 @@ -command-usage: "&6[LockettePro] &bLockettePro plugin help\n&c1. In order to add a user to a sign, right click the sign, then enter /lock to change the line.\n&c2. To reload configuration, enter /lock reload.\nLockettePro by connection_lost" -you-can-quick-lock-it: '&6[LockettePro] &aRight click the block with a sign to lock.' -you-can-manual-lock-it: '&6[LockettePro] &aPlace a sign and write [Private] to lock it.' -config-reloaded: '&6[LockettePro] &aConfig reloaded.' -no-permission: '&6[LockettePro] &cYou don''t have permission to do that.' -no-sign-selected: '&6[LockettePro] &cSelect a sign by right-clicking on it first.' -sign-need-reselect: '&6[LockettePro] &cPlease re-select the sign.' -line-is-too-long: '&6[LockettePro] &cThis line is too long!' -cannot-change-this-line: '&6[LockettePro] &cYou cannot change this line.' -sign-changed: '&6[LockettePro] &aSign edited successfully.' -locked-quick: '&6[LockettePro] &aBlock locked successfully.' -additional-sign-added-quick: '&6[LockettePro] &aAdditional sign added successfully.' -cannot-lock-quick: '&6[LockettePro] &cYou cannot lock this.' -cannot-add-additional-sign-quick: '&6[LockettePro] &cYou cannot add a sign here' -locked-manual: '&6[LockettePro] &aBlock locked successfully.' -additional-sign-added-manual: '&6[LockettePro] &aAdditional sign added successfully.' -cannot-lock-manual: '&6[LockettePro] &cYou cannot lock this.' -cannot-add-additional-sign-manual: '&6[LockettePro] &cYou cannot add a sign here' -not-locked-yet-manual: '&6[LockettePro] &cThis block is not locked yet.' -cannot-lock-door-nearby-manual: '&6[LockettePro] &cThere is a door nearby.' -block-already-locked-manual: '&6[LockettePro] &cThis block is already locked.' -block-is-not-lockable: '&6[LockettePro] &cThis block is not lockable.' -sign-selected: '&6[LockettePro] &aSign Selected.' -break-own-lock-sign: '&6[LockettePro] &aYou broke your lock sign.' -cannot-break-this-lock-sign: '&6[LockettePro] &cYou cannot break this lock sign.' -break-own-additional-sign: '&6[LockettePro] &aYou broke your additional sign.' -break-redundant-additional-sign: '&6[LockettePro] &aYou broke a redundant additional sign.' -cannot-break-this-additional-sign: '&6[LockettePro] &cYou cannot break this additional sign.' -block-is-locked: '&6[LockettePro] &cThis block is locked.' -cannot-interfere-with-others: '&6[LockettePro] &cYou cannot place a block that may interfere others.' -sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/LockettePro/src/main/resources/lang_de.yml b/LockettePro/src/main/resources/lang_de.yml deleted file mode 100644 index c264067..0000000 --- a/LockettePro/src/main/resources/lang_de.yml +++ /dev/null @@ -1,33 +0,0 @@ -# German translation by HeartCore - -command-usage: "&6[LockettePro] &bLockettePro Plugin-Hilfe\n&c1. Um einen User einem Schild hinzuzufügen, rechtsklicke das Schild und gib anschließend /lock ein, um den Text zu ändern\n&c2. Um die Konfiguration neu zu laden, gib /lock reload ein.\nLockettePro von connection_lost" -you-can-quick-lock-it: '&6[LockettePro] &aRechtsklicke den Block mit einem Schild, um ihn zu sichern.' -you-can-manual-lock-it: '&6[LockettePro] &aPlatziere ein Schild und schreibe [Private] darauf, um es zu sichern.' -config-reloaded: '&6[LockettePro] &aKonfiguratio neu geladen..' -no-permission: '&6[LockettePro] &cDu hast keine Rechte, um dies zu tun.' -no-sign-selected: '&6[LockettePro] &cWähle zuerst ein Schild aus, indem du es rechtsklickst.' -sign-need-reselect: '&6[LockettePro] &cBitte wähle das Schild erneut aus.' -line-is-too-long: '&6[LockettePro] &cDiese Zeile ist zu lang!' -cannot-change-this-line: '&6[LockettePro] &cDu kannst diese Zeile nicht verändern.' -sign-changed: '&6[LockettePro] &aSchild erfolgreich bearbeitet.' -locked-quick: '&6[LockettePro] &aBlock erfolgreich gesichert.' -additional-sign-added-quick: '&6[LockettePro] &aZusätzliches Schild erfolgreich hinzugefügt.' -cannot-lock-quick: '&6[LockettePro] &cDu kannst das nicht sichern.' -cannot-add-additional-sign-quick: '&6[LockettePro] &cDu kannst hier kein Schild hinzufügen' -locked-manual: '&6[LockettePro] &aBlock erfolgreich gesichert.' -additional-sign-added-manual: '&6[LockettePro] &aZusätzliches Schild erfolgreich hinzugefügt.' -cannot-lock-manual: '&6[LockettePro] &cDu kannst das nicht sichern.' -cannot-add-additional-sign-manual: '&6[LockettePro] &cDu kannst hier kein Schild hinzufügen' -not-locked-yet-manual: '&6[LockettePro] &cDieser Block ist noch nicht gesichert.' -cannot-lock-door-nearby-manual: '&6[LockettePro] &cHier ist eine Tür in der Nähe.' -block-already-locked-manual: '&6[LockettePro] &cDieser Block ist bereits gesichert.' -block-is-not-lockable: '&6[LockettePro] &cDieser Block kann nicht gesichert werden.' -sign-selected: '&6[LockettePro] &aSchild ausgewählt.' -break-own-lock-sign: '&6[LockettePro] &aDu hast dein Sicherungsschild zerstört.' -cannot-break-this-lock-sign: '&6[LockettePro] &cDu kannst dieses Sicherungsschild nicht zerstören.' -break-own-additional-sign: '&6[LockettePro] &aDu hast dein zusätzliches Schild zerstört.' -break-redundant-additional-sign: '&6[LockettePro] &aDu hast ein redundantes zusätzliches Schild zerstört.' -cannot-break-this-additional-sign: '&6[LockettePro] &cDu kansnt dieses zusätzliche Schild nicht zerstören.' -block-is-locked: '&6[LockettePro] &cDieser Block ist gesichert.' -cannot-interfere-with-others: '&6[LockettePro] &cDu kannst keinen Block platzieren, der in andere eingreifen könnte.' -sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/LockettePro/src/main/resources/lang_es.yml b/LockettePro/src/main/resources/lang_es.yml deleted file mode 100644 index f061655..0000000 --- a/LockettePro/src/main/resources/lang_es.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Spanish translation by Alarar -command-usage: "&6[Private] &bPrivate plugin ayuda\n&c1. Para a?adir un usuario al private, click derecho en el cartel, y escribe /lock para cambiar o a?adir l��nea.\n&c2. Para recargar la config, utiliza /lock reload.\nLockettepro by connection_lost" -you-can-quick-lock-it: '&6[Private] &aClick derecho con el cartel en lo que quieras proteger.' -you-can-manual-lock-it: '&6[Private] &aPon un cartel y escribe [Private] para privatizarlo.' -config-reloaded: '&6[Private] &aConfig recargada.' -no-permission: '&6[Private] &cNo tienes permisos para hacer esto.' -no-sign-selected: '&6[Private] &cPrimero selecciona un cartel con click derecho.' -sign-need-reselect: '&6[Private] &cPor favor selecciona otra vez el cartel.' -line-is-too-long: '&6[Private] &c?Esta l��nea es muy larga!' -cannot-change-this-line: '&6[Private] &cT�� no puedes cambiar esta l��nea.' -sign-changed: '&6[Private] &aCartel editado correctamente.' -locked-quick: '&6[Private] &aObjeto privatizado correctamente.' -additional-sign-added-quick: '&6[Private] &aCartel adicional agregado correctamente.' -cannot-lock-quick: '&6[Private] &cNo puedes privatizar eso.' -cannot-add-additional-sign-quick: '&6[Private] &cNo puedes colocar un cartel aqu��.' -locked-manual: '&6[Private] &aPrivatizado correctamente.' -additional-sign-added-manual: '&6[Private] &aCartel adicional a?adido correctamente.' -cannot-lock-manual: '&6[Private] &cNo puedes proteger esto.' -cannot-add-additional-sign-manual: '&6[Private] &cNo puedes a?adir un cartel aqu��.' -not-locked-yet-manual: '&6[Private] &cEste objeto no esta protegido todav��a.' -cannot-lock-door-nearby-manual: '&6[Private] &cHay una puerta cerca.' -block-already-locked-manual: '&6[Private] &cEste bloque esta ya privatizado.' -block-is-not-lockable: '&6[Private] &cEste bloque no se puede privatizar.' -sign-selected: '&6[Private] &aCartel seleccionado.' -break-own-lock-sign: '&6[Private] &a?Has roto t�� cartel private!.' -cannot-break-this-lock-sign: '&6[Private] &c?No puedes romper este cartel private!.' -break-own-additional-sign: '&6[Private] &aHas roto t�� cartel adicional private.' -break-redundant-additional-sign: '&6[Private] &aHas roto un cartel private que era redundante.' -cannot-break-this-additional-sign: '&6[Private] &cNo puedes romper este cartel adicional de private!.' -block-is-locked: '&6[Private] &c?Este bloque esta protegido!.' -cannot-interfere-with-others: '&6[Private] &c?No puedes poner un cartel interfiriendo con otros de private!.' -sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/LockettePro/src/main/resources/lang_fr.yml b/LockettePro/src/main/resources/lang_fr.yml deleted file mode 100644 index f9fc7d9..0000000 --- a/LockettePro/src/main/resources/lang_fr.yml +++ /dev/null @@ -1,33 +0,0 @@ -# German translation by Morgan_vonBrylan - -command-usage: "&6[LockettePro] aide du plugin &bLockettePro\n&c1. Pour ajouter un joueur au panneau, faites clic droit dessus, puis entrez /lock pour changer la ligne.\n&c2. Pour recharger la configuration, entrez /lock reload.\nLockettePro par connection_lost" -you-can-quick-lock-it: '&6[LockettePro] &aClick droit sur un bloc avec un panneau pour le verrouiller.' -you-can-manual-lock-it: '&6[LockettePro] &aPlacez un panneau et crivez [Private] pour le verrouiller.' -config-reloaded: '&6[LockettePro] &aConfiguration recharge.' -no-permission: '&6[LockettePro] &cVous n''avez pas la permission de faire a.' -no-sign-selected: '&6[LockettePro] &cSlectionnez un panneau en faisant clic droit dessus.' -sign-need-reselect: '&6[LockettePro] &cVeuillez re-slectionner le panneau.' -line-is-too-long: '&6[LockettePro] &cCette ligne est trop longue !' -cannot-change-this-line: '&6[LockettePro] &cVous ne pouvez pas changer cette ligne.' -sign-changed: '&6[LockettePro] &aPanneau modifi avec succs.' -locked-quick: '&6[LockettePro] &aBloc verrouill avec succs.' -additional-sign-added-quick: '&6[LockettePro] &aPanneau supplmentaire ajout avec succs.' -cannot-lock-quick: '&6[LockettePro] &cVous ne pouvez pas verrouiller a.' -cannot-add-additional-sign-quick: '&6[LockettePro] &cVous ne pouvez pas mettre de panneau l.' -locked-manual: '&6[LockettePro] &aBloc verrouill avec succs.' -additional-sign-added-manual: '&6[LockettePro] &aPanneau supplmentaire ajout avec succs.' -cannot-lock-manual: '&6[LockettePro] &cVous ne pouvez pas verrouiller a.' -cannot-add-additional-sign-manual: '&6[LockettePro] &cVous ne pouvez pas mettre de panneau l.' -not-locked-yet-manual: '&6[LockettePro] &cCe bloc n''est pas envore verrouill.' -cannot-lock-door-nearby-manual: '&6[LockettePro] &cIl y a une porte proximit.' -block-already-locked-manual: '&6[LockettePro] &cCe bloc est dj verrouill.' -block-is-not-lockable: '&6[LockettePro] &cCe bloc n''est pas verrouillable.' -sign-selected: '&6[LockettePro] &aPanneau slectionn.' -break-own-lock-sign: '&6[LockettePro] &aVous avez cass votre panneau verrou.' -cannot-break-this-lock-sign: '&6[LockettePro] &cVous ne pouvez pas casser ce panneau verrou.' -break-own-additional-sign: '&6[LockettePro] &aVous avez cass votre panneau supplmentaire.' -break-redundant-additional-sign: '&6[LockettePro] &aVous avez cass un panneau supplmentaire redondant.' -cannot-break-this-additional-sign: '&6[LockettePro] &cVous ne pouvez pas cesser ce panneau supplmentaire.' -block-is-locked: '&6[LockettePro] &cCe bloc est verrouill.' -cannot-interfere-with-others: '&6[LockettePro] &cVous ne pouvez pas placer de bloc qui pourrait interfrer avec d''autres.' -sign-error: '&4[ERREUR]' \ No newline at end of file diff --git a/LockettePro/src/main/resources/lang_hu.yml b/LockettePro/src/main/resources/lang_hu.yml deleted file mode 100644 index becc8cb..0000000 --- a/LockettePro/src/main/resources/lang_hu.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Hungarian translation by andris155 -command-usage: "&6[LockettePro] &bLockettePro plugin segítség\n&c1. Ha szeretnél valakit hozzáadni a védéshez, akkor jobb klikkelj a táblára és írd be /lock , hogy megváltoztasd a sort.\n&c2. Ha újra szeretnéd tölteni a plugin-t, akkor írd be /lock reload.\nLockettePro by connection_lost" -you-can-quick-lock-it: '&6[LockettePro] &aJobb klikkelj a blokkra egy táblával a levédéséhez.' -you-can-manual-lock-it: '&6[LockettePro] &aKérlek helyezz le egy táblát és írd rá, hogy [Lock] a levédéshez.' -config-reloaded: '&6[LockettePro] &aA konfig újratöltve.' -no-permission: '&6[LockettePro] &cEhhez nincs jogod.' -no-sign-selected: '&6[LockettePro] &cElőször válaszd ki a táblát jobb klikkel.' -sign-need-reselect: '&6[LockettePro] &cKérlek válaszd ki újra a táblát.' -line-is-too-long: '&6[LockettePro] &cA sor túl rövid!' -cannot-change-this-line: '&6[LockettePro] &cEzt a sort nem módosíthatod.' -sign-changed: '&6[LockettePro] &aA tábla sikeresen megváltoztatva.' -locked-quick: '&6[LockettePro] &aA blokk sikeresen levédve.' -additional-sign-added-quick: '&6[LockettePro] &aKiegészítő tábla sikeresen hozzáadva.' -cannot-lock-quick: '&6[LockettePro] &cEzt nem védheted le.' -cannot-add-additional-sign-quick: '&6[LockettePro] &cItt nem adhatsz hozzá táblát' -locked-manual: '&6[LockettePro] &aA blokk sikeresen levédve.' -additional-sign-added-manual: '&6[LockettePro] &aKiegészítő tábla sikeresen hozzáadva.' -cannot-lock-manual: '&6[LockettePro] &cEzt nem védheted le.' -cannot-add-additional-sign-manual: '&6[LockettePro] &cItt nem adhatsz hozzá táblát' -not-locked-yet-manual: '&6[LockettePro] &cEzt a blokkot még nem védted le.' -cannot-lock-door-nearby-manual: '&6[LockettePro] &cVan a közelben egy ajtó.' -block-already-locked-manual: '&6[LockettePro] &cEz a blokk már védett.' -block-is-not-lockable: '&6[LockettePro] &cEz a blokk nem levédhető.' -sign-selected: '&6[LockettePro] &aA Tábla kiválasztva.' -break-own-lock-sign: '&6[LockettePro] &aKiütötted a Lock táblád.' -cannot-break-this-lock-sign: '&6[LockettePro] &cNem ütheted ki ezt a levédés táblát.' -break-own-additional-sign: '&6[LockettePro] &aKiütötted a kiegészítő táblád.' -break-redundant-additional-sign: '&6[LockettePro] &aKiütöttél egy felesleges kiegészítő táblát.' -cannot-break-this-additional-sign: '&6[LockettePro] &cNem ütheted ki ezt a kiegészítő táblát.' -block-is-locked: '&6[LockettePro] &cEz a blokk védett.' -cannot-interfere-with-others: '&6[LockettePro] &cNem helyezhetsz blokkot oda, ahol ütközik más védésével.' -sign-error: '&4[HIBA]' diff --git a/LockettePro/src/main/resources/lang_it.yml b/LockettePro/src/main/resources/lang_it.yml deleted file mode 100644 index fbea67d..0000000 --- a/LockettePro/src/main/resources/lang_it.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Lingua Italiana creata da Maxetto. -command-usage: "&6[LockettePro] &bAiuto LockettePro\n&c1. Per aggiungere un giocatore nel cartello, fai tasto destro sul cartello, poi scrivi /lock per modificare la linea indicata.\n&c2. Per ricaricare la configurazione, scrivi /lock reload.\nLockettePro di connection_lost" -you-can-quick-lock-it: '&6[LockettePro] &aFai tasto destro sul blocco con un cartello per privatizzarlo.' -you-can-manual-lock-it: '&6[LockettePro] &aPiazza un cartello e scrivi [Private] per privatizzarlo.' -config-reloaded: '&6[LockettePro] &aConfigurazione ricaricata correttamente.' -no-permission: '&6[LockettePro] &cNon hai il permesso di fare ciò.' -no-sign-selected: '&6[LockettePro] &cDevi selezionare un cartello facendo tasto destro su di esso prima di eseguire questo comando.' -sign-need-reselect: '&6[LockettePro] &cPer favore riseleziona il cartello.' -line-is-too-long: '&6[LockettePro] &cIl testo inserito è troppo lungo!' -cannot-change-this-line: '&6[LockettePro] &cNon puoi modificare questa linea.' -sign-changed: '&6[LockettePro] &aCartello modificato correttamente.' -locked-quick: '&6[LockettePro] &aBlocco privatizzato correttamente.' -additional-sign-added-quick: '&6[LockettePro] &aCartello aggiuntivo piazzato correttamente.' -cannot-lock-quick: '&6[LockettePro] &cNon puoi privatizzare questo blocco.' -cannot-add-additional-sign-quick: '&6[LockettePro] &cNon puoi piazzare un cartello qua.' -locked-manual: '&6[LockettePro] &aBlocco privatizzato correttamente.' -additional-sign-added-manual: '&6[LockettePro] &aCartello aggiuntivo piazzato correttamente.' -cannot-lock-manual: '&6[LockettePro] &cNon puoi privatizzare questo blocco.' -cannot-add-additional-sign-manual: '&6[LockettePro] &cNon puoi piazzare un cartello qua.' -not-locked-yet-manual: '&6[LockettePro] &cQuesto blocco non è stato ancora privatizzato.' -cannot-lock-door-nearby-manual: '&6[LockettePro] &cNon puoi privatizzare questo blocco perché c''è una porta nelle vicinanze.' -block-already-locked-manual: '&6[LockettePro] &cQuesto blocco è già privatizzato.' -block-is-not-lockable: '&6[LockettePro] &cQuesto blocco non è privatizzabile.' -sign-selected: '&6[LockettePro] &aCartello selezionato correttamente.' -break-own-lock-sign: '&6[LockettePro] &aHai rimosso il cartello di privatizzazione.' -cannot-break-this-lock-sign: '&6[LockettePro] &cNon puoi rimuovere questo cartello di privatizzazione.' -break-own-additional-sign: '&6[LockettePro] &aHai rimosso il cartello aggiuntivo.' -break-redundant-additional-sign: '&6[LockettePro] &aHai rimosso un cartello aggiuntivo.' -cannot-break-this-additional-sign: '&6[LockettePro] &cNon puoi rimuovere questo cartello aggiuntivo.' -block-is-locked: '&6[LockettePro] &cQuesto blocco è stato privatizzato da un giocatore.' -cannot-interfere-with-others: '&6[LockettePro] &cNon puoi piazzare un blocco che può interferire con altri.' -sign-error: '&4[ERRORE]' diff --git a/LockettePro/src/main/resources/lang_pl.yml b/LockettePro/src/main/resources/lang_pl.yml deleted file mode 100644 index cfce093..0000000 --- a/LockettePro/src/main/resources/lang_pl.yml +++ /dev/null @@ -1,32 +0,0 @@ -#Polskie tłumaczenie od Szwendacz99 -command-usage: "&6[LockettePro] &bPomoc pluginu LockettePro\n&c1. W celu dodania gracza do tabliczki, kliknij prawym tabliczkę i wpisz /lock żeby zmienić daną linię.\n&c2. Żeby odświeżyć ustawienia, wpisz /lock reload.\nLockettePro od connection_lost" -you-can-quick-lock-it: '&6[LockettePro] &aKliknij prawym przycieskiem na blok, trzymając tabliczkę, aby zablokować.' -you-can-manual-lock-it: '&6[LockettePro] &aPostaw tabliczkę z napisem [Private] aby to zablokować.' -config-reloaded: '&6[LockettePro] &aUstawienia odświeżone.' -no-permission: '&6[LockettePro] &cNie masz uprawnień aby to zrobić.' -no-sign-selected: '&6[LockettePro] &cNajpierw wybierz tabliczkę klikając na nią prawym.' -sign-need-reselect: '&6[LockettePro] &cWybierz tabliczkę ponownie.' -line-is-too-long: '&6[LockettePro] &cTa linia jest za długa!' -cannot-change-this-line: '&6[LockettePro] &cNie możeszz zmienić tej linii.' -sign-changed: '&6[LockettePro] &aTabliczka edytowana pomyślnie.' -locked-quick: '&6[LockettePro] &aBlok zablokowany pomyślnie.' -additional-sign-added-quick: '&6[LockettePro] &aKolejna tabliczka dodana pomyślnie.' -cannot-lock-quick: '&6[LockettePro] &cNie możesz tego zablokować.' -cannot-add-additional-sign-quick: '&6[LockettePro] &cNie możesz tutaj postawić tabliczki' -locked-manual: '&6[LockettePro] &aBlok zablokowany pomyślnie.' -additional-sign-added-manual: '&6[LockettePro] &aKolejna tabliczka dodana pomyślnie.' -cannot-lock-manual: '&6[LockettePro] &cNie możesz tego zablokować.' -cannot-add-additional-sign-manual: '&6[LockettePro] &cNie możesz tutaj postawić tabliczki' -not-locked-yet-manual: '&6[LockettePro] &cTen blok nie jest jeszcze zablokowany.' -cannot-lock-door-nearby-manual: '&6[LockettePro] &cW pobliżu są drzwi.' -block-already-locked-manual: '&6[LockettePro] &cTen blok jest już zablokowany.' -block-is-not-lockable: '&6[LockettePro] &cTego bloku nie można zablokować.' -sign-selected: '&6[LockettePro] &aTabliczka wybrana.' -break-own-lock-sign: '&6[LockettePro] &aZniszczyłeś swoją bkokującą tabliczkę.' -cannot-break-this-lock-sign: '&6[LockettePro] &cNie możesz zniszczyć tej tabliczki blokującej.' -break-own-additional-sign: '&6[LockettePro] &aZniszczyłeś swoją dodatkową tabliczkę.' -break-redundant-additional-sign: '&6[LockettePro] &aZniszczyłeś niepotrzebną tabliczkę.' -cannot-break-this-additional-sign: '&6[LockettePro] &cNie możesz zniszczyć tej dodatkowej tabliczki.' -block-is-locked: '&6[LockettePro] &cTen blok jest zablokowany.' -cannot-interfere-with-others: '&6[LockettePro] &cNie możesz postawić bloku który może wpływać na inne.' -sign-error: '&4[BŁĄD]' \ No newline at end of file diff --git a/LockettePro/src/main/resources/lang_zh-cn.yml b/LockettePro/src/main/resources/lang_zh-cn.yml deleted file mode 100644 index 705ef12..0000000 --- a/LockettePro/src/main/resources/lang_zh-cn.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Chinese (simplified) translation by connection_lost -command-usage: "&6[LockettePro] &bLockettePro 插件说明\n&c1. 为箱子添加或删除用户,首先右键选中一个牌子, 然后输入/lock 行号 玩家名 即可。\n&c2. 管理员重载插件配置,使用 /lock reload\nLockettePro by connection_lost" -you-can-quick-lock-it: '&6[LockettePro] 手持牌子右键箱子即可上锁。' -you-can-manual-lock-it: '&6[LockettePro] 贴上一个牌子并写上[Private]即可上锁。' -config-reloaded: '&6[LockettePro] &a配置已重新加载。' -no-permission: '&6[LockettePro] &c你没有使用这个指令的权限。' -no-sign-selected: '&6[LockettePro] &c请先右键选择一个牌子。' -sign-need-reselect: '&6[LockettePro] &c请重新选择一下牌子。' -line-is-too-long: '&6[LockettePro] &c你为牌子输入的文字太长了!' -cannot-change-this-line: '&6[LockettePro] &c你不可以修改这一行。' -sign-changed: '&6[LockettePro] &a牌子已修改。' -locked-quick: '&6[LockettePro] &a方块已上锁。' -additional-sign-added-quick: '&6[LockettePro] &a额外的用户牌子已添加。' -cannot-lock-quick: '&6[LockettePro] &c你不可以锁这个方块。' -cannot-add-additional-sign-quick: '&6[LockettePro] &c你不可以在这里添加牌子。' -locked-manual: '&6[LockettePro] &a方块已上锁。' -additional-sign-added-manual: '&6[LockettePro] &a额外的用户牌子已添加。' -cannot-lock-manual: '&6[LockettePro] &c你不可以锁这个方块。' -cannot-add-additional-sign-manual: '&6[LockettePro] &c你不可以在这里添加牌子。' -not-locked-yet-manual: '&6[LockettePro] &c这个方块还没有上锁。' -cannot-lock-door-nearby-manual: '&6[LockettePro] &c这附近有别人的门。' -block-already-locked-manual: '&6[LockettePro] &c这个方块已经被锁好了。' -block-is-not-lockable: '&6[LockettePro] &c这种方块不能上锁。' -sign-selected: '&6[LockettePro] &a你选中了一个牌子,输入/lock 行号 玩家名 来修改它。' -break-own-lock-sign: '&6[LockettePro] &a你拆掉了你的锁。' -cannot-break-this-lock-sign: '&6[LockettePro] &c你不可以拆掉别人的锁。' -break-own-additional-sign: '&6[LockettePro] &a你拆掉了你的额外用户牌子。' -break-redundant-additional-sign: '&6[LockettePro] &a你拆掉了废弃的额外用户牌子。' -cannot-break-this-additional-sign: '&6[LockettePro] &c你不可以拆掉别人的牌子。' -block-is-locked: '&6[LockettePro] &c这个方块已上锁。' -cannot-interfere-with-others: '&6[LockettePro] &c你不能在已上锁的方块附近放这个。' -sign-error: '&4[ERROR]' \ No newline at end of file diff --git a/LockettePro/src/main/resources/plugin.yml b/LockettePro/src/main/resources/plugin.yml deleted file mode 100644 index 5eac849..0000000 --- a/LockettePro/src/main/resources/plugin.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: LockettePro -main: me.crafter.mc.lockettepro.LockettePro -author: connection_lost -softdepend: [Vault, WorldGuard, ProtocolLib, CoreProtect] -loadbefore: [SignShop] -version: 2.10.10 -api-version: 1.13 -description: > - LockettePro is a chest protection plugin for Bukkit. It is 100% compatible with original Lockette, but delivers a lot of performance enhancements and feature options. -commands: - lockettepro: - permission: lockettepro.command - usage: | - /lock - aliases: [lock, lockette, lockit] -permissions: - lockettepro.command: - description: Command permission for LockettePro - default: true - lockettepro.lock: - description: Basic lock permission - default: true - lockettepro.edit: - description: Edit sign permission - default: true \ No newline at end of file From 9edef0603beb189cf33cece30736de1cac9559ba Mon Sep 17 00:00:00 2001 From: DefineOutside <49797025+MWHunter@users.noreply.github.com> Date: Mon, 29 Mar 2021 12:16:33 -0500 Subject: [PATCH 4/4] Fix pom --- .gitignore | 95 ++++++++++++++++++++++++++++++++++++++++++++---------- pom.xml | 5 --- 2 files changed, 78 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index a1c2a23..ca22821 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,84 @@ -# Compiled class file +############################## +## Java +############################## +.mtj.tmp/ *.class +*.jar +*.war +*.ear +*.nar +hs_err_pid* -# Log file -*.log +############################## +## Maven +############################## +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +pom.xml.bak +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar -# BlueJ files -*.ctxt +############################## +## Gradle +############################## +bin/ +build/ +.gradle +.gradletasknamecache +gradle-app.setting +!gradle-wrapper.jar -# Mobile Tools for Java (J2ME) -.mtj.tmp/ +############################## +## IntelliJ +############################## +out/ +.idea/ +.idea_modules/ +*.iml +*.ipr +*.iws -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar +############################## +## Eclipse +############################## +.settings/ +bin/ +tmp/ +.metadata +.classpath +.project +*.tmp +*.bak +*.swp +*~.nib +local.properties +.loadpath +.factorypath -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* +############################## +## NetBeans +############################## +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +nbactions.xml +nb-configuration.xml + +############################## +## Visual Studio Code +############################## +.vscode/ +.code-workspace + +############################## +## OS X +############################## +.DS_Store diff --git a/pom.xml b/pom.xml index cbbfc6c..1232147 100644 --- a/pom.xml +++ b/pom.xml @@ -36,10 +36,6 @@ false - - com.comphenix - me.crafter.mc.shaded.com.comphenix - net.sf.cglib me.crafter.mc.shaded.net.sf.cglib @@ -94,7 +90,6 @@ com.comphenix.protocol ProtocolLib 4.6.0 - provided net.coreprotect