Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2014-07-02 16:05:37 -07:00
commit 8eaad57516
4 changed files with 156 additions and 28 deletions

View File

@ -14,12 +14,14 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Creature;
@ -40,6 +42,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
public class WorldManager extends MiniPlugin
{
@ -259,4 +262,11 @@ public class WorldManager extends MiniPlugin
event.setCancelled(true);
}
}
@EventHandler
public void BoatBreak(CustomDamageEvent event)
{
if (event.GetDamageeEntity() instanceof Boat)
event.SetCancelled("Boat Cancel");
}
}

View File

@ -899,7 +899,9 @@ public class GameLobbyManager implements IPacketRunnable, Listener
objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players");
}
int line = 14;
int line = 15;
objective.getScore(" ").setScore(line--);
objective.getScore(C.cYellow + "Players").setScore(line--);

View File

@ -36,6 +36,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
@ -338,4 +339,42 @@ public class GamePlayerManager implements Listener
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void TeleportCommand(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().toLowerCase().startsWith("/tp"))
return;
Game game = Manager.GetGame();
if (game == null)
return;
Player player = event.getPlayer();
if (game.IsAlive(player) || player.getGameMode() != GameMode.CREATIVE)
{
UtilPlayer.message(player, F.main("Game", "Only Spectators can use teleport."));
event.setCancelled(true);
return;
}
String[] tokens = event.getMessage().split(" ");
if (tokens.length != 2)
{
UtilPlayer.message(player, F.main("Game", "Invalid Input. " + F.elem("/tp <Name>") + "."));
event.setCancelled(true);
return;
}
Player target = UtilPlayer.searchOnline(player, tokens[1], true);
if (target != null)
{
UtilPlayer.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + "."));
player.teleport(target);
event.setCancelled(true);
}
}
}

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.scoreboard;
import java.util.ArrayList;
import java.util.HashSet;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
@ -26,7 +27,7 @@ public class GameScoreboard
private Objective _sideObjective;
private ArrayList<ScoreboardElement> _elements = new ArrayList<ScoreboardElement>();
private String _space = " ";
private String[] _current = new String[15];
private String _title;
@ -110,6 +111,7 @@ public class GameScoreboard
_scoreboard.resetScores(line);
}
/*
public void Reset()
{
for (ScoreboardElement elem : _elements)
@ -124,6 +126,7 @@ public class GameScoreboard
_space = " ";
}
*/
public String Clean(String line)
{
@ -166,22 +169,96 @@ public class GameScoreboard
public void WriteBlank()
{
_elements.add(new ScoreboardElementText(_space));
_space += " ";
_elements.add(new ScoreboardElementText(" "));
}
public void Draw()
{
int i = 15;
//System.out.println();
//System.out.println("/////////////////////////");
//Generate Lines
ArrayList<String> newLines = new ArrayList<String>();
for (ScoreboardElement elem : _elements)
{
for (String line : elem.GetLines())
{
GetObjectiveSide().getScore(line).setScore(i--);
//Ensure no duplicate lines
while (true)
{
boolean matched = false;
for (String otherLine : newLines)
{
if (line.equals(otherLine))
{
line += ChatColor.RESET;
matched = true;
}
}
if (i <= 0)
if (!matched)
break;
}
newLines.add(line);
}
}
//Find Changes
HashSet<Integer> toUpdate = new HashSet<Integer>();
HashSet<Integer> toDelete = new HashSet<Integer>();
for (int i=0 ; i<15 ; i++)
{
//Delete Old Excess Row
if (i >= newLines.size())
{
if (_current[i] != null)
{
//System.out.println("Delete: " + i + " [" + _current[i] + "]");
toDelete.add(i);
}
continue;
}
//Update or Add Row
if (_current[i] == null || !_current[i].equals(newLines.get(i)))
{
//System.out.println("Update: " + i + " [" + newLines.get(i) + "]");
toUpdate.add(i);
}
}
//Add/Update Elements
for (int i : toUpdate)
{
//Remove Old Line at Index
if (_current[i] != null)
ResetScore(_current[i]);
//Insert New Line
String newLine = newLines.get(i);
GetObjectiveSide().getScore(newLine).setScore(15-i);
_current[i] = newLine;
}
//Delete Elements
for (int i : toDelete)
{
//Remove Old Line at Index
if (_current[i] != null)
{
ResetScore(_current[i]);
_current[i] = null;
}
}
}
public void Reset()
{
_elements.clear();
}
}