Did more work, but its not going to be done soon. So doing a release with it disabled
This commit is contained in:
parent
8869354b46
commit
58f39401d2
@ -45,7 +45,6 @@ public class DisguiseAPI {
|
|||||||
private static boolean hearSelfDisguise;
|
private static boolean hearSelfDisguise;
|
||||||
private static boolean hidingArmor;
|
private static boolean hidingArmor;
|
||||||
private static boolean hidingHeldItem;
|
private static boolean hidingHeldItem;
|
||||||
private static LibsDisguises libsDisguises;
|
|
||||||
|
|
||||||
// A internal storage of fake entity ID's I can use.
|
// A internal storage of fake entity ID's I can use.
|
||||||
// Realistically I could probably use a ID like "4" for everyone seeing as no one shares the ID
|
// Realistically I could probably use a ID like "4" for everyone seeing as no one shares the ID
|
||||||
@ -144,10 +143,6 @@ public class DisguiseAPI {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void init(LibsDisguises mainPlugin) {
|
|
||||||
libsDisguises = mainPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this entity disguised
|
* Is this entity disguised
|
||||||
*/
|
*/
|
||||||
|
@ -70,13 +70,12 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
PacketsManager.init(this);
|
PacketsManager.init(this);
|
||||||
DisguiseAPI.init(this);
|
|
||||||
DisguiseAPI.setSoundsEnabled(getConfig().getBoolean("DisguiseSounds"));
|
DisguiseAPI.setSoundsEnabled(getConfig().getBoolean("DisguiseSounds"));
|
||||||
DisguiseAPI.setVelocitySent(getConfig().getBoolean("SendVelocity"));
|
DisguiseAPI.setVelocitySent(getConfig().getBoolean("SendVelocity"));
|
||||||
DisguiseAPI.setViewDisguises(getConfig().getBoolean("ViewDisguises"));
|
DisguiseAPI.setViewDisguises(getConfig().getBoolean("ViewDisguises"));
|
||||||
DisguiseAPI.setHearSelfDisguise(getConfig().getBoolean("HearSelfDisguise"));
|
DisguiseAPI.setHearSelfDisguise(getConfig().getBoolean("HearSelfDisguise"));
|
||||||
DisguiseAPI.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor"));
|
// DisguiseAPI.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor"));
|
||||||
DisguiseAPI.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem"));
|
// DisguiseAPI.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem"));
|
||||||
if (DisguiseAPI.isHidingArmorFromSelf() || DisguiseAPI.isHidingHeldItemFromSelf()) {
|
if (DisguiseAPI.isHidingArmorFromSelf() || DisguiseAPI.isHidingHeldItemFromSelf()) {
|
||||||
DisguiseAPI.setInventoryListenerEnabled(true);
|
DisguiseAPI.setInventoryListenerEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -683,7 +683,7 @@ public class PacketsManager {
|
|||||||
};
|
};
|
||||||
// TODO Potentionally combine both listeners.
|
// TODO Potentionally combine both listeners.
|
||||||
inventoryListenerServer = new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.HIGHEST,
|
inventoryListenerServer = new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.HIGHEST,
|
||||||
Packets.Server.SET_SLOT) {
|
Packets.Server.SET_SLOT, Packets.Server.WINDOW_ITEMS) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
// If the inventory is the players inventory
|
// If the inventory is the players inventory
|
||||||
@ -735,6 +735,33 @@ public class PacketsManager {
|
|||||||
case Packets.Server.WINDOW_ITEMS: {
|
case Packets.Server.WINDOW_ITEMS: {
|
||||||
// TODO Find out how this works
|
// TODO Find out how this works
|
||||||
// It seems to 'update' the inventory.. Screw you..
|
// It seems to 'update' the inventory.. Screw you..
|
||||||
|
event.setPacket(event.getPacket().deepClone());
|
||||||
|
StructureModifier<Object> mods = event.getPacket().getModifier();
|
||||||
|
ItemStack[] items = (ItemStack[]) mods.read(1);
|
||||||
|
for (int slot = 0; slot < items.length; slot++) {
|
||||||
|
if (slot >= 5 && slot <= 8) {
|
||||||
|
if (disguise.isHidingArmorFromSelf()) {
|
||||||
|
// Get the bukkit armor slot!
|
||||||
|
int armorSlot = Math.abs((slot - 5) - 3);
|
||||||
|
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot];
|
||||||
|
if (item != null && item.getType() != Material.AIR) {
|
||||||
|
items[slot] = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Else if its a hotbar slot
|
||||||
|
} else if (slot >= 36 && slot <= 44) {
|
||||||
|
if (disguise.isHidingHeldItemFromSelf()) {
|
||||||
|
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||||
|
// Check if the player is on the same slot as the slot that its setting
|
||||||
|
if (slot == currentSlot + 36) {
|
||||||
|
org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand();
|
||||||
|
if (item != null && item.getType() != Material.AIR) {
|
||||||
|
items[slot] = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -850,6 +877,8 @@ public class PacketsManager {
|
|||||||
org.bukkit.inventory.ItemStack clickedItem;
|
org.bukkit.inventory.ItemStack clickedItem;
|
||||||
if (event.getPacket().getIntegers().read(3) == 1) {
|
if (event.getPacket().getIntegers().read(3) == 1) {
|
||||||
// Its a shift click
|
// Its a shift click
|
||||||
|
// TODO Make the item appear in the right place
|
||||||
|
// Also set the armor/item in hand to air cos the client is stupid.
|
||||||
clickedItem = event.getPacket().getItemModifier().read(0);
|
clickedItem = event.getPacket().getItemModifier().read(0);
|
||||||
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
|
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
|
||||||
org.bukkit.inventory.ItemStack armorItem = null;
|
org.bukkit.inventory.ItemStack armorItem = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user