|
World message for rare dropi was looking at this and saw how ugly it was so i decided to update it
-----------------------------------------------------Updated code-----------------------------------------------------
-----------------------------------------------------OLD CODE-----------------------------------------------------Code:public static String[] rareDrops = { "torva", "pernix", "virtus", "bones" , "iron dagger"}; public void rareDropMsg(Player player, String drop) { for (String dropNames : rareDrops) { if (drop.contains(dropNames)) { if (drop.endsWith("s")) { World.sendWorldMessage("<col=990000><img=5>News:</col><col=FF0000>" + Utils.formatPlayerNameForDisplay(player.getUsername()) + "<col=00FF00> has received <col=FF0000>" + Utils.formatPlayerNameForDisplay(drop) + "<col=00FF00> as a rare drop!", false); } else { World.sendWorldMessage("<col=990000><img=5>News:</col><col=FF0000>" + Utils.formatPlayerNameForDisplay(player.getUsername()) + "<col=00FF00> has received a <col=FF0000>" + Utils.formatPlayerNameForDisplay(drop) + "<col=00FF00> as a rare drop!", false); } } } }
In npc.java replace your senddrop method with this
Code:public void sendDrop(Player player, Drop drop) { int size = getSize(); String dropName = ItemDefinitions.getItemDefinitions(drop.getItemId()) .getName().toLowerCase(); Item item = ItemDefinitions.getItemDefinitions(drop.getItemId()).isStackable() ? new Item(drop.getItemId(), (drop.getMinAmount() * Settings.DROP_RATE) + Utils.getRandom(drop.getExtraAmount() *Settings.DROP_RATE)) : new Item(drop.getItemId(), drop.getMinAmount() + Utils.getRandom(drop.getExtraAmount())); World.addGroundItem(item, new WorldTile(getCoordFaceX(size), getCoordFaceY(size), getPlane()), player, false, 180, true); if (dropName.contains("pernix") || dropName.contains("torva") || dropName.contains("virtus") || dropName.contains("bones") ) { World.sendWorldMessage(Utils.formatPlayerNameForDisplay(player.getUsername()) + "has received a " + dropName + " as a rare drop", false); } }
shieeeeeet
did it a lot neater than I did
argh wtf.
You can try this,
replace your method "sendDrop" in Npc.java with this.
and add this into Settings.java,Code:public void sendDrop(Player player, Drop drop) { int size = getSize(); String dropName = ItemDefinitions.getItemDefinitions(drop.getItemId()) .getName().toLowerCase(); Item item = ItemDefinitions.getItemDefinitions(drop.getItemId()) .isStackable() ? new Item(drop.getItemId(), (drop.getMinAmount() * Settings.DROP_RATE) + Utils.getRandom(drop.getExtraAmount() * Settings.DROP_RATE)) : new Item( drop.getItemId(), drop.getMinAmount() + Utils.getRandom(drop.getExtraAmount())); World.addGroundItem(item, new WorldTile(getCoordFaceX(size), getCoordFaceY(size), getPlane()), player, false, 180, true); for (String strings : Settings.DROPS) { if (dropName.contains(strings)) { World.sendWorldMessage( Utils.formatPlayerNameForDisplay(player.getUsername()) + " has received a " + dropName + " as a rare drop", false); return; } } }
Pretty much the same thing just looks neater in my opinion, but anyways just keep adding to the array list of what you think is a "rare drop". Hope that helps.Code:public static String[] DROPS = { "torva", "pernix", "virtus", "bones" };
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |