mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2025-01-06 00:18:34 +01:00
Fixed Offline Players Not Opening Chests
Fixed bug where it wasn't possible to open offline players chests!
This commit is contained in:
parent
4a33fae7b5
commit
265a84c6a3
@ -1,7 +1,10 @@
|
||||
package com.jamesdpeters.minecraft.chests.commands;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.*;
|
||||
import com.jamesdpeters.minecraft.chests.inventories.ChestLinkMenu;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Config;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Messages;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Permissions;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -77,7 +80,7 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
case OPEN:
|
||||
if(args.length > 1){
|
||||
if(sender.hasPermission(Permissions.OPEN)) {
|
||||
InventoryStorage invs = Config.getInventoryStorage(player, args[1]);
|
||||
InventoryStorage invs = Config.getInventoryStorage(player.getUniqueId(), args[1]);
|
||||
Utils.openInventory(player, invs.getInventory());
|
||||
return true;
|
||||
} else {
|
||||
@ -115,7 +118,7 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
if(args.length > 2){
|
||||
if(sender.hasPermission(Permissions.MEMBER)){
|
||||
Player toAdd = Bukkit.getPlayer(args[2]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player,args[1]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(),args[1]);
|
||||
if(storage != null && storage.addMember(toAdd)) Messages.ADDED_MEMBER(player,storage,args[2]);
|
||||
else Messages.UNABLE_TO_ADD_MEMBER(player,args[2]);
|
||||
}
|
||||
@ -129,7 +132,7 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
if(args.length > 2){
|
||||
if(sender.hasPermission(Permissions.MEMBER)){
|
||||
Player toAdd = Bukkit.getPlayer(args[2]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player,args[1]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(),args[1]);
|
||||
if(storage != null && storage.removeMember(toAdd)) Messages.REMOVE_MEMBER(player,storage,args[2]);
|
||||
else Messages.UNABLE_TO_REMOVE_MEMBER(player,args[2]);
|
||||
}
|
||||
@ -163,7 +166,7 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
case REMOVE:
|
||||
case ADDMEMBER:
|
||||
case REMOVEMEMBER:
|
||||
return new ArrayList<>(Config.getPlayer(player).keySet());
|
||||
return new ArrayList<>(Config.getPlayer(player.getUniqueId()).keySet());
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
}
|
||||
@ -173,7 +176,7 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
case ADDMEMBER:
|
||||
return Utils.getOnlinePlayers();
|
||||
case REMOVEMEMBER:
|
||||
return Utils.getPlayersAsNameList(Config.getInventoryStorage(player,args[1]).getMembers());
|
||||
return Utils.getPlayersAsNameList(Config.getInventoryStorage(player.getUniqueId(),args[1]).getMembers());
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.jamesdpeters.minecraft.chests.containers;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.Config;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Config;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,14 +15,14 @@ public class ChestLinkInfo {
|
||||
private InventoryStorage storage;
|
||||
|
||||
public ChestLinkInfo(String playerUUID, String group){
|
||||
this(Bukkit.getOfflinePlayer(UUID.fromString(playerUUID)).getPlayer(),group);
|
||||
this(UUID.fromString(playerUUID),group);
|
||||
}
|
||||
|
||||
public ChestLinkInfo(Player player, String group){
|
||||
public ChestLinkInfo(UUID playerUUID, String group){
|
||||
this.group = group;
|
||||
this.storage = Config.getInventoryStorage(player,group);
|
||||
this.player = player;
|
||||
this.playerUUID = player.getUniqueId();
|
||||
this.storage = Config.getInventoryStorage(playerUUID,group);
|
||||
this.player = Bukkit.getOfflinePlayer(playerUUID).getPlayer();
|
||||
this.playerUUID = playerUUID;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.jamesdpeters.minecraft.chests.inventories;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import fr.minuskube.inv.ClickableItem;
|
||||
import fr.minuskube.inv.SmartInventory;
|
||||
|
@ -1,17 +1,14 @@
|
||||
package com.jamesdpeters.minecraft.chests.inventories;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.Config;
|
||||
import com.jamesdpeters.minecraft.chests.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Config;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import fr.minuskube.inv.ClickableItem;
|
||||
import fr.minuskube.inv.SmartInventory;
|
||||
import fr.minuskube.inv.content.InventoryContents;
|
||||
import fr.minuskube.inv.content.InventoryProvider;
|
||||
import fr.minuskube.inv.content.Pagination;
|
||||
import fr.minuskube.inv.content.SlotIterator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -29,7 +26,7 @@ public class ChestLinkMenu implements InventoryProvider {
|
||||
private SmartInventory menu;
|
||||
|
||||
private ChestLinkMenu(Player player){
|
||||
this.storages = Config.getPlayer(player).values();
|
||||
this.storages = Config.getPlayer(player.getUniqueId()).values();
|
||||
menu = SmartInventory.builder()
|
||||
.id("chestLinkMenu")
|
||||
.title("Inventory Storage")
|
||||
|
@ -1,29 +1,23 @@
|
||||
package com.jamesdpeters.minecraft.chests.listeners;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.*;
|
||||
import com.jamesdpeters.minecraft.chests.containers.ChestLinkInfo;
|
||||
import com.jamesdpeters.minecraft.chests.misc.*;
|
||||
import com.jamesdpeters.minecraft.chests.runnables.ChestLinkVerifier;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.Directional;
|
||||
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.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ChestLinkListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
@ -35,7 +29,7 @@ public class ChestLinkListener implements Listener {
|
||||
public void onSignChange(SignChangeEvent signChangeEvent) {
|
||||
if (event.getBlockPlaced().getLocation().equals(signChangeEvent.getBlock().getLocation())) {
|
||||
Sign sign = (Sign) signChangeEvent.getBlock().getState();
|
||||
ChestLinkInfo info = Utils.getChestLinkInfo(sign, signChangeEvent.getLines(), signChangeEvent.getPlayer());
|
||||
ChestLinkInfo info = Utils.getChestLinkInfo(sign, signChangeEvent.getLines(),event.getPlayer().getUniqueId());
|
||||
if (info != null) {
|
||||
if(event.getPlayer().hasPermission(Permissions.ADD)) {
|
||||
if (Utils.isValidSignPosition(event.getBlockAgainst().getLocation())) {
|
||||
|
Loading…
Reference in New Issue
Block a user