Add in Potion Effect Debug Messages everywhere... Hopefully to find the

problem.
dev
sigonasr2 9 years ago
parent cf4ef2ef4f
commit c70a620551
  1. BIN
      TwosideKeeper.jar
  2. 50
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  3. 5
      src/sig/plugin/TwosideKeeper/DeathManager.java
  4. 14
      src/sig/plugin/TwosideKeeper/EliteMonster.java
  5. 86
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  6. 5
      src/sig/plugin/TwosideKeeper/SpleefGame.java
  7. 73
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java

Binary file not shown.

@ -98,6 +98,11 @@ public class CustomDamage {
//Custom damage right here.
flags = setFlag(flags,SPECIALATTACK);
}
if (getDamagerEntity(damager) instanceof Player) {
Player p = (Player)getDamagerEntity(damager);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.lasthitproperties=NONE;
}
if (!InvulnerableCheck(damager,target,flags)) {
double dmg = 0.0;
if (isFlagSet(flags,TRUEDMG)) {
@ -139,6 +144,7 @@ public class CustomDamage {
dmg+=getBaseWeaponDamage(damage, weapon, damager, target, reason);
if (weapon.getType()==Material.BOW) {
if ((damager instanceof Projectile)) {
TwosideKeeper.log("This is a projectile! Reason: "+reason+", Damager: "+damager.toString(), 2);
dmg += addMultiplierToPlayerLogger(damager,target,"Ranger Mult",dmg * calculateRangerMultiplier(weapon,damager));
double headshotdmg = addMultiplierToPlayerLogger(damager,target,"Headshot Mult",dmg * calculateHeadshotMultiplier(weapon,damager,target));
if (headshotdmg!=0.0) {headshot=true;}
@ -440,9 +446,9 @@ public class CustomDamage {
int resistancelv = GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p);
int resistance_duration = GenericFunctions.getPotionEffectDuration(PotionEffectType.DAMAGE_RESISTANCE, p);
if (resistancelv>0) {
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Math.max(resistance_duration,20*20),resistancelv-1),true);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.DAMAGE_RESISTANCE, Math.max(resistance_duration,20*20), resistancelv-1, p, true);
} else {
p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.DAMAGE_RESISTANCE,p);
}
pd.swiftaegisamt--;
TwosideKeeper.log(pd.swiftaegisamt+" stacks of Aegis remaining.", 5);
@ -1054,10 +1060,10 @@ public class CustomDamage {
pd.iframetime=TwosideKeeper.getServerTickTime()+ticks;
int level = GenericFunctions.getPotionEffectLevel(PotionEffectType.NIGHT_VISION, p);
if (level==64) {
p.removePotionEffect(PotionEffectType.NIGHT_VISION);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.NIGHT_VISION,p);
}
p.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING,ticks,0),true);
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,ticks,64));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.GLOWING, ticks, 0, p, true);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.NIGHT_VISION,ticks,64, p);
}
}
}
@ -1075,12 +1081,12 @@ public class CustomDamage {
if (p!=null) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.iframetime=0;
p.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING,1,1), true);
p.removePotionEffect(PotionEffectType.GLOWING);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.GLOWING,1,1,p,true);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.GLOWING,p);
int level = GenericFunctions.getPotionEffectLevel(PotionEffectType.NIGHT_VISION, p);
if (level==64) {
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,1,1), true);
p.removePotionEffect(PotionEffectType.NIGHT_VISION);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.NIGHT_VISION,1,1,p,true);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.NIGHT_VISION,p);
}
}
}
@ -1345,7 +1351,9 @@ public class CustomDamage {
TwosideKeeper.log("Distance: "+(arrowLoc.distanceSquared(monsterHead)), 5);
double headshotvaly=0.22/TwosideKeeper.HEADSHOT_ACC;
TwosideKeeper.log("In here.", 2);
if (proj.getShooter() instanceof Player) {
TwosideKeeper.log("We somehow made it to here???", 2);
Player p = (Player)proj.getShooter();
if (PlayerMode.isRanger(p) &&
GenericFunctions.getBowMode(weapon)==BowMode.SNIPE) {
@ -1374,18 +1382,18 @@ public class CustomDamage {
if (Iterables.get(p.getActivePotionEffects(), i1).getType().equals(PotionEffectType.SLOW)) {
int lv = Iterables.get(p.getActivePotionEffects(), i1).getAmplifier();
TwosideKeeper.log("New Slowness level: "+lv,5);
p.removePotionEffect(PotionEffectType.SLOW);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,99,lv+1));
p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99,lv+1));
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.SLOW,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SLOW,99,lv+1,p);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.DAMAGE_RESISTANCE,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.DAMAGE_RESISTANCE,99,lv+1,p);
break;
}
}
} else {
p.removePotionEffect(PotionEffectType.SLOW);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,99,0));
p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99,0));
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.SLOW,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SLOW,99,0,p);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.DAMAGE_RESISTANCE,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.DAMAGE_RESISTANCE,99,0,p);
}
final Player pl = p;
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("TwosideKeeper"), new Runnable() {
@ -1903,10 +1911,10 @@ public class CustomDamage {
if (totalmoney>=0.01) {
p_loc.setY(0);
p.teleport(p_loc);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*2 /*Approx 2 sec of no movement.*/,10));
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*26 /*Reduces fall damage temporarily.*/,500));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SLOW,20*2,10,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.REGENERATION,20*16,6,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.LEVITATION,20*18,6,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.DAMAGE_RESISTANCE,20*26,50,p);
DecimalFormat df = new DecimalFormat("0.00");
double rand_amt = 0.0;
if (totalmoney>5) {

@ -16,6 +16,7 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class DeathManager {
static String Pick5Text = "Mercy (Pick 5 Lost Items)";
@ -33,8 +34,8 @@ public class DeathManager {
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
@Override
public void run() {
p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,15,-2),true);
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,15,100),true);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.LEVITATION,15,-2,p,true);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.JUMP,15,100,p,true);
p.setVelocity(new Vector(0,0,0));
CustomDamage.removeIframe(p);
Location loc = p.getLocation();

@ -318,15 +318,15 @@ public class EliteMonster {
if (Math.random()<=0.01) {
Player p = ChooseRandomTarget();
//p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*5,-31));
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,20*5,-1));
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*1,7));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.JUMP,20*5,-1,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.BLINDNESS,20*1,7,p);
if (Math.random()<=0.25) {
m.setTarget(p);
}
p.setFlying(false);
p.setVelocity(new Vector(0,-1,0));
p.removePotionEffect(PotionEffectType.LEVITATION);
p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,(int)(20*2.25),0));
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.LEVITATION,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.CONFUSION,(int)(20*2.25),0,p);
p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_FALL, 0.4f, 0.8f);
p.playSound(p.getLocation(), Sound.ENTITY_MAGMACUBE_SQUISH, 1.0f, 1.0f);
}
@ -466,7 +466,7 @@ public class EliteMonster {
dpslist.put(p.getName(), currentdps+dmg);
if ((!p.hasPotionEffect(PotionEffectType.WEAKNESS) || GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, p)<9) &&
!PlayerMode.isRanger(p)) {
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS,35,9),true);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.WEAKNESS,35,9,p,true);
}
}
last_regen_time=TwosideKeeper.getServerTickTime();
@ -645,7 +645,7 @@ public class EliteMonster {
private Player ChooseRandomTarget() {
if (targetlist.size()>0) {
Player p = targetlist.get((int)(Math.random() * targetlist.size()));
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*1,7));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.BLINDNESS,20*1,7,p);
m.setTarget(p);
TwosideKeeper.log("Set new target to "+p.getName(), 2);
return p;
@ -690,7 +690,7 @@ public class EliteMonster {
Player p = (Player)ent;
if (storingenergy_hit>0) {
p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,20*4,0));
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")) {

@ -40,6 +40,7 @@ import org.inventivetalent.glow.GlowAPI.Color;
import com.google.common.collect.Iterables;
import aPlugin.DiscordMessageSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ -1146,7 +1147,7 @@ public class GenericFunctions {
case THICK:
return "Thick Arrow";
case UNCRAFTABLE:
return "Arrow";
return "Tipped Arrow";
case WATER:
return "Water Bottle";
case WATER_BREATHING:
@ -1158,7 +1159,7 @@ public class GenericFunctions {
return "Arrow of Weakness";
}
default:
return "Arrow";
return "Tipped Arrow";
}
}
case LINGERING_POTION:{
@ -2721,12 +2722,55 @@ public class GenericFunctions {
}
ApplySwiftAegis(p);
CustomDamage.addIframe(dodgeduration, p);
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,dodgeduration,2));
//TwosideKeeper.log("Added "+dodgeduration+" glowing ticks to "+p.getName()+" for dodging.",3);
logAndApplyPotionEffectToPlayer(PotionEffectType.SPEED,dodgeduration,2,p);
}
}
}
public static void logAndApplyPotionEffectToPlayer(PotionEffectType type, int ticks, int amplifier, Player p) {
logAndApplyPotionEffectToPlayer(type,ticks,amplifier,p,false);
}
public static void logAndApplyPotionEffectToPlayer(PotionEffectType type, int ticks, int amplifier, Player p, boolean force) {
TwosideKeeper.log(ChatColor.WHITE+"Adding Potion Effect "+type.getName()+" "+WorldShop.toRomanNumeral((amplifier+1))+"("+amplifier+") to "+p.getName()+" with "+ticks+" tick duration. "+((force)?ChatColor.RED+"FORCED":""), TwosideKeeper.POTION_DEBUG_LEVEL);
if (p.hasPotionEffect(type)) {
TwosideKeeper.log(ChatColor.YELLOW+" Already had effect on Player "+p.getName()+". "+type.getName()+" "+WorldShop.toRomanNumeral((getPotionEffectLevel(type,p)+1))+"("+getPotionEffectLevel(type,p)+"), Duration: "+getPotionEffectDuration(type,p)+" ticks", TwosideKeeper.POTION_DEBUG_LEVEL);
if (!force) {
TwosideKeeper.log(ChatColor.RED+" This should not be overwritten due to no FORCE!", TwosideKeeper.POTION_DEBUG_LEVEL);
}
}
p.addPotionEffect(new PotionEffect(type,ticks,amplifier),force);
TwosideKeeper.log(ChatColor.GRAY+" Effect on Player "+p.getName()+" is now "+type.getName()+" "+WorldShop.toRomanNumeral((amplifier+1))+"("+amplifier+"), Duration: "+ticks+" ticks", TwosideKeeper.POTION_DEBUG_LEVEL);
if (amplifier==-1 || ticks==0) {
//Something really bad happened!!!
TwosideKeeper.log("OUT OF PARAMETERS! Reporting", TwosideKeeper.POTION_DEBUG_LEVEL);
StackTraceElement[] stacktrace = new Throwable().getStackTrace();
StringBuilder stack = new StringBuilder("Mini stack tracer:");
for (int i=0;i<Math.min(10, stacktrace.length);i++) {
stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber());
}
DiscordMessageSender.sendToSpam(stack.toString());
}
}
public static void logAndRemovePotionEffectFromPlayer(PotionEffectType type, Player p) {
TwosideKeeper.log(ChatColor.WHITE+"Removing Potion Effect "+type+" "+WorldShop.toRomanNumeral((getPotionEffectLevel(type,p)+1))+"("+getPotionEffectLevel(type,p)+") on Player "+p.getName()+" Duration: "+getPotionEffectDuration(type,p)+" ticks", TwosideKeeper.POTION_DEBUG_LEVEL);
p.removePotionEffect(type);
if (p.hasPotionEffect(type)) {
TwosideKeeper.log(ChatColor.DARK_RED+" Effect on Player "+p.getName()+" is now "+type+" "+WorldShop.toRomanNumeral((getPotionEffectLevel(type,p)+1))+"("+getPotionEffectLevel(type,p)+"), Duration: "+getPotionEffectDuration(type,p)+" ticks", TwosideKeeper.POTION_DEBUG_LEVEL);
TwosideKeeper.log(ChatColor.RED+"THIS SHOULD NOT BE HAPPENING! Reporting", TwosideKeeper.POTION_DEBUG_LEVEL);
StackTraceElement[] stacktrace = new Throwable().getStackTrace();
StringBuilder stack = new StringBuilder("Mini stack tracer:");
for (int i=0;i<Math.min(10, stacktrace.length);i++) {
stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber());
}
DiscordMessageSender.sendToSpam(stack.toString());
}
}
public static String GetEntityDisplayName(Entity e) {
if (e instanceof LivingEntity) {
LivingEntity l = (LivingEntity)e;
@ -2775,7 +2819,9 @@ public class GenericFunctions {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
if (CustomDamage.getDamagerEntity(damager)!=null) {
damager = CustomDamage.getDamagerEntity(damager);
}
}
if (pd.hitlist.containsKey(damager.getUniqueId())) {
long time = pd.hitlist.get(damager.getUniqueId());
@ -2803,7 +2849,9 @@ public class GenericFunctions {
MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
if (CustomDamage.getDamagerEntity(damager)!=null) {
damager = CustomDamage.getDamagerEntity(damager);
}
}
if (md.hitlist.containsKey(damager.getUniqueId())) {
long time = md.hitlist.get(damager.getUniqueId());
@ -2863,7 +2911,9 @@ public class GenericFunctions {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
if (CustomDamage.getDamagerEntity(damager)!=null) {
damager = CustomDamage.getDamagerEntity(damager);
}
}
pd.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
} else {
@ -2876,7 +2926,9 @@ public class GenericFunctions {
MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
if (CustomDamage.getDamagerEntity(damager)!=null) {
damager = CustomDamage.getDamagerEntity(damager);
}
}
md.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
} else {
@ -2899,8 +2951,8 @@ public class GenericFunctions {
if (pd.last_rejuvenate+TwosideKeeper.REJUVENATE_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
player.playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0f, 1.0f);
addIFrame(player,40);
player.removePotionEffect(PotionEffectType.REGENERATION);
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200,9));
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.REGENERATION,player);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.REGENERATION,200,9,player);
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN);
}
}
@ -3173,7 +3225,7 @@ public class GenericFunctions {
if (isBadEffect(eff.getType())) {
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,
() -> {
p.removePotionEffect(eff.getType());
logAndRemovePotionEffectFromPlayer(eff.getType(),p);
}, 1);
}
}
@ -3601,10 +3653,10 @@ public class GenericFunctions {
if (resistancelv+swiftaegislv<9) {
//Apply it directly.
pd.swiftaegisamt+=swiftaegislv;
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Math.max(20*20, resistance_duration), (resistancelv+swiftaegislv)),true);
logAndApplyPotionEffectToPlayer(PotionEffectType.DAMAGE_RESISTANCE, Math.max(20*20, resistance_duration), (resistancelv+swiftaegislv),p,true);
} else {
pd.swiftaegisamt+=Math.max(9-resistancelv,0);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Math.max(20*20, resistance_duration), 9),true);
logAndApplyPotionEffectToPlayer(PotionEffectType.DAMAGE_RESISTANCE, Math.max(20*20, resistance_duration),9,p,true);
}
}
TwosideKeeper.log("New Aegis level: "+pd.swiftaegisamt,5);
@ -3639,12 +3691,12 @@ public class GenericFunctions {
int currentlv = getPotionEffectLevel(type,p);
PotionEffect neweffect = new PotionEffect(type,tick_duration,(currentlv+incr_amt<maxlv)?(currentlv+incr_amt):maxlv);
if (tick_duration+BUFFER >= duration) {
p.removePotionEffect(type);
p.addPotionEffect(neweffect, true);
logAndRemovePotionEffectFromPlayer(type,p);
logAndApplyPotionEffectToPlayer(neweffect.getType(), neweffect.getDuration(),neweffect.getAmplifier(), p, true);
}
} else {
PotionEffect neweffect = new PotionEffect(type,tick_duration,0);
p.addPotionEffect(neweffect);
PotionEffect neweffect = new PotionEffect(type,tick_duration,0);
logAndApplyPotionEffectToPlayer(neweffect.getType(), neweffect.getDuration(),neweffect.getAmplifier(), p);
}
}

@ -21,6 +21,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import sig.plugin.TwosideKeeper.HelperStructures.SpleefArena;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -328,7 +329,7 @@ public class SpleefGame implements Listener {
(corner1.getBlockZ()>corner2.getBlockZ())?(corner1.getBlockZ()-2-(Math.random()*(corner1.getBlockZ()-corner2.getBlockZ()-4))):(corner2.getBlockZ()-2-(Math.random()*(corner2.getBlockZ()-corner1.getBlockZ()-4)))
), TeleportCause.PLUGIN);
//Give players Resistance 100 so they can never die.
Bukkit.getServer().getPlayer(players.get(i).player).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,100));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.DAMAGE_RESISTANCE,99999,100,Bukkit.getServer().getPlayer(players.get(i).player));
}
active=true;
starttime=TwosideKeeper.getServerTickTime();
@ -385,7 +386,7 @@ public class SpleefGame implements Listener {
void RemovePlayer(SpleefPlayerData p, RemovePlayerReason rs) {
p.ClearInventory();
p.RestoreInventory();
Bukkit.getServer().getPlayer(p.player).removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.DAMAGE_RESISTANCE,Bukkit.getServer().getPlayer(p.player));
for (int i=0;i<players.size();i++) {
if (players.get(i).player.equalsIgnoreCase(p.player)) {
players.remove(i);

@ -56,6 +56,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
@ -416,7 +417,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
if (Math.random()<=removechance/100) {
if (type!=null && (!type.equals(PotionEffectType.WEAKNESS) || level<9)) {
p.removePotionEffect(type);
GenericFunctions.logAndRemovePotionEffectFromPlayer(type,p);
p.sendMessage(ChatColor.DARK_GRAY+"You successfully resisted the application of "+ChatColor.WHITE+GenericFunctions.CapitalizeFirstLetters(type.getName().replace("_", " ")));
}
}
@ -555,12 +556,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
for (int i3=0;i3<p.getEquipment().getArmorContents().length;i3++) {
if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getArmorContents()[i3]) &&
p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) {
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,20,1));
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) {
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,20,1));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SPEED,20,1,p);
//log("Apply speed. The light level here is "+p.getLocation().add(0,-1,0).getBlock().getLightLevel(),2);
}
@ -729,10 +730,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (absorption_amt>0) {
if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) {
int oldlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.ABSORPTION, p)+1;
p.removePotionEffect(PotionEffectType.ABSORPTION);
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4)+oldlv));
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.ABSORPTION,p);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4)+oldlv,p);
} else {
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4)));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4),p);
}
}
}
@ -941,6 +942,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static CustomPotion LIFE_VIAL;
public static CustomPotion HARDENING_VIAL;
public static final int POTION_DEBUG_LEVEL=1;
public static final int DODGE_COOLDOWN=100;
public static final int DEATHMARK_COOLDOWN=240;
public static final int EARTHWAVE_COOLDOWN=300;
@ -1230,7 +1233,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (p.getLocation().add(0,0,0).getBlock().getType()==Material.PISTON_MOVING_PIECE) {
p.getLocation().add(0,0,0).getBlock().setType(Material.AIR);
}
if (SERVER_TYPE==ServerType.TEST && p.isOp()) {
if ((SERVER_TYPE==ServerType.TEST || SERVER_TYPE==ServerType.QUIET) && p.isOp()) {
/*PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.swordcombo=20;*/
/*float f = ((org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity)p).getHandle().getAbsorptionHearts();
@ -1238,6 +1241,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (args.length>0) {
((org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity)p).getHandle().setAbsorptionHearts(Float.valueOf(args[0]));
}*/
/*
StackTraceElement[] stacktrace = new Throwable().getStackTrace();
StringBuilder stack = new StringBuilder("Mini stack tracer:");
for (int i=0;i<Math.min(10, stacktrace.length);i++) {
stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber());
}
DiscordMessageSender.sendToSpam(stack.toString());*/
/*Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE);
m.setHealth(m.getMaxHealth()/16d);*/
//aPlugin.API.sendActionBarMessage(p, "Testing/nMultiple Lines.\nLolz");
@ -1628,15 +1639,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
GenericFunctions.updateSetItemsInInventory(ev.getPlayer().getInventory());
ev.getPlayer().setCollidable(true);
ev.getPlayer().removePotionEffect(PotionEffectType.LEVITATION);
ev.getPlayer().removePotionEffect(PotionEffectType.JUMP);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.LEVITATION,ev.getPlayer());
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.JUMP,ev.getPlayer());
ev.getPlayer().setVelocity(new Vector(0,0,0));
CustomDamage.removeIframe(ev.getPlayer());
//Update player max health. Check equipment too.
setPlayerMaxHealth(ev.getPlayer());
ev.getPlayer().removePotionEffect(PotionEffectType.GLOWING);
ev.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.GLOWING,ev.getPlayer());
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.NIGHT_VISION,ev.getPlayer());
ev.getPlayer().getScoreboard().getTeam(ev.getPlayer().getName().toLowerCase()).setSuffix(createHealthbar(((ev.getPlayer().getHealth())/ev.getPlayer().getMaxHealth())*100,ev.getPlayer()));
ev.getPlayer().getScoreboard().getTeam(ev.getPlayer().getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(ev.getPlayer()));
ev.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0d);
@ -2205,7 +2216,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Player p = ev.getPlayer();
if (PlayerMode.isRanger(p) && p.isSneaking() && p.getEquipment().getItemInMainHand().getType()==Material.BOW) {
//Rotate Bow Modes.
p.removePotionEffect(PotionEffectType.SLOW);
GenericFunctions.logAndRemovePotionEffectFromPlayer(PotionEffectType.SLOW,p);
BowMode mode = GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand());
if (ev.getAction().name().contains("RIGHT")) {
@ -2319,7 +2330,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (player.isBlocking()) {
//Give absorption hearts.
if (PlayerMode.isDefender(player)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,200,1));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.ABSORPTION,200,1,player);
List<Entity> entities = player.getNearbyEntities(16, 16, 16);
for (int i=0;i<entities.size();i++) {
if (entities.get(i) instanceof Monster) {
@ -2329,7 +2340,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
} else {
player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,200,0));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.ABSORPTION,200,0,player);
}
DecimalFormat df = new DecimalFormat("0.0");
PlayerStructure pd = PlayerStructure.GetPlayerStructure(player);
@ -3238,7 +3249,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Vector facing = ev.getPlayer().getLocation().getDirection();
if (!second_charge) {
facing = ev.getPlayer().getLocation().getDirection().setY(0);
ev.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW,(ex_version)?7:15,20));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.SLOW,(ex_version)?7:15,20,ev.getPlayer());
}
if (!ex_version || second_charge) {
aPlugin.API.sendCooldownPacket(ev.getPlayer(), ev.getItemDrop().getItemStack(), LINEDRIVE_COOLDOWN);
@ -3937,10 +3948,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Respawn this shop item.",5);
}
}
TwosideRecyclingCenter.AddItemToRecyclingCenter(i);
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onItemDespawn(BlockDispenseEvent ev) {
ev.setItem(ev.getItem());
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onChunkLoadEvent(ChunkLoadEvent ev) {
//Grab all entities. Create monster structures for all monsters. Detect elites and leaders and set their status accordingly.
@ -4764,7 +4781,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
DeathManager.continueAction(p);
}
p.setVelocity(new Vector(0,0,0));
p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,Integer.MAX_VALUE,255));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.LEVITATION,Integer.MAX_VALUE,255,p);
CustomDamage.setAbsorptionHearts(p, 0.0f);
GenericFunctions.addIFrame(p, Integer.MAX_VALUE);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
@ -4903,7 +4920,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Player p = (Player)(affected.get(i));
int weaknesslv = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[1]);
int duration = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[2]);
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS,duration,-weaknesslv),true);
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.WEAKNESS,duration,-weaknesslv,p,true);
log("Weakness Level: "+GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, p),5);
} else {
affected.remove(i);
@ -5341,7 +5358,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
pd.lastarrowpower=arr.getVelocity().lengthSquared();
pd.lastarrowwasinrangermode=(PlayerMode.isRanger(p)&&GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand())==BowMode.SNIPE);
log("Arrow velocity is "+arr.getVelocity().lengthSquared(),5);
arr.setCustomName("HIT");
} else
if (arr.getCustomName()==null && (arr instanceof Arrow)) {
if (arr.getType()==EntityType.TIPPED_ARROW) {
//This might be special. Let's get the potion meta.
TippedArrow ta = (TippedArrow)arr;
@ -5369,7 +5388,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
}
arr.setCustomName("HIT");
}
}
}
@ -5655,15 +5673,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
GenericFunctions.addObscureHardenedItemBreaks(newartifact, 5-GenericFunctions.getObscureHardenedItemBreaks(newartifact));
//Lines can all be transferred over. No lines need to be preserved.
//Transfer over all old enchantments. Don't transfer enchantments weaker than current enchantments.
ItemStack resultitem = ev.getInventory().getResult().clone();
for (int i=0;i<resultitem.getEnchantments().size();i++) {
Enchantment e = (Enchantment)resultitem.getEnchantments().keySet().toArray()[i];
for (Enchantment e : newartifact.getEnchantments().keySet()) {
if (newartifact.containsEnchantment(e) && artifact_item.getEnchantmentLevel(e)>newartifact.getEnchantmentLevel(e)) {
log("Contains "+e.toString()+" "+newartifact.getEnchantmentLevel(e), 5);
log("Contains "+e.toString()+" "+newartifact.getEnchantmentLevel(e), 2);
//These are the enchantments that clash. If the resultitem ones are greater, apply them to the new item.
newartifact.addUnsafeEnchantment(e, artifact_item.getEnchantmentLevel(e));
log("Applied "+e.getName()+" "+artifact_item.getEnchantmentLevel(e)+" to the artifact",5);
log("Applied "+e.getName()+" "+artifact_item.getEnchantmentLevel(e)+" to the artifact",2);
}
}
for (int i=0;i<artifact_item.getEnchantments().size();i++) {
@ -5672,7 +5687,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//log("Contains "+e.toString()+" "+newartifact.getEnchantmentLevel(e), 2);
//These are the enchantments that clash. If the resultitem ones are greater, apply them to the new item.
newartifact.addUnsafeEnchantment(e, artifact_item.getEnchantmentLevel(e));
log("Applied "+e.getName()+" "+artifact_item.getEnchantmentLevel(e)+" to the artifact",5);
log("Applied "+e.getName()+" "+artifact_item.getEnchantmentLevel(e)+" to the artifact",2);
}
}
@ -6449,7 +6464,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (PlayerMode.isDefender(p)) {
hp+=10;
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,60,(p.isBlocking())?1:0));
GenericFunctions.logAndApplyPotionEffectToPlayer(PotionEffectType.REGENERATION,60,(p.isBlocking())?1:0,p);
}
@ -6702,11 +6717,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
switch (loglv) {
case 0: {
//Only game breaking messages appear in level 0.
Bukkit.getConsoleSender().sendMessage(ChatColor.RED+ChatColor.stripColor(logmessage));
Bukkit.getConsoleSender().sendMessage(ChatColor.RED+"[ERROR]"+ChatColor.RESET+logmessage);
}break;
case 1: {
//Only warning messages appear in level 1.
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW+ChatColor.stripColor(logmessage));
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW+"[WARNING]"+ChatColor.RESET+logmessage);
}break;
case 2: {
//Regular Gameplay information can appear here.

Loading…
Cancel
Save