Skip to content

Instantly share code, notes, and snippets.

@mooman219
Last active December 20, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mooman219/6094041 to your computer and use it in GitHub Desktop.
Save mooman219/6094041 to your computer and use it in GitHub Desktop.
package com.gmail.mooman219;
import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
public class AntiShiftClicker extends JavaPlugin implements Listener {
private static final Logger log = Logger.getLogger("Minecraft");
@Override
public void onEnable() {
this.getServer().getPluginManager().registerEvents(this, this);
PluginDescriptionFile pdfFile = getDescription();
log.info(pdfFile.getName() + " v" + pdfFile.getVersion() + " enabled. Created by: " + pdfFile.getAuthors());
}
@Override
public void onDisable() {
PluginDescriptionFile pdfFile = getDescription();
log.info(pdfFile.getName() + " v" + pdfFile.getVersion() + " disabled. Created by: " + pdfFile.getAuthors());
}
@EventHandler()
public void onClick(InventoryClickEvent event) {
if(event.isShiftClick()) {
event.setCancelled(true);
}
}
@SuppressWarnings("deprecation")
@EventHandler()
public void onInteract(PlayerInteractEvent event) {
if(event.hasItem() && event.getItem() != null && isArmor(event.getItem().getType())) {
event.setCancelled(true);
event.getPlayer().updateInventory();
}
}
public boolean isArmor(Material material) {
switch(material) {
case GOLD_HELMET:
case DIAMOND_HELMET:
case IRON_HELMET:
case CHAINMAIL_HELMET:
case LEATHER_HELMET:
case GOLD_CHESTPLATE:
case DIAMOND_CHESTPLATE:
case IRON_CHESTPLATE:
case CHAINMAIL_CHESTPLATE:
case LEATHER_CHESTPLATE:
case GOLD_LEGGINGS:
case DIAMOND_LEGGINGS:
case IRON_LEGGINGS:
case CHAINMAIL_LEGGINGS:
case LEATHER_LEGGINGS:
case GOLD_BOOTS:
case DIAMOND_BOOTS:
case IRON_BOOTS:
case CHAINMAIL_BOOTS:
case LEATHER_BOOTS:
return true;
default:
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment