- Fixed potion stacking and adding items to stacks with a different durability
- Modified /iteminfo a bit - Added a message to the DBpage generator - Added more functions to word datavalue - Modified the SignChange fourth line formatting
This commit is contained in:
parent
2e489774d8
commit
505dfb3449
|
@ -36,8 +36,9 @@ public class ItemInfo implements CommandExecutor {
|
||||||
String enchantment = (ench != null ? ChatColor.DARK_AQUA + "-" + ench : "");
|
String enchantment = (ench != null ? ChatColor.DARK_AQUA + "-" + ench : "");
|
||||||
|
|
||||||
sender.sendMessage(Config.getLocal(Language.iteminfo));
|
sender.sendMessage(Config.getLocal(Language.iteminfo));
|
||||||
sender.sendMessage(ChatColor.GRAY + uSign.capitalizeFirst(item.getType().name())
|
String itemname = Items.getName(item);
|
||||||
+ ChatColor.WHITE + " " + item.getTypeId() + durability + enchantment + ChatColor.WHITE);
|
sender.sendMessage(ChatColor.GRAY + itemname + ChatColor.WHITE + " "
|
||||||
|
+ item.getTypeId() + durability + enchantment + ChatColor.WHITE);
|
||||||
|
|
||||||
Map<Enchantment, Integer> map = item.getEnchantments();
|
Map<Enchantment, Integer> map = item.getEnchantments();
|
||||||
for (Map.Entry<Enchantment, Integer> e : map.entrySet())
|
for (Map.Entry<Enchantment, Integer> e : map.entrySet())
|
||||||
|
|
|
@ -112,6 +112,9 @@ public class Generator implements Runnable {
|
||||||
|
|
||||||
private static void generateStats() {
|
private static void generateStats() {
|
||||||
try {
|
try {
|
||||||
|
File f = new File(filePath).getParentFile();
|
||||||
|
if (!f.exists()) f.mkdir();
|
||||||
|
|
||||||
fileStart();
|
fileStart();
|
||||||
|
|
||||||
buf = new BufferedWriter(new FileWriter(filePath, true));
|
buf = new BufferedWriter(new FileWriter(filePath, true));
|
||||||
|
@ -124,6 +127,7 @@ public class Generator implements Runnable {
|
||||||
fileEnd();
|
fileEnd();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logging.log("Couldn't generate statistics page!");
|
Logging.log("Couldn't generate statistics page!");
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.CoalType;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.TreeSpecies;
|
import org.bukkit.TreeSpecies;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.*;
|
import org.bukkit.material.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +28,11 @@ public class DataValue {
|
||||||
materialData = new Step(Items.getMaterial(type));
|
materialData = new Step(Items.getMaterial(type));
|
||||||
break;
|
break;
|
||||||
case WOOL:
|
case WOOL:
|
||||||
case INK_SACK:
|
|
||||||
materialData = new Wool(DyeColor.valueOf(type));
|
materialData = new Wool(DyeColor.valueOf(type));
|
||||||
break;
|
break;
|
||||||
|
case INK_SACK:
|
||||||
|
materialData = new Wool(15 - DyeColor.valueOf(type).getData());
|
||||||
|
break;
|
||||||
case COAL:
|
case COAL:
|
||||||
materialData = new Coal(CoalType.valueOf(type));
|
materialData = new Coal(CoalType.valueOf(type));
|
||||||
break;
|
break;
|
||||||
|
@ -38,4 +41,37 @@ public class DataValue {
|
||||||
|
|
||||||
return (materialData == null ? 0 : materialData.getData());
|
return (materialData == null ? 0 : materialData.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getName(ItemStack is){
|
||||||
|
short dur = is.getDurability();
|
||||||
|
if (dur == 0) return null;
|
||||||
|
|
||||||
|
Material material = is.getType();
|
||||||
|
|
||||||
|
String name = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch (material) {
|
||||||
|
case SAPLING:
|
||||||
|
case LOG:
|
||||||
|
name = TreeSpecies.getByData((byte) dur).name();
|
||||||
|
break;
|
||||||
|
case STEP:
|
||||||
|
case DOUBLE_STEP:
|
||||||
|
name = new Step(Material.getMaterial(dur)).getMaterial().name();
|
||||||
|
break;
|
||||||
|
case WOOL:
|
||||||
|
name = DyeColor.getByData((byte) dur).name();
|
||||||
|
break;
|
||||||
|
case INK_SACK:
|
||||||
|
name = DyeColor.getByData((byte) (15 - dur)).name();
|
||||||
|
break;
|
||||||
|
case COAL:
|
||||||
|
name = CoalType.getByData((byte) dur).name();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) { return null; }
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.Acrobot.ChestShop.Items;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.Utils.uEnchantment;
|
import com.Acrobot.ChestShop.Utils.uEnchantment;
|
||||||
import com.Acrobot.ChestShop.Utils.uNumber;
|
import com.Acrobot.ChestShop.Utils.uNumber;
|
||||||
|
import com.Acrobot.ChestShop.Utils.uSign;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -31,6 +32,15 @@ public class Items {
|
||||||
}
|
}
|
||||||
return finalMaterial;
|
return finalMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getName(ItemStack is){
|
||||||
|
return getName(is, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getName(ItemStack is, boolean showData){
|
||||||
|
String name = DataValue.getName(is);
|
||||||
|
return uSign.capitalizeFirst((name != null && showData ? name + '_' : "") + is.getType());
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemStack getItemStack(String itemName) {
|
public static ItemStack getItemStack(String itemName) {
|
||||||
ItemStack toReturn = getFromOddItem(itemName);
|
ItemStack toReturn = getFromOddItem(itemName);
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class signChange extends BlockListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setLine(2, thirdLine);
|
event.setLine(2, thirdLine);
|
||||||
event.setLine(3, formatFourthLine(line[3], mat));
|
event.setLine(3, formatFourthLine(line[3], stock));
|
||||||
|
|
||||||
Chest chest = uBlock.findChest(signBlock);
|
Chest chest = uBlock.findChest(signBlock);
|
||||||
|
|
||||||
|
@ -148,15 +148,18 @@ public class signChange extends BlockListener {
|
||||||
return (thirdLine.length() > 15 ? null : thirdLine);
|
return (thirdLine.length() > 15 ? null : thirdLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatFourthLine(String fourthLine, Material material) {
|
private static String formatFourthLine(String fourthLine, ItemStack is) {
|
||||||
int index = (fourthLine.indexOf(':') != -1 ? fourthLine.indexOf(':') : 9999);
|
int index = (fourthLine.indexOf(':') != -1 ? fourthLine.indexOf(':') : 9999);
|
||||||
if (fourthLine.indexOf('-') < index && fourthLine.indexOf('-') != -1) index = fourthLine.indexOf('-');
|
if (fourthLine.indexOf('-') < index && fourthLine.indexOf('-') != -1) index = fourthLine.indexOf('-');
|
||||||
|
|
||||||
StringBuilder toReturn = new StringBuilder(3);
|
StringBuilder toReturn = new StringBuilder(3);
|
||||||
String matName = uSign.capitalizeFirst(material.name());
|
String matName = fourthLine.split(":|-")[0];
|
||||||
if (index != 9999 && matName.length() > (15 - (fourthLine.length() - index))) matName = matName.substring(0, 15 - (fourthLine.length() - index));
|
matName = matName.trim();
|
||||||
if (Items.getMaterial(matName) == material) toReturn.append(matName);
|
if (uNumber.isInteger(matName)) matName = Items.getName(is, false);
|
||||||
else toReturn.append(material.getId());
|
int iPos = 15 - (fourthLine.length() - index);
|
||||||
|
if (index != 9999 && matName.length() > iPos) matName = matName.substring(0, iPos);
|
||||||
|
if (Items.getItemStack(matName).getType() == is.getType()) toReturn.append(matName);
|
||||||
|
else toReturn.append(is.getTypeId());
|
||||||
|
|
||||||
if (index != -1 && index != 9999) toReturn.append(fourthLine.substring(index));
|
if (index != -1 && index != 9999) toReturn.append(fourthLine.substring(index));
|
||||||
return toReturn.toString();
|
return toReturn.toString();
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class uInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int addManually(Inventory inv, ItemStack item, int amount) {
|
private static int addManually(Inventory inv, ItemStack item, int amount) {
|
||||||
return addManually(inv, item, amount, item.getType().getMaxStackSize());
|
return addManually(inv, item, amount, (item.getType() != Material.POTION ? item.getType().getMaxStackSize() : 1)); //TODO Change it when it's repaired in Bukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int addAndStackTo64(Inventory inv, ItemStack item, int amount) {
|
public static int addAndStackTo64(Inventory inv, ItemStack item, int amount) {
|
||||||
|
@ -76,7 +76,7 @@ public class uInventory {
|
||||||
dupe.addEnchantments(item.getEnchantments());
|
dupe.addEnchantments(item.getEnchantments());
|
||||||
amount -= dupe.getAmount();
|
amount -= dupe.getAmount();
|
||||||
inv.setItem(slot, dupe);
|
inv.setItem(slot, dupe);
|
||||||
} else if (equals(item, curItem, item.getDurability()) && curItem.getAmount() != max) {
|
} else if (equals(item, curItem, curItem.getDurability()) && curItem.getAmount() != max) {
|
||||||
int cA = curItem.getAmount();
|
int cA = curItem.getAmount();
|
||||||
int amountAdded = amount > max - cA ? max - cA : amount;
|
int amountAdded = amount > max - cA ? max - cA : amount;
|
||||||
dupe.setAmount(cA + amountAdded);
|
dupe.setAmount(cA + amountAdded);
|
||||||
|
|
|
@ -2,7 +2,7 @@ name: ChestShop
|
||||||
|
|
||||||
main: com.Acrobot.ChestShop.ChestShop
|
main: com.Acrobot.ChestShop.ChestShop
|
||||||
|
|
||||||
version: 3.30
|
version: 3.31
|
||||||
|
|
||||||
|
|
||||||
author: Acrobot
|
author: Acrobot
|
||||||
|
|
Loading…
Reference in New Issue