Add LobbyArea in order to restrict ScoreBoard display

Rename AddLobby and RemoveLobby into AddLobbyWall and RemoveLobbyWall command
Add AddLobbyArea and RemoveLobbyArea command
Fix lobby.yml config saving
This commit is contained in:
Arnaud G. GIBERT 2021-05-06 01:02:51 +02:00
parent dc0f2c69fb
commit 80ad510729
8 changed files with 363 additions and 118 deletions

View File

@ -5,18 +5,18 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class AddLobbyCommand public class AddLobbyAreaCommand
implements BasicCommand { implements BasicCommand {
private final Quake _plugin; private final Quake _plugin;
public AddLobbyCommand(Quake pl) { public AddLobbyAreaCommand(Quake pl) {
_plugin = pl; _plugin = pl;
} }
@Override @Override
public boolean onCommand(Player player, String[] args) { public boolean onCommand(Player player, String[] args) {
if (Quake.hasPermission(player, getPermission())) { if (Quake.hasPermission(player, getPermission())) {
_plugin._lobby.addLobby(player); _plugin._lobby.addLobbyArea(player);
_plugin._lobby.saveconfig(); _plugin._lobby.saveconfig();
} else { } else {
player.sendMessage(_plugin._trad.get("NoPermission")); player.sendMessage(_plugin._trad.get("NoPermission"));
@ -32,7 +32,7 @@ implements BasicCommand {
@Override @Override
public String help(Player p) { public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) { if (Quake.hasPermission(p, getPermission())) {
return "/quake addlobby - Add a sign wall lobby."; return "/quake addlobbyarea - Add a lobby area.";
} }
return ""; return "";
} }

View File

@ -0,0 +1,46 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class AddLobbyWallCommand
implements BasicCommand {
private final Quake _plugin;
public AddLobbyWallCommand(Quake pl) {
_plugin = pl;
}
@Override
public boolean onCommand(Player player, String[] args) {
if (Quake.hasPermission(player, getPermission())) {
_plugin._lobby.addLobbyWall(player);
_plugin._lobby.saveconfig();
} else {
player.sendMessage(_plugin._trad.get("NoPermission"));
}
return true;
}
@Override
public String getPermission() {
return "Quake.lobby";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
return "/quake addlobbywall - Add a sign wall lobby.";
}
return "";
}
@Override
public List<String> getCompletionList(Player player, String[] args) {
List<String> list = new ArrayList();
return list;
}
}

View File

@ -31,9 +31,11 @@ public class MyCommandExecutor implements CommandExecutor {
_commands.put("setmap", new SetMapCommand(_plugin)); _commands.put("setmap", new SetMapCommand(_plugin));
_commands.put("setmin", new SetMinCommand(_plugin)); _commands.put("setmin", new SetMinCommand(_plugin));
_commands.put("setmax", new SetMaxCommand(_plugin)); _commands.put("setmax", new SetMaxCommand(_plugin));
_commands.put("addlobby", new AddLobbyCommand(_plugin)); _commands.put("addlobbyarea", new AddLobbyAreaCommand(_plugin));
_commands.put("addlobbywall", new AddLobbyWallCommand(_plugin));
_commands.put("setlobbyspawn", new SetLobbySpawnCommand(_plugin)); _commands.put("setlobbyspawn", new SetLobbySpawnCommand(_plugin));
_commands.put("removelobby", new RemoveLobbyCommand(_plugin)); _commands.put("removelobbyarea", new RemoveLobbyAreaCommand(_plugin));
_commands.put("removelobbywall", new RemoveLobbyWallCommand(_plugin));
_commands.put("join", new JoinCommand(_plugin)); _commands.put("join", new JoinCommand(_plugin));
_commands.put("leave", new LeaveCommand(_plugin)); _commands.put("leave", new LeaveCommand(_plugin));
_commands.put("start", new StartCommand(_plugin)); _commands.put("start", new StartCommand(_plugin));

View File

@ -13,10 +13,10 @@ import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class RemoveLobbyCommand implements BasicCommand { public class RemoveLobbyAreaCommand implements BasicCommand {
private final Quake _plugin; private final Quake _plugin;
public RemoveLobbyCommand(Quake pl) { public RemoveLobbyAreaCommand(Quake pl) {
_plugin = pl; _plugin = pl;
} }
@ -24,12 +24,12 @@ public class RemoveLobbyCommand implements BasicCommand {
public boolean onCommand(Player player, String[] args) { public boolean onCommand(Player player, String[] args) {
if (Quake.hasPermission(player, getPermission())) { if (Quake.hasPermission(player, getPermission())) {
if (args.length != 1) { if (args.length != 1) {
player.sendMessage(ChatColor.RED + "Please type a good number of lobby !"); player.sendMessage(ChatColor.RED + "Please type a good lobby ID!");
return true; return true;
} }
int lobby = Integer.valueOf(args[0]); int lobbyarea = Integer.valueOf(args[0]);
_plugin._lobby.removeLobby("lobby" + (lobby - 1)); _plugin._lobby.removeLobbyArea("lobbyarea" + lobbyarea);
player.sendMessage(ChatColor.YELLOW + "Lobby number : " + (lobby - 1) + " removed with success"); player.sendMessage(ChatColor.YELLOW + "Lobby area number " + lobbyarea + " successfully removed.");
_plugin._lobby.saveconfig(); _plugin._lobby.saveconfig();
} else { } else {
player.sendMessage(_plugin._trad.get("NoPermission")); player.sendMessage(_plugin._trad.get("NoPermission"));
@ -45,7 +45,7 @@ public class RemoveLobbyCommand implements BasicCommand {
@Override @Override
public String help(Player p) { public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) { if (Quake.hasPermission(p, getPermission())) {
return "/quake removelobby [ID of the lobby] - Remove a lobby wall."; return "/quake removelobby [ID of the lobby] - Remove a lobby area.";
} }
return ""; return "";
} }
@ -56,7 +56,7 @@ public class RemoveLobbyCommand implements BasicCommand {
if( args.length <= 2) { if( args.length <= 2) {
list = _plugin._lobby.getLobbyIndexList(); list = _plugin._lobby.getLobbyAreaIDList();
} else { } else {
list = new ArrayList(); list = new ArrayList();
} }

View File

@ -0,0 +1,67 @@
/*
* Decompiled with CFR 0_114.
*
* Could not load the following classes:
* org.bukkit.ChatColor
* org.bukkit.entity.Player
*/
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class RemoveLobbyWallCommand implements BasicCommand {
private final Quake _plugin;
public RemoveLobbyWallCommand(Quake pl) {
_plugin = pl;
}
@Override
public boolean onCommand(Player player, String[] args) {
if (Quake.hasPermission(player, getPermission())) {
if (args.length != 1) {
player.sendMessage(ChatColor.RED + "Please type a good lobby wall ID!");
return true;
}
int lobbywall = Integer.valueOf(args[0]);
_plugin._lobby.removeLobbyWall("lobbywall " + lobbywall);
player.sendMessage(ChatColor.YELLOW + "Lobby wall number " + lobbywall + " successfully removed.");
_plugin._lobby.saveconfig();
} else {
player.sendMessage(_plugin._trad.get("NoPermission"));
}
return true;
}
@Override
public String getPermission() {
return "Quake.lobby";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
return "/quake removelobbywall [ID of the lobby wall] - Remove a lobby wall.";
}
return "";
}
@Override
public List<String> getCompletionList(Player player, String[] args) {
List<String> list;
if( args.length <= 2) {
list = _plugin._lobby.getLobbyWallIDList();
} else {
list = new ArrayList();
}
return list;
}
}

View File

@ -52,7 +52,7 @@ public class PlayerListener implements Listener {
Arena arena = _plugin._am.getArenabyPlayer(player); Arena arena = _plugin._am.getArenabyPlayer(player);
if(arena == null) { if(arena == null) {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if ((action == Action.LEFT_CLICK_BLOCK || action == Action.RIGHT_CLICK_BLOCK) && _plugin._lobby.isinLobby(event.getClickedBlock().getLocation()) && block.getState() instanceof Sign) { if ((action == Action.LEFT_CLICK_BLOCK || action == Action.RIGHT_CLICK_BLOCK) && _plugin._lobby.isinLobbyWall(event.getClickedBlock().getLocation()) && block.getState() instanceof Sign) {
Sign sign = (Sign)block.getState(); Sign sign = (Sign)block.getState();
if (sign.getLine(1).equals("")) { if (sign.getLine(1).equals("")) {
return; return;
@ -244,17 +244,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority=EventPriority.HIGHEST) @EventHandler(priority=EventPriority.HIGHEST)
public void onPlayerTeleport(PlayerTeleportEvent event) { public void onPlayerTeleport(PlayerTeleportEvent event) {
Player p = event.getPlayer(); Player p = event.getPlayer();
if (isScoreWorld(event.getFrom().getWorld().getName()) && !isScoreWorld(event.getTo().getWorld().getName())) {
p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); if( isScoreWorld(event.getFrom().getWorld().getName()) ^ isScoreWorld(event.getTo().getWorld().getName())) {
return;
}
if (!isScoreWorld(event.getFrom().getWorld().getName()) && isScoreWorld(event.getTo().getWorld().getName())) {
if (_plugin._scores.containsKey(p.getName())) { if (_plugin._scores.containsKey(p.getName())) {
p.setScoreboard(_plugin._scores.get(p.getName()).getScoreBoard()); _plugin._scores.get(p.getName()).displayScoreB( event.getTo().getWorld().getName());
} else { } else {
_plugin._scores.put(p.getName(), new ScoreB(_plugin, p)); _plugin._scores.put(p.getName(), new ScoreB(_plugin, p));
} }
return;
} }
} }
@ -354,7 +351,7 @@ public class PlayerListener implements Listener {
if (arena == null) { if (arena == null) {
return; return;
} }
_plugin.getLogger().warning("Player : " + player.getName() + " Rage Quit !"); _plugin.getLogger().warning("Player : " + player.getName() + " Rage Quit!");
arena.CrashLeaveArena(event.getPlayer()); arena.CrashLeaveArena(event.getPlayer());
} }

View File

@ -24,8 +24,10 @@ import org.bukkit.entity.Player;
public class LobbyManager { public class LobbyManager {
public Quake _plugin; public Quake _plugin;
public HashMap<String, Location> _locmin = new HashMap(); public HashMap<String, Location> _arealocmin = new HashMap();
public HashMap<String, Location> _locmax = new HashMap(); public HashMap<String, Location> _arealocmax = new HashMap();
public HashMap<String, Location> _walllocmin = new HashMap();
public HashMap<String, Location> _walllocmax = new HashMap();
public Location _lobbyspawn = null; public Location _lobbyspawn = null;
public List<Lobby> _LOBBYS = new ArrayList<>(); public List<Lobby> _LOBBYS = new ArrayList<>();
public List<Lobby_Sign> _LOBBYS_SIGN = new ArrayList<>(); public List<Lobby_Sign> _LOBBYS_SIGN = new ArrayList<>();
@ -36,42 +38,83 @@ public class LobbyManager {
} }
public final void loadconfig() { public final void loadconfig() {
String nom; String name;
File fichier_config = new File(_plugin.getDataFolder(), String.valueOf(File.separator) + "lobby.yml"); int number,i;
YamlConfiguration config = YamlConfiguration.loadConfiguration((File)fichier_config); File config_file = new File(_plugin.getDataFolder(), String.valueOf(File.separator) + "lobby.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration((File)config_file);
_lobbyspawn = str2loc(config.getString("LobbySpawn")); _lobbyspawn = str2loc(config.getString("LobbySpawn"));
int nombre = config.getInt("Nombre");
int i = 0; number = config.getInt("LobbyAreaNb");
while (i < nombre) { i = 0;
nom = config.getString("min.lobby" + i); while (i < number) {
_locmin.put("lobby" + i, str2loc(nom)); name = config.getString("min.lobbyarea" + i);
_arealocmin.put("lobbyarea" + i, str2loc(name));
++i; ++i;
} }
i = 0; i = 0;
while (i < nombre) { while (i < number) {
nom = config.getString("max.lobby" + i); name = config.getString("max.lobbyarea" + i);
_locmax.put("lobby" + i, str2loc(nom)); _arealocmax.put("lobbyarea" + i, str2loc(name));
++i; ++i;
} }
_plugin.getLogger().info("Lobby loading (" + nombre + ")..."); _plugin.getLogger().info("Lobby Area Loaded: " + number + "!");
number = config.getInt("LobbyWallNb");
i = 0;
while (i < number) {
name = config.getString("min.lobbywall" + i);
_walllocmin.put("lobbywall" + i, str2loc(name));
++i;
}
i = 0;
while (i < number) {
name = config.getString("max.lobbywall" + i);
_walllocmax.put("lobbywall" + i, str2loc(name));
++i;
}
_plugin.getLogger().info("Lobby Wall Loaded: " + number + "!");
} }
public void saveconfig() { public void saveconfig() {
Location loc; Location loc;
File fichier_config = new File(_plugin.getDataFolder(), String.valueOf(File.separator) + "lobby.yml"); File config_file = new File(_plugin.getDataFolder(), String.valueOf(File.separator) + "lobby.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(fichier_config);
config_file.delete();
if(!config_file.exists()) {
try {
config_file.createNewFile();
} catch(IOException e) {
// empty catch block
}
}
YamlConfiguration config = YamlConfiguration.loadConfiguration(config_file);
if(_lobbyspawn != null) { if(_lobbyspawn != null) {
config.set("LobbySpawn", (String.valueOf(_lobbyspawn.getWorld().getName()) + ", " + _lobbyspawn.getX() + ", " + _lobbyspawn.getY() + ", " + _lobbyspawn.getZ() + ", " + _lobbyspawn.getYaw() + ", " + _lobbyspawn.getPitch())); config.set("LobbySpawn", (String.valueOf(_lobbyspawn.getWorld().getName()) + ", " + _lobbyspawn.getX() + ", " + _lobbyspawn.getY() + ", " + _lobbyspawn.getZ() + ", " + _lobbyspawn.getYaw() + ", " + _lobbyspawn.getPitch()));
} }
config.set("Nombre", _locmin.size()); config.set("LobbyAreaNb", _arealocmin.size());
for(String l2 : _locmin.keySet()) { config.set("LobbyWallNb", _walllocmin.size());
loc = _locmin.get(l2);
for(String l2 : _arealocmin.keySet()) {
loc = _arealocmin.get(l2);
config.set("min." + l2, (String.valueOf(loc.getWorld().getName()) + ", " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ", " + loc.getYaw() + ", " + loc.getPitch())); config.set("min." + l2, (String.valueOf(loc.getWorld().getName()) + ", " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ", " + loc.getYaw() + ", " + loc.getPitch()));
} }
for(String l2 : _locmax.keySet()) { for(String l2 : _arealocmax.keySet()) {
loc = _locmax.get(l2); loc = _arealocmax.get(l2);
config.set("max." + l2, (String.valueOf(loc.getWorld().getName()) + ", " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ", " + loc.getYaw() + ", " + loc.getPitch()));
}
for(String l2 : _walllocmin.keySet()) {
loc = _walllocmin.get(l2);
config.set("min." + l2, (String.valueOf(loc.getWorld().getName()) + ", " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ", " + loc.getYaw() + ", " + loc.getPitch()));
}
for(String l2 : _walllocmax.keySet()) {
loc = _walllocmax.get(l2);
config.set("max." + l2, (String.valueOf(loc.getWorld().getName()) + ", " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ", " + loc.getYaw() + ", " + loc.getPitch())); config.set("max." + l2, (String.valueOf(loc.getWorld().getName()) + ", " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ", " + loc.getYaw() + ", " + loc.getPitch()));
} }
@ -81,7 +124,7 @@ public class LobbyManager {
} catch (IOException l) { } catch (IOException l) {
// empty catch block // empty catch block
} }
_plugin.getLogger().info("Lobby saving..."); _plugin.getLogger().info("Lobby config saved!");
} }
public Location str2loc(String loc) { public Location str2loc(String loc) {
@ -98,32 +141,60 @@ public class LobbyManager {
_lobbyspawn = player.getLocation(); _lobbyspawn = player.getLocation();
} }
public Boolean removeLobby(String lobby) { public Boolean addLobbyArea(Player player) {
_locmin.remove(lobby); String lobby = "lobbyarea" + _arealocmin.size();
_locmax.remove(lobby);
HashMap<String, Location> tempmin = new HashMap<>();
HashMap<String, Location> tempmax = new HashMap<>();
int i = 0;
for (String s : _locmin.keySet()) {
tempmin.put("lobby" + i, _locmin.get(s));
tempmax.put("lobby" + i, _locmax.get(s));
++i;
}
_locmin = tempmin;
_locmax = tempmax;
return true;
}
public Boolean addLobby(Player player) {
String lobby = "lobby" + _locmin.size();
try { try {
LocalSession ls = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player)); LocalSession ls = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
Region reg = ls.getSelection(BukkitAdapter.adapt(player.getWorld())); Region reg = ls.getSelection(BukkitAdapter.adapt(player.getWorld()));
if(reg != null) { if(reg != null) {
_locmin.put(lobby, BukkitAdapter.adapt(player.getWorld(), reg.getMinimumPoint())); _arealocmin.put(lobby, BukkitAdapter.adapt(player.getWorld(), reg.getMinimumPoint()));
_locmax.put(lobby, BukkitAdapter.adapt(player.getWorld(), reg.getMaximumPoint())); _arealocmax.put(lobby, BukkitAdapter.adapt(player.getWorld(), reg.getMaximumPoint()));
player.sendMessage(ChatColor.YELLOW + "Lobby " + _locmin.size() + " cr\u00e9e successful \u00e9s"); player.sendMessage(ChatColor.YELLOW + "Lobby " + (_arealocmin.size() - 1) + " successfully created.");
return true;
}
} catch(Exception ex) {
player.sendMessage(ChatColor.RED + "Internal error on region selection.");
}
return false;
}
public Boolean removeLobbyArea(String lobby) {
_arealocmin.remove(lobby);
_arealocmax.remove(lobby);
HashMap<String, Location> tempmin = new HashMap<>();
HashMap<String, Location> tempmax = new HashMap<>();
int i = 0;
for (String s : _arealocmin.keySet()) {
tempmin.put("lobbyarea" + i, _arealocmin.get(s));
tempmax.put("lobbyarea" + i, _arealocmax.get(s));
++i;
}
_arealocmin = tempmin;
_arealocmax = tempmax;
return true;
}
public List getLobbyAreaIDList() {
List<String> list = new ArrayList();
for (int i = 0; i < _arealocmin.size(); i++) {
list.add(String.valueOf(i));
}
return list;
}
public Boolean addLobbyWall(Player player) {
String lobby = "lobbywall" + _walllocmin.size();
try {
LocalSession ls = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
Region reg = ls.getSelection(BukkitAdapter.adapt(player.getWorld()));
if(reg != null) {
_walllocmin.put(lobby, BukkitAdapter.adapt(player.getWorld(), reg.getMinimumPoint()));
_walllocmax.put(lobby, BukkitAdapter.adapt(player.getWorld(), reg.getMaximumPoint()));
player.sendMessage(ChatColor.YELLOW + "Lobby wall " + (_walllocmin.size() - 1) + " successfully created.");
initsign(); initsign();
return true; return true;
} }
@ -133,23 +204,42 @@ public class LobbyManager {
return false; return false;
} }
public List getLobbyIndexList() { public Boolean removeLobbyWall(String lobbywall) {
List<String> list = new ArrayList(); _walllocmin.remove(lobbywall);
_walllocmax.remove(lobbywall);
return new ArrayList<>(_locmin.keySet()); HashMap<String, Location> tempmin = new HashMap<>();
HashMap<String, Location> tempmax = new HashMap<>();
int i = 0;
for (String s : _walllocmin.keySet()) {
tempmin.put("lobbywall" + i, _walllocmin.get(s));
tempmax.put("lobbywall" + i, _walllocmax.get(s));
++i;
}
_walllocmin = tempmin;
_walllocmax = tempmax;
return true;
} }
public List getLobbyWallIDList() {
List<String> list = new ArrayList();
for (int i = 0; i < _walllocmin.size(); i++) {
list.add(String.valueOf(i));
}
return list;
}
public Boolean initsign() { public Boolean initsign() {
int index = 0; int index = 0;
int i = 0; int i = 0;
while(i < _locmin.size()) { while(i < _walllocmin.size()) {
int x; int x;
int y; int y;
Arena arena; Arena arena;
String lobby = "lobby" + i; String lobby = "lobbywall" + i;
Location min = _locmin.get(lobby); Location min = _walllocmin.get(lobby);
Location max = _locmax.get(lobby); Location max = _walllocmax.get(lobby);
int xmax = 0; int xmax = 0;
int xmin = 0; int xmin = 0;
int z = 0; int z = 0;
@ -201,31 +291,61 @@ public class LobbyManager {
return true; return true;
} }
public Boolean isinLobby(Location loc) { public Boolean isinLobbyArea(Location loc) {
int oui = _locmin.size(); int yes = _arealocmin.size();
int i = 0; int i = 0;
while (i < _locmin.size()) { while (i < _arealocmin.size()) {
String lobby = "lobby" + i; String lobby = "lobbyarea" + i;
Location min = _locmin.get(lobby); Location min = _arealocmin.get(lobby);
Location max = _locmax.get(lobby); Location max = _arealocmax.get(lobby);
if (min.getWorld() != loc.getWorld()) { if (min.getWorld() != loc.getWorld()) {
--oui; --yes;
} else if (loc.getX() < min.getX()) { } else if (loc.getX() < min.getX()) {
--oui; --yes;
} else if (loc.getX() > max.getX()) { } else if (loc.getX() > max.getX()) {
--oui; --yes;
} else if (loc.getZ() < min.getZ()) { } else if (loc.getZ() < min.getZ()) {
--oui; --yes;
} else if (loc.getZ() > max.getZ()) { } else if (loc.getZ() > max.getZ()) {
--oui; --yes;
} else if (loc.getY() < min.getY()) { } else if (loc.getY() < min.getY()) {
--oui; --yes;
} else if (loc.getY() > max.getY()) { } else if (loc.getY() > max.getY()) {
--oui; --yes;
} }
++i; ++i;
} }
if (oui <= 0) { if (yes <= 0) {
return false;
}
return true;
}
public Boolean isinLobbyWall(Location loc) {
int yes = _walllocmin.size();
int i = 0;
while (i < _walllocmin.size()) {
String lobby = "lobbywall" + i;
Location min = _walllocmin.get(lobby);
Location max = _walllocmax.get(lobby);
if (min.getWorld() != loc.getWorld()) {
--yes;
} else if (loc.getX() < min.getX()) {
--yes;
} else if (loc.getX() > max.getX()) {
--yes;
} else if (loc.getZ() < min.getZ()) {
--yes;
} else if (loc.getZ() > max.getZ()) {
--yes;
} else if (loc.getY() < min.getY()) {
--yes;
} else if (loc.getY() > max.getY()) {
--yes;
}
++i;
}
if (yes <= 0) {
return false; return false;
} }
return true; return true;

View File

@ -38,17 +38,11 @@ public final class ScoreB {
_objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots); _objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots);
_objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins); _objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins);
if (isScoreWorld(_player.getWorld().getName())) { displayScoreB( "");
_player.setScoreboard(_board);
} else if (!isScoreWorld(_player.getWorld().getName())) {
_player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
}
} }
public void updateScore() { public void updateScore() {
if (_Shots == _plugin._eco.getScore(_player, Score.Type.Shot) && _Deaths == _plugin._eco.getScore(_player, Score.Type.Death) && _Money == _plugin._eco.getPlayerMoney(_player)) { if( _Shots != _plugin._eco.getScore(_player, Score.Type.Shot) || _Deaths != _plugin._eco.getScore(_player, Score.Type.Death) || _Money != _plugin._eco.getPlayerMoney(_player)) {
return;
}
_Kills = _plugin._eco.getScore(_player, Score.Type.Kill); _Kills = _plugin._eco.getScore(_player, Score.Type.Kill);
_Deaths = _plugin._eco.getScore(_player, Score.Type.Death); _Deaths = _plugin._eco.getScore(_player, Score.Type.Death);
_Shots = _plugin._eco.getScore(_player, Score.Type.Shot); _Shots = _plugin._eco.getScore(_player, Score.Type.Shot);
@ -59,18 +53,37 @@ public final class ScoreB {
_objective.getScore(_plugin._trad.get("ScoreBoard.Deaths.name")).setScore(_Deaths); _objective.getScore(_plugin._trad.get("ScoreBoard.Deaths.name")).setScore(_Deaths);
_objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots); _objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots);
_objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins); _objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins);
if (isScoreWorld(_player.getWorld().getName())) {
_player.setScoreboard(_board);
} else {
_player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
} }
displayScoreB( "");
} }
public Scoreboard getScoreBoard() { public Scoreboard getScoreBoard() {
return _board; return _board;
} }
public void displayScoreB(String target_world) {
String world;
if( target_world != "") {
world = target_world;
} else {
world = _player.getWorld().getName();
}
if( isScoreWorld( world)) {
if( _plugin._lobby.isinLobbyArea(_player.getLocation())) {
_player.setScoreboard(_board);
} else {
_player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
}
} else {
_player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
}
return;
}
public Boolean isScoreWorld(String name) { public Boolean isScoreWorld(String name) {
return _plugin._ScoreWorlds.contains(name); return _plugin._ScoreWorlds.contains(name);
} }