->Item Cube Navigation is now implemented! Opening item cubes will save

their opened order such that closing your inventory will then open up
the previous item cube viewed until you have closed all previously
opened Item Cubes. In addition, you can click outside the inventory
window to completely close your inventory immediately and ignore all
opened Item Cube history.
->All artifacts when broken now turn into dust... This dust is not
useless however. With patience, the Artifact's power may return to
you...
->All obfuscated in-game text is now obfuscated properly in Discord chat
as well.
->getHardenedItemBreaks() no longer produces a null pointer exception
when referencing a null player.
dev
sigonasr2 9 years ago
parent 504017fe6b
commit cb1b8fbd6a
  1. BIN
      TwosideKeeper.jar
  2. 2
      src/plugin.yml
  3. 6
      src/sig/plugin/TwosideKeeper/AutoUpdatePlugin.java
  4. 87
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  5. 52
      src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java
  6. 46
      src/sig/plugin/TwosideKeeper/ItemCubeWindow.java
  7. 2
      src/sig/plugin/TwosideKeeper/PlayerStructure.java
  8. 29
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.8.4
version: 3.8.4b
commands:
money:
description: Tells the player the amount of money they are holding.

@ -89,6 +89,9 @@ public class AutoUpdatePlugin implements Runnable {
DiscordMessageSender.sendItalicizedRawMessageDiscord("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+".");
Bukkit.broadcastMessage("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+"."+ChatColor.GRAY+ChatColor.ITALIC+"If all players leave, the update will occur immediately.");
}
if (restarting) {
TwosideKeeper.updateServer();
}
}},1);
TwosideKeeper.log("New hash: "+md5, 2);
plugins.get(i).hash = md5;
@ -104,9 +107,6 @@ public class AutoUpdatePlugin implements Runnable {
}*/
}
}
if (restarting) {
TwosideKeeper.updateServer();
}
}
public void AddPlugin(String name, String url) {

@ -114,7 +114,9 @@ public class GenericFunctions {
if (p!=null && break_count==0) {
p.sendMessage(ChatColor.GOLD+"WARNING!"+ChatColor.GREEN+ " Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.WHITE+" is going to break soon! You should let it recharge by waiting 24 hours!");
}
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
if (p!=null) {
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
}
return breakObscureHardenedItem(item);
} else {
lore.set(i, ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+(break_count-1));
@ -130,15 +132,78 @@ public class GenericFunctions {
break_count--;
if (p!=null && break_count==0) {
p.sendMessage(ChatColor.GOLD+"WARNING!"+ChatColor.GREEN+ " Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.WHITE+" is going to break soon!");
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
}
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
return item;
//By setting the amount to 1, you refresh the item in the player's inventory.
} else {
//This item is technically destroyed.
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
return new ItemStack(Material.AIR);
if (p!=null) {
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
}
if (isArtifactEquip(item)) {
//We can turn it into dust!
if (p!=null) {
p.sendMessage(ChatColor.LIGHT_PURPLE+"You still feel the artifact's presence inside of you...");
}
return convertArtifactToDust(item);
}
return null;
}
}
public static ItemStack convertArtifactToDust(ItemStack item) {
//Add one line of lore to indicate it's broken dust.
ItemMeta m = item.getItemMeta();
List<String> oldlore = m.getLore();
oldlore.add(0,ChatColor.DARK_BLUE+""+ChatColor.MAGIC+item.getType());
oldlore.add(1,ChatColor.GOLD+""+ChatColor.BOLD+"[ARTIFACT DUST]");
oldlore.add(2,ChatColor.DARK_BLUE+""+ChatColor.MAGIC+item.getType());
oldlore.add(3,ChatColor.DARK_PURPLE+"Its physical form may be lost");
oldlore.add(4,ChatColor.DARK_PURPLE+"but there might still be some");
oldlore.add(5,ChatColor.DARK_PURPLE+"power hidden within...");
oldlore.add(6,"");
for (int i=0;i<oldlore.size();i++) {
if (oldlore.get(i).contains(ChatColor.BLUE+""+ChatColor.MAGIC)) {
//See what the previous time was.
long time = Long.parseLong(ChatColor.stripColor(oldlore.get(i)));
oldlore.set(i, ChatColor.BLUE+""+ChatColor.MAGIC+TwosideKeeper.getServerTickTime());
}
}
m.setLore(oldlore);
item.setItemMeta(m);
item.setType(Material.SULPHUR);
item.setDurability((short)0);
return item;
}
public static ItemStack convertArtifactDustToItem(ItemStack item) {
ItemMeta m = item.getItemMeta();
List<String> oldlore = m.getLore();
Material gettype = Material.valueOf(ChatColor.stripColor(oldlore.get(0)));
oldlore.remove(6);
oldlore.remove(5);
oldlore.remove(4);
oldlore.remove(3);
oldlore.remove(2);
oldlore.remove(1);
oldlore.remove(0);
for (int i=0;i<oldlore.size();i++) {
if (oldlore.get(i).contains(ChatColor.BLUE+""+ChatColor.MAGIC)) {
//See what the previous time was.
long time = Long.parseLong(ChatColor.stripColor(oldlore.get(i)));
oldlore.set(i, ChatColor.BLUE+""+ChatColor.MAGIC+TwosideKeeper.getServerTickTime());
}
}
m.setLore(oldlore);
item.setItemMeta(m);
item.setType(gettype);
item.setDurability((short)0);
item = addHardenedItemBreaks(item,5);
return item;
}
public static ItemStack addHardenedItemBreaks(ItemStack item, int breaks) {
@ -342,7 +407,7 @@ public class GenericFunctions {
//By setting the amount to 1, you refresh the item in the player's inventory.
} else {
//This item is technically destroyed.
return new ItemStack(Material.AIR);
return null;
}
}
@ -3173,9 +3238,9 @@ public class GenericFunctions {
b.getType()==Material.COAL_ORE ||
b.getType()==Material.DIAMOND_ORE ||
b.getType()==Material.GOLD_ORE ||
b.getType()==Material.IRON_ORE ||
b.getType()==Material.IRON_ORE ||
b.getType()==Material.REDSTONE_ORE ||
b.getType()==Material.LAPIS_ORE ||
b.getType()==Material.LAPIS_ORE ||
b.getType()==Material.EMERALD_ORE) {
return true;
} else {
@ -3242,9 +3307,17 @@ public class GenericFunctions {
item = UpdateSetLore(set,tier,item);
}
UpdateOldRangerPieces(item);
UpdateArtifactDust(item);
return item;
}
private static void UpdateArtifactDust(ItemStack item) {
if (Artifact.isArtifact(item) &&
item.getType()==Material.SULPHUR) {
item = convertArtifactDustToItem(item);
}
}
private static ItemStack UpdateSetLore(ItemSet set, int tier, ItemStack item) {
List<String> newlore = new ArrayList<String>();

@ -464,9 +464,61 @@ public class WorldShop {
if (message.endsWith("\n")) {
message.substring(0, message.length()-1);
}
message=obfuscateAllMagicCodes(message);
return message;
}
private static String obfuscateAllMagicCodes(String message) {
StringBuilder newstring = new StringBuilder("");
boolean isMagic=false;
boolean WillBeMagic=false;
int linenumb = 0;
int charnumb = 0;
boolean isColorCode=false;
for (int i=0;i<message.length();i++) {
ChatColor col = null;
if (WillBeMagic) {
isMagic=true;
WillBeMagic=false;
}
if (isColorCode) {
col=ChatColor.getByChar(message.charAt(i));
isColorCode=false;
}
if (col!=null) {
TwosideKeeper.log("Col is "+col.name()+", char is "+message.charAt(i), 2);
}
if (col!=null &&
col == ChatColor.MAGIC) {
TwosideKeeper.log("Found a Magic Char at Line "+(linenumb+1)+", Character "+(charnumb+1), 2);
WillBeMagic=true;
}
if (col!=null &&
col == ChatColor.RESET && isMagic) {
isMagic=!isMagic;
}
if (message.charAt(i)==ChatColor.COLOR_CHAR) {
isColorCode=true;
}
if (message.charAt(i)=='\n' && isMagic) {
isMagic=!isMagic;
}
if (message.charAt(i)=='\n') {
linenumb++;
charnumb=0;
}
if (isMagic) {
newstring.append(Character.toChars('z'-(int)((Math.random()*57))));
} else {
newstring.append(message.charAt(i));
}
charnumb++;
}
return newstring.toString();
}
public void sendItemInfo(Player player) {
//Returns all the lore and enchantments for this particular item to the player, so they know what this item is.
String[] temp = GetItemInfo(item).split("\n");

@ -3,13 +3,55 @@ package sig.plugin.TwosideKeeper;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import sig.plugin.TwosideKeeper.HelperStructures.CubeType;
import sig.plugin.TwosideKeeper.HelperStructures.ItemCube;
public class ItemCubeWindow {
int id = 0;
public static void addItemCubeWindow(Player p, int id) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.itemcubelist.add(id);
TwosideKeeper.log("Added cube "+id+" to Item Cube List for Player "+p.getName()+". New list: "+pd.itemcubelist.toString(), 2);
}
public static void popItemCubeWindow(Player p) {
//Opens the next possible item cube inventory from the list of inventories.
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.itemcubelist.size()>0 && !pd.opened_another_cube) {
int index = pd.itemcubelist.size()-1;
Integer itemcubeid = pd.itemcubelist.get(index);
TwosideKeeper.log("Popping Item Cube ID "+index+" from "+p.getName()+"'s list.", 2);
pd.itemcubelist.remove(index);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
if (!ItemCube.isSomeoneViewingItemCube(itemcubeid,p)) {
//pd.itemcubeviews.add(p.getOpenInventory());
CubeType size = TwosideKeeper.itemCube_getCubeType(itemcubeid);
int inv_size = 9;
if (size!=CubeType.NORMAL) {
inv_size=27;
}
Inventory temp = Bukkit.getServer().createInventory(p, inv_size, "Item Cube #"+itemcubeid);
TwosideKeeper.openItemCubeInventory(temp);
InventoryView newinv = p.openInventory(temp);
pd.isViewingItemCube=true;
p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f);
} else {
p.openInventory(ItemCube.getViewingItemCubeInventory(itemcubeid, p));
pd.isViewingItemCube=true;
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f);
}
}},1);
}
}
public static void removeAllItemCubeWindows(Player p) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.itemcubelist.clear();
}
/*int id = 0; //LEGACY CODE.
int size = 0;
public ItemCubeWindow(int id, int size) {
@ -80,5 +122,5 @@ public class ItemCubeWindow {
return p.getOpenInventory().getTopInventory().getSize();
}
return -1;
}
}*/
}

@ -92,6 +92,7 @@ public class PlayerStructure {
public long lastdeath = 0;
public int previousparty = -1;
public long lastblock = 0;
public List<Integer> itemcubelist = new ArrayList<Integer>();
public double prev_weapondmg=0.0;
public double prev_buffdmg=0.0;
@ -110,6 +111,7 @@ public class PlayerStructure {
public boolean isPlayingSpleef=false;
public long lastrightclick = 0;
public boolean opened_another_cube=false;
//Needs the instance of the player object to get all other info. Only to be called at the beginning.
public PlayerStructure(Player p, long serverTickTime) {

@ -3245,6 +3245,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_CLOSE, 1.0f, 1.0f);
itemCube_saveConfig(id,itemcube_contents);
ItemCubeWindow.popItemCubeWindow(p);
pd.isViewingItemCube=false;
}
if (ev.getInventory().getLocation()!=null) {
@ -3462,6 +3463,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
if (ev.getInventory().getTitle().contains("Item Cube #") &&
ev.getRawSlot()==-999) {
//log("Cursor: "+ev.getCursor().toString(),2);
ItemStack item = ev.getCursor();
if (item.getType()==Material.AIR) {
ItemCubeWindow.removeAllItemCubeWindows((Player)ev.getWhoClicked());
ev.getWhoClicked().closeInventory();
}
}
//LEFT CLICK STUFF.
//WARNING! This only happens for ITEM CUBES! Do not add other items in here!
pd = (PlayerStructure) playerdata.get(ev.getWhoClicked().getUniqueId());
@ -3745,8 +3756,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//p.playSound(p.getLocation(), Sound.BLOCK_NOTE_HARP, 0.4f, 0.2f);
ev.setCancelled(true);
} else {
log("This is an Item Cube.",5);
Player p = (Player)ev.getWhoClicked();
if (itemcubeid!=-1) {
//This means we are viewing an item cube currently. Add it to our list.
ItemCubeWindow.addItemCubeWindow(p, itemcubeid);
}
log("This is an Item Cube.",5);
int inventory_size;
if (ev.getCurrentItem().getType()==Material.CHEST) {
inventory_size=9;
@ -3758,9 +3773,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true);
ev.setResult(Result.DENY);
//pd.itemcubeviews.add(p.getOpenInventory());
pd.opened_another_cube=true;
Inventory temp = Bukkit.getServer().createInventory(p, inventory_size, "Item Cube #"+idnumb);
openItemCubeInventory(temp);
InventoryView newinv = p.openInventory(temp);
pd.opened_another_cube=false;
pd.isViewingItemCube=true;
p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f);
} else {
@ -3768,8 +3785,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setResult(Result.DENY);
//ItemCube.displayErrorMessage(p);
//pd.itemcubeviews.add(p.getOpenInventory());
pd.opened_another_cube=true;
p.openInventory(ItemCube.getViewingItemCubeInventory(idnumb, p));
pd.isViewingItemCube=true;
pd.opened_another_cube=false;
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f);
}
}
@ -4933,9 +4952,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
GenericFunctions.breakHardenedItem(item,p);
} else
{
ItemStack test = GenericFunctions.breakHardenedItem(item,p);
if (test!=null) {
//We have to give this player the item!
GenericFunctions.giveItem(p, test);
}
breakdownItem(item,p);
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
@ -6108,7 +6131,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
return ItemCube_items;
}
public CubeType itemCube_getCubeType(int id){
public static CubeType itemCube_getCubeType(int id){
List<ItemStack> ItemCube_items = new ArrayList<ItemStack>();
File config;
config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data");

Loading…
Cancel
Save