Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
8eaad57516
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -899,8 +899,10 @@ 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--);
|
||||
|
||||
// Remove old
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,14 +27,14 @@ 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;
|
||||
|
||||
public GameScoreboard(Game game)
|
||||
{
|
||||
Game = game;
|
||||
|
||||
|
||||
_title = " MINEPLEX ";
|
||||
|
||||
//Scoreboard
|
||||
@ -43,7 +44,7 @@ public class GameScoreboard
|
||||
_sideObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
_sideObjective.setDisplayName(C.Bold + _title);
|
||||
}
|
||||
|
||||
|
||||
public Scoreboard GetScoreboard()
|
||||
{
|
||||
return _scoreboard;
|
||||
@ -53,12 +54,12 @@ public class GameScoreboard
|
||||
{
|
||||
return _sideObjective;
|
||||
}
|
||||
|
||||
|
||||
public void UpdateTitle()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String ParseTeamName(String name)
|
||||
{
|
||||
return name.substring(0, Math.min(16, name.length()));
|
||||
@ -93,7 +94,7 @@ public class GameScoreboard
|
||||
teamName = "";
|
||||
|
||||
String team = ParseTeamName(Game.Manager.GetClients().Get(player).GetRank().Name + teamName);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
_scoreboard.getTeam(team).addPlayer(player);
|
||||
@ -110,6 +111,7 @@ public class GameScoreboard
|
||||
_scoreboard.resetScores(line);
|
||||
}
|
||||
|
||||
/*
|
||||
public void Reset()
|
||||
{
|
||||
for (ScoreboardElement elem : _elements)
|
||||
@ -121,38 +123,39 @@ public class GameScoreboard
|
||||
}
|
||||
|
||||
_elements.clear();
|
||||
|
||||
|
||||
_space = " ";
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public String Clean(String line)
|
||||
{
|
||||
if (line.length() >= 16)
|
||||
line = line.substring(0, 15);
|
||||
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
public void Write(String line)
|
||||
{
|
||||
line = Clean(line);
|
||||
|
||||
|
||||
_elements.add(new ScoreboardElementText(line));
|
||||
}
|
||||
|
||||
|
||||
public void WriteOrdered(String key, String line, int value, boolean prependScore)
|
||||
{
|
||||
if (prependScore)
|
||||
line = value + " " + line;
|
||||
|
||||
|
||||
line = Clean(line);
|
||||
|
||||
|
||||
for (ScoreboardElement elem : _elements)
|
||||
{
|
||||
if (elem instanceof ScoreboardElementScores)
|
||||
{
|
||||
ScoreboardElementScores scores = (ScoreboardElementScores)elem;
|
||||
|
||||
|
||||
if (scores.IsKey(key))
|
||||
{
|
||||
scores.AddScore(line, value);
|
||||
@ -160,28 +163,102 @@ public class GameScoreboard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_elements.add(new ScoreboardElementScores(key, line, value, true));
|
||||
}
|
||||
|
||||
|
||||
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 (!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;
|
||||
}
|
||||
|
||||
if (i <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_elements.clear();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user