Make auto equipping function with a full inventory.
This commit is contained in:
parent
310f5c687f
commit
a5000283d3
Binary file not shown.
@ -3367,6 +3367,9 @@ public class GenericFunctions {
|
||||
//This is an item cube. Update its lore.
|
||||
int id = Integer.parseInt(ItemUtils.GetLoreLineContainingSubstring(item, ChatColor.DARK_PURPLE+"ID#").split("#")[1]);
|
||||
ItemCubeUtils.updateVacuumCubeSuctionLoreLine(item);
|
||||
if (TwosideKeeper.PLAYERJOINTOGGLE) {
|
||||
ItemCubeUtils.updateItemCubeUpdateList(item);
|
||||
}
|
||||
if (TwosideKeeper.itemcube_updates.containsKey(id)) {
|
||||
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents (");
|
||||
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.AQUA+" ");
|
||||
|
@ -338,4 +338,23 @@ public class ItemCubeUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void updateItemCubeUpdateList(ItemStack item) {
|
||||
List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>();
|
||||
for (ItemStack items : ItemCubeUtils.getItemCubeContents(ItemCubeUtils.getItemCubeID(item))) {
|
||||
if (ItemUtils.isValidItem(items)) {
|
||||
boolean found=false;
|
||||
for (int j=0;j<itemcube_list.size();j++) {
|
||||
if (itemcube_list.get(j).getItem().isSimilar(items)) {
|
||||
itemcube_list.get(j).setAmount(itemcube_list.get(j).getAmount()+items.getAmount());
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
itemcube_list.add(new ItemContainer(items));
|
||||
}
|
||||
}
|
||||
}
|
||||
TwosideKeeper.itemcube_updates.put(ItemCubeUtils.getItemCubeID(item), itemcube_list);
|
||||
}
|
||||
}
|
||||
|
@ -558,6 +558,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
|
||||
boolean lamps_are_turned_on = false;
|
||||
|
||||
public static boolean PLAYERJOINTOGGLE=false;
|
||||
|
||||
|
||||
private final class GivePlayerPurchasedItems implements Runnable {
|
||||
private final Chest cc;
|
||||
@ -2469,7 +2471,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
playerdata.put(ev.getPlayer().getUniqueId(), new PlayerStructure(ev.getPlayer(),getServerTickTime()));
|
||||
log("[TASK] New Player Data has been added. Size of array: "+playerdata.size(),4);
|
||||
|
||||
PLAYERJOINTOGGLE=true;
|
||||
GenericFunctions.updateSetItemsInInventory(ev.getPlayer().getInventory());
|
||||
PLAYERJOINTOGGLE=false;
|
||||
ev.getPlayer().setCollidable(true);
|
||||
|
||||
ev.getPlayer().setVelocity(new Vector(0,0,0));
|
||||
@ -5152,6 +5156,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}
|
||||
if (CustomItem.isVacuumCube(item)) {
|
||||
ItemCubeUtils.toggleSuction(ItemCubeUtils.getItemCubeID(item));
|
||||
ItemCubeUtils.updateItemCubeUpdateList(item);
|
||||
GenericFunctions.UpdateItemCubeContentsList(item);
|
||||
if (ItemCubeUtils.isSuctionOn(ItemCubeUtils.getItemCubeID(item))) {
|
||||
SoundUtils.playLocalSoundsWithDelay(4, player, new SoundData[]{new SoundData(Sound.BLOCK_NOTE_HARP,0.7f,1.0f),new SoundData(Sound.BLOCK_NOTE_HARP,1.0f,1.0f)});
|
||||
@ -7829,7 +7834,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean AutoEquipItem(ItemStack item, Player p) {
|
||||
public static boolean AutoEquipItem(ItemStack item, Player p) {
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
if (item.getType().toString().contains("BOOTS") ||
|
||||
item.getType().toString().contains("LEGGINGS") ||
|
||||
@ -7838,7 +7843,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
item.getType().toString().contains("SHIELD") ||
|
||||
item.getType().toString().contains("TIPPED_ARROW") ||
|
||||
item.getType().toString().contains("CHORUS_FLOWER") ||
|
||||
item.getType().toString().contains("_AXE")) {
|
||||
item.getType().toString().contains("_AXE") ||
|
||||
item.getType().toString().contains("BOW")) {
|
||||
ItemStack armor = item;
|
||||
//See if this armor type is not being worn by the player.
|
||||
if (armor.getType().toString().contains("BOOTS") &&
|
||||
@ -7919,6 +7925,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
p.updateInventory();
|
||||
return true;
|
||||
} else
|
||||
if (armor.getType().toString().contains("BOW") &&
|
||||
p.getEquipment().getItemInMainHand().getType()==Material.AIR &&
|
||||
GenericFunctions.AllLeatherArmor(p) &&
|
||||
pd.equipweapons) {
|
||||
p.getEquipment().setItemInMainHand(armor);
|
||||
p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item)));
|
||||
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(armor));
|
||||
GenericFunctions.playProperEquipSound(p,armor.getType());
|
||||
p.updateInventory();
|
||||
return true;
|
||||
} else
|
||||
if (ArrowQuiver.isValidQuiver(armor) && p.getInventory().getExtraContents()[0]==null &&
|
||||
pd.equipweapons) {
|
||||
p.getInventory().setExtraContents(new ItemStack[]{armor});
|
||||
|
@ -632,12 +632,18 @@ final class runServerHeartbeat implements Runnable {
|
||||
events.PlayerManualPickupItemEvent ev = new events.PlayerManualPickupItemEvent(p, it.getItemStack());
|
||||
Bukkit.getPluginManager().callEvent(ev);
|
||||
if (!ev.isCancelled()) {
|
||||
boolean handled = TwosideKeeper.AutoEquipItem(it.getItemStack(), p);
|
||||
if (!handled) {
|
||||
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, it.getItemStack());
|
||||
if (remaining.length==0) {
|
||||
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(it.getItemStack()));
|
||||
TwosideKeeper.PlayPickupParticle(p,it);
|
||||
it.remove();
|
||||
}
|
||||
} else {
|
||||
TwosideKeeper.PlayPickupParticle(p,it);
|
||||
it.remove();
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user