This repository has been archived by the owner on Jun 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed 1.14.X compatibility Added 1.15.X compatibility
- Loading branch information
1 parent
f643088
commit 3f269cf
Showing
13 changed files
with
348 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/me/shakeforprotein/treebotickets/Listeners/InventoryEvents/PlayerUseItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package me.shakeforprotein.treebotickets.Listeners.InventoryEvents; | ||
|
||
import me.shakeforprotein.treebotickets.TreeboTickets; | ||
import net.minecraft.server.v1_15_R1.NBTTagCompound; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.BookMeta; | ||
|
||
import java.util.Set; | ||
|
||
public class PlayerUseItem implements Listener { | ||
|
||
private TreeboTickets pl; | ||
|
||
public PlayerUseItem(TreeboTickets main) { | ||
this.pl = main; | ||
} | ||
|
||
@EventHandler | ||
public void playerUseItem(PlayerInteractEvent e) { | ||
Inventory inv = Bukkit.createInventory(null,9,"AntiHack Triggered"); | ||
Player p = e.getPlayer(); | ||
if (e.getItem() != null) { | ||
if (e.getItem().getType() == Material.WRITTEN_BOOK) { | ||
if (e.getItem().hasItemMeta()) { | ||
if (e.getItem().getItemMeta() instanceof BookMeta) { | ||
net.minecraft.server.v1_15_R1.ItemStack nmsItem = getNMSItem(e.getItem()); | ||
NBTTagCompound compound = getCompound(nmsItem); | ||
Set<String> compoundKeys = compound.getKeys(); | ||
for(String item : compoundKeys){ | ||
if(compound.get(item).asString().contains("clickEvent")){ | ||
e.getItem().setItemMeta(null); | ||
e.getPlayer().openInventory(inv); | ||
e.getPlayer().closeInventory(); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public net.minecraft.server.v1_15_R1.ItemStack getNMSItem(ItemStack item){ | ||
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); | ||
return nmsItem; | ||
} | ||
|
||
public NBTTagCompound getCompound(net.minecraft.server.v1_15_R1.ItemStack nmsItem){ | ||
NBTTagCompound nmsCompound = (nmsItem.hasTag()) ? nmsItem.getTag() : new NBTTagCompound(); | ||
return nmsCompound; | ||
} | ||
|
||
public ItemStack getBukkitItem(net.minecraft.server.v1_15_R1.ItemStack nmsItem){ | ||
ItemStack bukkitItem = CraftItemStack.asBukkitCopy(nmsItem); | ||
return bukkitItem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.