Plugin category: Prison Server Plugin Suggested name: GuardStick What I want: So, I'm not sure if this plugin has already been created (haven't seen it anywhere on bukkit.org), but, I've seen it on other prison servers. What I'd like this plugin to do is when you take a blaze rod (any type, whether it is from gm, the nether, etc), and click on a player holding a sword in their hand, it'll take the sword, putting it into your inventory, but with NO ENCHANTS (if there are any enchants that is). Also, in the config you may change the blaze rod to any item. Ideas for commands: No commands, just add a kit in the essentials config giving you a blaze rod. Ideas for permissions: - guardstick.use (gives perms for the player to use the blaze rod to take another player's sword away) When I'd like it by: Two days or less.
nuperu nuperu that message saying ‘Sure, that’d be great.’ only just showed up for me xD EDIT by Moderator: merged posts, please use the edit button instead of double posting.
nuperu <Edit by Moderator: Redacted mediafire url> It took longer than 15 minutes because i found a bug and fixed it real quick, if you find any bugs, which I’m pretty sure you won’t, then tell me. I’ll be adding a option in the config, that if you set the messages to ‘none’ a message won’t be displayed. Tell me if you want that version or not. Also if you got a prison server would you mind letting me play on it? xD Enjoy bud.
maved145 Thanks again, the plugin is great as it is. My server IP is <removed advertising> , the only thing I really need to do on it is finish up the enjin site and set up some voting links.
maved145 default players can take the swords also, and they don't even have blaze rods, just their fists :/
Don't bump within 24 hours If people don't respond immediately they may be busy as we do have lives outside Minecraft and Bukkit
Geekxboy Well, I do know that you all have lives outside of minecraft, so do I, but you don't have to be rude about saying it. This plugin is really all I need for my mc server to be finished so.. you know, I'm kinda anxious.
Just wait for maved145 to come back and he will fix any issues with the plugin Or if I get the okay from him then I'll fix any issues there might be
Geekxboy i don’t really know whats going on. my code looks right to me, but if you want to do it its fine by me.
Geekxboy heres my code. The checking of the sword in the target players hand works, but the checking of the blaze rod, in the players hand doesn’t work. it lets you use anything to steal the sword. Code:java package me.Maved145.GuardStick; import java.util.Map.Entry; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Material;import org.bukkit.command.CommandSender;import org.bukkit.enchantments.Enchantment;import org.bukkit.entity.HumanEntity;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerInteractEntityEvent;import org.bukkit.inventory.ItemStack;import org.bukkit.plugin.java.JavaPlugin; public class GuardStick extends JavaPlugin implements Listener{public void onEnable(){sendConsoleMessage("&bGuardStick &6v1.0 &dhas been Enabled!");sendConsoleMessage("&bGuardStick &dmade by Maved145!");getServer().getPluginManager().registerEvents(this, this);saveDefaultConfig();} public void onDisable(){saveDefaultConfig();sendConsoleMessage("&bGuardStick &6v1.0 &dhas been Disabled!");sendConsoleMessage("&bGuardStick &dmade by Maved145!");} public String sendConsoleMessage(String msg){return sendMessage(Bukkit.getConsoleSender(), msg);} public String sendMessage(CommandSender target, String msg){target.sendMessage(msg.replace('&', '§'));return msg.replace('&', '§');} @SuppressWarnings("deprecation")@EventHandlerpublic void onPlayerClick(PlayerInteractEntityEvent event){if ((event).getRightClicked() instanceof HumanEntity){Player playerTarget = (Player) event.getRightClicked();Player player = (Player) event.getPlayer(); if (player.getItemInHand().getType() == Material.BLAZE_ROD && playerTarget.getItemInHand().getType() == Material.DIAMOND_SWORD || playerTarget.getItemInHand().getType() == Material.GOLD_SWORD || playerTarget.getItemInHand().getType() == Material.IRON_SWORD || playerTarget.getItemInHand().getType() == Material.STONE_SWORD || playerTarget.getItemInHand().getType() == Material.WOOD_SWORD){ ItemStack ItemInHand = new ItemStack(playerTarget.getItemInHand());for (Entry<Enchantment, Integer> e : ItemInHand.getEnchantments().entrySet()){ItemInHand.removeEnchantment(e.getKey());} playerTarget.getInventory().remove(playerTarget.getItemInHand());playerTarget.updateInventory(); player.getInventory().addItem((ItemInHand));player.updateInventory();String stolensword = ItemInHand.getType().toString();String messagetothief = getConfig().getString("Thief.message-to-user").replaceAll("&0", ChatColor.BLACK + "").replaceAll("&1", ChatColor.DARK_BLUE + "").replaceAll("&2", ChatColor.DARK_GREEN + "").replaceAll("&3", ChatColor.DARK_AQUA + "").replaceAll("&4", ChatColor.DARK_RED + "").replaceAll("&5", ChatColor.DARK_PURPLE + "").replaceAll("&6", ChatColor.GOLD + "").replaceAll("&7", ChatColor.GRAY + "").replaceAll("&8", ChatColor.DARK_GRAY + "").replaceAll("&9", ChatColor.BLUE + "").replaceAll("&a", ChatColor.GREEN + "").replaceAll("&b", ChatColor.AQUA + "").replaceAll("&c", ChatColor.RED + "").replaceAll("&d", ChatColor.LIGHT_PURPLE + "").replaceAll("&e", ChatColor.YELLOW + "").replaceAll("&f", ChatColor.WHITE + "").replaceAll("&l", ChatColor.BOLD + "").replaceAll("&n", ChatColor.UNDERLINE + "").replaceAll("&o", ChatColor.ITALIC + "").replaceAll("&k", ChatColor.MAGIC + "").replaceAll("&m", ChatColor.STRIKETHROUGH + "").replaceAll("&r", ChatColor.RESET + "").replaceAll("%stolensword%", stolensword).replaceAll("%victim%", playerTarget.getName()).replaceAll("%thief%", player.getName()).replaceAll("DIAMOND_SWORD", "Diamond Sword").replaceAll("GOLD_SWORD", "Gold Sword").replaceAll("IRON_SWORD", "Iron Sword").replaceAll("STONE_SWORD", "Stone Sword").replaceAll("WOOD_SWORD", "Wood Sword");String messagetovictim = getConfig().getString("Victim.message-to-user").replaceAll("&0", ChatColor.BLACK + "").replaceAll("&1", ChatColor.DARK_BLUE + "").replaceAll("&2", ChatColor.DARK_GREEN + "").replaceAll("&3", ChatColor.DARK_AQUA + "").replaceAll("&4", ChatColor.DARK_RED + "").replaceAll("&5", ChatColor.DARK_PURPLE + "").replaceAll("&6", ChatColor.GOLD + "").replaceAll("&7", ChatColor.GRAY + "").replaceAll("&8", ChatColor.DARK_GRAY + "").replaceAll("&9", ChatColor.BLUE + "").replaceAll("&a", ChatColor.GREEN + "").replaceAll("&b", ChatColor.AQUA + "").replaceAll("&c", ChatColor.RED + "").replaceAll("&d", ChatColor.LIGHT_PURPLE + "").replaceAll("&e", ChatColor.YELLOW + "").replaceAll("&f", ChatColor.WHITE + "").replaceAll("&l", ChatColor.BOLD + "").replaceAll("&n", ChatColor.UNDERLINE + "").replaceAll("&o", ChatColor.ITALIC + "").replaceAll("&k", ChatColor.MAGIC + "").replaceAll("&m", ChatColor.STRIKETHROUGH + "").replaceAll("&r", ChatColor.RESET + "").replaceAll("%stolensword%", stolensword).replaceAll("%victim%", playerTarget.getName()).replaceAll("%thief%", player.getName()).replaceAll("DIAMOND_SWORD", "Diamond Sword").replaceAll("GOLD_SWORD", "Gold Sword").replaceAll("IRON_SWORD", "Iron Sword").replaceAll("STONE_SWORD", "Stone Sword").replaceAll("WOOD_SWORD", "Wood Sword");player.sendMessage(messagetothief);playerTarget.sendMessage(messagetovictim);}else{return;}}else{return;} } }
Small issue with your if statement so i broke the statement up into 2 parts nuperu Download below and I haven't tested it Download link
Geekxboy Code? I’d like to see what the problem was. Geekxboy wow don’t matter, i see. so i couldn’t use && to do it, i had to make it a whole different if statement ;/ logic EDIT by Moderator: merged posts, please use the edit button instead of double posting.
in your if statement of your PlayerInteractEntityEvent event there was no separation between your ANDs and ORs so they could have the perm and the guard stick OR have any of the swords
It didnt need to be a whole different statement (you can use parenthesis to separate them) but i did it because i hate long if statements
nuperu I sent you the most recent file on Skype with the permissions added in. Geekxboy Yeah i know what you mean, I should of thought about it really, I’m still a beginner so, i learn things new everyday EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Sorry for all the struggle guys. Just want to say thank you so much! This plugin is exactly what I wanted and it fits perfectly.