mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
it working yeah
Former-commit-id: df40d5a6c77a80dfed0b2f0fabcc00448c955815 [formerly c090d5450d209a91f1cdf1e8555219d2a250a69d] Former-commit-id: c145e0d2bf365d55c71ee1b0cd40484532ec6284
This commit is contained in:
1 parent
fec6fcec2a
commit
3bedbe9f68
2 files changed
+36
-43
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package org.maxgamer.quickshop.Command;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -52,7 +51,8 @@ public class QS implements CommandExecutor {
|
||||
public void signGUIApi(ArrayList<Object> data, String arg) {
|
||||
Shop shop = (Shop) data.get(0);
|
||||
String type = (String) data.get(1);
|
||||
Player player = Bukkit.getPlayer((String) data.get(3));
|
||||
Player player = Bukkit.getPlayer(UUID.fromString(String.valueOf(data.get(2))));
|
||||
Util.debugLog(String.valueOf(data.size()));
|
||||
switch (type) {
|
||||
case "owner":
|
||||
uiOwner(shop, arg, player);
|
||||
@@ -228,34 +228,29 @@ public class QS implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
private void sign(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player))
|
||||
return;
|
||||
if (args.length < 10) // sign world x y z type line1 line2 line3 line4
|
||||
return;
|
||||
ShopManager manager = new ShopManager(plugin);
|
||||
Util.debugLog("sign");
|
||||
ShopManager manager = plugin.getShopManager();
|
||||
Shop shop = manager.getShop(new Location(Bukkit.getWorld(args[1]), Integer.valueOf(args[2]),
|
||||
Integer.valueOf(args[3]), Integer.valueOf(args[4])));
|
||||
if (shop == null)
|
||||
if (shop == null) {
|
||||
Util.debugLog("shop null!");
|
||||
return;
|
||||
String[] texts = new String[3];
|
||||
String type = args[5];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String string = args[i];
|
||||
if (i < 6)
|
||||
return;
|
||||
texts[i - 6] = string;
|
||||
}
|
||||
try {
|
||||
Util.debugLog("remakeing data...");
|
||||
String[] texts = new String[4];
|
||||
String type = args[5];
|
||||
texts[0] = args[6];
|
||||
texts[1] = args[7];
|
||||
texts[2] = args[8];
|
||||
texts[3] = args[9];
|
||||
Util.debugLog("done");
|
||||
Util.debugLog("submiting data");
|
||||
ArrayList<Object> data = new ArrayList<>();
|
||||
data.add(shop);
|
||||
data.add(type);
|
||||
data.add(((Player) sender).getUniqueId());
|
||||
signPlayerCache.put(((Player) sender).getUniqueId(), data);
|
||||
Util.sendSignEditForGUI((Player) sender, texts);
|
||||
} catch (InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void remove(CommandSender sender, String[] args) {
|
||||
@@ -830,7 +825,7 @@ public class QS implements CommandExecutor {
|
||||
if (subArg.equals("unlimited")) {
|
||||
setUnlimited(sender);
|
||||
return true;
|
||||
} else if (subArg.startsWith("unlimited")) {
|
||||
} else if (subArg.startsWith("silentunlimited")) {
|
||||
silentUnlimited(sender, args);
|
||||
return true;
|
||||
} else if (subArg.equals("setowner")) {
|
||||
@@ -942,7 +937,7 @@ public class QS implements CommandExecutor {
|
||||
if (args.length < 5) {
|
||||
return;
|
||||
}
|
||||
ShopManager manager = new ShopManager(plugin);
|
||||
ShopManager manager = plugin.getShopManager();
|
||||
try {
|
||||
Shop shop = manager.getShop(new Location(Bukkit.getWorld(args[4]), Integer.parseInt(args[1]),
|
||||
Integer.parseInt(args[2]), Integer.parseInt(args[3])));
|
||||
|
||||
@@ -31,8 +31,7 @@ import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -186,31 +185,30 @@ public class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void sendSignEditForGUI(Player player, String[] texts) throws InvocationTargetException {
|
||||
public static void sendSignEditForGUI(Player player, String[] lines) {
|
||||
debugLog("SignEdit");
|
||||
ProtocolManager manager = plugin.getProtocolLib();
|
||||
BlockPosition position = new BlockPosition(player.getLocation().getBlockX(), 255,
|
||||
player.getLocation().getBlockZ());
|
||||
|
||||
PacketContainer blockPacket = manager.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
|
||||
blockPacket.getBlockPositionModifier().write(0, position);
|
||||
blockPacket.getBlockData().write(0, WrappedBlockData.createData(Material.WALL_SIGN));
|
||||
PacketContainer blockChange = manager.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
|
||||
blockChange.getBlockPositionModifier().write(0, position);
|
||||
blockChange.getBlockData().write(0, WrappedBlockData.createData(Material.WALL_SIGN));
|
||||
PacketContainer updateSign = manager.createPacket(PacketType.Play.Server.UPDATE_SIGN);
|
||||
updateSign.getBlockPositionModifier().write(0, position);
|
||||
updateSign.getChatComponentArrays().write(0, new WrappedChatComponent[]{WrappedChatComponent.fromText(lines[0]), WrappedChatComponent.fromText(lines[1]), WrappedChatComponent.fromText(lines[2]), WrappedChatComponent.fromText(lines[3])});
|
||||
PacketContainer open = manager.createPacket(PacketType.Play.Server.OPEN_SIGN_ENTITY);
|
||||
open.getBlockPositionModifier().write(0, position);
|
||||
|
||||
PacketContainer dataPacket = manager.createPacket(PacketType.Play.Server.TILE_ENTITY_DATA);
|
||||
dataPacket.getBlockPositionModifier().write(0, position);
|
||||
dataPacket.getIntegers().write(0, 9);
|
||||
|
||||
NbtCompound compound = (NbtCompound) dataPacket.getNbtModifier().read(0);
|
||||
for (int index = 0; index < 4; index++) {
|
||||
compound.put("Text" + (index + 1), "{\"extra\":[{\"text\":\"" + MsgUtil.getMessage(texts[index]) + "\"}],\"text\":\"\"}");
|
||||
try {
|
||||
manager.sendServerPacket(player, blockChange);
|
||||
manager.sendServerPacket(player, updateSign);
|
||||
manager.sendServerPacket(player, open);
|
||||
} catch (InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
dataPacket.getNbtModifier().write(0, compound);
|
||||
|
||||
PacketContainer editorPacket = manager.createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
|
||||
editorPacket.getBlockPositionModifier().write(0, position);
|
||||
|
||||
manager.sendServerPacket(player, blockPacket);
|
||||
manager.sendServerPacket(player, dataPacket);
|
||||
manager.sendServerPacket(player, editorPacket);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user