Glow restructuring has been done as well as adding AFK checks for tool

damaging while in stealth and monster spawning algorithm.
dev
sigonasr2 9 years ago
parent a89595fe14
commit 47a5b508dc
  1. BIN
      TwosideKeeper.jar
  2. 13
      src/sig/plugin/TwosideKeeper/EliteMonster.java
  3. 18
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  4. 4
      src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java
  5. 32
      src/sig/plugin/TwosideKeeper/MonsterController.java
  6. 48
      src/sig/plugin/TwosideKeeper/MonsterStructure.java
  7. 439
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  8. 467
      src/sig/plugin/TwosideKeeper/runServerHeartbeat.java

Binary file not shown.

@ -113,7 +113,7 @@ public class EliteMonster {
weakenTeam();
retargetInAir();
destroyLiquids(2);
reapplyGlow();
getGlow();
}
}
@ -290,8 +290,7 @@ public class EliteMonster {
ChargeZombie.BreakBlocksAroundArea(2, m.getLocation());
}
private void reapplyGlow() {
if (last_applyglow_time+GLOW_TIME<=TwosideKeeper.getServerTickTime()) {
public GlowAPI.Color getGlow() {
GlowAPI.Color col = GlowAPI.Color.DARK_PURPLE;
if (m.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
col = GlowAPI.Color.YELLOW;
@ -299,8 +298,8 @@ public class EliteMonster {
if (storingenergy) {
col = GlowAPI.Color.GREEN;
}
GenericFunctions.setGlowing(m, col);
}
//GenericFunctions.setGlowing(m, col);
return col;
}
private void destroyLiquids(int radius) {
@ -604,7 +603,7 @@ public class EliteMonster {
for (int x=-radius;x<radius+1;x++) {
for (int z=-radius;z<radius+1;z++) {
Block b = target.getLocation().add(x,-0.9,z).getBlock();
if (b.getType()!=Material.AIR && b.getType()!=Material.STAINED_GLASS) {
if (b.getType()!=Material.AIR && b.getType()!=Material.STAINED_GLASS && aPlugin.API.isExplosionProof(b)) {
storedblocks.put(b, b.getType());
b.setType(Material.STAINED_GLASS);
b.setData((byte)4);
@ -701,7 +700,7 @@ public class EliteMonster {
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.CONFUSION,20*4,0,p);
TwosideKeeper.log("Got hit for "+storingenergy_hit+" damage!", 2);
GenericFunctions.removeNoDamageTick(p, m);
if (CustomDamage.ApplyDamage(storingenergy_hit, m, p, null, "Stored Energy")) {
if (CustomDamage.ApplyDamage(storingenergy_hit, m, p, null, "Stored Energy", CustomDamage.IGNOREDODGE)) {
//TwosideKeeperAPI.DealDamageToEntity(.CalculateDamageReduction(storingenergy_hit,p,m),p,m);
storingenergy_hit=0;
}

@ -3451,12 +3451,14 @@ public class GenericFunctions {
}
public static void setGlowing(Monster m, Color color) {
/*
for (Player p : Bukkit.getOnlinePlayers()) {
GlowAPI.setGlowing(m, false, p);
if (!GlowAPI.isGlowing(m, p)) {
GlowAPI.setGlowing(m, color, p);
}
}
}*/
MonsterStructure.getMonsterStructure(m).setGlobalGlow(color);
}
public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range, boolean knockup, double knockupamt, Entity damager, String reason, boolean truedmg) {
@ -4070,7 +4072,7 @@ public class GenericFunctions {
}
public static void DamageRandomTool(Player p) {
if (ItemSet.GetSetCount(GenericFunctions.getHotbarItems(p), ItemSet.LORASYS, p)==0) {
if (!aPlugin.API.isAFK(p) && ItemSet.GetSetCount(GenericFunctions.getHotbarItems(p), ItemSet.LORASYS, p)==0) {
ItemStack[] inv = p.getInventory().getContents();
for (int i=0;i<9;i++) {
if (inv[i]!=null &&
@ -4093,8 +4095,10 @@ public class GenericFunctions {
}
public static boolean isIsolatedTarget(Monster m, Player p) {
return GlowAPI.isGlowing(m, p) &&
GlowAPI.getGlowColor(m, p).equals(Color.WHITE);
return ((GlowAPI.isGlowing(m, p) &&
GlowAPI.getGlowColor(m, p).equals(Color.WHITE)) ||
GenericFunctions.GetNearbyMonsterCount(m, 10)==0) &&
PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER;
}
public static boolean isSpecialGlowMonster(Monster m) {
@ -4143,10 +4147,16 @@ public class GenericFunctions {
if (!TwosideKeeper.suppressed_entities.contains(ent)) {
TwosideKeeper.suppressed_entities.add(ent);
}
if (ent instanceof Monster) {
//MonsterStructure.getMonsterStructure((Monster)ent).setGlobalGlow(GlowAPI.Color.BLACK);
MonsterStructure.getMonsterStructure((Monster)ent).UpdateGlow();
} else {
GlowAPI.setGlowing(ent, GlowAPI.Color.BLACK, Bukkit.getOnlinePlayers());
}
if (ent instanceof LivingEntity) {
LivingEntity l = (LivingEntity)ent;
l.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,ticks,99));
l.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,ticks,99));
}
}

@ -357,7 +357,11 @@ public enum MonsterDifficulty {
}
private boolean isValidSetItem(ItemStack goodie) {
if (goodie!=null) {
return TwosideKeeper.validsetitems.contains(goodie.getType());
} else {
return false;
}
}
public ItemSet PickAnItemSet(PlayerMode pm, ItemStack item) {

@ -153,7 +153,7 @@ public class MonsterController {
double dist = 999999999;
int nearbyplayers=0;
for (Player p : Bukkit.getOnlinePlayers()) {
if (ent.getWorld().equals(p.getWorld())) {
if (ent.getWorld().equals(p.getWorld()) && !aPlugin.API.isAFK(p)) {
double temp = ent.getLocation().distanceSquared(p.getLocation());
if (temp<4096) {nearbyplayers++;}
dist = (temp<dist)?temp:dist;
@ -741,11 +741,13 @@ public class MonsterController {
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
//GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(800); //Target is 800 HP.
m.setHealth(m.getMaxHealth());
TwosideKeeper.log(m.getCustomName()+" health is "+m.getMaxHealth(), 5);
MonsterStructure.getMonsterStructure(m).SetLeader(true);
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*2.0);
@ -767,10 +769,11 @@ public class MonsterController {
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(1200); //Target is 1200 HP.
m.setHealth(m.getMaxHealth());
MonsterStructure.getMonsterStructure(m).SetLeader(true);
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*3.0);
@ -799,7 +802,9 @@ public class MonsterController {
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
m.setMaxHealth(1600); //Target is 1600 HP.
m.setHealth(m.getMaxHealth());
MonsterStructure.getMonsterStructure(m).SetLeader(true);
@ -819,7 +824,6 @@ public class MonsterController {
//m.setCustomNameVisible(true);
m.setMaxHealth(4800);
m.setHealth(m.getMaxHealth());
GlowAPI.setGlowing(m, Color.DARK_PURPLE, Bukkit.getOnlinePlayers());
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,4);
@ -832,7 +836,9 @@ public class MonsterController {
}
m.setCustomNameVisible(true);
m.setRemoveWhenFarAway(false);
MonsterStructure.getMonsterStructure(m).SetElite(true);
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
ms.SetElite(true);
ms.UpdateGlow();
m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(72.0);
}break;
default: {
@ -846,11 +852,12 @@ public class MonsterController {
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(400);
m.setHealth(m.getMaxHealth());
m.setCustomName("Zombie Leader");
MonsterStructure.getMonsterStructure(m).SetLeader(true);
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*1.0);
@ -873,10 +880,11 @@ public class MonsterController {
SetupCustomName(ChatColor.DARK_BLUE+""+ChatColor.MAGIC+"End",m);
if(isZombieLeader(m))
{
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(32000); //Target is 1600 HP.
m.setHealth(m.getMaxHealth());
MonsterStructure.getMonsterStructure(m).SetLeader(true);
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*80.0);

@ -3,8 +3,13 @@ package sig.plugin.TwosideKeeper;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.inventivetalent.glow.GlowAPI;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class MonsterStructure {
public LivingEntity target;
@ -13,6 +18,7 @@ public class MonsterStructure {
public boolean isLeader=false;
public boolean isElite=false;
public HashMap<UUID,Long> hitlist = new HashMap<UUID,Long>();
public HashMap<Player,GlowAPI.Color> glowcolorlist = new HashMap<Player,GlowAPI.Color>();
public MonsterStructure(Monster m) {
target=null;
@ -62,6 +68,48 @@ public class MonsterStructure {
return this.isElite;
}
public void setGlow(Player p, GlowAPI.Color col) {
glowcolorlist.put(p, col);
GlowAPI.setGlowing(m, col, p);
}
public void setGlobalGlow(GlowAPI.Color col) {
for (Player p : Bukkit.getOnlinePlayers()) {
glowcolorlist.put(p, col);
GlowAPI.setGlowing(m, col, p);
}
}
public void UpdateGlow() {
//Updates the glow color for all players. We base it on default statuses here. CALL THIS INSTEAD OF
// SETTING THE GLOW DIRECTLY ANYMORE!
for (Player p : Bukkit.getOnlinePlayers()) {
if (GenericFunctions.isSuppressed(m)) {
setGlow(p,GlowAPI.Color.BLACK);
} else
if (getLeader() || GenericFunctions.isBossMonster(m)) {
setGlow(p,GlowAPI.Color.DARK_RED);
} else
if (getElite()) {
boolean handled=false;
for (EliteMonster em : TwosideKeeper.elitemonsters) {
if (em.getMonster().equals(m)) {
setGlow(p,em.getGlow());
}
}
if (!handled) {
setGlow(p,GlowAPI.Color.DARK_PURPLE);
}
} else
if (GenericFunctions.isIsolatedTarget(m, p)) {
setGlow(p,GlowAPI.Color.WHITE);
} else {
//No glow.
setGlow(p,null);
}
}
}
//Either gets a monster structure that exists or creates a new one.
public static MonsterStructure getMonsterStructure(Monster m) {
UUID id = m.getUniqueId();

@ -137,7 +137,6 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import org.inventivetalent.glow.GlowAPI;
import aPlugin.DiscordMessageSender;
import aPlugin.API.Chests;
import events.PluginLoadEvent;
import net.md_5.bungee.api.chat.ClickEvent;
@ -283,435 +282,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
private final class runServerHeartbeat implements Runnable {
@SuppressWarnings("deprecation")
public void run(){
log("Server time passed: "+(Bukkit.getWorld("world").getFullTime()-STARTTIME)+". New Server Time: "+(Bukkit.getWorld("world").getFullTime()-STARTTIME+SERVERTICK),5);
//Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()-10); //LEGACY CODE.
adjustServerTime(10);
//WORK IN PROGRESS: Lamp updating code TO GO HERE.
sendAllLoggedMessagesToSpam();
//SAVE SERVER SETTINGS.
if (getServerTickTime()-LASTSERVERCHECK>=SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT)
saveOurData();
//Advertisement messages could go here.
//MOTD: "Thanks for playing on Sig's Minecraft!\n*bCheck out http://z-gamers.net/mc for update info!\n*aReport any bugs you find at http://zgamers.domain.com/mc/"
getMOTD();
getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('*', MOTD));
habitat_data.increaseHabitationLevels();
habitat_data.startinglocs.clear();
for (int i=0;i<Bukkit.getOnlinePlayers().size();i++) {
Player p = (Player)(Bukkit.getOnlinePlayers().toArray()[i]);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.hitlist.clear();
}
/*
getServer().broadcastMessage("Thanks for playing on Sig's Minecraft!");
getServer().broadcastMessage(ChatColor.AQUA+"Check out http://z-gamers.net/mc for update info!");
getServer().broadcastMessage(" ");
*/
//End Advertisements.
LASTSERVERCHECK=getServerTickTime();
}
if (Bukkit.getWorld("world").getTime()>=12000) {
Collection<? extends Player> players = getServer().getOnlinePlayers();
//Count the number of players sleeping. Compare to "sleepingplayers" count.
log("[DEBUG] Time: "+Bukkit.getWorld("world").getTime()+" Full Time: "+Bukkit.getWorld("world").getFullTime() + " SERVERTICKTIME: "+getServerTickTime(),4);
//This functionality only makes sense when two or more players are on.
int sleeping=0;
for (Player p : players) {
if (p.isSleeping()) {
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.slayermodehp=p.getMaxHealth();
}
p.setHealth(p.getMaxHealth());
sleeping++;
}
}
if (sleepingPlayers!=sleeping) {
sleepingPlayers=sleeping;
if (players.size()>1) {
getServer().broadcastMessage(ChatColor.GOLD+""+sleepingPlayers+" Player"+(sleepingPlayers!=1?"s are":" is")+" in bed "+ChatColor.WHITE+"("+sleepingPlayers+"/"+(players.size()/2)+")");
}
}
if (sleepingPlayers>=Math.max(players.size()/2,1)) {
//Make it the next day.
if (players.size()>1) {
getServer().broadcastMessage(ChatColor.GOLD+"Enough Players sleeping! It's now morning!");
}
/*Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()+10);
SERVERTICK=getServerTickTime();*/
long temptime = Bukkit.getWorld("world").getFullTime();
Bukkit.getWorld("world").setTime(0);
time_passed+=temptime-Bukkit.getWorld("world").getFullTime();
Bukkit.getWorld("world").setThundering(false);
/*
STARTTIME=Bukkit.getWorld("world").getFullTime();
LASTSERVERCHECK=getServerTickTime();*/
//Make sure we keep SERVERTICK in check.
sleepingPlayers=0;
}
}
if (getServerTickTime()-LastClearStructureTime>=100) {
//Perform a clear of Monster Structure.
for(UUID id : monsterdata.keySet()) {
MonsterStructure mon = monsterdata.get(id);
Monster m = mon.m;
if (!m.isValid()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
() -> {
monsterdata.remove(id);
log("Removed one from Structure",5);
}, 1);
}
if (mon.isLeader || MonsterController.isZombieLeader(m)) {
//Make it glow red.
GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_RED);
}
if (mon.isElite || MonsterController.getMonsterDifficulty(m)==MonsterDifficulty.ELITE) {
//Make it glow dark purple.
GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_PURPLE);
boolean hasstruct = false;
for (EliteMonster em : elitemonsters) {
if (em.m.equals(m)) {
hasstruct=true;
}
}
if (!hasstruct) {
elitemonsters.add(new EliteMonster(m));
}
}
}
}
//See if each player needs to regenerate their health.
for (Player p : Bukkit.getOnlinePlayers()) {
if (!p.isDead()) {
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
GenericFunctions.RemoveNewDebuffs(p);
if (p.isSprinting() && pd.lastsprintcheck+(20*5)<getServerTickTime()) {
pd.lastsprintcheck=getServerTickTime();
GenericFunctions.ApplySwiftAegis(p);
}
if (banksessions.containsKey(p.getUniqueId())) {
//See if it expired.
BankSession bs = (BankSession)banksessions.get(p.getUniqueId());
if (bs.isSessionExpired()) {
banksessions.remove(p.getUniqueId());
}
}
/*
if (GenericFunctions.isRanger(p) &&
GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand())==BowMode.SNIPE) {
p.removePotionEffect(PotionEffectType.SLOW);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20,5));
}*/
if (TwosideShops.PlayerHasPurchases(p)) {
TwosideShops.PlayerSendPurchases(p);
}
if (TwosideShops.IsPlayerUsingTerminal(p) &&
(TwosideShops.GetSession(p).GetSign().getBlock()==null || TwosideShops.GetSession(p).IsTimeExpired())) {
p.sendMessage(ChatColor.RED+"Ran out of time! "+ChatColor.WHITE+"Shop session closed.");
TwosideShops.RemoveSession(p);
}
pd.highwinder=ArtifactAbility.containsEnchantment(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand());
if (pd.highwinder) {
pd.highwinderdmg=GenericFunctions.getAbilityValue(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand());
}
if (93.182445*pd.velocity>4.317) {
pd.velocity/=2;
} else {
pd.velocity=0;
}
if (pd.highwinder && pd.target!=null && !pd.target.isDead()) {
aPlugin.API.sendActionBarMessage(p, drawVelocityBar(pd.velocity,pd.highwinderdmg));
}
if (pd.target!=null && !pd.target.isDead() && pd.target.getLocation().getWorld().equals(p.getWorld()) && pd.target.getLocation().distanceSquared(p.getLocation())>256) {
pd.target=null;
}
if (pd.lasthittarget+20*15<=getServerTickTime() && pd.storedbowxp>0 && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
p.getEquipment().getItemInMainHand().getType()==Material.BOW) {
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), pd.storedbowxp, p);
TwosideKeeper.log("Added "+pd.storedbowxp+" Artifact XP", 2);
pd.storedbowxp=0;
}
if (p.getFireTicks()>0 && p.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) {
int duration = GenericFunctions.getPotionEffectDuration(PotionEffectType.FIRE_RESISTANCE, p);
int lv = GenericFunctions.getPotionEffectLevel(PotionEffectType.FIRE_RESISTANCE, p);
if (lv>10) {lv=10;}
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.FIRE_RESISTANCE, duration-(20*(10-lv)), lv, p, true);
}
if (GenericFunctions.hasStealth(p)) {GenericFunctions.DamageRandomTool(p);}
p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents()));
ItemStack[] equips = p.getEquipment().getArmorContents();
if (pd.last_regen_time+HEALTH_REGENERATION_RATE<=getServerTickTime()) {
pd.last_regen_time=getServerTickTime();
//See if this player needs to be healed.
if (p!=null &&
!p.isDead() && //Um, don't heal them if they're dead...That's just weird.
p.getHealth()<p.getMaxHealth() &&
p.getFoodLevel()>=16) {
if (PlayerMode.getPlayerMode(p)!=PlayerMode.SLAYER || pd.lastcombat+(20*60)<getServerTickTime()) {
double totalregen = 1+(p.getMaxHealth()*0.05);
double bonusregen = 0.0;
bonusregen += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.ALIKAHN, 4, 4);
totalregen += bonusregen;
for (ItemStack equip : equips) {
if (GenericFunctions.isArtifactEquip(equip)) {
double regenamt = GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH_REGEN, equip);
bonusregen += regenamt;
log("Bonus regen increased by "+regenamt,5);
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)) {
totalregen /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)?2:1;
}
}
}
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) {
totalregen /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())?2:1;
}
p.setHealth((p.getHealth()+totalregen>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen);
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
pd.slayermodehp=p.getHealth();
}
}
}
}
if (p.getWorld().getName().equalsIgnoreCase("world_the_end")) {
if (pd.endnotification+72000<getServerTickTime()) {
pd.endnotification=getServerTickTime();
playEndWarningNotification(p);
}
randomlyAggroNearbyEndermen(p);
}
//See if this player is sleeping.
if (p.isSleeping()) {
p.setHealth(Bukkit.getPlayer(pd.name).getMaxHealth()); //Heals the player fully when sleeping.
}
//We need to see if this player's damage reduction has changed recently. If so, notify them.
//Check damage reduction by sending an artifical "1" damage to the player.
if (!p.isDead()) {log("Player is not dead.",5); setPlayerMaxHealth(p);}
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
for (ItemStack equip : equips) {
if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, equip) &&
p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) {
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SPEED,20,1,p);
}
}
if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getItemInMainHand()) &&
p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) {
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SPEED,20,1,p);
//log("Apply speed. The light level here is "+p.getLocation().add(0,-1,0).getBlock().getLightLevel(),2);
}
if (ArtifactAbility.containsEnchantment(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand()) &&
pd.last_swordhit+40<getServerTickTime()) {
pd.swordcombo=0; //Reset the sword combo meter since the time limit expired.
}
if (PlayerMode.isSlayer(p)) {
if (pd.lastsneak+50<=getServerTickTime() &&
p.isSneaking() &&
ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.MOONSHADOW, 7)) {
GenericFunctions.deAggroNearbyTargets(p);
GenericFunctions.applyStealth(p, true);
}
List<Monster> mobs = GenericFunctions.getNearbyMobs(p.getLocation(), 16);
for (Monster m : mobs) {
if (!GenericFunctions.isIsolatedTarget(m,p) &&
!GenericFunctions.isSpecialGlowMonster(m)) {GlowAPI.setGlowing(m, GlowAPI.Color.WHITE, p);}
if (GenericFunctions.isIsolatedTarget(m,p) &&
!GenericFunctions.isSpecialGlowMonster(m) &&
GenericFunctions.GetNearbyMonsterCount(m, 8)>0) {
GlowAPI.setGlowing(m, false, p);
}
}
} else {
List<Monster> mobs = GenericFunctions.getNearbyMobs(p.getLocation(), 16);
for (Monster m : mobs) {
if (GenericFunctions.isIsolatedTarget(m,p) &&
!GenericFunctions.isSpecialGlowMonster(m)) {GlowAPI.setGlowing(m, false, p);}
}
}
GenericFunctions.AutoRepairItems(p);
}
}
PartyManager.SetupParties();
TwosideSpleefGames.TickEvent();
}
private void randomlyAggroNearbyEndermen(Player p) {
List<Monster> ents = GenericFunctions.getNearbyMobs(p.getLocation(), 16);
for (Monster m : ents) {
if (Math.random()<=0.05 && !m.hasPotionEffect(PotionEffectType.GLOWING)) {
m.setTarget(p);
}
}
}
private void playEndWarningNotification(Player p) {
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.sendMessage(ChatColor.GOLD+"A Mysterious Entity glares at you...");
}
},1);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.sendMessage(ChatColor.BLUE+" \"You DO NOT BELONG HERE.\"");
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},20);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.playSound(p.getLocation().add(0,20,0), Sound.ENTITY_GHAST_WARN, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},23);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.playSound(p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},27);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.playSound(p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},30);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.sendMessage(ChatColor.RED+"You cannot identify The End properly!");
}
},90);
}
private void sendAllLoggedMessagesToSpam() {
StringBuilder finalstring = new StringBuilder();
for (String msg : TwosideKeeper.log_messages) {
finalstring.append(msg+"\n");
}
TwosideKeeper.log_messages.clear();
if (finalstring.length()>0) {
DiscordMessageSender.sendToSpam(finalstring.toString());
}
}
private double subtractVanillaArmorBar(ItemStack[] armorContents) {
double lostamt = 0.0d;
for (ItemStack equip : armorContents) {
if (equip!=null &&
equip.getType()!=Material.AIR) {
switch (equip.getType()) {
case LEATHER_HELMET:{
lostamt-=1;
}break;
case LEATHER_CHESTPLATE:{
lostamt-=3;
}break;
case LEATHER_LEGGINGS:{
lostamt-=2;
}break;
case LEATHER_BOOTS:{
lostamt-=1;
}break;
case GOLD_HELMET:{
lostamt-=2;
}break;
case GOLD_CHESTPLATE:{
lostamt-=5;
}break;
case GOLD_LEGGINGS:{
lostamt-=3;
}break;
case GOLD_BOOTS:{
lostamt-=1;
}break;
case CHAINMAIL_HELMET:{
lostamt-=2;
}break;
case CHAINMAIL_CHESTPLATE:{
lostamt-=5;
}break;
case CHAINMAIL_LEGGINGS:{
lostamt-=4;
}break;
case CHAINMAIL_BOOTS:{
lostamt-=1;
}break;
case IRON_HELMET:{
lostamt-=2;
}break;
case IRON_CHESTPLATE:{
lostamt-=6;
}break;
case IRON_LEGGINGS:{
lostamt-=5;
}break;
case IRON_BOOTS:{
lostamt-=2;
}break;
case DIAMOND_HELMET:{
lostamt-=3;
}break;
case DIAMOND_CHESTPLATE:{
lostamt-=8;
}break;
case DIAMOND_LEGGINGS:{
lostamt-=6;
}break;
case DIAMOND_BOOTS:{
lostamt-=3;
}break;
default:{
}
}
}
}
return lostamt;
}
}
private final class ReapplyAbsorptionHeartsFromSet implements Runnable {
public void run(){
for (Player p : Bukkit.getOnlinePlayers()) {
@ -799,9 +369,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
for (Entity e : suppressed_entities) {
if (e==null || !e.isValid() ||
GenericFunctions.getSuppressionTime(e)<=0) {
if (GlowAPI.isGlowing(e, Bukkit.getOnlinePlayers(),false)) {
GlowAPI.setGlowing(e, null, Bukkit.getOnlinePlayers());
}
ScheduleRemoval(suppressed_entities,e);
}
}
@ -1172,7 +739,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
getServer().getScheduler().scheduleSyncRepeatingTask(this, new ReapplyAbsorptionHeartsFromSet(),0l,600l);
//This is the constant timing method.
getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerHeartbeat(), 20l, 20l);
getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerHeartbeat(this), 20l, 20l);
}
@Override
@ -4649,10 +4216,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
}
if ((ev.getEntity() instanceof Monster) && GenericFunctions.isBossMonster((Monster)ev.getEntity())) {
Monster m = (Monster)ev.getEntity();
GlowAPI.setGlowing(m, GlowAPI.Color.DARK_RED, Bukkit.getOnlinePlayers());
}
if (ev.getTarget() instanceof Player &&
ev.getEntity() instanceof Monster) {
Player p = (Player)ev.getTarget();

@ -0,0 +1,467 @@
package sig.plugin.TwosideKeeper;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.inventivetalent.glow.GlowAPI;
import aPlugin.DiscordMessageSender;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility;
import sig.plugin.TwosideKeeper.HelperStructures.BankSession;
import sig.plugin.TwosideKeeper.HelperStructures.ItemSet;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
final class runServerHeartbeat implements Runnable {
/**
*
*/
private final TwosideKeeper ServerHeartbeat;
/**
* @param twosideKeeper
*/
runServerHeartbeat(TwosideKeeper twosideKeeper) {
ServerHeartbeat = twosideKeeper;
}
@SuppressWarnings("deprecation")
public void run(){
TwosideKeeper.log("Server time passed: "+(Bukkit.getWorld("world").getFullTime()-TwosideKeeper.STARTTIME)+". New Server Time: "+(Bukkit.getWorld("world").getFullTime()-TwosideKeeper.STARTTIME+TwosideKeeper.SERVERTICK),5);
//Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()-10); //LEGACY CODE.
TwosideKeeper.adjustServerTime(10);
//WORK IN PROGRESS: Lamp updating code TO GO HERE.
sendAllLoggedMessagesToSpam();
//SAVE SERVER SETTINGS.
if (TwosideKeeper.getServerTickTime()-TwosideKeeper.LASTSERVERCHECK>=TwosideKeeper.SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT)
ServerHeartbeat.saveOurData();
//Advertisement messages could go here.
//MOTD: "Thanks for playing on Sig's Minecraft!\n*bCheck out http://z-gamers.net/mc for update info!\n*aReport any bugs you find at http://zgamers.domain.com/mc/"
ServerHeartbeat.getMOTD();
ServerHeartbeat.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('*', TwosideKeeper.MOTD));
TwosideKeeper.habitat_data.increaseHabitationLevels();
TwosideKeeper.habitat_data.startinglocs.clear();
for (int i=0;i<Bukkit.getOnlinePlayers().size();i++) {
Player p = (Player)(Bukkit.getOnlinePlayers().toArray()[i]);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.hitlist.clear();
}
/*
getServer().broadcastMessage("Thanks for playing on Sig's Minecraft!");
getServer().broadcastMessage(ChatColor.AQUA+"Check out http://z-gamers.net/mc for update info!");
getServer().broadcastMessage(" ");
*/
//End Advertisements.
TwosideKeeper.LASTSERVERCHECK=TwosideKeeper.getServerTickTime();
}
if (Bukkit.getWorld("world").getTime()>=12000) {
Collection<? extends Player> players = ServerHeartbeat.getServer().getOnlinePlayers();
//Count the number of players sleeping. Compare to "sleepingplayers" count.
TwosideKeeper.log("[DEBUG] Time: "+Bukkit.getWorld("world").getTime()+" Full Time: "+Bukkit.getWorld("world").getFullTime() + " SERVERTICKTIME: "+TwosideKeeper.getServerTickTime(),4);
//This functionality only makes sense when two or more players are on.
int sleeping=0;
for (Player p : players) {
if (p.isSleeping()) {
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.slayermodehp=p.getMaxHealth();
}
p.setHealth(p.getMaxHealth());
sleeping++;
}
}
if (ServerHeartbeat.sleepingPlayers!=sleeping) {
ServerHeartbeat.sleepingPlayers=sleeping;
if (players.size()>1) {
ServerHeartbeat.getServer().broadcastMessage(ChatColor.GOLD+""+ServerHeartbeat.sleepingPlayers+" Player"+(ServerHeartbeat.sleepingPlayers!=1?"s are":" is")+" in bed "+ChatColor.WHITE+"("+ServerHeartbeat.sleepingPlayers+"/"+(players.size()/2)+")");
}
}
if (ServerHeartbeat.sleepingPlayers>=Math.max(players.size()/2,1)) {
//Make it the next day.
if (players.size()>1) {
ServerHeartbeat.getServer().broadcastMessage(ChatColor.GOLD+"Enough Players sleeping! It's now morning!");
}
/*Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()+10);
SERVERTICK=getServerTickTime();*/
long temptime = Bukkit.getWorld("world").getFullTime();
Bukkit.getWorld("world").setTime(0);
TwosideKeeper.time_passed+=temptime-Bukkit.getWorld("world").getFullTime();
Bukkit.getWorld("world").setThundering(false);
/*
STARTTIME=Bukkit.getWorld("world").getFullTime();
LASTSERVERCHECK=getServerTickTime();*/
//Make sure we keep SERVERTICK in check.
ServerHeartbeat.sleepingPlayers=0;
}
}
//See if each player needs to regenerate their health.
for (Player p : Bukkit.getOnlinePlayers()) {
if (!p.isDead()) {
PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId());
GenericFunctions.RemoveNewDebuffs(p);
if (p.isSprinting() && pd.lastsprintcheck+(20*5)<TwosideKeeper.getServerTickTime()) {
pd.lastsprintcheck=TwosideKeeper.getServerTickTime();
GenericFunctions.ApplySwiftAegis(p);
}
if (TwosideKeeper.banksessions.containsKey(p.getUniqueId())) {
//See if it expired.
BankSession bs = (BankSession)TwosideKeeper.banksessions.get(p.getUniqueId());
if (bs.isSessionExpired()) {
TwosideKeeper.banksessions.remove(p.getUniqueId());
}
}
/*
if (GenericFunctions.isRanger(p) &&
GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand())==BowMode.SNIPE) {
p.removePotionEffect(PotionEffectType.SLOW);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20,5));
}*/
if (TwosideKeeper.TwosideShops.PlayerHasPurchases(p)) {
TwosideKeeper.TwosideShops.PlayerSendPurchases(p);
}
if (TwosideKeeper.TwosideShops.IsPlayerUsingTerminal(p) &&
(TwosideKeeper.TwosideShops.GetSession(p).GetSign().getBlock()==null || TwosideKeeper.TwosideShops.GetSession(p).IsTimeExpired())) {
p.sendMessage(ChatColor.RED+"Ran out of time! "+ChatColor.WHITE+"Shop session closed.");
TwosideKeeper.TwosideShops.RemoveSession(p);
}
pd.highwinder=ArtifactAbility.containsEnchantment(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand());
if (pd.highwinder) {
pd.highwinderdmg=GenericFunctions.getAbilityValue(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand());
}
if (93.182445*pd.velocity>4.317) {
pd.velocity/=2;
} else {
pd.velocity=0;
}
if (pd.highwinder && pd.target!=null && !pd.target.isDead()) {
aPlugin.API.sendActionBarMessage(p, TwosideKeeper.drawVelocityBar(pd.velocity,pd.highwinderdmg));
}
if (pd.target!=null && !pd.target.isDead() && pd.target.getLocation().getWorld().equals(p.getWorld()) && pd.target.getLocation().distanceSquared(p.getLocation())>256) {
pd.target=null;
}
if (pd.lasthittarget+20*15<=TwosideKeeper.getServerTickTime() && pd.storedbowxp>0 && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
p.getEquipment().getItemInMainHand().getType()==Material.BOW) {
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), pd.storedbowxp, p);
TwosideKeeper.log("Added "+pd.storedbowxp+" Artifact XP", 2);
pd.storedbowxp=0;
}
if (p.getFireTicks()>0 && p.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) {
int duration = GenericFunctions.getPotionEffectDuration(PotionEffectType.FIRE_RESISTANCE, p);
int lv = GenericFunctions.getPotionEffectLevel(PotionEffectType.FIRE_RESISTANCE, p);
if (lv>10) {lv=10;}
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.FIRE_RESISTANCE, duration-(20*(10-lv)), lv, p, true);
}
if (GenericFunctions.hasStealth(p)) {GenericFunctions.DamageRandomTool(p);}
p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents()));
ItemStack[] equips = p.getEquipment().getArmorContents();
if (pd.last_regen_time+TwosideKeeper.HEALTH_REGENERATION_RATE<=TwosideKeeper.getServerTickTime()) {
pd.last_regen_time=TwosideKeeper.getServerTickTime();
//See if this player needs to be healed.
if (p!=null &&
!p.isDead() && //Um, don't heal them if they're dead...That's just weird.
p.getHealth()<p.getMaxHealth() &&
p.getFoodLevel()>=16) {
if (PlayerMode.getPlayerMode(p)!=PlayerMode.SLAYER || pd.lastcombat+(20*60)<TwosideKeeper.getServerTickTime()) {
double totalregen = 1+(p.getMaxHealth()*0.05);
double bonusregen = 0.0;
bonusregen += ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.ALIKAHN, 4, 4);
totalregen += bonusregen;
for (ItemStack equip : equips) {
if (GenericFunctions.isArtifactEquip(equip)) {
double regenamt = GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH_REGEN, equip);
bonusregen += regenamt;
TwosideKeeper.log("Bonus regen increased by "+regenamt,5);
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)) {
totalregen /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)?2:1;
}
}
}
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) {
totalregen /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())?2:1;
}
p.setHealth((p.getHealth()+totalregen>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen);
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
pd.slayermodehp=p.getHealth();
}
}
}
}
if (p.getWorld().getName().equalsIgnoreCase("world_the_end")) {
if (pd.endnotification+72000<TwosideKeeper.getServerTickTime()) {
pd.endnotification=TwosideKeeper.getServerTickTime();
playEndWarningNotification(p);
}
randomlyAggroNearbyEndermen(p);
}
//See if this player is sleeping.
if (p.isSleeping()) {
p.setHealth(Bukkit.getPlayer(pd.name).getMaxHealth()); //Heals the player fully when sleeping.
}
//We need to see if this player's damage reduction has changed recently. If so, notify them.
//Check damage reduction by sending an artifical "1" damage to the player.
if (!p.isDead()) {TwosideKeeper.log("Player is not dead.",5); TwosideKeeper.setPlayerMaxHealth(p);}
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(TwosideKeeper.createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
for (ItemStack equip : equips) {
if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, equip) &&
p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) {
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SPEED,20,1,p);
}
}
if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getItemInMainHand()) &&
p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) {
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SPEED,20,1,p);
//log("Apply speed. The light level here is "+p.getLocation().add(0,-1,0).getBlock().getLightLevel(),2);
}
if (ArtifactAbility.containsEnchantment(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand()) &&
pd.last_swordhit+40<TwosideKeeper.getServerTickTime()) {
pd.swordcombo=0; //Reset the sword combo meter since the time limit expired.
}
if (PlayerMode.isSlayer(p)) {
if (pd.lastsneak+50<=TwosideKeeper.getServerTickTime() &&
p.isSneaking() &&
ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.MOONSHADOW, 7)) {
GenericFunctions.deAggroNearbyTargets(p);
GenericFunctions.applyStealth(p, true);
}
/*List<Monster> mobs = GenericFunctions.getNearbyMobs(p.getLocation(), 16);
for (Monster m : mobs) {
if (!GenericFunctions.isIsolatedTarget(m,p) &&
!GenericFunctions.isSpecialGlowMonster(m) &&
m.getLocation().distanceSquared(p.getLocation())<196) {GlowAPI.setGlowing(m, GlowAPI.Color.WHITE, p);}
if (GenericFunctions.isIsolatedTarget(m,p) &&
!GenericFunctions.isSpecialGlowMonster(m) &&
GenericFunctions.GetNearbyMonsterCount(m, 8)>0) {
GlowAPI.setGlowing(m, false, p);
}
}*/
} else {
/*List<Monster> mobs = GenericFunctions.getNearbyMobs(p.getLocation(), 16);
for (Monster m : mobs) {
if (GenericFunctions.isIsolatedTarget(m,p) &&
!GenericFunctions.isSpecialGlowMonster(m)) {GlowAPI.setGlowing(m, false, p);}
}*/
}
GenericFunctions.AutoRepairItems(p);
}
}
MaintainMonsterData();
PartyManager.SetupParties();
TwosideKeeper.TwosideSpleefGames.TickEvent();
}
private void MaintainMonsterData() {
Set<UUID> data= TwosideKeeper.monsterdata.keySet();
for (UUID id : data) {
MonsterStructure ms = TwosideKeeper.monsterdata.get(id);
if (ms.m==null || !ms.m.isValid()) {
TwosideKeeper.monsterdata.remove(data);
TwosideKeeper.log("Removed Monster Structure for "+id+". New Size: "+TwosideKeeper.monsterdata.size(), 5);
} else {
AddEliteStructureIfOneDoesNotExist(ms);
ms.UpdateGlow();
}
}
}
public void AddEliteStructureIfOneDoesNotExist(MonsterStructure ms) {
if (ms.isElite || MonsterController.getMonsterDifficulty(ms.m)==MonsterDifficulty.ELITE) {
//Make it glow dark purple.
//GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_PURPLE);
boolean hasstruct = false;
for (EliteMonster em : TwosideKeeper.elitemonsters) {
if (em.m.equals(ms.m)) {
hasstruct=true;
}
}
if (!hasstruct) {
TwosideKeeper.elitemonsters.add(new EliteMonster(ms.m));
}
}
}
private void randomlyAggroNearbyEndermen(Player p) {
List<Monster> ents = GenericFunctions.getNearbyMobs(p.getLocation(), 16);
for (Monster m : ents) {
if (Math.random()<=0.05 && !m.hasPotionEffect(PotionEffectType.GLOWING)) {
m.setTarget(p);
}
}
}
private void playEndWarningNotification(Player p) {
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.sendMessage(ChatColor.GOLD+"A Mysterious Entity glares at you...");
}
},1);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.sendMessage(ChatColor.BLUE+" \"You DO NOT BELONG HERE.\"");
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},20);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.playSound(p.getLocation().add(0,20,0), Sound.ENTITY_GHAST_WARN, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},23);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.playSound(p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},27);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.playSound(p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f);
p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f);
}
},30);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.sendMessage(ChatColor.RED+"You cannot identify The End properly!");
}
},90);
}
private void sendAllLoggedMessagesToSpam() {
StringBuilder finalstring = new StringBuilder();
for (String msg : TwosideKeeper.log_messages) {
finalstring.append(msg+"\n");
}
TwosideKeeper.log_messages.clear();
if (finalstring.length()>0) {
DiscordMessageSender.sendToSpam(finalstring.toString());
}
}
private double subtractVanillaArmorBar(ItemStack[] armorContents) {
double lostamt = 0.0d;
for (ItemStack equip : armorContents) {
if (equip!=null &&
equip.getType()!=Material.AIR) {
switch (equip.getType()) {
case LEATHER_HELMET:{
lostamt-=1;
}break;
case LEATHER_CHESTPLATE:{
lostamt-=3;
}break;
case LEATHER_LEGGINGS:{
lostamt-=2;
}break;
case LEATHER_BOOTS:{
lostamt-=1;
}break;
case GOLD_HELMET:{
lostamt-=2;
}break;
case GOLD_CHESTPLATE:{
lostamt-=5;
}break;
case GOLD_LEGGINGS:{
lostamt-=3;
}break;
case GOLD_BOOTS:{
lostamt-=1;
}break;
case CHAINMAIL_HELMET:{
lostamt-=2;
}break;
case CHAINMAIL_CHESTPLATE:{
lostamt-=5;
}break;
case CHAINMAIL_LEGGINGS:{
lostamt-=4;
}break;
case CHAINMAIL_BOOTS:{
lostamt-=1;
}break;
case IRON_HELMET:{
lostamt-=2;
}break;
case IRON_CHESTPLATE:{
lostamt-=6;
}break;
case IRON_LEGGINGS:{
lostamt-=5;
}break;
case IRON_BOOTS:{
lostamt-=2;
}break;
case DIAMOND_HELMET:{
lostamt-=3;
}break;
case DIAMOND_CHESTPLATE:{
lostamt-=8;
}break;
case DIAMOND_LEGGINGS:{
lostamt-=6;
}break;
case DIAMOND_BOOTS:{
lostamt-=3;
}break;
default:{
}
}
}
}
return lostamt;
}
}
Loading…
Cancel
Save