Development Assistance Problem with stuff

Discussion in 'Plugin Help/Development/Requests' started by BizarrePlatinum, Jun 3, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    BizarrePlatinum

    Show Spoiler

    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            boolean isValid = false;
            if(!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "Console may not send this command!");
                return true;
            }
        
            Player p = (Player) sender;
        
            if(cmd.getName().equalsIgnoreCase("spawnvendor")) {
                if(args.length > 0) {
                    String vendorType = args[0].toUpperCase();
                    if(p.hasPermission("destiny.spawnvendor")) {
                        String[] validTypes = PlayerConfigs.getInstance().validVendorTypes;
                        for(int i = 0; i < validTypes.length; i++) {
                            if(validTypes[i] == vendorType) {
                                isValid = true;
                                break;
                            }
                        }
                        if(isValid == true) {
                            Entity e = p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
                            PlayerConfigs.getInstance().vendorType.put(e, vendorType);
                            return true;
                        }
                        p.sendMessage(ChatColor.RED + "Given vendor type is not valid.");
                        return true;
                    }
                    p.sendMessage(ChatColor.RED + "Insufficient permissions.");
                    return true;
                }
                p.sendMessage(ChatColor.RED + "A vendor type is required.");
                return true;
            }
            return true;
        }
    

    Show Spoiler

    Code:
    //Allows variables to be accessed remotely
        private static PlayerConfigs instance = new PlayerConfigs();
            
        public static PlayerConfigs getInstance() {
                    return instance;
                }
        
                //Misc inventories
                Inventory characterSelection = Bukkit.getServer().createInventory(null, 54, "Select Character");
                Inventory createCharacter = Bukkit.getServer().createInventory(null, 54, "Create Character");
            
                //Vendor inventories
                Inventory cryptarch = Bukkit.getServer().createInventory(null, 54, "Cryptarch");
                Inventory bounties = Bukkit.getServer().createInventory(null, 54, "Bounty Tracker");
                Inventory postMaster = Bukkit.getServer().createInventory(null, 54, "Postmaster");
                Inventory gunSmith = Bukkit.getServer().createInventory(null, 54, "Gunsmith");
                Inventory agentOfTheNine = Bukkit.getServer().createInventory(null, 54, "Xûr");
                Inventory crucibleHandler = Bukkit.getServer().createInventory(null, 54, "Crucible Handler");
                Inventory crucibleQuartermaster = Bukkit.getServer().createInventory(null, 54, "Crucible Quartermaster");
                Inventory deadOrbit = Bukkit.getServer().createInventory(null, 54, "Dead Orbit");
                Inventory discipleOfOsiris = Bukkit.getServer().createInventory(null, 54, "Disciple of Osiris");
                Inventory erisMorn = Bukkit.getServer().createInventory(null, 54, "Eris Morn");
                Inventory futureWarCult = Bukkit.getServer().createInventory(null, 54, "Future War Cult");
                Inventory guardianOutfitter = Bukkit.getServer().createInventory(null, 54, "Guardian Outfitter");
                Inventory houseOfJudgment = Bukkit.getServer().createInventory(null, 54, "House of Judgment");
                Inventory hunterVanguard = Bukkit.getServer().createInventory(null, 54, "Hunter Vanguard");
                Inventory ironBanner = Bukkit.getServer().createInventory(null, 54, "Iron Banner");
                Inventory newMonarchy = Bukkit.getServer().createInventory(null, 54, "New Monarchy");
                Inventory queensEmissary = Bukkit.getServer().createInventory(null, 54, "Queen's Emissary");
                Inventory queensWrath = Bukkit.getServer().createInventory(null, 54, "Queen's Wrath");
                Inventory shipWright = Bukkit.getServer().createInventory(null, 54, "Shipwright");
                Inventory specialOrders = Bukkit.getServer().createInventory(null, 54, "Special Orders");
                Inventory speaker = Bukkit.getServer().createInventory(null, 54, "The Speaker");
                Inventory titanVanguard = Bukkit.getServer().createInventory(null, 54, "Titan Vanguard");
                Inventory vanguardQuartermaster = Bukkit.getServer().createInventory(null, 54, "Vanguard Quartermaster");
                Inventory warlockVanguard = Bukkit.getServer().createInventory(null, 54, "Warlock Vanguard");
            
                //Used for checking if a vendor trying to be spawned is valid
                public String[] validVendorTypes = new String[]{"AGENTOFTHENINE", "BOUNTY", "CRUCIBLEHANDLER", "CRUCIBLEQUARTERMASTER", "CRYPTARCH", "DEADORBIT", "DISCIPLEOFOSIRIS", "ERISMORN", "FWC", "GUARDIANOUTFITTER", "GUNSMITH", "HOUSEOFJUDGMENT", "HUNTERVANGUARD", "IRONBANNER", "NEWMONARCHY", "POSTMASTER", "QUEENSEMISSARY", "QUEENSWRATH", "SHIPWRIGHT", "SPECIALORDERS", "SPEAKER", "TITANVANGUARD", "VANGUARDQUARTERMASTER", "WARLOCKVANGUARD"};
            
                //Misc hashmaps
                HashMap<Player, Integer> characterCount = new HashMap<Player, Integer>();
            
                //Reputation
                HashMap<Player, Double> vanguardRep = new HashMap<Player, Double>();
                HashMap<Player, Double> crucibleRep = new HashMap<Player, Double>();
                HashMap<Player, Double> deadOrbitRep = new HashMap<Player, Double>();
                HashMap<Player, Double> futureWarCultRep = new HashMap<Player, Double>();
                HashMap<Player, Double> newMonarchyRep = new HashMap<Player, Double>();
                HashMap<Player, Double> queensWrathRep = new HashMap<Player, Double>();
                HashMap<Player, Double> ironBannerRep = new HashMap<Player, Double>();
                HashMap<Player, Double> crotasBaneRep = new HashMap<Player, Double>();
                HashMap<Player, String> characterClass = new HashMap<Player, String>();
                public HashMap<Entity, String> vendorType = new HashMap<Entity, String>();
            
                //Currencies
                HashMap<Player, Integer> glimmer = new HashMap<Player, Integer>();
                HashMap<Player, Integer> vanguardMarks = new HashMap<Player, Integer>();
                HashMap<Player, Integer> crucibleMarks = new HashMap<Player, Integer>();
    
                public String getClass(Player p) {
                
                    return characterClass.get(p);
                }
            
                public String getVendorType(Entity e) {
                    if(vendorType.containsKey(e)) {
                        return vendorType.get(e);
                    }
                    return null;
                }
    


    When I run this command, I receive my invalid vendor type message. I would think it is probably due to the way I have the classes set up (I need to access these hashmaps and inventories from more than one class). If someone could help me out with this, that'd be great.

    EDIT - I believe I have figured it out, it appears that declaring the variables as public static will allow me to access the values remotely (have not tested on my server yet however).
    EDIT -- Still doesn't fix the command.
     
    Last edited: Jun 5, 2015
  2. Offline

    BizarrePlatinum

  3. Offline

    BizarrePlatinum

  4. Offline

    BizarrePlatinum

  5. Offline

    BizarrePlatinum

Thread Status:
Not open for further replies.

Share This Page