Added things to make Team PvP more distinguishable. Added custom PVP

spawnzones.
patch_branch
sigonasr2 8 years ago
parent f438d3e16f
commit abe745c0ac
  1. BIN
      TwosideKeeper.jar
  2. 63
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  3. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  4. 91
      src/sig/plugin/TwosideKeeper/PVP.java
  5. 243
      src/sig/plugin/TwosideKeeper/PVPArena.java
  6. 119
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  7. 22
      src/sig/plugin/TwosideKeeper/runServerHeartbeat.java

Binary file not shown.

@ -818,6 +818,7 @@ public class CustomDamage {
}
}
} else {
pd.slayermodehp=0;
GenericFunctions.AttemptRevive(p, damager, damage, reason);
}
damage=0;
@ -2315,7 +2316,7 @@ public class CustomDamage {
* @return Returns true if the target cannot be hit. False otherwise.
*/
static public boolean InvulnerableCheck(Entity damager, double damage, LivingEntity target, ItemStack weapon, String reason, int flags) {
if (target.isDead()) {
if (target.isDead() || target.getHealth()<=0) {
return true; //Cancel all damage events if they are dead.
}
LivingEntity shooter = getDamagerEntity(damager);
@ -4102,36 +4103,38 @@ public class CustomDamage {
}
public static void executeVoidSurvival(Player p) {
Location p_loc = p.getLocation();
double totalmoney = TwosideKeeper.getPlayerMoney(p);
if (totalmoney>=0.01) {
p_loc.setY(0);
p.teleport(p_loc);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW,20*2,10,p);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION,20*16,6,p);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION,20*18,6,p);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.DAMAGE_RESISTANCE,20*26,50,p);
DecimalFormat df = new DecimalFormat("0.00");
double rand_amt = 0.0;
if (totalmoney>5) {
rand_amt = Math.random()*5;
if (p!=null && p.isOnline() && p.getGameMode()==GameMode.SURVIVAL) {
Location p_loc = p.getLocation();
double totalmoney = TwosideKeeper.getPlayerMoney(p);
if (totalmoney>=0.01) {
p_loc.setY(0);
p.teleport(p_loc);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW,20*2,10,p);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION,20*16,6,p);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.LEVITATION,20*18,6,p);
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.DAMAGE_RESISTANCE,20*26,50,p);
DecimalFormat df = new DecimalFormat("0.00");
double rand_amt = 0.0;
if (totalmoney>5) {
rand_amt = Math.random()*5;
} else {
rand_amt = Math.random()*TwosideKeeper.getPlayerMoney(p);
}
p.sendMessage("A Mysterious Entity forcefully removes "+ChatColor.YELLOW+"$"+df.format(rand_amt)+ChatColor.WHITE+" from your pockets.");
TwosideKeeper.givePlayerMoney(p, -rand_amt);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
if (p!=null) {
p.sendMessage(ChatColor.AQUA+""+ChatColor.ITALIC+" \"Enjoy the ride!\"");
}
}}
,40);
} else {
rand_amt = Math.random()*TwosideKeeper.getPlayerMoney(p);
}
p.sendMessage("A Mysterious Entity forcefully removes "+ChatColor.YELLOW+"$"+df.format(rand_amt)+ChatColor.WHITE+" from your pockets.");
TwosideKeeper.givePlayerMoney(p, -rand_amt);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
if (p!=null) {
p.sendMessage(ChatColor.AQUA+""+ChatColor.ITALIC+" \"Enjoy the ride!\"");
}
}}
,40);
} else {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.last_laugh_time+400<TwosideKeeper.getServerTickTime()) {
p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+"A Mysterious Entity looks at your empty pockets with disdain, then laughs chaotically as you fall to your doom.");
pd.last_laugh_time=TwosideKeeper.getServerTickTime();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.last_laugh_time+400<TwosideKeeper.getServerTickTime()) {
p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+"A Mysterious Entity looks at your empty pockets with disdain, then laughs chaotically as you fall to your doom.");
pd.last_laugh_time=TwosideKeeper.getServerTickTime();
}
}
}
}

@ -3712,7 +3712,7 @@ public class GenericFunctions {
//Check all artifact armor for a perk.
pd.lastdamagetaken=dmg;
pd.lasthitdesc=reason;
pd.slayermodehp = p.getMaxHealth();
//pd.slayermodehp = p.getMaxHealth();
if (damager!=null) {
LivingEntity shooter = CustomDamage.getDamagerEntity(damager);

@ -12,11 +12,13 @@ import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.ImmutableList;
@ -29,6 +31,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem;
import sig.plugin.TwosideKeeper.HelperStructures.CustomItem;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.DebugUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.TextUtils;
public class PVP {
@ -59,7 +62,7 @@ public class PVP {
public PVP(Player...players) {
for (Player p : players) {
this.players.put(p.getName(),new PVPPlayer());
SetupNewPVPPlayer(p);
findFreshBloodPlayer();
//Bukkit.getServer().broadcastMessage(ChatColor.GREEN+"Waiting for any additional players to join the PVP Match...");
//Bukkit.getServer().broadcastMessage(ChatColor.GREEN+"Players must click on "+getParticipants()+" to join in.");
@ -128,7 +131,7 @@ public class PVP {
public void joinMatch(Player p) {
if (!players.containsKey(p.getName())) {
players.put(p.getName(), new PVPPlayer());
SetupNewPVPPlayer(p);
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
Player pl = Bukkit.getPlayer(s);
@ -147,7 +150,25 @@ public class PVP {
timer = TwosideKeeper.getServerTickTime();
}
}
private void SetupNewPVPPlayer(Player p) {
PVPPlayer newpp = new PVPPlayer();
players.put(p.getName(), newpp);
newpp.original_inv = Bukkit.createInventory(p, 54);
for (int i=0;i<p.getInventory().getSize();i++) {
if (ItemUtils.isValidItem(p.getInventory().getItem(i))) {
newpp.original_inv.setItem(i, p.getInventory().getItem(i).clone());
}
}
filterInventory(p);
}
private void filterInventory(Player p) {
for (int i=9;i<36;i++) {
p.getInventory().setItem(i, new ItemStack(Material.AIR));
}
}
private void leaveMatch(String s) {
if (players.containsKey(s)) {
TwosideKeeper.ScheduleRemoval(players,s);
@ -256,7 +277,7 @@ public class PVP {
p.sendMessage(ChatColor.YELLOW+style.getTitle()+ChatColor.GREEN+" has been voted as the style for this PVP match!");
}
}
if (players.size()>2 && style.name().contains("ROUNDS")) {
if (players.size()>=2 && style.name().contains("ROUNDS")) {
state = CHOICEENGINE.WAITFORTEAMCHOICES;
isTeamMatch=true;
lastSelected=TwosideKeeper.getServerTickTime();
@ -358,8 +379,8 @@ public class PVP {
}break;
case PREPAREFORBATTLE:{
if (timer+200<=TwosideKeeper.getServerTickTime()) {
TransferPlayersToArena();
setupConditions();
TransferPlayersToArena();
state = CHOICEENGINE.FIGHTING;
}
}break;
@ -371,6 +392,7 @@ public class PVP {
Bukkit.getServer().broadcastMessage(sb.toString());
aPlugin.API.discordSendRaw("```"+sb.toString()+"```");
}
giveBackInventories();
computeWinner();
//TwosideKeeper.log("Players: "+players, 1);
announceWinner();
@ -394,6 +416,18 @@ public class PVP {
return true;
}
private void giveBackInventories() {
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
Player p = Bukkit.getPlayer(s);
if (p!=null && p.isOnline()) {
for (int i=0;i<p.getInventory().getSize();i++) {
p.getInventory().setItem(i, pp.original_inv.getItem(i));
}
}
}
}
private boolean everyoneIsReady() {
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
@ -540,7 +574,8 @@ public class PVP {
int highestY = cs.getHighestBlockYAt(Math.floorMod(p.getLocation().getBlockX(),16), Math.floorMod(p.getLocation().getBlockZ(),16));
p.teleport(p.getLocation().add(0, highestY-p.getLocation().getBlockY()+2, 0));
} else {
p.teleport(currentArena.pickRandomLocation());
respawnPlayer(p);
//p.teleport(currentArena.pickRandomLocation());
}
}
}, 120);
@ -549,6 +584,28 @@ public class PVP {
}
}
private void respawnPlayer(Player p) {
if (scorematch) {
if (players.containsKey(p.getName())) {
PVPPlayer pp = players.get(p.getName());
TwosideKeeper.log("Team is "+pp.team, 1);
if (pp.team!=0) {
//TwosideKeeper.log("In here.", 1);
p.teleport(currentArena.pickRandomTeamLocation(pp.team));
} else {
//This is not a team match.
p.teleport(currentArena.pickRandomLocation());
}
} else {
TwosideKeeper.log("WARNING! Could not find key "+p.getName()+" in active PVP Players! Just dropping them in...", 1);
p.teleport(currentArena.pickRandomLocation());
}
} else {
//This is Free For All.
p.teleport(currentArena.pickRandomLocation());
}
}
private StringBuilder PrepareCurrentScores() {
StringBuilder sb = new StringBuilder("\n\n");
sb.append("------- PVP Match -------\n");
@ -927,6 +984,12 @@ public class PVP {
for (String s : players.keySet()) {
Player p = Bukkit.getPlayer(s);
if (p==null || !p.isOnline()) {
PVPPlayer pp = players.get(removedPlayer);
for (int i=0;i<p.getInventory().getSize();i++) {
if (ItemUtils.isValidItem(pp.original_inv.getItem(i))) {
p.getInventory().setItem(i, pp.original_inv.getItem(i));
}
}
removedPlayer = s;
break;
}
@ -1013,14 +1076,21 @@ public class PVP {
if (pp.team!=0) {
String firstMember = GetFirstMemberOfTeam(pp.team);
PVP.setTeam(firstMember+"_TEAM"+pp.team, Bukkit.getPlayer(s));
if (pp.team==1) {
pd.customtitle.modifySmallCenterTitle(ChatColor.BLUE+"You are on the blue team!", 60);
pd.customtitle.update();
} else {
pd.customtitle.modifySmallCenterTitle(ChatColor.RED+"You are on the red team!", 60);
pd.customtitle.update();
}
} else {
PVP.setTeam(s+"_PVP", Bukkit.getPlayer(s));
}
pp.lastLoc = Bukkit.getPlayer(s).getLocation().clone();
if (currentArena!=null) {
p.teleport(currentArena.pickRandomLocation());
respawnPlayer(p);
}
//TwosideKeeper.log("Set team of "+s+" to "+PVP.getTeam(Bukkit.getPlayer(s)), 2);
pp.lastLoc = Bukkit.getPlayer(s).getLocation().clone();
Bukkit.getPlayer(s).sendMessage(ChatColor.GREEN+"The PVP Match between "+getParticipants()+" has begun!");
}
}
@ -1381,7 +1451,8 @@ public class PVP {
int highestY = cs.getHighestBlockYAt(Math.floorMod(p.getLocation().getBlockX(),16), Math.floorMod(p.getLocation().getBlockZ(),16));
p.teleport(p.getLocation().add(0, highestY-p.getLocation().getBlockY()+2, 0));
} else {
p.teleport(currentArena.pickRandomLocation());
//p.teleport(currentArena.pickRandomLocation());
respawnPlayer(p);
}
}
}, 120);
@ -1404,7 +1475,8 @@ public class PVP {
} else {
if (players.containsKey(p.getName())) {
if (currentArena!=null) {
p.teleport(currentArena.pickRandomLocation());
//p.teleport(currentArena.pickRandomLocation());
respawnPlayer(p);
}
}
}
@ -1449,6 +1521,7 @@ class PVPPlayer {
boolean isAlive;
long respawnTimer;
boolean isReady;
Inventory original_inv;
PVPPlayer() {
score=0;

@ -14,86 +14,70 @@ import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
public class PVPArena {
Location startCorner;
Location endCorner;
Span arenabounds;
String name;
String desc;
List<Location> safelocs;
List<Span> spawnlocs;
List<Span> team1spawnlocs;
List<Span> team2spawnlocs;
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()));
this.endCorner = new Location(startCorner.getWorld(),Math.max(startCorner.getBlockX(), endCorner.getBlockX()),Math.max(startCorner.getBlockY(), endCorner.getBlockY()),Math.max(startCorner.getBlockZ(), endCorner.getBlockZ()));
public PVPArena(Span bounds, String arenaName, String desc) {
this.arenabounds=bounds;
this.name=arenaName;
this.desc=desc;
this.safelocs = new ArrayList<Location>();
this.spawnlocs = new ArrayList<Span>();
this.team1spawnlocs = new ArrayList<Span>();
this.team2spawnlocs = new ArrayList<Span>();
}
public Location getStartCorner() {
return startCorner;
return arenabounds.getStartCorner();
}
public Location getEndCorner() {
return endCorner;
return arenabounds.getEndCorner();
}
public String getArenaName() {
return name;
}
public void addSpawnLocation(Span loc) {
spawnlocs.add(loc);
}
public void addTeamSpawnLocation(Span loc, int team) {
if (team==1) {
team1spawnlocs.add(loc);
} else {
team2spawnlocs.add(loc);
}
}
public boolean insideBounds(Location loc) {
return (loc.getBlockX()>startCorner.getBlockX() &&
loc.getBlockX()<endCorner.getBlockX() &&
loc.getBlockY()>startCorner.getBlockY() &&
loc.getBlockY()<endCorner.getBlockY() &&
loc.getBlockZ()>startCorner.getBlockZ() &&
loc.getBlockZ()<endCorner.getBlockZ());
return arenabounds.insideBounds(loc);
}
public Location pickRandomLocation() {
//Pick a random point.
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;
int y = endCorner.getBlockY()-startCorner.getBlockY()-2;
Location finalloc = null;
while (tries>0) {
//Find a safe Y Location
int ytries=50;
while (ytries>0) {
Block testBlock = startCorner.clone().add(randomx+0.5,y-1,randomz+0.5).getBlock();
if (testBlock.isLiquid() || !testBlock.getType().isOccluding()) {
y--;
ytries--;
} else {
break;
}
if (spawnlocs.size()>0) {
return spawnlocs.get((int)(Math.random()*spawnlocs.size())).pickRandomLocation();
} else {
return arenabounds.pickRandomLocation();
}
}
public Location pickRandomTeamLocation(int team) {
if (team==1) {
if (team1spawnlocs.size()>0) {
return team1spawnlocs.get((int)(Math.random()*team1spawnlocs.size())).pickRandomLocation();
}
finalloc = new Location(startCorner.getWorld(),
startCorner.getBlockX()+randomx+0.5,
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);
TwosideKeeper.log("Final Block Below is "+finalloc.getBlock().getRelative(0, -1, 0), 1);*/
if (safelocs.size()<20) {
safelocs.add(finalloc.clone());
}
return finalloc.clone();
} else {
tries--;
randomx = ((int)(Math.random()*(endCorner.getBlockX()-startCorner.getBlockX()))) + 1;
randomz = ((int)(Math.random()*(endCorner.getBlockZ()-startCorner.getBlockZ()))) + 1;
y = endCorner.getBlockX()-startCorner.getBlockX()-1;
} else {
if (team2spawnlocs.size()>0) {
return team2spawnlocs.get((int)(Math.random()*team2spawnlocs.size())).pickRandomLocation();
}
}
if (safelocs.size()>0) {
finalloc = safelocs.get((int)(Math.random()*safelocs.size()));
if (spawnlocs.size()>0) {
return spawnlocs.get((int)(Math.random()*spawnlocs.size())).pickRandomLocation();
} else {
TwosideKeeper.log("WARNING! Could not find a safe random location. Dropping them in with what we got...", 1);
return arenabounds.pickRandomLocation();
}
return finalloc.clone();
}
public String getDescription() {
@ -102,32 +86,36 @@ public class PVPArena {
public TextComponent getComponent(int index) {
TextComponent tc = new TextComponent("["+name+"]");
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/pvp _ARENA_ "+(9000+index)+""));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/pvp _ARENA_ "+(9000-index)+""));
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder(desc).create()));
return tc;
}
public String getDataString() {
StringBuilder sb = new StringBuilder("");
sb.append(startCorner.getWorld().getName());
sb.append(",");
sb.append(startCorner.getX());
sb.append(",");
sb.append(startCorner.getY());
sb.append(",");
sb.append(startCorner.getZ());
sb.append(",");
sb.append(endCorner.getWorld().getName());
sb.append(",");
sb.append(endCorner.getX());
sb.append(",");
sb.append(endCorner.getY());
sb.append(",");
sb.append(endCorner.getZ());
sb.append(arenabounds.getDataString());
sb.append(",");
sb.append(name);
sb.append(",");
sb.append(desc);
for (Span s : spawnlocs) {
sb.append(",");
sb.append(s.getDataString());
sb.append(",");
sb.append("SPAWN");
}
for (Span s : team1spawnlocs) {
sb.append(",");
sb.append(s.getDataString());
sb.append(",");
sb.append("TEAM1");
}
for (Span s : team2spawnlocs) {
sb.append(",");
sb.append(s.getDataString());
sb.append(",");
sb.append("TEAM2");
}
return sb.toString();
}
@ -140,11 +128,11 @@ public class PVPArena {
sb.append("desc=");
sb.append(desc);
sb.append(",");
sb.append("startCorner=");
sb.append(startCorner);
sb.append("arenabounds.getStartCorner()=");
sb.append(arenabounds.getStartCorner());
sb.append(",");
sb.append("endCorner=");
sb.append(endCorner);
sb.append("arenabounds.getEndCorner()=");
sb.append(arenabounds.getEndCorner());
sb.append("}");
return sb.toString();
}
@ -153,9 +141,11 @@ public class PVPArena {
class Span {
Location startCorner;
Location endCorner;
List<Location> safelocs;
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()));
this.safelocs = new ArrayList<Location>();
}
Location getStartCorner() {
@ -164,4 +154,109 @@ class Span {
Location getEndCorner() {
return endCorner.clone();
}
boolean insideBounds(Location loc) {
return insideBounds(loc,false);
}
boolean insideBounds(Location loc, boolean includeEdges) {
if (includeEdges) {
return (loc.getBlockX()>=startCorner.getBlockX() &&
loc.getBlockX()<=endCorner.getBlockX() &&
loc.getBlockY()>=startCorner.getBlockY() &&
loc.getBlockY()<=endCorner.getBlockY() &&
loc.getBlockZ()>=startCorner.getBlockZ() &&
loc.getBlockZ()<=endCorner.getBlockZ());
} else {
return (loc.getBlockX()>startCorner.getBlockX() &&
loc.getBlockX()<endCorner.getBlockX() &&
loc.getBlockY()>startCorner.getBlockY() &&
loc.getBlockY()<endCorner.getBlockY() &&
loc.getBlockZ()>startCorner.getBlockZ() &&
loc.getBlockZ()<endCorner.getBlockZ());
}
}
public String toString() {
StringBuilder sb = new StringBuilder("");
sb.append("Span{");
sb.append("startCorner=");
sb.append(getStartCorner());
sb.append(",");
sb.append("endCorner()=");
sb.append(getEndCorner());
sb.append("}");
return sb.toString();
}
String getDataString() {
StringBuilder sb = new StringBuilder("");
sb.append(getStartCorner().getWorld().getName());
sb.append(",");
sb.append(getStartCorner().getX());
sb.append(",");
sb.append(getStartCorner().getY());
sb.append(",");
sb.append(getStartCorner().getZ());
sb.append(",");
sb.append(getEndCorner().getWorld().getName());
sb.append(",");
sb.append(getEndCorner().getX());
sb.append(",");
sb.append(getEndCorner().getY());
sb.append(",");
sb.append(getEndCorner().getZ());
return sb.toString();
}
Location pickRandomLocation() {
//Pick a random point.
int tries=500; //Number of tries before we give up and drop them in.
int randomx = ((int)(Math.random()*(getEndCorner().getBlockX()-getStartCorner().getBlockX()))) + 1;
int randomz = ((int)(Math.random()*(getEndCorner().getBlockZ()-getStartCorner().getBlockZ()))) + 1;
int y = getEndCorner().getBlockY()-getStartCorner().getBlockY()-2;
Location finalloc = null;
while (tries>0) {
//Find a safe Y Location
int ytries=50;
while (ytries>0) {
Block testBlock = getStartCorner().clone().add(randomx+0.5,y-1,randomz+0.5).getBlock();
if (testBlock.isLiquid() || !testBlock.getType().isOccluding()) {
y--;
ytries--;
} else {
break;
}
}
finalloc = new Location(getStartCorner().getWorld(),
getStartCorner().getBlockX()+randomx+0.5,
getStartCorner().getBlockY()+y,
getStartCorner().getBlockZ()+randomz+0.5);
if (!finalloc.getBlock().isLiquid() &&
finalloc.getBlock().getRelative(0, 1, 0).getType()==Material.AIR &&
insideBounds(finalloc,true)) {
/*TwosideKeeper.log("Final Block is "+finalloc.getBlock(), 1);
TwosideKeeper.log("Final Block Above is "+finalloc.getBlock().getRelative(0, 1, 0), 1);
TwosideKeeper.log("Final Block Below is "+finalloc.getBlock().getRelative(0, -1, 0), 1);*/
if (safelocs.size()<20) {
safelocs.add(finalloc.clone());
}
return finalloc.clone();
} else {
tries--;
randomx = ((int)(Math.random()*(getEndCorner().getBlockX()-getStartCorner().getBlockX()))) + 1;
randomz = ((int)(Math.random()*(getEndCorner().getBlockZ()-getStartCorner().getBlockZ()))) + 1;
y = getEndCorner().getBlockX()-getStartCorner().getBlockX()-1;
}
}
if (safelocs.size()>0) {
finalloc = safelocs.get((int)(Math.random()*safelocs.size()));
} else {
TwosideKeeper.log("WARNING! Could not find a safe random location. Dropping them in with what we got...", 1);
}
return finalloc.clone();
}
}
enum SpawnType{
NORMAL,
TEAM1,
TEAM2
}

@ -2583,7 +2583,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} else {
if (args.length==3) {
Set<Material> types = null;
PVPArena arena = new PVPArena(pd.arenaLocRef,p.getTargetBlock(types, 100).getLocation().clone(),
PVPArena arena = new PVPArena(new Span(pd.arenaLocRef,p.getTargetBlock(types, 100).getLocation().clone()),
ChatColor.translateAlternateColorCodes('§', args[1]),ChatColor.translateAlternateColorCodes('§', args[1]));
PVP.arenas.add(arena);
p.sendMessage(ChatColor.LIGHT_PURPLE+"Set Ref Location of Arena corner 2 to "+p.getTargetBlock(types, 100).getLocation().clone());
@ -2607,6 +2607,74 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
}break;
case "DEFINESPAWN":{
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
//TwosideKeeper.log("Args are "+Arrays.toString(args), 3);
if (pd.arenaLocRef==null) {
Set<Material> types = null;
pd.arenaLocRef = p.getTargetBlock(types, 100).getLocation().clone();
pd.playerLocRef=p.getLocation().clone();
p.sendMessage(ChatColor.LIGHT_PURPLE+"Set Ref Location of Arena corner 1 to "+pd.arenaLocRef);
} else {
Set<Material> types = null;
/*PVPArena arena = new PVPArena(new Span(pd.arenaLocRef,p.getTargetBlock(types, 100).getLocation().clone()),
ChatColor.translateAlternateColorCodes('§', args[1]),ChatColor.translateAlternateColorCodes('§', args[1]));
PVP.arenas.add(arena);*/
p.sendMessage(ChatColor.LIGHT_PURPLE+"Set Ref Location of Arena corner 2 to "+p.getTargetBlock(types, 100).getLocation().clone());
PVPArena arena=null;
for (PVPArena a : PVP.arenas) {
if (a.insideBounds(p.getLocation()) &&
a.insideBounds(pd.arenaLocRef)) {
arena = a;
}
}
if (arena==null) {
p.sendMessage(ChatColor.RED+"Could not set spawn area of an Arena. You are not standing inside an arena!");
} else {
p.sendMessage(ChatColor.GREEN+" Successfully added a spawn zone for arena "+arena.name+"!");
arena.addSpawnLocation(new Span(p.getLocation(),pd.arenaLocRef));
}
p.teleport(pd.playerLocRef);
pd.playerLocRef=null;
pd.arenaLocRef=null;
}
}break;
case "DEFINETEAMSPAWN":{
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
//TwosideKeeper.log("Args are "+Arrays.toString(args), 3);
if (pd.arenaLocRef==null) {
Set<Material> types = null;
pd.arenaLocRef = p.getTargetBlock(types, 100).getLocation().clone();
pd.playerLocRef=p.getLocation().clone();
p.sendMessage(ChatColor.LIGHT_PURPLE+"Set Ref Location of Arena corner 1 to "+pd.arenaLocRef);
} else {
if (args.length==2) {
Set<Material> types = null;
/*PVPArena arena = new PVPArena(new Span(pd.arenaLocRef,p.getTargetBlock(types, 100).getLocation().clone()),
ChatColor.translateAlternateColorCodes('§', args[1]),ChatColor.translateAlternateColorCodes('§', args[1]));
PVP.arenas.add(arena);*/
p.sendMessage(ChatColor.LIGHT_PURPLE+"Set Ref Location of Arena corner 2 to "+p.getTargetBlock(types, 100).getLocation().clone());
PVPArena arena=null;
for (PVPArena a : PVP.arenas) {
if (a.insideBounds(p.getLocation()) &&
a.insideBounds(pd.arenaLocRef)) {
arena = a;
}
}
if (arena==null) {
p.sendMessage(ChatColor.RED+"Could not set spawn area of an Arena. You are not standing inside an arena!");
} else {
p.sendMessage(ChatColor.GREEN+" Successfully added a spawn zone for arena "+arena.name+" for Team "+args[1]+"!");
arena.addTeamSpawnLocation(new Span(p.getLocation(),pd.arenaLocRef),Integer.parseInt(args[1]));
}
p.teleport(pd.playerLocRef);
pd.playerLocRef=null;
pd.arenaLocRef=null;
} else {
p.sendMessage("Use /fix DEFINETEAMSPAWN <numb>. Where <numb> is the number of the team (1 or 2)");
}
}
}break;
case "MINIBOSSES":{
p.sendMessage("There are "+(GenericBoss.nearbyBosses(p.getLocation(),50))+" Minibosses nearby.");
}break;
@ -3476,12 +3544,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
/*PVP session = PVP.getMatch(p);
PVP session = PVP.getMatch(p);
if (session!=null) {
if (session.matchTimer!=null) {
session.matchTimer.removePlayer(p);
PVPPlayer pp = session.players.get(p);
for (int i=0;i<p.getInventory().getSize();i++) {
if (ItemUtils.isValidItem(pp.original_inv.getItem(i))) {
p.getInventory().setItem(i, pp.original_inv.getItem(i));
}
}
}*/
}
//Bukkit.getScheduler().scheduleSyncDelayedTask(this, new ShutdownServerForUpdate(),5);
@ -11161,15 +11232,37 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (getConfig().contains("ARENA"+i+"_data")) {
String data = getConfig().getString("ARENA"+i+"_data");
String[] split = data.split(",");
if (split.length==10) {
PVP.arenas.add(new PVPArena(
new Location(Bukkit.getWorld(split[0]),Double.parseDouble(split[1]),Double.parseDouble(split[2]),Double.parseDouble(split[3])),
new Location(Bukkit.getWorld(split[4]),Double.parseDouble(split[5]),Double.parseDouble(split[6]),Double.parseDouble(split[7])),
split[8],
split[9]));
} else {
TwosideKeeper.log("WARNING! Malformed Arena data for Arena "+i+". Skipping...", 1);
PVPArena ar = new PVPArena(
new Span(new Location(Bukkit.getWorld(split[0]),Double.parseDouble(split[1]),Double.parseDouble(split[2]),Double.parseDouble(split[3])),
new Location(Bukkit.getWorld(split[4]),Double.parseDouble(split[5]),Double.parseDouble(split[6]),Double.parseDouble(split[7]))),
split[8],
split[9]);
//Extra data...
int marker=10;
while (marker<split.length) {
switch (split[marker+8]) {
case "SPAWN":{
Span s = new Span(new Location(Bukkit.getWorld(split[marker+0]),Double.parseDouble(split[marker+1]),Double.parseDouble(split[marker+2]),Double.parseDouble(split[marker+3])),
new Location(Bukkit.getWorld(split[marker+4]),Double.parseDouble(split[marker+5]),Double.parseDouble(split[marker+6]),Double.parseDouble(split[marker+7])));
//TwosideKeeper.log("...Added Span "+s+" to Normal spawns.", 2);
ar.addSpawnLocation(s);
}break;
case "TEAM1":{
Span s = new Span(new Location(Bukkit.getWorld(split[marker+0]),Double.parseDouble(split[marker+1]),Double.parseDouble(split[marker+2]),Double.parseDouble(split[marker+3])),
new Location(Bukkit.getWorld(split[marker+4]),Double.parseDouble(split[marker+5]),Double.parseDouble(split[marker+6]),Double.parseDouble(split[marker+7])));
//TwosideKeeper.log("...Added Span "+s+" to Team 1 spawns.", 2);
ar.addTeamSpawnLocation(s,1);
}break;
case "TEAM2":{
Span s = new Span(new Location(Bukkit.getWorld(split[marker+0]),Double.parseDouble(split[marker+1]),Double.parseDouble(split[marker+2]),Double.parseDouble(split[marker+3])),
new Location(Bukkit.getWorld(split[marker+4]),Double.parseDouble(split[marker+5]),Double.parseDouble(split[marker+6]),Double.parseDouble(split[marker+7])));
//TwosideKeeper.log("...Added Span "+s+" to Team 2 spawns.", 2);
ar.addTeamSpawnLocation(s,2);
}break;
}
marker+=9;
}
PVP.arenas.add(ar);
} else {
TwosideKeeper.log("WARNING! Malformed Arena data for Arena "+i+". Skipping...", 1);
}

@ -814,7 +814,27 @@ final public class runServerHeartbeat implements Runnable {
//DebugUtils.showStackTrace();
}
TwosideKeeper.HeartbeatLogger.AddEntry("==Scoreboard/Health Management - Set Suffix", (int)(System.nanoTime()-time));time=System.nanoTime();
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
if (PVP.isPvPing(p)) {
PVP match = PVP.getMatch(p);
if (match!=null) {
if (match.scorematch) {
if (match.players.containsKey(p.getName())) {
PVPPlayer pp = match.players.get(p.getName());
if (pp.team!=0) {
if (pp.team==1) {
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.BLUE+ChatColor.stripColor(GenericFunctions.PlayerModePrefix(p)));
} else {
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.RED+ChatColor.stripColor(GenericFunctions.PlayerModePrefix(p)));
}
}
}
}
} else {
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
}
} else {
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
}
TwosideKeeper.HeartbeatLogger.AddEntry("==Scoreboard/Health Management - Set Prefix", (int)(System.nanoTime()-time));time=System.nanoTime();
}

Loading…
Cancel
Save