Fix colored names being ruined when placed in an anvil.
This commit is contained in:
parent
338e17a4ff
commit
82cbf67562
Binary file not shown.
@ -37,7 +37,11 @@ public class RecyclingCenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Location getRandomNode() {
|
public Location getRandomNode() {
|
||||||
|
if (nodes.size()>0) {
|
||||||
return nodes.get((int)(Math.floor(Math.random()*nodes.size())));
|
return nodes.get((int)(Math.floor(Math.random()*nodes.size())));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfNodes() {
|
public int getNumberOfNodes() {
|
||||||
|
@ -1658,6 +1658,32 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
},1);
|
},1);
|
||||||
|
|
||||||
|
if (ev.getInventory().getType()==InventoryType.ANVIL &&
|
||||||
|
ev.getRawSlot()==2) {
|
||||||
|
//The results slot was clicked. We should set the result's item name properly back to what it was.
|
||||||
|
if (ev.getCurrentItem()!=null &&
|
||||||
|
ev.getInventory().getItem(0)!=null &&
|
||||||
|
ev.getInventory().getItem(0).getItemMeta().hasDisplayName()) {
|
||||||
|
//It's possible we may have to fix the color code for this item. Check the first two characters.
|
||||||
|
String oldname = ev.getInventory().getItem(0).getItemMeta().getDisplayName();
|
||||||
|
ChatColor first = ChatColor.getByChar(oldname.charAt(1));
|
||||||
|
log("First character is "+first,4);
|
||||||
|
ChatColor second = ChatColor.getByChar(oldname.charAt(0));
|
||||||
|
log("Second character is "+second,4);
|
||||||
|
if (first!=null) {
|
||||||
|
if (second!=null) {
|
||||||
|
ItemMeta m = ev.getCurrentItem().getItemMeta();
|
||||||
|
m.setDisplayName(first+""+second+ev.getCurrentItem().getItemMeta().getDisplayName().substring(2));
|
||||||
|
ev.getCurrentItem().setItemMeta(m);
|
||||||
|
} else {
|
||||||
|
ItemMeta m = ev.getCurrentItem().getItemMeta();
|
||||||
|
m.setDisplayName(first+ev.getCurrentItem().getItemMeta().getDisplayName().substring(1));
|
||||||
|
ev.getCurrentItem().setItemMeta(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ev.getInventory().getTitle().equalsIgnoreCase("Death Loot")) {
|
if (ev.getInventory().getTitle().equalsIgnoreCase("Death Loot")) {
|
||||||
//See how many items are in our inventory. Determine final balance.
|
//See how many items are in our inventory. Determine final balance.
|
||||||
//Count the occupied slots.
|
//Count the occupied slots.
|
||||||
@ -2193,6 +2219,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
if (Math.random()*100<=RECYCLECHANCE &&
|
if (Math.random()*100<=RECYCLECHANCE &&
|
||||||
TwosideRecyclingCenter.IsItemAllowed(i.getItemStack())) {
|
TwosideRecyclingCenter.IsItemAllowed(i.getItemStack())) {
|
||||||
//Recycle allowed. Now figure out which node to go to.
|
//Recycle allowed. Now figure out which node to go to.
|
||||||
|
if (TwosideRecyclingCenter.getNumberOfNodes()>0) {
|
||||||
Location rand_node=TwosideRecyclingCenter.getRandomNode();
|
Location rand_node=TwosideRecyclingCenter.getRandomNode();
|
||||||
Block b = Bukkit.getWorld("world").getBlockAt(rand_node);
|
Block b = Bukkit.getWorld("world").getBlockAt(rand_node);
|
||||||
if (b!=null && b.getType()==Material.CHEST ||
|
if (b!=null && b.getType()==Material.CHEST ||
|
||||||
@ -2215,10 +2242,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
c.getBlockInventory().setItem(itemslot2, oldItem);
|
c.getBlockInventory().setItem(itemslot2, oldItem);
|
||||||
}
|
}
|
||||||
c.getBlockInventory().setItem(itemslot, i.getItemStack());
|
c.getBlockInventory().setItem(itemslot, i.getItemStack());
|
||||||
log("Sent "+GenericFunctions.UserFriendlyMaterialName(i.getItemStack())+" to Recycling Center Node "+rand_node.toString(),2);
|
log("Sent "+GenericFunctions.UserFriendlyMaterialName(i.getItemStack())+" to Recycling Center Node "+rand_node.toString(),3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log("No Recycling Center Nodes set! All dropped items will continue to be discarded. Use /recyclingcenter to define them.",1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user