Filter Cube compatibility added, Adventurer Mode added, Artifact Dust

now shows time on interaction.
testdev
sigonasr2 8 years ago
parent 9b22eb4bb3
commit d7fbbb6619
  1. BIN
      TwosideKeeper.jar
  2. 5
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  3. 20
      src/sig/plugin/TwosideKeeper/DeathManager.java
  4. 10
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  5. 10
      src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java
  6. 23
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java
  7. 3
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java
  8. 4
      src/sig/plugin/TwosideKeeper/PlayerStructure.java
  9. 139
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  10. 36
      src/sig/plugin/TwosideKeeper/runServerHeartbeat.java

Binary file not shown.

@ -1760,6 +1760,7 @@ public class CustomDamage {
double rangerdmgdiv = 0; double rangerdmgdiv = 0;
double tacticspct = 0; double tacticspct = 0;
double darknessdiv = 0; double darknessdiv = 0;
double playermodediv = 0;
if (target instanceof LivingEntity) { if (target instanceof LivingEntity) {
ItemStack[] armor = GenericFunctions.getArmor(target); ItemStack[] armor = GenericFunctions.getArmor(target);
@ -1914,7 +1915,8 @@ public class CustomDamage {
}*/ }*/
tacticspct = API.getPlayerBonuses(p).getBonusPercentDamageReduction(); tacticspct = API.getPlayerBonuses(p).getBonusPercentDamageReduction();
setbonus = ((100-ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL, 4, 4))/100d); setbonus = ((100-ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL, 4, 4))/100d);
playermodediv=(PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL)?0.2d:0;
} }
//Blocking: -((p.isBlocking())?ev.getDamage()*0.33:0) //33% damage will be reduced if we are blocking. //Blocking: -((p.isBlocking())?ev.getDamage()*0.33:0) //33% damage will be reduced if we are blocking.
@ -1952,6 +1954,7 @@ public class CustomDamage {
*(1d-darknessdiv) *(1d-darknessdiv)
*(1d-((partylevel*10d)/100d)) *(1d-((partylevel*10d)/100d))
*(1d-tacticspct) *(1d-tacticspct)
*(1d-playermodediv)
*setbonus *setbonus
*((target instanceof Player && ((Player)target).isBlocking())?(PlayerMode.isDefender((Player)target))?0.30:0.50:1) *((target instanceof Player && ((Player)target).isBlocking())?(PlayerMode.isDefender((Player)target))?0.30:0.50:1)
*((target instanceof Player)?((PlayerMode.isDefender((Player)target))?0.9:(target.getEquipment().getItemInOffHand()!=null && target.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?0.95:1):1); *((target instanceof Player)?((PlayerMode.isDefender((Player)target))?0.9:(target.getEquipment().getItemInOffHand()!=null && target.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?0.95:1):1);

@ -1,5 +1,6 @@
package sig.plugin.TwosideKeeper; package sig.plugin.TwosideKeeper;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -15,6 +16,7 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure; import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure;
import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class DeathManager { public class DeathManager {
@ -114,23 +116,31 @@ public class DeathManager {
Inventory deathinv = Bukkit.getServer().createInventory(p, 45, "Death Loot"); Inventory deathinv = Bukkit.getServer().createInventory(p, 45, "Death Loot");
GenericFunctions.TransferItemsToInventory(p.getInventory(), deathinv); GenericFunctions.TransferItemsToInventory(p.getInventory(), deathinv);
double totalmoney = TwosideKeeper.getPlayerMoney(Bukkit.getPlayer(p.getName()))+TwosideKeeper.getPlayerBankMoney(Bukkit.getPlayer(p.getName())); double totalmoney = TwosideKeeper.getPlayerMoney(Bukkit.getPlayer(p.getName()))+TwosideKeeper.getPlayerBankMoney(Bukkit.getPlayer(p.getName()));
int price = 1; double price = 1;
if (structure.deathloc.getBlockY()<=60) { if (structure.deathloc.getBlockY()<=60) {
price += 24-(structure.deathloc.getBlockY()/2.5); price += 24-(structure.deathloc.getBlockY()/2.5);
} }
PlayerStructure pd = PlayerStructure.GetPlayerStructure(Bukkit.getPlayer(p.getName())); PlayerStructure pd = PlayerStructure.GetPlayerStructure(Bukkit.getPlayer(p.getName()));
if (pd.playermode_on_death==PlayerMode.NORMAL) {
price /= 2d;
}
pd.hasDied=false; pd.hasDied=false;
DecimalFormat df = new DecimalFormat("0.00");
p.openInventory(deathinv); p.openInventory(deathinv);
p.sendMessage(ChatColor.AQUA+"You can buy back up to "+ChatColor.YELLOW+(int)(totalmoney/price)+ChatColor.AQUA+" items, costing $"+ChatColor.GREEN+price+ChatColor.WHITE+" per item."); p.sendMessage(ChatColor.AQUA+"You can buy back up to "+ChatColor.YELLOW+(int)(totalmoney/price)+ChatColor.AQUA+" items, costing $"+ChatColor.GREEN+df.format(price)+ChatColor.WHITE+" per item.");
p.sendMessage(" The rest will drop at your death location."); p.sendMessage(" The rest will drop at your death location.");
p.sendMessage(ChatColor.GRAY+"Close your inventory once you've picked your items."); p.sendMessage(ChatColor.GRAY+"Close your inventory once you've picked your items.");
} }
public static int CalculateDeathPrice(Player p) { public static double CalculateDeathPrice(Player p) {
DeathStructure ds = getDeathStructure(p); DeathStructure ds = getDeathStructure(p);
return (int)(1+((ds.deathloc.getBlockY()<=60)?(24-(ds.deathloc.getBlockY()/2.5)):0)); double price = (1+((ds.deathloc.getBlockY()<=60)?(24-(ds.deathloc.getBlockY()/2.5)):0));
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.playermode_on_death==PlayerMode.NORMAL) {
price /= 2d;
}
return price;
} }
public static int CountOccupiedSlots(Inventory inv) { public static int CountOccupiedSlots(Inventory inv) {
int occupiedslots = 0; int occupiedslots = 0;

@ -2174,11 +2174,11 @@ public class GenericFunctions {
public static String PlayerModePrefix(Player p) { public static String PlayerModePrefix(Player p) {
PlayerMode pm = PlayerMode.getPlayerMode(p); PlayerMode pm = PlayerMode.getPlayerMode(p);
if (pm!=PlayerMode.NORMAL) { //if (pm!=PlayerMode.NORMAL) {
return pm.getColor()+""+ChatColor.ITALIC+"("+pm.getAbbreviation()+") "+ChatColor.RESET+pm.getColor(); return pm.getColor()+""+ChatColor.ITALIC+"("+pm.getAbbreviation()+") "+ChatColor.RESET+pm.getColor();
} else { /*} else {
return ""; return "";
} }*/
} }
public static TextComponent PlayerModeName(Player p) { public static TextComponent PlayerModeName(Player p) {
@ -4777,9 +4777,7 @@ public class GenericFunctions {
public static boolean itemCanBeSuckedUp(Item ent) { public static boolean itemCanBeSuckedUp(Item ent) {
ItemStack item = ent.getItemStack(); ItemStack item = ent.getItemStack();
//TwosideKeeper.log(item.toString()+": "+ent.getTicksLived()+".."+ent.getPickupDelay()+".."+((Item)ent).getName()+".."+((Item)ent).isCustomNameVisible()+".."+((Item)ent).getCustomName(), 0); //TwosideKeeper.log(item.toString()+": "+ent.getTicksLived()+".."+ent.getPickupDelay()+".."+((Item)ent).getName()+".."+((Item)ent).isCustomNameVisible()+".."+((Item)ent).getCustomName(), 0);
if (ItemUtils.isValidLoreItem(item) || if (ent.getPickupDelay()>=0) {
ent.isGlowing() ||
ent.getPickupDelay()>=6000) {
return false; return false;
} }
return true; return true;

@ -98,8 +98,14 @@ public enum PlayerMode {
+ ChatColor.WHITE+"->Slayers can use the Assassination ability. Press the Drop key while looking at an enemy to perform an assassination: You jump directly behind the enemy, gaining 0.5 seconds of invulnerability. If the next hit after Assassination is performed kills the target, you gain a speed and strength buff. These buffs cap at Speed V and Strength X respectively and last 10 seconds. Assassination cooldown is reset whenever a target is instantly killed in this manner, and you get immediately put back into stealth, preventing further detection from other monsters.\n"), + ChatColor.WHITE+"->Slayers can use the Assassination ability. Press the Drop key while looking at an enemy to perform an assassination: You jump directly behind the enemy, gaining 0.5 seconds of invulnerability. If the next hit after Assassination is performed kills the target, you gain a speed and strength buff. These buffs cap at Speed V and Strength X respectively and last 10 seconds. Assassination cooldown is reset whenever a target is instantly killed in this manner, and you get immediately put back into stealth, preventing further detection from other monsters.\n"),
SUMMONER(ChatColor.DARK_PURPLE,"SM","Summoner", SUMMONER(ChatColor.DARK_PURPLE,"SM","Summoner",
ChatColor.DARK_PURPLE+""+ChatColor.BOLD+"Summoner mode Perks: "+ChatColor.RESET+"\n"), ChatColor.DARK_PURPLE+""+ChatColor.BOLD+"Summoner mode Perks: "+ChatColor.RESET+"\n"),
NORMAL(ChatColor.WHITE,"","Normal", NORMAL(ChatColor.WHITE,"A","Adventurer",
"This mode has no perks!"); ChatColor.WHITE+""+ChatColor.BOLD+"Adventurer mode Perks: "+ChatColor.RESET+"\n"
+ ChatColor.WHITE+"->Players are identified as 'Adventurers' by default.\n"
+ ChatColor.GRAY+"->Adventurers gain +10 Health.\n"
+ ChatColor.WHITE+"->Adventurers gain +20% Damage Reduction.\n"
+ ChatColor.GRAY+"->Adventurers gain +50% Health Regeneration.\n"
+ ChatColor.WHITE+"->If Adventurers are killed, their Buy-Backs are 50% cheaper.\n"
+ ChatColor.GRAY+"->Adventurers do not get exhausted when performing light activities.\n");
; ;
final public static int UPDATE_GRACE_PERIOD=9; //How often to update the mode of the player. final public static int UPDATE_GRACE_PERIOD=9; //How often to update the mode of the player.

@ -168,4 +168,27 @@ public class InventoryUtils {
} }
return true; return true;
} }
public static ItemStack AttemptToFillPartialSlotsFirst(Player p, ItemStack itemStackAdded) {
Inventory inv = p.getInventory();
for (int i=0;i<inv.getSize();i++) {
if (inv.getItem(i)!=null) {
ItemStack itemStackInventory = inv.getItem(i);
if (itemStackInventory.isSimilar(itemStackAdded) && itemStackInventory.getAmount()<itemStackInventory.getMaxStackSize()) {
int amt = itemStackInventory.getMaxStackSize()-itemStackInventory.getAmount();
if (itemStackAdded.getAmount()>=amt) {
int remaining = itemStackAdded.getAmount()-amt;
itemStackInventory.setAmount(itemStackInventory.getMaxStackSize());
itemStackAdded.setAmount(remaining);
} else {
itemStackInventory.setAmount(itemStackInventory.getAmount()+itemStackAdded.getAmount());
itemStackAdded=null;
break; //Ran out, we're done here.
}
inv.setItem(i, itemStackInventory);
}
}
}
TwosideKeeper.log("Item: "+itemStackAdded, 1);
return itemStackAdded;
}
} }

@ -127,7 +127,8 @@ public class ItemUtils {
public static boolean isArtifactDust(ItemStack item) { public static boolean isArtifactDust(ItemStack item) {
if (isValidLoreItem(item) && if (isValidLoreItem(item) &&
LoreContainsSubstring(item,ChatColor.BLUE+""+ChatColor.MAGIC)) { LoreContainsSubstring(item,ChatColor.BLUE+""+ChatColor.MAGIC) &&
item.getType()==Material.SULPHUR) {
//TwosideKeeper.log("This is Artifact Dust.", 0); //TwosideKeeper.log("This is Artifact Dust.", 0);
return true; return true;
} else { } else {

@ -137,6 +137,7 @@ public class PlayerStructure {
public long ignoretargetarmor = TwosideKeeper.getServerTickTime(); public long ignoretargetarmor = TwosideKeeper.getServerTickTime();
public long lastcandyconsumed = TwosideKeeper.getServerTickTime(); public long lastcandyconsumed = TwosideKeeper.getServerTickTime();
public long icewandused = TwosideKeeper.getServerTickTime(); public long icewandused = TwosideKeeper.getServerTickTime();
public PlayerMode playermode_on_death=PlayerMode.NORMAL;
public long iframetime = 0; public long iframetime = 0;
@ -328,6 +329,7 @@ public class PlayerStructure {
workable.set("holidaychest3", holidaychest3); workable.set("holidaychest3", holidaychest3);
workable.set("holidaychest4", holidaychest4); workable.set("holidaychest4", holidaychest4);
workable.set("lastsantabox2", lastsantabox2); workable.set("lastsantabox2", lastsantabox2);
workable.set("playermode_on_death", playermode_on_death.name());
//ConfigurationSection deathlootlist = workable.createSection("deathloot"); //ConfigurationSection deathlootlist = workable.createSection("deathloot");
if (DeathManager.deathStructureExists(Bukkit.getPlayer(name))) { if (DeathManager.deathStructureExists(Bukkit.getPlayer(name))) {
DeathStructure ds = DeathManager.getDeathStructure(Bukkit.getPlayer(name)); DeathStructure ds = DeathManager.getDeathStructure(Bukkit.getPlayer(name));
@ -383,6 +385,7 @@ public class PlayerStructure {
workable.addDefault("holidaychest3", holidaychest3); workable.addDefault("holidaychest3", holidaychest3);
workable.addDefault("holidaychest4", holidaychest4); workable.addDefault("holidaychest4", holidaychest4);
workable.addDefault("lastsantabox2", lastsantabox2); workable.addDefault("lastsantabox2", lastsantabox2);
workable.addDefault("playermode_on_death", playermode_on_death.name());
workable.options().copyDefaults(); workable.options().copyDefaults();
@ -417,6 +420,7 @@ public class PlayerStructure {
this.holidaychest3 = workable.getBoolean("holidaychest3"); this.holidaychest3 = workable.getBoolean("holidaychest3");
this.holidaychest4 = workable.getBoolean("holidaychest4"); this.holidaychest4 = workable.getBoolean("holidaychest4");
this.lastsantabox2 = workable.getLong("lastsantabox2"); this.lastsantabox2 = workable.getLong("lastsantabox2");
this.playermode_on_death = PlayerMode.valueOf(workable.getString("playermode_on_death"));
if (this.hasDied) { if (this.hasDied) {
List<ItemStack> deathlootlist = new ArrayList<ItemStack>(); List<ItemStack> deathlootlist = new ArrayList<ItemStack>();

@ -3,6 +3,7 @@ package sig.plugin.TwosideKeeper;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.time.OffsetDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
@ -2573,6 +2574,26 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
return; return;
} }
if (ItemUtils.isArtifactDust(p.getEquipment().getItemInMainHand())) {
long time = TwosideKeeper.getServerTickTime();
List<String> oldlore = p.getEquipment().getItemInMainHand().getItemMeta().getLore();
for (int i=0;i<oldlore.size();i++) {
if (oldlore.get(i).contains(ChatColor.BLUE+""+ChatColor.MAGIC)) {
//See what the previous time was.
time = Long.parseLong(ChatColor.stripColor(oldlore.get(i)));
TwosideKeeper.log("Time is "+time, 5);
}
}
long tickdiff = (time+12096000)-TwosideKeeper.getServerTickTime();
TwosideKeeper.log("tickdiff is "+tickdiff, 5);
DecimalFormat df = new DecimalFormat("00");
if (tickdiff<0) {
GenericFunctions.convertArtifactDustToItem(p.getEquipment().getItemInMainHand());
} else {
p.sendMessage("Your "+GenericFunctions.UserFriendlyMaterialName(p.getEquipment().getItemInMainHand())+ChatColor.RESET+" will reactivate its energy in "+ChatColor.AQUA+DisplayTimeDifference(tickdiff));
}
}
if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) && if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) &&
PlayerMode.getPlayerMode(p)==PlayerMode.BARBARIAN) { PlayerMode.getPlayerMode(p)==PlayerMode.BARBARIAN) {
aPlugin.API.swingOffHand(p); aPlugin.API.swingOffHand(p);
@ -3395,6 +3416,27 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
} }
private String DisplayTimeDifference(long tickdiff) {
int seconds = (int)(tickdiff/20);
int minutes = (int)(seconds/60);
int hours = (int)(minutes/60);
int days = (int)(hours/24);
StringBuilder string = new StringBuilder();
TwosideKeeper.log(seconds+","+minutes+","+hours+","+days, 5);
if (days>0) {
string.append(days+" Days");
}
if (hours>0) {
string.append(((string.length()>0)?", ":" ")+(hours%24)+" Hours");
}
if (minutes>0) {
string.append(((string.length()>0)?", ":" ")+(minutes%60)+" Minutes");
}
if (seconds>0) {
string.append(((string.length()>0)?", ":" ")+(seconds%60)+" Seconds");
}
return string.toString();
}
public ItemStack ProceedWithMalleableBaseQuest(final Player p, ItemStack base) { public ItemStack ProceedWithMalleableBaseQuest(final Player p, ItemStack base) {
for (int i=0;i<=8;i++) { for (int i=0;i<=8;i++) {
if (p.getInventory().getItem(i)!=null) { if (p.getInventory().getItem(i)!=null) {
@ -3551,6 +3593,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
final Player p = ev.getEntity(); final Player p = ev.getEntity();
if (!DeathManager.deathStructureExists(p)) { if (!DeathManager.deathStructureExists(p)) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.playermode_on_death=pd.lastmode;
if (pd.target!=null && if (pd.target!=null &&
pd.target.getCustomName()!=null) { pd.target.getCustomName()!=null) {
ev.setDeathMessage(ev.getDeathMessage().replace(pd.target.getCustomName(), GenericFunctions.getDisplayName(pd.target))); ev.setDeathMessage(ev.getDeathMessage().replace(pd.target.getCustomName(), GenericFunctions.getDisplayName(pd.target)));
@ -3861,7 +3904,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ArrowQuiver.updateQuiverLore(quiver); ArrowQuiver.updateQuiverLore(quiver);
List<ItemStack> contents = ArrowQuiver.getContents(ArrowQuiver.getID(quiver)); List<ItemStack> contents = ArrowQuiver.getContents(ArrowQuiver.getID(quiver));
if (contents.size()>0) { if (contents.size()>0) {
String message = ChatColor.DARK_GRAY+"Now Firing "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(contents.get(mode))+ChatColor.GRAY+" ["+contents.get(mode).getAmount()+"]"; String message = ChatColor.GOLD+"Now Firing "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(contents.get(mode))+ChatColor.GOLD+" ["+contents.get(mode).getAmount()+"]";
GenericFunctions.sendActionBarMessage(p, message, true); GenericFunctions.sendActionBarMessage(p, message, true);
} else { } else {
String message = ChatColor.RED+"Quiver is empty!"; String message = ChatColor.RED+"Quiver is empty!";
@ -5211,9 +5254,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (ev.getDamager() instanceof Player) { if (ev.getDamager() instanceof Player) {
Player p = (Player)ev.getDamager(); Player p = (Player)ev.getDamager();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (Math.random()<=0.1) { int piecesWthorns=getNumberofPiecesWithThorns(p);
GenericFunctions.spawnXP(ev.getEntity().getLocation(), (int)(dmgdealt)); GenericFunctions.spawnXP(p.getLocation(), (int)(1.85d*piecesWthorns));
}
//Spill some XP out of the damaged target. //Spill some XP out of the damaged target.
dmgdealt += pd.thorns_amt; dmgdealt += pd.thorns_amt;
pd.thorns_amt=0; pd.thorns_amt=0;
@ -5302,6 +5344,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
private int getNumberofPiecesWithThorns(Player p) {
int pieces=0;
for (ItemStack item : GenericFunctions.getArmor(p)) {
if (item!=null && item.containsEnchantment(Enchantment.THORNS)) {
pieces++;
}
}
return pieces;
}
private void DisplayPlayerDurability(Entity ent) { private void DisplayPlayerDurability(Entity ent) {
if (ent instanceof Player) { if (ent instanceof Player) {
StringBuilder armorstring = new StringBuilder("Armor Durability: {"); StringBuilder armorstring = new StringBuilder("Armor Durability: {");
@ -6056,7 +6107,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Last death: "+pd.lastdeath, 2); log("Last death: "+pd.lastdeath, 2);
} }
},1); },1);
} else {
Location newloc = ev.getRespawnLocation(); Location newloc = ev.getRespawnLocation();
newloc.setY(newloc.getWorld().getHighestBlockYAt(ev.getRespawnLocation())); newloc.setY(newloc.getWorld().getHighestBlockYAt(ev.getRespawnLocation()));
ev.setRespawnLocation(newloc.add(0,10,0)); ev.setRespawnLocation(newloc.add(0,10,0));
@ -6364,6 +6414,62 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onaPluginPickupEvent(PlayerGainItemEvent ev) {
//TwosideKeeper.log("["+TwosideKeeper.getServerTickTime()+"] PlayerGainItemEvent fired w/ "+ev.getItemStack(), 1);
Player p = ev.getPlayer();
ItemStack newstack = InventoryUtils.AttemptToFillPartialSlotsFirst(p,ev.getItemStack());
if (newstack==null) {
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItemStack()));
ev.setCancelled(true);return;}
GenericFunctions.UpdateItemLore(newstack);
HandlePickupAchievements(ev.getPlayer(), newstack);
boolean handled = AutoEquipItem(newstack, p);
if (handled) {
ev.setCancelled(handled);
return;
}
if (AutoConsumeItem(p,newstack)) {
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f);
ev.setCancelled(true);
return;
}
if (GenericFunctions.isValidArrow(newstack) && ArrowQuiver.getArrowQuiverInPlayerInventory(p)!=null) {
ev.setCancelled(true);
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(newstack));
AddToPlayerInventory(newstack, p);
return;
}
if (newstack.getType().isBlock() && InventoryUtils.isCarryingVacuumCube(p)) {
//Try to insert it into the Vacuum cube.
ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, newstack);
if (remaining.length==0) {
ev.setCancelled(true);
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(newstack));
return;
} else {
newstack=remaining[0];
}
}
if (InventoryUtils.isCarryingFilterCube(p)) {
//Try to insert it into the Filter cube.
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, newstack);
if (remaining.length==0) {
ev.setCancelled(true);
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(newstack));
return;
} else {
newstack=remaining[0];
}
}
ev.setCancelled(true);
ItemStack givenitem = newstack.clone();
GenericFunctions.giveItem(p, givenitem);
return;
}
@EventHandler(priority=EventPriority.LOWEST,ignoreCancelled = true) @EventHandler(priority=EventPriority.LOWEST,ignoreCancelled = true)
public void onArrowPickup(PlayerPickupArrowEvent ev) { public void onArrowPickup(PlayerPickupArrowEvent ev) {
if (ev.getArrow() instanceof Arrow) { if (ev.getArrow() instanceof Arrow) {
@ -6415,26 +6521,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
private void attemptToStackInInventory(Player p, ItemStack collect) { private void attemptToStackInInventory(Player p, ItemStack collect) {
GenericFunctions.giveItem(p, collect); GenericFunctions.giveItem(p, collect);
} }
//TODO Add PlayerGainItemEvent.
/*@EventHandler(priority=EventPriority.HIGH,ignoreCancelled = true)
public void onItemGiven(PlayerGainItemEvent ev) {
//Try to put this item into any of our Filter/Vacuum Cubes.
ItemStack item = ev.getItem();
Player p = ev.get
if (item.getType().isBlock() && InventoryUtils.isCarryingVacuumCube(p)) {
}
}*/
@EventHandler(priority=EventPriority.HIGH,ignoreCancelled = true) @EventHandler(priority=EventPriority.HIGH,ignoreCancelled = true)
public void onItemPickup(PlayerPickupItemEvent ev) { public void onItemPickup(PlayerPickupItemEvent ev) {
//Arrow quiver code goes here. //Arrow quiver code goes here.
//TwosideKeeper.log("["+TwosideKeeper.getServerTickTime()+"] PlayerPickupItemEvent fired w/ "+ev.getItem().getItemStack(), 1);
if (ev.isCancelled()) { if (ev.isCancelled()) {
return; return;
} }
log("Pickup Metadata: "+ev.getItem().getItemStack().getItemMeta().toString(),5);
Player p = ev.getPlayer(); Player p = ev.getPlayer();
ItemStack newstack = InventoryUtils.AttemptToFillPartialSlotsFirst(p,ev.getItem().getItemStack());
if (newstack==null || newstack.getType()==Material.AIR) {
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack()));
ev.getItem().remove();ev.setCancelled(true);return;}
ev.getItem().setItemStack(newstack);
log("Pickup Metadata: "+ev.getItem().getItemStack().getItemMeta().toString(),5);
//GenericFunctions.updateSetItems(p.getInventory()); //GenericFunctions.updateSetItems(p.getInventory());
GenericFunctions.UpdateItemLore(ev.getItem().getItemStack()); GenericFunctions.UpdateItemLore(ev.getItem().getItemStack());
/*//LEGACY CODE /*//LEGACY CODE
@ -8112,6 +8213,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+ ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+ ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.JAMDAK, 4, 4);*/ ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.JAMDAK, 4, 4);*/
if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) {
hp+=10;
}
hp*=maxdeduction; hp*=maxdeduction;

@ -330,6 +330,10 @@ final class runServerHeartbeat implements Runnable {
} }
} }
if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) {
p.setExhaustion(Math.max(0, p.getExhaustion()-0.5f));
}
if (pd.last_regen_time+TwosideKeeper.HEALTH_REGENERATION_RATE<=serverTickTime) { if (pd.last_regen_time+TwosideKeeper.HEALTH_REGENERATION_RATE<=serverTickTime) {
pd.last_regen_time=serverTickTime; pd.last_regen_time=serverTickTime;
//See if this player needs to be healed. //See if this player needs to be healed.
@ -360,7 +364,7 @@ final class runServerHeartbeat implements Runnable {
if (pd.pctbonusregentime+100>TwosideKeeper.getServerTickTime()) { if (pd.pctbonusregentime+100>TwosideKeeper.getServerTickTime()) {
totalregen += totalregen*pd.pctbonusregen; totalregen += totalregen*pd.pctbonusregen;
} }
totalregen += totalregen*((PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL)?0.5d:0d);
p.setHealth((p.getHealth()+totalregen>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); p.setHealth((p.getHealth()+totalregen>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen);
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
@ -453,13 +457,16 @@ final class runServerHeartbeat implements Runnable {
for (Entity ent : ents) { for (Entity ent : ents) {
if (ent instanceof Item && GenericFunctions.itemCanBeSuckedUp((Item)ent)) { if (ent instanceof Item && GenericFunctions.itemCanBeSuckedUp((Item)ent)) {
Item it = (Item)ent; Item it = (Item)ent;
if (it.getPickupDelay()==0) { if (it.getPickupDelay()<=0) {
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, it.getItemStack()); events.PlayerManualPickupItemEvent ev = new events.PlayerManualPickupItemEvent(p, it.getItemStack());
if (remaining.length==0) { if (!ev.isCancelled()) {
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(it.getItemStack())); ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, it.getItemStack());
it.remove(); if (remaining.length==0) {
return; SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(it.getItemStack()));
} it.remove();
return;
}
}
} }
} }
} }
@ -502,14 +509,17 @@ final class runServerHeartbeat implements Runnable {
Math.abs(deltay)<0.25 && Math.abs(deltay)<0.25 &&
Math.abs(deltaz)<0.25 && Math.abs(deltaz)<0.25 &&
InventoryUtils.hasFullInventory(p) && InventoryUtils.hasFullInventory(p) &&
((Item)ent).getPickupDelay()==0) { ((Item)ent).getPickupDelay()<=0) {
//Collect this item. //Collect this item.
if (((Item)ent).getItemStack().getType().isBlock()) { if (((Item)ent).getItemStack().getType().isBlock()) {
events.PlayerManualPickupItemEvent ev = new events.PlayerManualPickupItemEvent(p, ((Item) ent).getItemStack());
if (!ev.isCancelled()) {
ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, ((Item) ent).getItemStack()); ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, ((Item) ent).getItemStack());
if (remaining.length==0) { if (remaining.length==0) {
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(((Item) ent).getItemStack())); SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(((Item) ent).getItemStack()));
ent.remove(); ent.remove();
return; return;
}
} }
} }
} else { } else {

Loading…
Cancel
Save