Implemented custom item displays using server PHP GD system. Modified

detection of linked items to allow for multiple items to be linked at
once and have proper detection. Added new ways to link items. Fixed bugs
related to PvP and finally found a good fix for Bow Cooldown packet
sending without loss of bow usage.
This commit is contained in:
sigonasr2 2017-06-14 19:09:15 -05:00
parent 7789fbe900
commit f438d3e16f
20 changed files with 382 additions and 129 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.12.0
version: 3.12.1
loadbefore: [aPlugin]
commands:
money:

View File

@ -808,6 +808,7 @@ public class CustomDamage {
if (damage>2) {
damage=2;
}
if (pd.slayermodehp-damage>0) {
GenericFunctions.SubtractSlayerModeHealth(p, damage);
//p.setHealth(pd.slayermodehp);
//damage=0;
@ -816,8 +817,10 @@ public class CustomDamage {
GenericFunctions.removeStealth(p);
}
}
damage=0;
} else {
GenericFunctions.AttemptRevive(p, damager, damage, reason);
}
damage=0;
} else
if (damage>0 && GenericFunctions.AttemptRevive(p, damager, damage, reason)) {
damage=0;
@ -1288,7 +1291,7 @@ public class CustomDamage {
GenericFunctions.RandomlyBreakBaubles(p);
SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f);
pd.lastrevivecandyconsumed=TwosideKeeper.getServerTickTime();
aPlugin.API.sendCooldownPacket(p, Material.GOLDEN_APPLE, 400);
aPluginAPIWrapper.sendCooldownPacket(p, Material.GOLDEN_APPLE, 400);
return 0;
}
}
@ -1365,8 +1368,8 @@ public class CustomDamage {
if (consumed) {
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);
aPluginAPIWrapper.sendCooldownPacket(p, Material.GOLDEN_CARROT, 40);
aPluginAPIWrapper.sendCooldownPacket(p, Material.RAW_FISH, 40);
}
return damage;
}
@ -1926,21 +1929,23 @@ public class CustomDamage {
Block b = mon.getLocation().add(x,-1,z).getBlock();
if (aPlugin.API.isDestroyable(b) && GenericFunctions.isSoftBlock(b)) {
//log(b.getType()+" is destroyable.",2);
if (!PVP.isPvPing(p)) {
@SuppressWarnings("deprecation")
FallingBlock fb = (FallingBlock)b.getLocation().getWorld().spawnFallingBlock(b.getLocation().add(0,0.1,0),b.getType(),(byte)0);
fb.setVelocity(new Vector(0,Math.random()*1.35,0));
fb.setMetadata("FAKE", new FixedMetadataValue(TwosideKeeper.plugin,true));
//b.breakNaturally();
b.setType(Material.AIR);
}
aPlugin.API.sendSoundlessExplosion(b.getLocation(), 1);
}
}
}
SoundUtils.playGlobalSound(mon.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f);
}
}
}
}
SoundUtils.playLocalSound(p, Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0f, 1.0f);
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p));
pd.last_shovelspell=TwosideKeeper.getServerTickTime()+GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p);
}
}
@ -2440,7 +2445,7 @@ public class CustomDamage {
pd.last_rejuvenate-=40;
int remainingtime = GenericFunctions.GetRemainingCooldownTime(p, pd.last_rejuvenate, TwosideKeeper.REJUVENATE_COOLDOWN);
if (remainingtime>0) {
aPlugin.API.sendCooldownPacket(p, Material.SHIELD, remainingtime);
aPluginAPIWrapper.sendCooldownPacket(p, Material.SHIELD, remainingtime);
}
}
@ -4190,8 +4195,8 @@ public class CustomDamage {
pd.lastassassinatetime-=(int)(GenericFunctions.GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,(Player)shooter)*0.5);
//TwosideKeeper.log("Subtracted "+(int)(GenericFunctions.GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,(Player)shooter)*0.5)+" ticks from Last Assassinate.", 0);
if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,(Player)shooter)<TwosideKeeper.getServerTickTime()) { //Don't overwrite life saver cooldowns.
//aPlugin.API.sendCooldownPacket((Player)shooter, name, (int)(GenericFunctions.GetModifiedCooldown((TwosideKeeper.ASSASSINATE_COOLDOWN),(Player)shooter)*0.5));
aPlugin.API.sendCooldownPacket((Player)shooter, name, GenericFunctions.GetRemainingCooldownTime((Player)shooter, pd.lastassassinatetime, TwosideKeeper.ASSASSINATE_COOLDOWN));
//aPluginAPIWrapper.sendCooldownPacket((Player)shooter, name, (int)(GenericFunctions.GetModifiedCooldown((TwosideKeeper.ASSASSINATE_COOLDOWN),(Player)shooter)*0.5));
aPluginAPIWrapper.sendCooldownPacket((Player)shooter, name, GenericFunctions.GetRemainingCooldownTime((Player)shooter, pd.lastassassinatetime, TwosideKeeper.ASSASSINATE_COOLDOWN));
}
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.potion.PotionEffectType;
import sig.plugin.TwosideKeeper.PlayerStructure;
import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.aPluginAPIWrapper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class ArrowBarrage implements Runnable{
@ -35,7 +36,11 @@ public class ArrowBarrage implements Runnable{
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW, 4, 9, p, true);
if (shots_left>0) {
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, this, 3);
} else {
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, 1));
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, TwosideKeeper.ARROWBARRAGE_COOLDOWN));
}, 1);
}
}
}

View File

@ -2009,12 +2009,14 @@ public class GenericFunctions {
}
public static String GetItemName(ItemStack item) {
if (item.hasItemMeta() &&
String finalstring = "";
if (item!=null && item.hasItemMeta() &&
item.getItemMeta().hasDisplayName()) {
return item.getItemMeta().getDisplayName();
finalstring = item.getItemMeta().getDisplayName();
} else {
return UserFriendlyMaterialName(item);
finalstring = UserFriendlyMaterialName(item);
}
return WorldShop.obfuscateAllMagicCodes(finalstring);
}
/**
@ -2781,10 +2783,14 @@ public class GenericFunctions {
if (Math.random() <= repairamt%1) {
repairamt++;
}
try {
if (p.getLocation().getY()>=0 && p.getLocation().getBlock().getLightFromSky()==0) {
repairamt/=2.0d;
//TwosideKeeper.log("In Darkness.",2);
}
} catch (ArrayIndexOutOfBoundsException e) {
//API causes this to occur.
}
double chance = 1;
if (Math.random()<=chance/100d) {
if (equip.getDurability()-repairamt<0) {
@ -2899,7 +2905,7 @@ public class GenericFunctions {
Bukkit.getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
pd.last_dodge=TwosideKeeper.getServerTickTime();
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.DODGE_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.DODGE_COOLDOWN,p));
SoundUtils.playLocalSound(p, Sound.ENTITY_DONKEY_CHEST, 1.0f, 1.0f);
int dodgeduration = 20;
@ -3199,7 +3205,7 @@ public class GenericFunctions {
SoundUtils.playGlobalSound(player.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0f, 1.0f);
addIFrame(player,40);
//GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION,200,9,player,true);
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.REJUVENATE_COOLDOWN,player));
aPluginAPIWrapper.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.REJUVENATE_COOLDOWN,player));
}
}
@ -3700,10 +3706,10 @@ public class GenericFunctions {
public static boolean AttemptRevive(Player p, Entity damager, double dmg, String reason) {
boolean revived=false;
boolean fromRoom=false;
if (p.getHealth()<=dmg) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (p.getHealth()<=dmg || (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER && pd.slayermodehp<=dmg)) {
//This means we would die from this attack. Attempt to revive the player.
//Check all artifact armor for a perk.
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.lastdamagetaken=dmg;
pd.lasthitdesc=reason;
pd.slayermodehp = p.getMaxHealth();
@ -3765,8 +3771,8 @@ public class GenericFunctions {
revived=true;
Bukkit.broadcastMessage(ChatColor.GOLD+p.getName()+ChatColor.WHITE+" should've died but managed to live!");
aPlugin.API.discordSendRawItalicized(ChatColor.GOLD+p.getName()+ChatColor.WHITE+" should've died but managed to live!");
aPlugin.API.sendCooldownPacket(p, Material.SKULL_ITEM, GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN, p));
aPlugin.API.sendCooldownPacket(p, Material.CHORUS_FLOWER, GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN, p));
aPluginAPIWrapper.sendCooldownPacket(p, Material.SKULL_ITEM, GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN, p));
aPluginAPIWrapper.sendCooldownPacket(p, Material.CHORUS_FLOWER, GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN, p));
//return true;
}
}
@ -3950,7 +3956,7 @@ public class GenericFunctions {
TwosideKeeper.log("dmg mult is "+damage_mult,4);
dmg = basedmg * damage_mult;
if (ent instanceof Player) {TwosideKeeper.log("Damage is "+dmg, 5);}
CustomDamage.ApplyDamage(dmg, damager, (LivingEntity)ent, null, reason, CustomDamage.IGNORE_DAMAGE_TICK);
CustomDamage.ApplyDamage(dmg, CustomDamage.getDamagerEntity(damager), (LivingEntity)ent, null, reason, CustomDamage.IGNORE_DAMAGE_TICK);
//subtractHealth((LivingEntity)nearbyentities.get(i),null,NewCombat.CalculateDamageReduction(dmg, (LivingEntity)nearbyentities.get(i), null));
}
}
@ -4147,7 +4153,7 @@ public class GenericFunctions {
Player p = (Player)damager;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.last_strikerspell = pd.last_strikerspell-40;
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetRemainingCooldownTime(p, pd.last_strikerspell, TwosideKeeper.LINEDRIVE_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetRemainingCooldownTime(p, pd.last_strikerspell, TwosideKeeper.LINEDRIVE_COOLDOWN));
}
updateNoDamageTickMap(m,(Player)damager);
}
@ -4702,7 +4708,7 @@ public class GenericFunctions {
logAndApplyPotionEffectToEntity(PotionEffectType.SLOW,(ex_version)?7:15,20,p);
}
if (!ex_version || second_charge) {
aPlugin.API.sendCooldownPacket(p, weaponused, GetModifiedCooldown(TwosideKeeper.LINEDRIVE_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, weaponused, GetModifiedCooldown(TwosideKeeper.LINEDRIVE_COOLDOWN,p));
pd.last_strikerspell=TwosideKeeper.getServerTickTime();
}
SoundUtils.playLocalSound(p, Sound.UI_BUTTON_CLICK, 1.0f, 1.0f);
@ -4762,7 +4768,7 @@ public class GenericFunctions {
if (ex_version) {
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
aPlugin.API.sendCooldownPacket(p, weaponused, GetModifiedCooldown(TwosideKeeper.LINEDRIVE_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, weaponused, GetModifiedCooldown(TwosideKeeper.LINEDRIVE_COOLDOWN,p));
pd.last_strikerspell=TwosideKeeper.getServerTickTime();
}
},17);
@ -4780,7 +4786,7 @@ public class GenericFunctions {
SoundUtils.playGlobalSound(player.getLocation(), Sound.BLOCK_NOTE_SNARE, 1.0f, 1.0f);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(player);
if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,player)<TwosideKeeper.getServerTickTime()) { //Don't overwrite life saver cooldowns.
aPlugin.API.sendCooldownPacket(player, name, GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,player));
aPluginAPIWrapper.sendCooldownPacket(player, name, GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,player));
}
pd.lastassassinatetime=TwosideKeeper.getServerTickTime();
pd.lastusedassassinate=TwosideKeeper.getServerTickTime();
@ -4799,7 +4805,7 @@ public class GenericFunctions {
target!=null && originalloc!=null && target.getLocation().distanceSquared(originalloc)<=25) {
pd.lastassassinatetime = TwosideKeeper.getServerTickTime()-GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,player)+40;
if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,player)<TwosideKeeper.getServerTickTime()) { //Don't overwrite life saver cooldowns.
aPlugin.API.sendCooldownPacket(player, name, 40);
aPluginAPIWrapper.sendCooldownPacket(player, name, 40);
}
}
} else {
@ -4852,7 +4858,7 @@ public class GenericFunctions {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(player);
pd.lastusedassassinate=TwosideKeeper.getServerTickTime();
if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,player)<TwosideKeeper.getServerTickTime()) { //Don't overwrite life saver cooldowns.
aPlugin.API.sendCooldownPacket(player, name, (int)(GetModifiedCooldown((TwosideKeeper.ASSASSINATE_COOLDOWN),player)*0.3));
aPluginAPIWrapper.sendCooldownPacket(player, name, (int)(GetModifiedCooldown((TwosideKeeper.ASSASSINATE_COOLDOWN),player)*0.3));
}
pd.lastassassinatetime=TwosideKeeper.getServerTickTime()-(int)(GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,player)*0.7);
//TwosideKeeper.log("Tick Time: "+TwosideKeeper.getServerTickTime()+". New Assassinate Time: "+pd.lastassassinatetime+".", 0);
@ -4917,7 +4923,7 @@ public class GenericFunctions {
Location newfacingdir = target.getLocation().setDirection(target.getLocation().getDirection());
target.teleport(newfacingdir);
if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,player)<TwosideKeeper.getServerTickTime()) { //Don't overwrite life saver cooldowns.
aPlugin.API.sendCooldownPacket(player, name, GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,player));
aPluginAPIWrapper.sendCooldownPacket(player, name, GetModifiedCooldown(TwosideKeeper.ASSASSINATE_COOLDOWN,player));
}
pd.lastassassinatetime=TwosideKeeper.getServerTickTime();
if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(player), player, ItemSet.WOLFSBANE, 5)) {
@ -4933,7 +4939,7 @@ public class GenericFunctions {
target.getLocation().distanceSquared(originalloc)<=25) {
if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,player)<TwosideKeeper.getServerTickTime()) { //Don't overwrite life saver cooldowns.
pd.lastassassinatetime = TwosideKeeper.getServerTickTime()-TwosideKeeper.ASSASSINATE_COOLDOWN+40;
aPlugin.API.sendCooldownPacket(player, name, 40);
aPluginAPIWrapper.sendCooldownPacket(player, name, 40);
}
}
}*/
@ -5377,7 +5383,8 @@ public class GenericFunctions {
if (p.isOnGround()) {
pd.last_arrowbarrage=TwosideKeeper.getServerTickTime();
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new ArrowBarrage(26,p,3), 3);
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.ARROWBARRAGE_COOLDOWN,p));
//aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.ARROWBARRAGE_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, TwosideKeeper.ARROWBARRAGE_COOLDOWN));
TwosideKeeper.sendSuccessfulCastMessage(p);
}
} else {
@ -5426,7 +5433,7 @@ public class GenericFunctions {
if (totalpoisonstacks>0) {
pd.last_siphon=TwosideKeeper.getServerTickTime();
SoundUtils.playLocalSound(p, Sound.BLOCK_FENCE_GATE_OPEN, 1.0f, 0.4f);
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.SIPHON_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.SIPHON_COOLDOWN,p));
for (LivingEntity ent : poisonlist) {
//Refresh poison stacks if necessary.
int totalpoisonlv = 0;
@ -5535,7 +5542,7 @@ public class GenericFunctions {
new WindSlash(p.getLocation(),p,ItemSet.GetItemTier(p.getEquipment().getItemInMainHand())*windcharges,20*10));
p.setVelocity(p.getLocation().getDirection().multiply(-0.7f-(0.01f*(windcharges/10))*((p.isOnGround())?1d:2d)));
GenericFunctions.sendActionBarMessage(p, "", true);
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.WINDSLASH_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.WINDSLASH_COOLDOWN,p));
pd.lastusedwindslash = TwosideKeeper.getServerTickTime();
TwosideKeeper.sendSuccessfulCastMessage(p);
} else {
@ -5559,7 +5566,7 @@ public class GenericFunctions {
SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_GENERIC_DRINK, 1.0f, 1.0f);
Buff.addBuff(p, "BEASTWITHIN", new Buff("Beast Within",(ItemSet.GetItemTier(p.getEquipment().getItemInMainHand())+ItemSet.BEASTWITHIN_DURATION)*20,1,org.bukkit.Color.MAROON,"",true,true));
GenericFunctions.sendActionBarMessage(p, "", true);
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.BEASTWITHIN_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.BEASTWITHIN_COOLDOWN,p));
pd.lastusedbeastwithin=TwosideKeeper.getServerTickTime();
TwosideKeeper.sendSuccessfulCastMessage(p);
} else {

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import sig.plugin.TwosideKeeper.PVP;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class EarthWaveTask implements Runnable{
@ -29,7 +30,7 @@ public class EarthWaveTask implements Runnable{
if (!damager.isDead()) {
for (int x=-radius;x<=radius;x++) { //Start at the top y.
Block b = centerpoint.getBlock().getRelative(x, 0, -radius);
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR) {
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR && !PVP.isPvPing(damager)) {
FallingBlock fb = centerpoint.getWorld().spawnFallingBlock(b.getLocation().add(0,0,0), b.getType(), b.getData());
fb.setVelocity(new Vector(0,vel,0));
b.setType(Material.AIR);
@ -42,7 +43,7 @@ public class EarthWaveTask implements Runnable{
}
for (int x=-radius;x<=radius;x++) { //Start at the top y.
Block b = centerpoint.getBlock().getRelative(x, 0, radius);
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR) {
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR && !PVP.isPvPing(damager)) {
FallingBlock fb = centerpoint.getWorld().spawnFallingBlock(b.getLocation().add(0,0,0), b.getType(), b.getData());
fb.setVelocity(new Vector(0,vel,0));
b.setType(Material.AIR);
@ -55,7 +56,7 @@ public class EarthWaveTask implements Runnable{
}
for (int y=-radius+1;y<radius;y++) { //Start at the top y.
Block b = centerpoint.getBlock().getRelative(radius, 0, y);
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR) {
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR && !PVP.isPvPing(damager)) {
FallingBlock fb = centerpoint.getWorld().spawnFallingBlock(b.getLocation().add(0,0,0), b.getType(), b.getData());
fb.setVelocity(new Vector(0,vel,0));
b.setType(Material.AIR);
@ -68,7 +69,7 @@ public class EarthWaveTask implements Runnable{
}
for (int y=-radius+1;y<radius;y++) { //Start at the top y.
Block b = centerpoint.getBlock().getRelative(-radius, 0, y);
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR) {
if (GenericFunctions.isSoftBlock(b) && b.getRelative(0, 1, 0).getType()==Material.AIR && !PVP.isPvPing(damager)) {
FallingBlock fb = centerpoint.getWorld().spawnFallingBlock(b.getLocation().add(0,0,0), b.getType(), b.getData());
fb.setVelocity(new Vector(0,vel,0));
b.setType(Material.AIR);

View File

@ -270,6 +270,7 @@ public class WorldShop {
public static String GetItemInfo(ItemStack item) {
//Gets all the info about this item in one gigantic string. (Separated by new lines. Useful for tellraw()).
String message = "";
if (item==null) {return message;}
if (GenericFunctions.isArtifactEquip(item) && !GenericFunctions.isArtifactArmor(item) /*Artifact armor already has this info displayed.*/) {
if (item.hasItemMeta() &&
item.getItemMeta().hasDisplayName()) {
@ -700,7 +701,7 @@ public class WorldShop {
return duration/1200+":"+df.format((duration/20)%60);
}
private static String obfuscateAllMagicCodes(String message) {
public static String obfuscateAllMagicCodes(String message) {
StringBuilder newstring = new StringBuilder("");
boolean isMagic=false;
boolean WillBeMagic=false;

View File

@ -215,11 +215,11 @@ public class GenericBoss extends CustomMonster{
private void updateHealthbarForNearbyPlayers() {
for (Player p : healthbar.getPlayers()) {
if (p.getWorld().equals(m.getWorld()) && p.getLocation().distanceSquared(m.getLocation())>2500) {
if (p.getWorld().equals(m.getWorld()) && p.getLocation().distanceSquared(m.getLocation())>576) {
healthbar.removePlayer(p);
}
}
for (Entity e : m.getNearbyEntities(50, 50, 50)) {
for (Entity e : m.getNearbyEntities(24, 24, 24)) {
if (e instanceof Player) {
Player p = (Player)e;
healthbar.addPlayer(p);
@ -398,4 +398,19 @@ public class GenericBoss extends CustomMonster{
}
return amt;
}
//Returns the number of nearby bosses in the specified location (That inherit this class).
public static int nearbyBosses(Location loc, int range) {
int amt=0;
for (UUID id : TwosideKeeper.custommonsters.keySet()) {
CustomMonster cm = TwosideKeeper.custommonsters.get(id);
if (cm instanceof GenericBoss) {
GenericBoss gb = (GenericBoss)cm;
if (gb.GetMonster().getLocation().distanceSquared(loc)<2500) {
amt++;
}
}
}
return amt;
}
}

View File

@ -939,8 +939,9 @@ public class Knight extends GenericBoss{
if ((TwosideKeeper.MINIBOSSES_ACTIVATED &&
//TwosideKeeper.LAST_SPECIAL_SPAWN+(3000/Math.max(Bukkit.getOnlinePlayers().size(),1))<=TwosideKeeper.getServerTickTime() &&
!m.getWorld().getName().contains("Instance") &&
Math.random()<=0.05 &&
Math.random()<=0.035 &&
TwosideKeeper.elitemonsters.size()==0 &&
GenericBoss.nearbyBosses(m.getLocation(),50)==0 &&
//GenericBoss.bossCount()==0 &&
GenericFunctions.AllNaturalBlocks(m.getLocation().getBlock(),16,8,16)) || force) {
Skeleton s = (Skeleton)m;

View File

@ -675,7 +675,8 @@ public class SniperSkeleton extends GenericBoss{
!m.getWorld().getName().contains("Instance") &&
Math.random()<=0.035 &&
TwosideKeeper.elitemonsters.size()==0 &&
GenericBoss.bossCount()<2 &&
//GenericBoss.bossCount()<2 &&
GenericBoss.nearbyBosses(m.getLocation(),50)==0 &&
GenericFunctions.AllNaturalBlocks(m.getLocation().getBlock(),16,8,16)) || force) {
Skeleton s = (Skeleton)m;
s.setSkeletonType(SkeletonType.NORMAL);

View File

@ -103,7 +103,7 @@ public class PVP {
for (String s : players.keySet()) {
Player p = Bukkit.getPlayer(s);
if (p!=null && p.isOnline()) {
Bukkit.getServer().broadcastMessage(ChatColor.YELLOW+""+ChatColor.ITALIC+" "+freshBloodPlayer+ChatColor.GRAY+" is a Fresh Blood player, doubling the drop rate of this match.");
p.sendMessage(ChatColor.YELLOW+""+ChatColor.ITALIC+" "+freshBloodPlayer+ChatColor.GRAY+" is a Fresh Blood player, doubling the drop rate of this match.");
}
}
}
@ -130,16 +130,20 @@ public class PVP {
if (!players.containsKey(p.getName())) {
players.put(p.getName(), new PVPPlayer());
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
Player pl = Bukkit.getPlayer(s);
if (pl!=null && pl.isValid() && pl.isOnline()) {
pl.sendMessage(ChatColor.YELLOW+p.getName()+" has joined the match. Current Participants: "+ChatColor.YELLOW+getParticipants());
findFreshBloodPlayer();
announceFreshBloodPlayer(false);
if (!pp.isReady) {
showReadyChoice(s);
}
} else {
//pl.sendMessage(ChatColor.YELLOW+s+ChatColor.GOLD+" has left the PVP Match...");
leaveMatch(s);
}
}
findFreshBloodPlayer();
announceFreshBloodPlayer(false);
timer = TwosideKeeper.getServerTickTime();
}
}
@ -623,10 +627,16 @@ public class PVP {
private boolean AllPlayersOnTeamDead(int teamnumb) {
List<String> members = getPlayersInTeam(teamnumb);
for (String s : members) {
if (players.containsKey(s)) {
PVPPlayer pp = players.get(s);
if (pp.isAlive) {
return false;
}
} else {
DebugUtils.showStackTrace();
TwosideKeeper.log("WARNING! This PVP Player ("+s+") was on a team but is not valid!", 1);
return false;
}
}
return true;
}
@ -873,6 +883,7 @@ public class PVP {
} else {
TwosideKeeper.log("WARNING! There were no winners!", 1);
}
freshBloodPlayer=null;
}
private void determineWinnerByEliminatingLosers() {
@ -1181,13 +1192,9 @@ public class PVP {
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
if (pp.team==i) {
if (freshBloodPlayer!=null && freshBloodPlayer.equalsIgnoreCase(s)) {
teams.add("*"+s);
} else {
teams.add(s);
}
}
}
return teams;
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
@ -18,6 +19,7 @@ public class PVPArena {
String name;
String desc;
List<Location> safelocs;
List<Span> spawnlocs;
public PVPArena(Location startCorner, Location endCorner, String arenaName, String desc) {
this.startCorner = new Location(startCorner.getWorld(),Math.min(startCorner.getBlockX(), endCorner.getBlockX()),Math.min(startCorner.getBlockY(), endCorner.getBlockY()),Math.min(startCorner.getBlockZ(), endCorner.getBlockZ()));
@ -47,7 +49,7 @@ public class PVPArena {
public Location pickRandomLocation() {
//Pick a random point.
int tries=400; //Number of tries before we give up and drop them in.
int tries=500; //Number of tries before we give up and drop them in.
int randomx = ((int)(Math.random()*(endCorner.getBlockX()-startCorner.getBlockX()))) + 1;
int randomz = ((int)(Math.random()*(endCorner.getBlockZ()-startCorner.getBlockZ()))) + 1;
@ -70,6 +72,7 @@ public class PVPArena {
startCorner.getBlockY()+y,
startCorner.getBlockZ()+randomz+0.5);
if (!finalloc.getBlock().isLiquid() &&
finalloc.getBlock().getRelative(0, 1, 0).getType()==Material.AIR &&
insideBounds(finalloc)) {
/*TwosideKeeper.log("Final Block is "+finalloc.getBlock(), 1);
TwosideKeeper.log("Final Block Above is "+finalloc.getBlock().getRelative(0, 1, 0), 1);
@ -146,3 +149,19 @@ public class PVPArena {
return sb.toString();
}
}
class Span {
Location startCorner;
Location endCorner;
Span(Location startCorner, Location endCorner) {
this.startCorner = new Location(startCorner.getWorld(),Math.min(startCorner.getBlockX(), endCorner.getBlockX()),Math.min(startCorner.getBlockY(), endCorner.getBlockY()),Math.min(startCorner.getBlockZ(), endCorner.getBlockZ()));
this.endCorner = new Location(startCorner.getWorld(),Math.max(startCorner.getBlockX(), endCorner.getBlockX()),Math.max(startCorner.getBlockY(), endCorner.getBlockY()),Math.max(startCorner.getBlockZ(), endCorner.getBlockZ()));
}
Location getStartCorner() {
return startCorner.clone();
}
Location getEndCorner() {
return endCorner.clone();
}
}

View File

@ -413,26 +413,26 @@ public class PlayerStructure {
public static void setDefaultCooldowns(Player p) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
aPlugin.API.sendCooldownPacket(p, Material.BOW, GenericFunctions.GetRemainingCooldownTime(p, pd.last_dodge, TwosideKeeper.DODGE_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, Material.BOW, GenericFunctions.GetRemainingCooldownTime(p, pd.last_dodge, TwosideKeeper.DODGE_COOLDOWN));
applyCooldownToAllTypes(p,"HOE",GenericFunctions.GetRemainingCooldownTime(p, pd.last_deathmark, TwosideKeeper.DEATHMARK_COOLDOWN));
applyCooldownToAllTypes(p,"SPADE",GenericFunctions.GetRemainingCooldownTime(p, pd.lastusedearthwave, TwosideKeeper.EARTHWAVE_COOLDOWN));
applyCooldownToAllTypes(p,"SWORD",GenericFunctions.GetRemainingCooldownTime(p, pd.last_strikerspell, TwosideKeeper.LINEDRIVE_COOLDOWN));
aPlugin.API.sendCooldownPacket(p, Material.SHIELD, GenericFunctions.GetRemainingCooldownTime(p, pd.last_rejuvenate, TwosideKeeper.REJUVENATE_COOLDOWN));
aPlugin.API.sendCooldownPacket(p, Material.SKULL_ITEM, GenericFunctions.GetRemainingCooldownTime(p, pd.lastlifesavertime, TwosideKeeper.LIFESAVER_COOLDOWN));
aPlugin.API.sendCooldownPacket(p, Material.CHORUS_FLOWER, GenericFunctions.GetRemainingCooldownTime(p, pd.lastlifesavertime, TwosideKeeper.LIFESAVER_COOLDOWN));
aPlugin.API.sendCooldownPacket(p, Material.WATCH, GenericFunctions.GetRemainingCooldownTime(p, pd.icewandused, TwosideKeeper.ICEWAND_COOLDOWN));
aPlugin.API.sendCooldownPacket(p, Material.RAW_FISH, GenericFunctions.GetRemainingCooldownTime(p, pd.lastcandyconsumed, 40));
aPlugin.API.sendCooldownPacket(p, Material.GOLDEN_APPLE, GenericFunctions.GetRemainingCooldownTime(p, pd.lastrevivecandyconsumed, 200));
aPluginAPIWrapper.sendCooldownPacket(p, Material.SHIELD, GenericFunctions.GetRemainingCooldownTime(p, pd.last_rejuvenate, TwosideKeeper.REJUVENATE_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, Material.SKULL_ITEM, GenericFunctions.GetRemainingCooldownTime(p, pd.lastlifesavertime, TwosideKeeper.LIFESAVER_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, Material.CHORUS_FLOWER, GenericFunctions.GetRemainingCooldownTime(p, pd.lastlifesavertime, TwosideKeeper.LIFESAVER_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, Material.WATCH, GenericFunctions.GetRemainingCooldownTime(p, pd.icewandused, TwosideKeeper.ICEWAND_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, Material.RAW_FISH, GenericFunctions.GetRemainingCooldownTime(p, pd.lastcandyconsumed, 40));
aPluginAPIWrapper.sendCooldownPacket(p, Material.GOLDEN_APPLE, GenericFunctions.GetRemainingCooldownTime(p, pd.lastrevivecandyconsumed, 200));
applyCooldownToAllTypes(p,"SWORD",GenericFunctions.GetRemainingCooldownTime(p, pd.lastusedwindslash, TwosideKeeper.WINDSLASH_COOLDOWN));
applyCooldownToAllTypes(p,"SWORD",GenericFunctions.GetRemainingCooldownTime(p, pd.lastusedbeastwithin, TwosideKeeper.BEASTWITHIN_COOLDOWN));
}
private static void applyCooldownToAllTypes(Player p, String item, int cooldown) {
aPlugin.API.sendCooldownPacket(p, Material.valueOf("WOOD_"+item), cooldown);
aPlugin.API.sendCooldownPacket(p, Material.valueOf("IRON_"+item), cooldown);
aPlugin.API.sendCooldownPacket(p, Material.valueOf("STONE_"+item), cooldown);
aPlugin.API.sendCooldownPacket(p, Material.valueOf("DIAMOND_"+item), cooldown);
aPlugin.API.sendCooldownPacket(p, Material.valueOf("GOLD_"+item), cooldown);
aPluginAPIWrapper.sendCooldownPacket(p, Material.valueOf("WOOD_"+item), cooldown);
aPluginAPIWrapper.sendCooldownPacket(p, Material.valueOf("IRON_"+item), cooldown);
aPluginAPIWrapper.sendCooldownPacket(p, Material.valueOf("STONE_"+item), cooldown);
aPluginAPIWrapper.sendCooldownPacket(p, Material.valueOf("DIAMOND_"+item), cooldown);
aPluginAPIWrapper.sendCooldownPacket(p, Material.valueOf("GOLD_"+item), cooldown);
}
//Save the configuration.

View File

@ -33,8 +33,8 @@ public class RecordKeeping {
public RecordKeeping(String displayName, boolean reverse) {
this.name=displayName;
recordlist = new ArrayList<Record>();
loadRecordsFromConfig();
this.reverse=reverse;
loadRecordsFromConfig();
}
public String getName() {
@ -225,21 +225,29 @@ public class RecordKeeping {
}
private void sortRecords() {
//TwosideKeeper.log(name+": Reverse? "+reverse, 2);
List<Record> sortedrecords = new ArrayList<Record>();
//TwosideKeeper.log("Record List: "+recordlist, 2);
while (recordlist.size()>0) {
Record bestrecord = null;
int slot = 0;
for (int i=0;i<recordlist.size();i++) {
Record rec = recordlist.get(i);
//TwosideKeeper.log("Checking Record: "+rec, 2);
if (bestrecord==null ||
(reverse && rec.getScore()<bestrecord.getScore()) || (!reverse && rec.getScore()>bestrecord.getScore())) {
//TwosideKeeper.log(" Beats Record: "+(bestrecord==null?"Null":bestrecord)+" Reverse? "+reverse, 2);
bestrecord = rec;
slot = i;
//TwosideKeeper.log(" New Record:"+bestrecord, 2);
}
}
sortedrecords.add(recordlist.remove(slot));
//TwosideKeeper.log("Record List: "+recordlist, 2);
//TwosideKeeper.log("Sorted Records: "+sortedrecords, 2);
}
recordlist = sortedrecords;
//TwosideKeeper.log("FINAL Record List: "+recordlist, 2);
}
}
class Record{
@ -269,4 +277,15 @@ class Record{
public void setMode(PlayerMode mode) {
this.mode = mode;
}
public String toString() {
StringBuilder sb = new StringBuilder("Record{");
sb.append("name=");
sb.append(name);
sb.append(",score=");
sb.append(score);
sb.append(",mode=");
sb.append(mode);
sb.append("}");
return sb.toString();
}
}

View File

@ -74,7 +74,7 @@ public class DPSChallengeRoom extends Room{
pd.locBeforeInstance = p.getLocation().clone();
pd.inTankChallengeRoom=true;
p.teleport(new Location(instance,ROOM_WIDTH/2,4,ROOM_LENGTH/2));
//GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION, 20*4, -30, p, true);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION, 2, -30, p, true);
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{
setupChallengeRoom();
}, 5);

View File

@ -54,7 +54,7 @@ public class ParkourChallengeRoom extends Room{
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.locBeforeInstance = p.getLocation().clone();
pd.inParkourChallengeRoom=true;
//GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION, 20*4, -30, p, true);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION, 2, -30, p, true);
p.teleport(new Location(instance,ROOM_WIDTH/2,4,ROOM_LENGTH/2));
storedinv = Bukkit.createInventory(p, 63);
for (int i=0;i<p.getInventory().getSize();i++) {

View File

@ -58,7 +58,7 @@ public class TankChallengeRoom extends Room {
pd.locBeforeInstance = p.getLocation().clone();
pd.inTankChallengeRoom=true;
p.teleport(new Location(instance,ROOM_WIDTH/2,4,ROOM_LENGTH/2));
//GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION, 20*4, -30, p, true);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION, 2, -30, p, true);
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{
setupChallengeRoom();
}, 5);

View File

@ -57,6 +57,6 @@ public class SpleefManager {
}
public static boolean playerIsPlayingSpleef(Player p) {
return PlayerStructure.GetPlayerStructure(p).isPlayingSpleef || PlayerStructure.GetPlayerStructure(p).inTankChallengeRoom;
return PlayerStructure.GetPlayerStructure(p).isPlayingSpleef || PlayerStructure.GetPlayerStructure(p).inTankChallengeRoom || PVP.isPvPing(p);
}
}

View File

@ -1,7 +1,13 @@
package sig.plugin.TwosideKeeper;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
@ -475,7 +481,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static final int REJUVENATE_COOLDOWN=6000;
public static final int ASSASSINATE_COOLDOWN=200;
public static final int LIFESAVER_COOLDOWN=6000;
public static final int ARROWBARRAGE_COOLDOWN=2400;
public static final int ARROWBARRAGE_COOLDOWN=200;
public static final int SIPHON_COOLDOWN = 900;
public static final int MOCK_COOLDOWN = 400;
public static final int ICEWAND_COOLDOWN = 1200;
@ -1355,7 +1361,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
/*MonsterTemplate newtemp = new MonsterTemplate(new File(filesave+"/monsterdata/KingSlime.md"));
int newint = (int)newtemp.getValue("timeToLive");
log(Integer.toString(newint),0);*/
log(" This is here to change the file size if necessary Kappa Kappa Kappa No Copy-pasterino Kappachino Lulu c: Please update version number. lololol cy@ storm is boosted. This is nice.",5);
log(" lolol. This is here to change the file size if necessary Kappa Kappa Kappa No Copy-pasterino Kappachino Lulu c: Please update version number. lololol cy@ storm is boosted. This is nice.",5);
}
private static void InitializeBotCommands() {
@ -2601,6 +2607,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
}break;
case "MINIBOSSES":{
p.sendMessage("There are "+(GenericBoss.nearbyBosses(p.getLocation(),50))+" Minibosses nearby.");
}break;
}
}
//LivingEntity m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE);
@ -3887,16 +3896,169 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
playMessageNotification(ev.getPlayer());
int pos = -1;
log(ev.getMessage()+" "+ev.getMessage().indexOf(" []"),5);
if (ev.getMessage().equalsIgnoreCase("[]") || ev.getMessage().indexOf(" []")>-1 || (ev.getMessage().indexOf("[] ")>-1 && ev.getMessage().indexOf("[] ")==0)) {
List<ItemStack> targetitem = new ArrayList<ItemStack>();
ItemStack[] tempitems = null;
Player p = ev.getPlayer();
int marker = 0;
byte[] messagebytes = ev.getMessage().getBytes();
TextComponent finalmsg = new TextComponent("<"+p.getName()+"> ");
TextComponent finalmsgDiscord = new TextComponent("");
for (int i=0;i<messagebytes.length;i++) {
if (messagebytes[i]=='[') {
if (messagebytes[Math.min(i+1, messagebytes.length-1)]==']' ||
messagebytes[Math.min(i+2, messagebytes.length-1)]==']') {
int advanceamt = 0;
byte importantbyte = -1;
if (messagebytes[Math.min(i+1, messagebytes.length-1)]==']') {
advanceamt=1;
} else {
importantbyte = messagebytes[Math.min(i+1, messagebytes.length-1)];
advanceamt=2;
}
if (importantbyte==-1) {
//Post our holding item.
tempitems = new ItemStack[]{p.getEquipment().getItemInMainHand()};
} else {
switch (importantbyte) {
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':{
tempitems = new ItemStack[]{p.getInventory().getItem(Integer.parseInt(Byte.toString((byte)(importantbyte-49))))};
}break;
case 'e':{
tempitems = GenericFunctions.getEquipment(p, true);
}break;
case 'h':{
tempitems = new ItemStack[]{p.getEquipment().getHelmet()};
}break;
case 'c':{
tempitems = new ItemStack[]{p.getEquipment().getChestplate()};
}break;
case 'l':{
tempitems = new ItemStack[]{p.getEquipment().getLeggings()};
}break;
case 'b':{
tempitems = new ItemStack[]{p.getEquipment().getBoots()};
}break;
case 'm':
case 'w':{
tempitems = new ItemStack[]{p.getEquipment().getItemInMainHand()};
}break;
case 'o':{
tempitems = new ItemStack[]{p.getEquipment().getItemInOffHand()};
}break;
}
}
if (tempitems!=null) {
for (int j=0;j<tempitems.length;j++) {
String item_text_output = GenericFunctions.GetItemName(tempitems[j])+WorldShop.GetItemInfo(tempitems[j]);
TextComponent tc = new TextComponent(ChatColor.GREEN+"["+GenericFunctions.GetItemName(tempitems[j])+ChatColor.RESET+ChatColor.GREEN+"]");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder(item_text_output).create()));
if (j>0) {
finalmsg.addExtra("\n");
finalmsgDiscord.addExtra("\n");
}
finalmsg.addExtra(tc);
finalmsgDiscord.addExtra("**");
finalmsgDiscord.addExtra(tc);
finalmsgDiscord.addExtra("**");
if (tempitems[j]!=null && tempitems[j].getType()!=Material.AIR) {
targetitem.add(tempitems[j]);
}
}
tempitems = null;
i+=advanceamt;
continue;
}
}
}
finalmsg.addExtra(String.valueOf(Character.toChars(messagebytes[i])));
finalmsgDiscord.addExtra(String.valueOf(Character.toChars(messagebytes[i])));
}
//p.spigot().sendMessage(finalmsg);
for (Player pl : Bukkit.getOnlinePlayers()) {
pl.spigot().sendMessage(finalmsg);
}
if (targetitem.size()>0) {
File record = null;
File record_folder = null;
File recordresult = null;
long serverTickTime = TwosideKeeper.getServerTickTime();
if (SERVER_TYPE==ServerType.MAIN) {
record = new File("/var/www/html/items/records/"+serverTickTime);
record_folder = new File("/var/www/html/items/records/");
recordresult = new File("/var/www/html/items/results/"+serverTickTime+".png");
} else {
record = new File(getDataFolder()+"/itemrecords/"+serverTickTime);
record_folder = new File(getDataFolder()+"/itemrecords/");
}
final String delimiter = "~!@#$%^&*()";
try {
if (!record_folder.exists()) {
record_folder.mkdirs();
}
if (!record.exists()) {
record.createNewFile();
}
FileWriter writer = new FileWriter(record,true);
for (int j=0;j<targetitem.size();j++) {
String item_text_output = GenericFunctions.GetItemName(targetitem.get(j))+WorldShop.GetItemInfo(targetitem.get(j));
writer.write(item_text_output+"\n");
writer.write(delimiter+"\n");
}
writer.close();
String tickURL = "http://45.33.13.215/items/generatedescriptions.php?tick="+serverTickTime;
URL server_run = new URL(tickURL);
URLConnection connection = server_run.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String inputLine;
try {
while ((inputLine = in.readLine()) != null)
TwosideKeeper.log(inputLine,5);
in.close();
String resultURL = "http://45.33.13.215/items/results/"+serverTickTime+".png";
if (recordresult!=null && recordresult.exists()) {
aPlugin.API.discordSendChat(p.getName(), finalmsgDiscord.toPlainText(), recordresult);
} else {
aPlugin.API.discordSendChat(p.getName(), finalmsgDiscord.toPlainText()+" "+resultURL);
}
} catch (java.io.IOException e) {
aPlugin.API.discordSendChat(p.getName(), finalmsgDiscord.toPlainText());
}
} catch (IOException e) {
e.printStackTrace();
}
} else {
aPlugin.API.discordSendChat(p.getName(), finalmsgDiscord.toPlainText());
}
ev.setCancelled(true);
//TwosideKeeper.log(finalmsg.toPlainText(), 2);
/*
ItemStack targetitem = ExtractTargetItem();
String itemTitle = GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand());
if ()*/
/*//LEGACY ITEM LINKING CODE.
* if (ev.getMessage().equalsIgnoreCase("[]") || ev.getMessage().indexOf(" []")>-1 || (ev.getMessage().indexOf("[] ")>-1 && ev.getMessage().indexOf("[] ")==0)) {
pos = ev.getMessage().indexOf("[]");
ev.setMessage(ev.getMessage().replace("[]", ""));
log("pos is "+pos+" message is: {"+ev.getMessage()+"}",5);
//aPlugin.API.discordSendRaw(("**"+ev.getPlayer().getName()+"** "+ev.getMessage().substring(0, pos)+"**["+ChatColor.stripColor(GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand()))+((ev.getPlayer().getEquipment().getItemInMainHand().getAmount()>1)?" x"+ev.getPlayer().getEquipment().getItemInMainHand().getAmount():"")+"]**"+"\n```"+WorldShop.GetItemInfo(ev.getPlayer().getEquipment().getItemInMainHand())+" ```\n"+ev.getMessage().substring(pos)));
aPlugin.API.discordSendChat(ev.getPlayer().getName(), ev.getMessage().substring(0, pos)+"**["+ChatColor.stripColor(GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand()))+((ev.getPlayer().getEquipment().getItemInMainHand().getAmount()>1)?" x"+ev.getPlayer().getEquipment().getItemInMainHand().getAmount():"")+"]**"+"\n```\n"+WorldShop.GetItemInfo(ev.getPlayer().getEquipment().getItemInMainHand())+"\n```\n"+ev.getMessage().substring(pos));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\"<"+ev.getPlayer().getName()+"> \"},{\"text\":\""+ev.getMessage().substring(0, pos)+"\"},{\"text\":\""+ChatColor.GREEN+"["+GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand())+ChatColor.RESET+ChatColor.YELLOW+((ev.getPlayer().getEquipment().getItemInMainHand().getAmount()>1)?" x"+ev.getPlayer().getEquipment().getItemInMainHand().getAmount():"")+ChatColor.GREEN+"]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand())+""+WorldShop.GetItemInfo(ev.getPlayer().getEquipment().getItemInMainHand()).replace("\"", "\\\"")+"\"}},{\"text\":\""+ev.getMessage().substring(pos)+"\"}]");
ev.setCancelled(true);
}
}*/
//if (ev.getMessage().matches("[0]"))
//Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\""+ChatColor.GREEN+"[Item]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+(ev.getPlayer().getEquipment().getItemInMainHand().getType())+"\"}},{\"text\":\" "+ev.getMessage().substring(0, pos)+" \"}]");
}
@ -4052,7 +4214,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
temporary_ice_list.add(new TemporaryIce(20,ent.getLocation().getBlock().getRelative(0, y, 0),ent));
}
SoundUtils.playGlobalSound(p.getLocation(), Sound.BLOCK_PORTAL_TRIGGER, 0.7f, 1.6f);
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.ICEWAND_COOLDOWN,p));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.ICEWAND_COOLDOWN,p));
pd.icewandused=TwosideKeeper.getServerTickTime();
return;
}
@ -4375,21 +4537,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
GenericFunctions.setBowMode(p,BowMode.SNIPE);
//GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand());
p.updateInventory();
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, ARROWBARRAGE_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_arrowbarrage, ARROWBARRAGE_COOLDOWN));
}break;
case SNIPE:{
SoundUtils.playLocalSound(p, Sound.BLOCK_BREWING_STAND_BREW, 0.5f, 0.1f);
GenericFunctions.setBowMode(p,BowMode.DEBILITATION);
//GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand());
p.updateInventory();
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_siphon, SIPHON_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_siphon, SIPHON_COOLDOWN));
}break;
case DEBILITATION:{
SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_LOCKED, 0.5f, 3.5f);
GenericFunctions.setBowMode(p,BowMode.CLOSE);
//GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand());
p.updateInventory();
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_dodge, DODGE_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetRemainingCooldownTime(p, pd.last_dodge, DODGE_COOLDOWN));
}break;
}
pd.lastbowmodeswitch=getServerTickTime();
@ -4436,7 +4598,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
SoundUtils.playLocalSound(p, Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0f, 1.0f);
/*aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p));
/*aPluginAPIWrapper.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p));
pd.last_shovelspell=TwosideKeeper.getServerTickTime()+GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p);*/
pd.lastusedearthwave=TwosideKeeper.getServerTickTime();
aPlugin.API.damageItem(p, weapon, (int) (weapon.getType().getMaxDurability()*0.05+5));
@ -5322,7 +5484,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (Buff.hasBuff(m, "DeathMark") && !m.isDead()) {
//This has stacks, burst!
bursted=true;
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
aPluginAPIWrapper.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
pd.last_deathmark = getServerTickTime();
int stackamt = GenericFunctions.GetDeathMarkAmt(m);
//GenericFunctions.DealDamageToMob(stackamt*dmg, m, player, null, "Death Mark");
@ -5344,7 +5506,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
if (reset) {
pd.last_deathmark = getServerTickTime()-GenericFunctions.GetModifiedCooldown(TwosideKeeper.DEATHMARK_COOLDOWN,player)+20;
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 10);
aPluginAPIWrapper.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 10);
}
}
}
@ -5388,6 +5550,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true);
return;
}
if (PVP.isPvPing(ev.getPlayer())) {
ev.setCancelled(true);
return;
}
Christmas.FillChristmasBox(ev.getPlayer(), ev.getItemInHand(), ev.getBlockPlaced());
if (!Christmas.ChristmasPlaceEvent(ev)) {
@ -6146,9 +6312,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
SoundUtils.playLocalSound(p, Sound.ENTITY_VILLAGER_AMBIENT, 1.0f, 0.3f);
aPlugin.API.displayEndRodParticle(p.getLocation(), 0, 0f, 0f, 5, 20);
if (hasFullSet) {
aPlugin.API.sendCooldownPacket(p, ev.getItemDrop().getItemStack().getType(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.MOCK_COOLDOWN/2,ev.getPlayer()));
aPluginAPIWrapper.sendCooldownPacket(p, ev.getItemDrop().getItemStack().getType(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.MOCK_COOLDOWN/2,ev.getPlayer()));
} else {
aPlugin.API.sendCooldownPacket(p, ev.getItemDrop().getItemStack().getType(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.MOCK_COOLDOWN,ev.getPlayer()));
aPluginAPIWrapper.sendCooldownPacket(p, ev.getItemDrop().getItemStack().getType(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.MOCK_COOLDOWN,ev.getPlayer()));
}
sendSuccessfulCastMessage(p);
} else {
@ -8555,7 +8721,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ItemStack[] inv = p.getInventory().getContents();
for (int i=0;i<9;i++) {
if (inv[i]!=null && (inv[i].getType()!=Material.SKULL_ITEM || pd.lastlifesavertime+GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,p)<TwosideKeeper.getServerTickTime())) {
aPlugin.API.sendCooldownPacket(p, inv[i], 0);
aPluginAPIWrapper.sendCooldownPacket(p, inv[i], 0);
}
}
GenericFunctions.addStackingPotionEffect(p, PotionEffectType.SPEED, 10*20, 4);
@ -8597,7 +8763,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ItemStack[] inv = p.getInventory().getContents();
for (int i=0;i<9;i++) {
if (inv[i]!=null && (inv[i].getType()!=Material.SKULL_ITEM || pd.lastlifesavertime+GenericFunctions.GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,p)<TwosideKeeper.getServerTickTime())) {
aPlugin.API.sendCooldownPacket(p, inv[i], GenericFunctions.GetRemainingCooldownTime(p, pd.lastassassinatetime, TwosideKeeper.ASSASSINATE_COOLDOWN));
aPluginAPIWrapper.sendCooldownPacket(p, inv[i], GenericFunctions.GetRemainingCooldownTime(p, pd.lastassassinatetime, TwosideKeeper.ASSASSINATE_COOLDOWN));
}
}
}
@ -9242,6 +9408,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Player p = ev.getPlayer();
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
if (PVP.isPvPing(p)) {
ev.setCancelled(true);
return;
}
if (p!=null) {
log(p.getName()+" has broken block "+GenericFunctions.UserFriendlyMaterialName(new ItemStack(ev.getBlock().getType())),3);
if (GenericFunctions.isTool(p.getEquipment().getItemInMainHand())) {
@ -10141,30 +10312,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
cm.runProjectileLaunchEvent(ev);
}
if (arr.getShooter() instanceof Player &&
arr instanceof Arrow) {
Player p = (Player)(arr.getShooter());
if (!p.isDead()) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
int slot = p.getInventory().getHeldItemSlot();
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{
ItemStack tempitem = p.getInventory().getItem(slot);
Location loc = p.getLocation().clone();
pd.weaponUsedForShooting = tempitem;
//p.getEquipment().setItemInMainHand(new ItemStack(Material.AIR));
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{
if (p!=null && p.isValid()) {
p.getInventory().setItem(slot, tempitem);
//p.getEquipment().setItemInMainHand(tempitem);
} else {
GenericFunctions.dropItem(tempitem, loc);
}
}, 1);
}, 1);
}
}
//Arrow newarrow = arr.getLocation().getWorld().spawnArrow(arr.getLocation(), arr.getVelocity(), 1, 12);
//TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(arr)+" being shot.", 0);
if (arr instanceof Fireball && (arr.getShooter() instanceof Ghast)) {
@ -10791,7 +10938,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
},20);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.linkplayer!=null && pd.linkplayer.isValid() && pd.lastlinkteleport+20<TwosideKeeper.getServerTickTime() &&
if (pd!=null && pd.linkplayer!=null && pd.linkplayer.isValid() && pd.lastlinkteleport+20<TwosideKeeper.getServerTickTime() &&
!ev.getTo().getWorld().getName().contains("Instance")) {
PlayerStructure pdl = PlayerStructure.GetPlayerStructure(pd.linkplayer);
pdl.lastlinkteleport=TwosideKeeper.getServerTickTime();

View File

@ -1,9 +1,13 @@
package sig.plugin.TwosideKeeper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_9_R1.EnumParticle;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class aPluginAPIWrapper {
public static void sendParticle(Location loc, EnumParticle particle, float dx, float dy, float dz, float v, int particleCount) {
@ -30,4 +34,25 @@ public class aPluginAPIWrapper {
}
return true;
}
public static void sendCooldownPacket(Player p, ItemStack item, int duration) {
for (int i=0;i<2;i++) {
aPlugin.API.sendCooldownPacket(p, item, duration);
}
p.getEquipment().setItemInMainHand(GenericFunctions.UpdateItemLore(p.getEquipment().getItemInMainHand()));
}
public static void sendCooldownPacket(Player p, int id, int duration) {
for (int i=0;i<2;i++) {
aPlugin.API.sendCooldownPacket(p, id, duration);
}
p.getEquipment().setItemInMainHand(GenericFunctions.UpdateItemLore(p.getEquipment().getItemInMainHand()));
}
public static void sendCooldownPacket(Player p, Material type, int duration) {
for (int i=0;i<2;i++) {
aPlugin.API.sendCooldownPacket(p, type, duration);
}
p.getEquipment().setItemInMainHand(GenericFunctions.UpdateItemLore(p.getEquipment().getItemInMainHand()));
}
}