Holiday candy and Revival Holiday candies are now on separate cooldowns,


			
			
				testdev
			
			
		
sigonasr2 8 years ago
parent 617d85d9c7
commit 25e4ffbb47
  1. BIN
      TwosideKeeper.jar
  2. 181
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  3. 1
      src/sig/plugin/TwosideKeeper/PlayerStructure.java

Binary file not shown.

@ -726,101 +726,106 @@ public class CustomDamage {
private static double modifyFateBasedOnHolidayTreats(Player p, double damage) { private static double modifyFateBasedOnHolidayTreats(Player p, double damage) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.lastcandyconsumed+40<TwosideKeeper.getServerTickTime()) { boolean consumed=false,consumed2=false;
boolean consumed=false; if (p.getHealth()-damage<=0 && pd.lastrevivecandyconsumed+200<TwosideKeeper.getServerTickTime()) {
if (p.getHealth()-damage<=0) { for (int i=0;i<9;i++) {
for (int i=0;i<9;i++) { ItemStack item = p.getInventory().getItem(i);
ItemStack item = p.getInventory().getItem(i); if (item!=null) {
if (item!=null) { if (Christmas.isHolidayRageCandyBarItem(item)) {
if (Christmas.isHolidayRageCandyBarItem(item)) { //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0);
//TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item));
p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); RemoveOneItem(p.getInventory(),item,i);
RemoveOneItem(p.getInventory(),item,i); Bukkit.broadcastMessage(ChatColor.GOLD+p.getName()+ChatColor.WHITE+" almost died... But came back to life!");
Bukkit.broadcastMessage(ChatColor.GOLD+p.getName()+ChatColor.WHITE+" almost died... But came back to life!"); aPlugin.API.discordSendRawItalicized(ChatColor.GOLD+p.getName()+ChatColor.WHITE+" almost died... But came back to life!");
aPlugin.API.discordSendRawItalicized(ChatColor.GOLD+p.getName()+ChatColor.WHITE+" almost died... But came back to life!"); SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f);
SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); p.setHealth(p.getMaxHealth());
p.setHealth(p.getMaxHealth()); GenericFunctions.RevivePlayer(p,p.getMaxHealth());
GenericFunctions.RevivePlayer(p,p.getMaxHealth()); ItemStack[] hotbar = GenericFunctions.getHotbarItems(p);
ItemStack[] hotbar = GenericFunctions.getHotbarItems(p); GenericFunctions.RandomlyBreakBaubles(p, hotbar);
GenericFunctions.RandomlyBreakBaubles(p, hotbar); consumed2=true;
consumed=true; return 0;
return 0;
}
} }
} }
} else }
if (p.getHealth()-damage<p.getMaxHealth()/2) { } else
//See if we can activate any treats. Check the hotbar. if (p.getHealth()-damage<p.getMaxHealth()/2 && pd.lastcandyconsumed+40<TwosideKeeper.getServerTickTime()) {
for (int i=0;i<9;i++) { //See if we can activate any treats. Check the hotbar.
ItemStack item = p.getInventory().getItem(i); for (int i=0;i<9;i++) {
if (item!=null) { ItemStack item = p.getInventory().getItem(i);
if (Christmas.isSmallCandyItem(item)) { if (item!=null) {
//TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); if (Christmas.isSmallCandyItem(item)) {
p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0);
RemoveOneItem(p.getInventory(),item,i); p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item));
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ RemoveOneItem(p.getInventory(),item,i);
if (!p.isDead()) { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{
SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); if (!p.isDead()) {
p.setHealth(Math.min(p.getHealth()+(0.1*p.getMaxHealth()), p.getMaxHealth())); SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f);
p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.1)+ChatColor.WHITE+" health has been restored!"); p.setHealth(Math.min(p.getHealth()+(0.1*p.getMaxHealth()), p.getMaxHealth()));
} p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.1)+ChatColor.WHITE+" health has been restored!");
},10); }
consumed=true;break; },10);
} else consumed=true;break;
if (Christmas.isLargeCandyItem(item)) { } else
//TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); if (Christmas.isLargeCandyItem(item)) {
p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0);
RemoveOneItem(p.getInventory(),item,i); p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item));
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ RemoveOneItem(p.getInventory(),item,i);
if (!p.isDead()) { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{
SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); if (!p.isDead()) {
p.setHealth(Math.min(p.getHealth()+(0.5*p.getMaxHealth()), p.getMaxHealth())); SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f);
p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.5)+ChatColor.WHITE+" health has been restored!"); p.setHealth(Math.min(p.getHealth()+(0.5*p.getMaxHealth()), p.getMaxHealth()));
} p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.5)+ChatColor.WHITE+" health has been restored!");
},10); }
consumed=true;break; },10);
} else consumed=true;break;
if (Christmas.isSourCandyItem(item)) { } else
//TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); if (Christmas.isSourCandyItem(item)) {
p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0);
RemoveOneItem(p.getInventory(),item,i); p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item));
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ RemoveOneItem(p.getInventory(),item,i);
if (!p.isDead()) { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{
if (!p.isDead()) {
SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION, 400, 4, p, true);
p.sendMessage(ChatColor.GREEN+" You feel a rejuvenating feeling inside of you.");
}
},10);
consumed=true;break;
} else
if (Christmas.isMysteryFlavorLollipopItem(item)) {
//TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0);
p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item));
RemoveOneItem(p.getInventory(),item,i);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{
if (!p.isDead()) {
if (Bukkit.getOnlinePlayers().size()>1) {
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.CONFUSION, 60, 4, p, true);
TeleportToARandomPlayer(p);
SoundUtils.playLocalSound(p, Sound.BLOCK_PORTAL_TRAVEL, 1.0f, 0.6f);
p.sendMessage(ChatColor.YELLOW+" You suddenly become disoriented.");
} else {
SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION, 400, 4, p, true); double randompct = Math.random();
p.sendMessage(ChatColor.GREEN+" You feel a rejuvenating feeling inside of you."); p.setHealth(Math.min(p.getHealth()+(randompct*p.getMaxHealth()), p.getMaxHealth()));
} p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*randompct)+ChatColor.WHITE+" health has been restored!");
},10);
consumed=true;break;
} else
if (Christmas.isMysteryFlavorLollipopItem(item)) {
//TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0);
p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item));
RemoveOneItem(p.getInventory(),item,i);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{
if (!p.isDead()) {
if (Bukkit.getOnlinePlayers().size()>1) {
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.CONFUSION, 60, 4, p, true);
TeleportToARandomPlayer(p);
SoundUtils.playLocalSound(p, Sound.BLOCK_PORTAL_TRAVEL, 1.0f, 0.6f);
p.sendMessage(ChatColor.YELLOW+" You suddenly become disoriented.");
} else {
SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f);
double randompct = Math.random();
p.setHealth(Math.min(p.getHealth()+(randompct*p.getMaxHealth()), p.getMaxHealth()));
p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*randompct)+ChatColor.WHITE+" health has been restored!");
}
} }
},10); }
consumed=true;break; },10);
} consumed=true;break;
} }
} }
} }
if (consumed) { }
SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f); if (consumed) {
pd.lastcandyconsumed=TwosideKeeper.getServerTickTime(); SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f);
} pd.lastcandyconsumed=TwosideKeeper.getServerTickTime();
aPlugin.API.sendCooldownPacket(p, Material.GOLDEN_CARROT, 40);
aPlugin.API.sendCooldownPacket(p, Material.RAW_FISH, 40);
}
if (consumed2) {
SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f);
pd.lastrevivecandyconsumed=TwosideKeeper.getServerTickTime();
aPlugin.API.sendCooldownPacket(p, Material.GOLDEN_APPLE, 200);
} }
return damage; return damage;
} }

@ -136,6 +136,7 @@ public class PlayerStructure {
public long lastabsorptionhealthgiven = TwosideKeeper.getServerTickTime(); public long lastabsorptionhealthgiven = TwosideKeeper.getServerTickTime();
public long ignoretargetarmor = TwosideKeeper.getServerTickTime(); public long ignoretargetarmor = TwosideKeeper.getServerTickTime();
public long lastcandyconsumed = TwosideKeeper.getServerTickTime(); public long lastcandyconsumed = TwosideKeeper.getServerTickTime();
public long lastrevivecandyconsumed = TwosideKeeper.getServerTickTime();
public long icewandused = TwosideKeeper.getServerTickTime(); public long icewandused = TwosideKeeper.getServerTickTime();
public PlayerMode playermode_on_death=PlayerMode.NORMAL; public PlayerMode playermode_on_death=PlayerMode.NORMAL;

Loading…
Cancel
Save