This commit is contained in:
Norbi Peti 2016-08-22 16:17:09 +02:00
parent 994af42e54
commit f4eb32c35f
2 changed files with 34 additions and 50 deletions

View file

@ -39,9 +39,18 @@ public class ChatPlayer extends TBMCPlayer {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static ChatPlayer GetFromName(String name) { public static ChatPlayer GetFromName(String name) {
OfflinePlayer p = Bukkit.getOfflinePlayer(name); OfflinePlayer p = Bukkit.getOfflinePlayer(name);
if (p != null) if (p != null) {
return OnlinePlayers.get(p.getUniqueId()); if (!ChatPlayer.OnlinePlayers.containsKey(p.getUniqueId())) {
else TBMCPlayer player = TBMCPlayer.LoadPlayer(p);
if (player == null) {
Bukkit.getServer().getLogger()
.warning("Can't load player " + p.getUniqueId() + " - " + p.getName());
return null;
}
ChatPlayer.OnlinePlayers.get(player.UUID);
}
return ChatPlayer.OnlinePlayers.get(p.getUniqueId());
} else
return null; return null;
} }
@ -71,7 +80,8 @@ public class ChatPlayer extends TBMCPlayer {
// Flairs from Command Block The Button - Teams // Flairs from Command Block The Button - Teams
// PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add() // PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
Player p = Bukkit.getPlayer(UUID); Player p = Bukkit.getPlayer(UUID);
p.setPlayerListName(String.format("%s%s", p.getName(), GetFormattedFlair())); if (p != null)
p.setPlayerListName(String.format("%s%s", p.getName(), GetFormattedFlair()));
} }
public short GetFlairColor() { public short GetFlairColor() {

View file

@ -41,6 +41,7 @@ import au.com.mineauz.minigames.MinigamePlayer;
import au.com.mineauz.minigames.Minigames; import au.com.mineauz.minigames.Minigames;
import buttondevteam.core.TBMCPlayer; import buttondevteam.core.TBMCPlayer;
import buttondevteam.core.TBMCPlayerAddEvent; import buttondevteam.core.TBMCPlayerAddEvent;
import buttondevteam.core.TBMCPlayerJoinEvent;
import buttondevteam.core.TBMCPlayerLoadEvent; import buttondevteam.core.TBMCPlayerLoadEvent;
import buttondevteam.core.TBMCPlayerSaveEvent; import buttondevteam.core.TBMCPlayerSaveEvent;
import buttondevteam.thebuttonmcchat.commands.ucmds.KittycannonCommand; import buttondevteam.thebuttonmcchat.commands.ucmds.KittycannonCommand;
@ -63,12 +64,6 @@ public class PlayerListener implements Listener {
public static int LoginWarningCountTotal = 5; public static int LoginWarningCountTotal = 5;
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (essentials == null)
essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"));
}
@EventHandler @EventHandler
public void onPlayerLoad(TBMCPlayerLoadEvent e) { public void onPlayerLoad(TBMCPlayerLoadEvent e) {
YamlConfiguration yc = e.GetPlayerConfig(); YamlConfiguration yc = e.GetPlayerConfig();
@ -86,7 +81,13 @@ public class PlayerListener implements Listener {
cp.FDeaths = yc.getInt("fdeaths"); cp.FDeaths = yc.getInt("fdeaths");
cp.FlairCheater = yc.getBoolean("flaircheater"); cp.FlairCheater = yc.getBoolean("flaircheater");
ChatPlayer.OnlinePlayers.put(cp.UUID, cp); ChatPlayer.OnlinePlayers.put(cp.UUID, cp);
}
@EventHandler
public void onPlayerTBMCJoin(TBMCPlayerJoinEvent e) {
if (essentials == null)
essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"));
ChatPlayer cp = ChatPlayer.OnlinePlayers.get(e.GetPlayer().UUID);
Player p = Bukkit.getPlayer(cp.UUID); Player p = Bukkit.getPlayer(cp.UUID);
if (!cp.FlairState.equals(FlairStates.NoComment)) { if (!cp.FlairState.equals(FlairStates.NoComment)) {
@ -283,50 +284,29 @@ public class PlayerListener implements Listener {
} }
} }
/* /*
* boolean tping = false; boolean tphering = false; if * boolean tping = false; boolean tphering = false; if (cmd.equalsIgnoreCase("tpa") || cmd.equalsIgnoreCase("call") || cmd.equalsIgnoreCase("ecall") || cmd.equalsIgnoreCase("etpa") ||
* (cmd.equalsIgnoreCase("tpa") || cmd.equalsIgnoreCase("call") || * cmd.equalsIgnoreCase("tpask") || cmd.equalsIgnoreCase("etpask")) tping = true; if (cmd.equalsIgnoreCase("tpahere") || cmd.equalsIgnoreCase("etpahere")) tphering = true;
* cmd.equalsIgnoreCase("ecall") || cmd.equalsIgnoreCase("etpa") ||
* cmd.equalsIgnoreCase("tpask") || cmd.equalsIgnoreCase("etpask"))
* tping = true; if (cmd.equalsIgnoreCase("tpahere") ||
* cmd.equalsIgnoreCase("etpahere")) tphering = true;
*/ */
/* /*
* for (HelpTopic ht : PluginMain.Instance.getServer() * for (HelpTopic ht : PluginMain.Instance.getServer() .getHelpMap().getHelpTopics()) { if (ht.getName().equalsIgnoreCase("/tpa")) { tping = true; break; } }
* .getHelpMap().getHelpTopics()) { if
* (ht.getName().equalsIgnoreCase("/tpa")) { tping = true; break; }
* }
*/ */
/* /*
* for (HelpTopic ht : PluginMain.Instance.getServer() * for (HelpTopic ht : PluginMain.Instance.getServer() .getHelpMap().getHelpTopics()) { if (ht.getName().equalsIgnoreCase("/tpahere")) tphering = true; break; }
* .getHelpMap().getHelpTopics()) { if
* (ht.getName().equalsIgnoreCase("/tpahere")) tphering = true;
* break; }
*/ */
/* /*
* if (tphering) { Player target = * if (tphering) { Player target = Bukkit.getPlayer(event.getMessage() .substring(index + 1).split(" ")[0]); if (target != null && BoardColl.get()
* Bukkit.getPlayer(event.getMessage() .substring(index + * .getFactionAt(PS.valueOf(target.getLocation())) .getId().equalsIgnoreCase("tower")) { event.getPlayer() .sendMessage( "§cYou are not allowed to teleport players out from the Tower");
* 1).split(" ")[0]); if (target != null && BoardColl.get()
* .getFactionAt(PS.valueOf(target.getLocation()))
* .getId().equalsIgnoreCase("tower")) { event.getPlayer()
* .sendMessage(
* "§cYou are not allowed to teleport players out from the Tower");
* event.setCancelled(true); } } * event.setCancelled(true); } }
*/ */
/* /*
* for (String s : Bukkit.getCommandAliases().get("/tpahere")) { if * for (String s : Bukkit.getCommandAliases().get("/tpahere")) { if (cmd.equalsIgnoreCase(s)) { tping = true; break; } }
* (cmd.equalsIgnoreCase(s)) { tping = true; break; } }
*/ */
/* /*
* if (tping) { if ( // * if (tping) { if ( // MPlayer.get(event.getPlayer()).getFaction().getId ().equalsIgnoreCase("nomansland")) // { BoardColl .get() .getFactionAt(
* MPlayer.get(event.getPlayer()).getFaction().getId * PS.valueOf(event.getPlayer().getLocation())) .getId().equalsIgnoreCase("tower")) { event.getPlayer().sendMessage( "§cYou are not allowed to teleport to the Tower");
* ().equalsIgnoreCase("nomansland")) // { BoardColl .get()
* .getFactionAt( PS.valueOf(event.getPlayer().getLocation()))
* .getId().equalsIgnoreCase("tower")) {
* event.getPlayer().sendMessage(
* "§cYou are not allowed to teleport to the Tower");
* event.setCancelled(true); } } * event.setCancelled(true); } }
*/ */
} }
@ -488,9 +468,7 @@ public class PlayerListener implements Listener {
// System.out.println("B"); // System.out.println("B");
/* /*
* if (!e.getPlayer().isOp() && (!mp.isInMinigame() || * if (!e.getPlayer().isOp() && (!mp.isInMinigame() || mp.getMinigame().getName(false) .equalsIgnoreCase(Commands.KittyCannonMinigame))) return;
* mp.getMinigame().getName(false)
* .equalsIgnoreCase(Commands.KittyCannonMinigame))) return;
*/ */
if (!(mp.isInMinigame() if (!(mp.isInMinigame()
&& mp.getMinigame().getName(false).equalsIgnoreCase(KittycannonCommand.KittyCannonMinigame))) && mp.getMinigame().getName(false).equalsIgnoreCase(KittycannonCommand.KittyCannonMinigame)))
@ -558,20 +536,16 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerTeleport(PlayerTeleportEvent e) { public void onPlayerTeleport(PlayerTeleportEvent e) {
/* /*
* if (BoardColl.get().getFactionAt(PS.valueOf(e.getFrom())).getId() * if (BoardColl.get().getFactionAt(PS.valueOf(e.getFrom())).getId() .equalsIgnoreCase("nomansland") || BoardColl.get().getFactionAt(PS.valueOf(e.getTo())).getId()
* .equalsIgnoreCase("nomansland") ||
* BoardColl.get().getFactionAt(PS.valueOf(e.getTo())).getId()
* .equalsIgnoreCase("nomansland")) { * .equalsIgnoreCase("nomansland")) {
*/ */
// e.setTo(e.getFrom()); // e.setTo(e.getFrom());
// e.setCancelled(true); // Relative coordinates mess it up // e.setCancelled(true); // Relative coordinates mess it up
/* /*
* System.out.println("From: " + e.getFrom()); System.out.println("To: " * System.out.println("From: " + e.getFrom()); System.out.println("To: " + e.getTo()); System.out.println("Cause: "+e.getCause());
* + e.getTo()); System.out.println("Cause: "+e.getCause());
*/ */
/* /*
* e.getPlayer().sendMessage( * e.getPlayer().sendMessage( "§cYou are not allowed to teleport to/from No Mans Land."); }
* "§cYou are not allowed to teleport to/from No Mans Land."); }
*/ */
if (ChatPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) { if (ChatPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) {