1

Command is not registering correctly.

GoldenRodHero's Avatar GoldenRodHero6/24/14 11:36 pm
1 emeralds 349 4
6/25/2014 10:20 pm
GoldenRodHero's Avatar GoldenRodHero
Hey, I just finished programming a plugin. It's called "GuardFreeze" which allows guards to hit players that are holding contraband items, which teleports them to an interrogation room. Where they have to give up the item to the guard, if not they receive jail time. The plugin is 30% done. You first as a guard, have to type '/guard' to receive the punisher(stick). But once I'm ingame I try to type '/guard' it doesn't register. It justs sends the same message over and over again: '/guard' It repeats it in white chat color.

Here is the code:
package me.GoldenRod.GuardFreeze;

import java.util.Arrays;
import java.util.List;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class Freeze extends JavaPlugin implements Listener{


@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if(sender instanceof Player){
if (!((Player) sender).hasPermission("custom.guardfreeze")) {
Player p = (Player)sender;
if((commandLabel.equalsIgnoreCase("guard"))&&(args.length == 0)) {
ItemStack guard = new ItemStack(Material.STICK, 1);
Inventory inv = p.getInventory();
inv.setItem(0, guard);
p.updateInventory();
if(inv.getItem(0) !=null){
ItemMeta guardIM = inv.getItem(0).getItemMeta();
guardIM.setDisplayName(ChatColor.GOLD + "Jail em");
List<String> lore = Arrays.asList("This amazing stick", "made with special powers, crafted", "from Apollo's Gods ");
guardIM.setLore(lore);
inv.getItem(0).setItemMeta(guardIM);
}

}
}
}
return false;
}

}
===============================================
Here's the plugin.yml:
name: GuardFreeze
version: 1
description: Freeze em players!
main: me.GoldenRod.GuardFreeze.Freeze
author: GoldenRodHero
commands:
guard:
description: freeze dem.
usage: /<command>
===============================================
Thank you if you find out what the problem was!
Posted by GoldenRodHero's Avatar
GoldenRodHero
Level 3 : Apprentice Modder
3

Create an account or sign in to comment.

4

GoldenRodHero
06/25/2014 10:20 pm
Level 3 : Apprentice Modder
GoldenRodHero's Avatar
I fixed it. Ty for the help. All it was, was registering the events.
1
GoldenRodHero
06/25/2014 12:33 am
Level 3 : Apprentice Modder
GoldenRodHero's Avatar
Thank you!

EDIT: Thanks for the suggestion, but that did not solve the problem. By the way that is how the PMC text box pastes the plugin.yml all that is spaced correctly on eclipse.
1
TeamCraft-Robbie
06/25/2014 1:00 am
Level 5 : Apprentice Miner
TeamCraft-Robbie's Avatar
Np, mind posting the error from the console?
1
TeamCraft-Robbie
06/25/2014 12:20 am
Level 5 : Apprentice Miner
TeamCraft-Robbie's Avatar
Implement command executer not listener, and make sure that you use spaces and not tabs when your spacing out the plugin.yml
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome