Update to 1.15.2 API (Should still work with 1.14)
Fixed permission bug
Fixed #3 chest sound bug with CCrates.
This commit is contained in:
jameslfc19 2020-04-15 11:59:11 +01:00
parent 5a68bd8c5f
commit 426fbbbe70
5 changed files with 24 additions and 20 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
Server/
Server_1_14_4/
target/
*.log

View File

@ -44,7 +44,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -28,7 +28,6 @@ public class ChestLinkListener implements Listener {
@EventHandler
public void playerInteract(BlockPlaceEvent event){
if(event.getPlayer().hasPermission(Permissions.ADD)){
if(event.getBlockPlaced().getState() instanceof Sign){
if(event.getBlockAgainst().getState() instanceof Chest) {
new TempListener() {
@ -38,16 +37,20 @@ public class ChestLinkListener implements Listener {
Sign sign = (Sign) signChangeEvent.getBlock().getState();
ChestLinkInfo info = Utils.getChestLinkInfo(sign, signChangeEvent.getLines(), signChangeEvent.getPlayer());
if (info != null) {
if(Utils.isValidSignPosition(event.getBlockAgainst().getLocation())) {
Config.addChest(info.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation());
Messages.CHEST_ADDED(event.getPlayer(), info.getGroup(), event.getPlayer().getDisplayName());
setLine(sign, signChangeEvent, 0, ChatColor.RED + ChatColor.stripColor(signChangeEvent.getLine(0)));
setLine(sign, signChangeEvent, 1, ChatColor.GREEN + ChatColor.stripColor(signChangeEvent.getLine(1)));
setLine(sign, signChangeEvent, 2, ChatColor.BOLD + ChatColor.stripColor(event.getPlayer().getDisplayName()));
sign.getPersistentDataContainer().set(Values.playerUUID, PersistentDataType.STRING, event.getPlayer().getUniqueId().toString());
sign.update();
if(event.getPlayer().hasPermission(Permissions.ADD)) {
if (Utils.isValidSignPosition(event.getBlockAgainst().getLocation())) {
Config.addChest(info.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation());
Messages.CHEST_ADDED(event.getPlayer(), info.getGroup(), event.getPlayer().getDisplayName());
setLine(sign, signChangeEvent, 0, ChatColor.RED + ChatColor.stripColor(signChangeEvent.getLine(0)));
setLine(sign, signChangeEvent, 1, ChatColor.GREEN + ChatColor.stripColor(signChangeEvent.getLine(1)));
setLine(sign, signChangeEvent, 2, ChatColor.BOLD + ChatColor.stripColor(event.getPlayer().getDisplayName()));
sign.getPersistentDataContainer().set(Values.playerUUID, PersistentDataType.STRING, event.getPlayer().getUniqueId().toString());
sign.update();
} else {
Messages.SIGN_FRONT_OF_CHEST(event.getPlayer());
}
} else {
Messages.SIGN_FRONT_OF_CHEST(event.getPlayer());
Messages.NO_PERMISSION(event.getPlayer());
}
}
done();
@ -58,9 +61,7 @@ public class ChestLinkListener implements Listener {
}
}
} else {
Messages.NO_PERMISSION(event.getPlayer());
}
}

View File

@ -6,6 +6,7 @@ import com.jamesdpeters.minecraft.chests.Permissions;
import com.jamesdpeters.minecraft.chests.Utils;
import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder;
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -23,13 +24,14 @@ public class InventoryListener implements Listener {
}
}
@EventHandler
@EventHandler (priority = EventPriority.LOWEST)
public void onInventoryOpen(InventoryOpenEvent event){
try {
if (event.getPlayer() instanceof Player) {
if (event.getInventory().getLocation() != null) {
InventoryStorage storage = Config.getInventoryStorage(event.getInventory().getLocation());
if (storage != null) {
event.setCancelled(true);
if (event.getPlayer().hasPermission(Permissions.OPEN) && storage.hasPermission((Player) event.getPlayer())) {
Utils.openInventory((Player) event.getPlayer(), storage.getInventory());
@ -45,11 +47,11 @@ public class InventoryListener implements Listener {
@EventHandler
public void onInventoryClose(InventoryCloseEvent event){
try {
if (event.getInventory().getLocation() == null) {
Utils.closeInventorySound((Player) event.getPlayer(), event.getInventory());
}
if (event.getInventory().getHolder() instanceof VirtualInventoryHolder) {
Config.save();
if (event.getInventory().getLocation() == null) {
Utils.closeInventorySound((Player) event.getPlayer(), event.getInventory());
}
}
} catch (NullPointerException ignore){} //Essentials does something weird with enderchests - shit fix but works :)
}

View File

@ -1,7 +1,7 @@
name: ChestsPlusPlus
version: 1.14.4-v1
version: 1.15.2-v1
main: com.jamesdpeters.minecraft.chests.ChestsPlusPlus
api-version: "1.14"
api-version: "1.15"
commands:
chestlink: