Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

Commit

Permalink
1.16.3 update
Browse files Browse the repository at this point in the history
Adjust protection for commands in books. There are more complex ways of doing this with better results, but this achieves the same goal.
Adds entries for Zombified Piglin, Piglin, and Piglin Brute
  • Loading branch information
ShakeforProtein committed Oct 6, 2020
1 parent f60095a commit d4e852b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 55 deletions.
4 changes: 2 additions & 2 deletions TreeboTickets.iml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.3-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.16.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.16.3-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.0.6" level="project" />
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.5" level="project" />
</component>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.ShakeforProtein</groupId>
<artifactId>TreeboTickets</artifactId>
<version>4.1.0 - SpMc1.16.2</version>
<version>4.2.0 - SpMc1.16.3</version>
<packaging>jar</packaging>

<name>TreeboTickets</name>
Expand Down Expand Up @@ -110,13 +110,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.2-R0.1-SNAPSHOT</version>
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.2-R0.1-SNAPSHOT</version>
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package me.shakeforprotein.treebotickets.Listeners.InventoryEvents;

import me.shakeforprotein.treebotickets.TreeboTickets;
import net.minecraft.server.v1_16_R2.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_16_R2.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.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;

import java.util.Set;

public class PlayerUseItem implements Listener {

Expand All @@ -25,49 +19,13 @@ public PlayerUseItem(TreeboTickets main) {
}

@EventHandler
public void playerUseItem(PlayerInteractEvent e) {
Inventory inv = Bukkit.createInventory(null,9,"AntiHack Triggered");
public void playerRunCommand(PlayerCommandPreprocessEvent e) {
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_16_R2.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;
}
}
}
}
}
if (e.getPlayer().hasPermission("tbtickets.admin.restoreinventory") && e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName() && e.getItem().getItemMeta().getDisplayName().contains("Death Docket -")) {
if (e.getItem().getItemMeta().getLore().get(4) != null) {
String cmd = "tellraw " + e.getPlayer().getName() + " [\"\",{\"text\":\"Click \"},{\"text\":\"[HERE]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/restoreplayerinventory " + e.getItem().getItemMeta().getLore().get(0).split(" - ")[1] + " " + e.getItem().getItemMeta().getLore().get(4).split(" - ")[1] + "\"}},{\"text\":\" to restore player inventory.\"}]";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);

}
}
ItemStack mainHandItem = e.getPlayer().getInventory().getItemInMainHand();
ItemStack offHandItem = e.getPlayer().getInventory().getItemInOffHand();
if(mainHandItem.getType() == Material.WRITTEN_BOOK || offHandItem.getType() == Material.WRITTEN_BOOK){
e.setCancelled(true);
p.sendMessage("For your protection, commands have been disabled while holding a written book.");
}
}

public net.minecraft.server.v1_16_R2.ItemStack getNMSItem(ItemStack item){
net.minecraft.server.v1_16_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
return nmsItem;
}

public NBTTagCompound getCompound(net.minecraft.server.v1_16_R2.ItemStack nmsItem){
NBTTagCompound nmsCompound = (nmsItem.hasTag()) ? nmsItem.getTag() : new NBTTagCompound();
return nmsCompound;
}

public ItemStack getBukkitItem(net.minecraft.server.v1_16_R2.ItemStack nmsItem){
ItemStack bukkitItem = CraftItemStack.asBukkitCopy(nmsItem);
return bukkitItem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ private void onPlayerKillEvent(EntityDeathEvent e) {
if (entity.getType().toString().toLowerCase().contains(mob.toLowerCase()) || entity.getType().toString().replace(" ","").replace("_","").toLowerCase().contains(mob.toLowerCase())) {
String killedMob = mob.toUpperCase().replace(" ","").replace("_", "");
if (killedMob.toLowerCase().equalsIgnoreCase("PIGZOMBIE")){killedMob = "ZOMBIEPIGMAN";}
if (killedMob.toLowerCase().equalsIgnoreCase("PIGLIN")){killedMob = "ZOMBIEPIGMAN";}
if (killedMob.toLowerCase().equalsIgnoreCase("PIGLIN_BRUTE")){killedMob = "ZOMBIEPIGMAN";}
if (killedMob.toLowerCase().equalsIgnoreCase("ZOMBIFIED_PIGLIN")){killedMob = "ZOMBIEPIGMAN";}
if (killedMob.toLowerCase().equalsIgnoreCase("WITHER")){killedMob = "WITHERBOSS";}
addStatistic.addStatistic(killer,"kills",killedMob);
addStatistic.addStatistic(killer,"kills","TOTALMOB");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -446,8 +447,11 @@ private void defineMobList() {
mobList.add("CAVE_SPIDER");
mobList.add("ELDER_GUARDIAN");
mobList.add("PIG_ZOMBIE");
mobList.add("ZOMBIE PIGMAN");
mobList.add("ZOMBIF PIGMAN");
mobList.add("ZOMBIFIED_PIGLIN");
mobList.add("ZOMBIE_VILLAGER");
mobList.add("PIGLIN");
mobList.add("PIGLIN_BRUTE");
mobList.add("IRON_GOLEM");
mobList.add("SNOW_GOLEM");
mobList.add("ENDER_DRAGON");
Expand Down

0 comments on commit d4e852b

Please sign in to comment.