Fixes and preparing to move things
This commit is contained in:
parent
f168931496
commit
ccdb53023e
4 changed files with 219 additions and 400 deletions
|
@ -24,23 +24,20 @@ public class ChatProcessing {
|
|||
// Returns e.setCancelled
|
||||
public static boolean ProcessChat(CommandSender sender, String message) {
|
||||
if (PlayerListener.essentials == null)
|
||||
PlayerListener.essentials = (Essentials) (Bukkit.getPluginManager()
|
||||
.getPlugin("Essentials"));
|
||||
PlayerListener.essentials = (Essentials) (Bukkit.getPluginManager().getPlugin("Essentials"));
|
||||
Player player = (sender instanceof Player ? (Player) sender : null);
|
||||
|
||||
if (player != null
|
||||
&& PlayerListener.essentials.getUser(player).isMuted())
|
||||
if (player != null && PlayerListener.essentials.getUser(player).isMuted())
|
||||
return true;
|
||||
|
||||
MaybeOfflinePlayer mp = null;
|
||||
TBMCPlayer mp = null;
|
||||
if (player != null) {
|
||||
mp = MaybeOfflinePlayer.AllPlayers.get(player.getUniqueId());
|
||||
mp = TBMCPlayer.AllPlayers.get(player.getUniqueId());
|
||||
if (message.equalsIgnoreCase("F")) {
|
||||
if (!mp.PressedF && PlayerListener.ActiveF) {
|
||||
PlayerListener.FCount++;
|
||||
mp.PressedF = true;
|
||||
if (PlayerListener.FPlayer != null
|
||||
&& PlayerListener.FPlayer.FCount < Integer.MAX_VALUE - 1)
|
||||
if (PlayerListener.FPlayer != null && PlayerListener.FPlayer.FCount < Integer.MAX_VALUE - 1)
|
||||
PlayerListener.FPlayer.FCount++;
|
||||
}
|
||||
}
|
||||
|
@ -59,8 +56,7 @@ public class ChatProcessing {
|
|||
}
|
||||
}
|
||||
}
|
||||
Channel currentchannel = (mp == null ? PlayerListener.ConsoleChannel
|
||||
: mp.CurrentChannel);
|
||||
Channel currentchannel = (mp == null ? PlayerListener.ConsoleChannel : mp.CurrentChannel);
|
||||
|
||||
ArrayList<ChatFormatter> formatters = new ArrayList<ChatFormatter>();
|
||||
|
||||
|
@ -73,8 +69,7 @@ public class ChatProcessing {
|
|||
colormode = ChatFormatter.Color.Green;
|
||||
// If greentext, ignore channel or player colors
|
||||
|
||||
formatters.add(new ChatFormatter(Pattern.compile(".+"), colormode, "",
|
||||
Priority.Low));
|
||||
formatters.add(new ChatFormatter(Pattern.compile(".+"), colormode, "", Priority.Low));
|
||||
|
||||
String formattedmessage = message;
|
||||
formattedmessage = formattedmessage.replace("\\", "\\\\");
|
||||
|
@ -83,20 +78,15 @@ public class ChatProcessing {
|
|||
|
||||
String suggestmsg = formattedmessage;
|
||||
|
||||
formatters
|
||||
.add(new ChatFormatter(
|
||||
Pattern.compile("(?<!\\\\)\\*\\*((?:\\\\\\*|[^\\*])+[^\\*\\\\])\\*\\*"),
|
||||
ChatFormatter.Format.Bold, "$1"));
|
||||
formatters.add(new ChatFormatter(Pattern
|
||||
.compile("(?<!\\\\)\\*((?:\\\\\\*|[^\\*])+[^\\*\\\\])\\*"),
|
||||
formatters.add(new ChatFormatter(Pattern.compile("(?<!\\\\)\\*\\*((?:\\\\\\*|[^\\*])+[^\\*\\\\])\\*\\*"),
|
||||
ChatFormatter.Format.Bold, "$1"));
|
||||
formatters.add(new ChatFormatter(Pattern.compile("(?<!\\\\)\\*((?:\\\\\\*|[^\\*])+[^\\*\\\\])\\*"),
|
||||
ChatFormatter.Format.Italic, "$1"));
|
||||
formatters.add(new ChatFormatter(Pattern
|
||||
.compile("(?<!\\\\)\\_((?:\\\\\\_|[^\\_])+[^\\_\\\\])\\_"),
|
||||
formatters.add(new ChatFormatter(Pattern.compile("(?<!\\\\)\\_((?:\\\\\\_|[^\\_])+[^\\_\\\\])\\_"),
|
||||
ChatFormatter.Format.Underlined, "$1"));
|
||||
|
||||
// URLs + Rainbow text
|
||||
formatters.add(new ChatFormatter(Pattern
|
||||
.compile("(http[\\w:/?=$\\-_.+!*'(),]+)"),
|
||||
formatters.add(new ChatFormatter(Pattern.compile("(http[\\w:/?=$\\-_.+!*'(),]+)"),
|
||||
ChatFormatter.Format.Underlined, "$1"));
|
||||
/*
|
||||
* formattedmessage = formattedmessage .replace( item, String.format(
|
||||
|
@ -113,112 +103,72 @@ public class ChatProcessing {
|
|||
sb.append(")");
|
||||
|
||||
formatters
|
||||
.add(new ChatFormatter(
|
||||
Pattern.compile(sb.toString()),
|
||||
ChatFormatter.Color.Aqua,
|
||||
(String match) -> {
|
||||
Player p = Bukkit.getPlayer(match);
|
||||
if (p == null) {
|
||||
System.out
|
||||
.println("Error: Can't find player "
|
||||
+ match
|
||||
+ " but it was reported as online.");
|
||||
return false;
|
||||
}
|
||||
MaybeOfflinePlayer mpp = MaybeOfflinePlayer
|
||||
.AddPlayerIfNeeded(p.getUniqueId());
|
||||
if (PlayerListener.NotificationSound == null)
|
||||
p.playSound(p.getLocation(),
|
||||
Sound.ENTITY_ARROW_HIT_PLAYER,
|
||||
1.0f, 0.5f); // TODO:
|
||||
// Airhorn
|
||||
else
|
||||
p.playSound(
|
||||
p.getLocation(),
|
||||
PlayerListener.NotificationSound,
|
||||
1.0f,
|
||||
(float) PlayerListener.NotificationPitch);
|
||||
String color = String.format("§%x",
|
||||
(mpp.GetFlairColor() == 0x00 ? 0xb
|
||||
: mpp.GetFlairColor()));
|
||||
return true; // TODO
|
||||
}, Priority.High));
|
||||
.add(new ChatFormatter(Pattern.compile(sb.toString()), ChatFormatter.Color.Aqua, (String match) -> {
|
||||
Player p = Bukkit.getPlayer(match);
|
||||
if (p == null) {
|
||||
System.out.println("Error: Can't find player " + match + " but it was reported as online.");
|
||||
return false;
|
||||
}
|
||||
TBMCPlayer mpp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
|
||||
if (PlayerListener.NotificationSound == null)
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO:
|
||||
// Airhorn
|
||||
else
|
||||
p.playSound(p.getLocation(), PlayerListener.NotificationSound, 1.0f,
|
||||
(float) PlayerListener.NotificationPitch);
|
||||
String color = String.format("§%x", (mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor()));
|
||||
return true; // TODO
|
||||
}, Priority.High));
|
||||
|
||||
formatters
|
||||
.add(new ChatFormatter(
|
||||
Pattern.compile(sb.toString()),
|
||||
ChatFormatter.Color.Aqua,
|
||||
(String match) -> {
|
||||
for (String n : PlayerListener.nicknames
|
||||
.keySet()) {
|
||||
String nwithoutformatting = new String(n);
|
||||
int index;
|
||||
while ((index = nwithoutformatting
|
||||
.indexOf("§k")) != -1)
|
||||
nwithoutformatting = nwithoutformatting.replace(
|
||||
"§k"
|
||||
+ nwithoutformatting
|
||||
.charAt(index + 2),
|
||||
""); // Support
|
||||
// for
|
||||
// one
|
||||
// random
|
||||
// char
|
||||
while ((index = nwithoutformatting
|
||||
.indexOf('§')) != -1)
|
||||
nwithoutformatting = nwithoutformatting.replace(
|
||||
"§"
|
||||
+ nwithoutformatting
|
||||
.charAt(index + 1),
|
||||
"");
|
||||
if (!match
|
||||
.equalsIgnoreCase(nwithoutformatting))
|
||||
return false; // TODO
|
||||
Player p = Bukkit
|
||||
.getPlayer(PlayerListener.nicknames
|
||||
.get(n));
|
||||
if (p == null) {
|
||||
System.out
|
||||
.println("Error: Can't find player "
|
||||
+ match
|
||||
+ " but it was reported as online.");
|
||||
return false;
|
||||
}
|
||||
MaybeOfflinePlayer mpp = MaybeOfflinePlayer
|
||||
.AddPlayerIfNeeded(p.getUniqueId());
|
||||
if (PlayerListener.NotificationSound == null)
|
||||
p.playSound(p.getLocation(),
|
||||
Sound.ENTITY_ARROW_HIT_PLAYER,
|
||||
1.0f, 0.5f); // TODO:
|
||||
// Airhorn
|
||||
else
|
||||
p.playSound(
|
||||
p.getLocation(),
|
||||
PlayerListener.NotificationSound,
|
||||
1.0f,
|
||||
(float) PlayerListener.NotificationPitch);
|
||||
String color = String.format("§%x", (mpp
|
||||
.GetFlairColor() == 0x00 ? 0xb
|
||||
: mpp.GetFlairColor()));
|
||||
}
|
||||
return true; // TODO
|
||||
}, Priority.High));
|
||||
.add(new ChatFormatter(Pattern.compile(sb.toString()), ChatFormatter.Color.Aqua, (String match) -> {
|
||||
for (String n : PlayerListener.nicknames.keySet()) {
|
||||
String nwithoutformatting = new String(n);
|
||||
int index;
|
||||
while ((index = nwithoutformatting.indexOf("§k")) != -1)
|
||||
nwithoutformatting = nwithoutformatting
|
||||
.replace("§k" + nwithoutformatting.charAt(index + 2), ""); // Support
|
||||
// for
|
||||
// one
|
||||
// random
|
||||
// char
|
||||
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
||||
nwithoutformatting = nwithoutformatting
|
||||
.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
||||
if (!match.equalsIgnoreCase(nwithoutformatting))
|
||||
return false; // TODO
|
||||
Player p = Bukkit.getPlayer(PlayerListener.nicknames.get(n));
|
||||
if (p == null) {
|
||||
System.out.println(
|
||||
"Error: Can't find player " + match + " but it was reported as online.");
|
||||
return false;
|
||||
}
|
||||
TBMCPlayer mpp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
|
||||
if (PlayerListener.NotificationSound == null)
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO:
|
||||
// Airhorn
|
||||
else
|
||||
p.playSound(p.getLocation(), PlayerListener.NotificationSound, 1.0f,
|
||||
(float) PlayerListener.NotificationPitch);
|
||||
String color = String.format("§%x",
|
||||
(mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor()));
|
||||
}
|
||||
return true; // TODO
|
||||
}, Priority.High));
|
||||
}
|
||||
|
||||
pingedconsole = false;
|
||||
formatters.add(new ChatFormatter(Pattern.compile("(?i)"
|
||||
+ Pattern.quote("@console")), ChatFormatter.Color.Aqua, (
|
||||
String match) -> {
|
||||
if (!pingedconsole) {
|
||||
System.out.print("\007");
|
||||
pingedconsole = true;
|
||||
}
|
||||
return true;
|
||||
}, Priority.High));
|
||||
formatters.add(new ChatFormatter(Pattern.compile("(?i)" + Pattern.quote("@console")), ChatFormatter.Color.Aqua,
|
||||
(String match) -> {
|
||||
if (!pingedconsole) {
|
||||
System.out.print("\007");
|
||||
pingedconsole = true;
|
||||
}
|
||||
return true;
|
||||
}, Priority.High));
|
||||
|
||||
formatters.add(new ChatFormatter(Pattern.compile("#(\\w+)"),
|
||||
ChatFormatter.Color.Blue, "https://twitter.com/hashtag/$1",
|
||||
Priority.High));
|
||||
formatters.add(new ChatFormatter(Pattern.compile("#(\\w+)"), ChatFormatter.Color.Blue,
|
||||
"https://twitter.com/hashtag/$1", Priority.High));
|
||||
|
||||
/*
|
||||
* if (!hadurls) {
|
||||
|
@ -234,34 +184,27 @@ public class ChatProcessing {
|
|||
|
||||
StringBuilder json = new StringBuilder();
|
||||
json.append("[\"\",");
|
||||
json.append(String
|
||||
.format("%s{\"text\":\"[%s]%s\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Copy message\",\"color\":\"blue\"}},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"%s\"}},",
|
||||
(mp != null && mp.ChatOnly ? "{\"text\":\"[C]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Chat only\",\"color\":\"blue\"}]}}},"
|
||||
// (mp != null && mp.ChatOnly ?
|
||||
// "{\"text:\":\"\"}," - I have been staring at
|
||||
// this one line for hours... Hours...
|
||||
: ""), currentchannel.DisplayName, (mp != null
|
||||
&& !mp.RPMode ? "[OOC]" : ""), suggestmsg));
|
||||
json.append(String.format(
|
||||
"%s{\"text\":\"[%s]%s\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Copy message\",\"color\":\"blue\"}},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"%s\"}},",
|
||||
(mp != null && mp.ChatOnly
|
||||
? "{\"text\":\"[C]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Chat only\",\"color\":\"blue\"}]}}},"
|
||||
// (mp != null && mp.ChatOnly ?
|
||||
// "{\"text:\":\"\"}," - I have been staring at
|
||||
// this one line for hours... Hours...
|
||||
: ""),
|
||||
currentchannel.DisplayName, (mp != null && !mp.RPMode ? "[OOC]" : ""), suggestmsg));
|
||||
json.append("{\"text\":\" <\"},");
|
||||
json.append(String.format("{\"text\":\"%s%s\",",
|
||||
(player != null ? player.getDisplayName() : sender.getName()),
|
||||
json.append(String.format("{\"text\":\"%s%s\",", (player != null ? player.getDisplayName() : sender.getName()),
|
||||
(mp != null ? mp.GetFormattedFlair() : "")));
|
||||
json.append("\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[");
|
||||
json.append(String.format("{\"text\":\"%s\n\",",
|
||||
(player != null ? player.getName() : sender.getName())));
|
||||
json.append(String
|
||||
.format("\"color\":\"aqua\"},{\"text\":\"World: %s\n\",\"color\":\"white\"},",
|
||||
(player != null ? player.getWorld().getName() : "-")));
|
||||
json.append(String
|
||||
.format("{\"text\":\"Respect: %s%s%s\",\"color\":\"white\"}]}}},",
|
||||
(mp != null ? (mp.FCount / (double) mp.FDeaths)
|
||||
: "Infinite"),
|
||||
(mp != null && mp.UserName != null
|
||||
&& !mp.UserName.isEmpty() ? "\nUserName: "
|
||||
+ mp.UserName : ""),
|
||||
(mp != null && mp.PlayerName.equals("\nAlpha_Bacca44") ? "\nDeaths: "
|
||||
+ PlayerListener.AlphaDeaths
|
||||
: "")));
|
||||
json.append(String.format("{\"text\":\"%s\n\",", (player != null ? player.getName() : sender.getName())));
|
||||
json.append(String.format("\"color\":\"aqua\"},{\"text\":\"World: %s\n\",\"color\":\"white\"},",
|
||||
(player != null ? player.getWorld().getName() : "-")));
|
||||
json.append(String.format("{\"text\":\"Respect: %s%s%s\",\"color\":\"white\"}]}}},",
|
||||
(mp != null ? (mp.FCount / (double) mp.FDeaths) : "Infinite"),
|
||||
(mp != null && mp.UserName != null && !mp.UserName.isEmpty() ? "\nUserName: " + mp.UserName : ""),
|
||||
(mp != null && mp.PlayerName.equals("\nAlpha_Bacca44") ? "\nDeaths: " + PlayerListener.AlphaDeaths
|
||||
: "")));
|
||||
json.append("{\"text\":\"> \",\"color\":\"white\"}");
|
||||
|
||||
/*
|
||||
|
@ -288,25 +231,21 @@ public class ChatProcessing {
|
|||
json.append("]");
|
||||
String jsonstr = json.toString();
|
||||
if (jsonstr.length() >= 32767) {
|
||||
sender.sendMessage("§cError: Message too large. Try shortening it, or remove hashtags and other formatting.");
|
||||
sender.sendMessage(
|
||||
"§cError: Message too large. Try shortening it, or remove hashtags and other formatting.");
|
||||
return true;
|
||||
}
|
||||
if (currentchannel.equals(Channel.TownChat)
|
||||
|| currentchannel.equals(Channel.NationChat)) {
|
||||
if (currentchannel.equals(Channel.TownChat) || currentchannel.equals(Channel.NationChat)) {
|
||||
if (player == null) {
|
||||
sender.sendMessage("§cYou are not a player!");
|
||||
return true;
|
||||
}
|
||||
for (Player p : PluginMain.GetPlayers()) {
|
||||
try {
|
||||
Resident resident = PluginMain.Instance.TU.getResidentMap()
|
||||
.get(p.getName().toLowerCase());
|
||||
if (!resident.getName().equals(player.getName())
|
||||
&& resident.getModes().contains("spy"))
|
||||
Bukkit.getPlayer(resident.getName()).sendMessage(
|
||||
String.format("[SPY-%s] - %s: %s",
|
||||
currentchannel.DisplayName,
|
||||
player.getDisplayName(), message));
|
||||
Resident resident = PluginMain.Instance.TU.getResidentMap().get(p.getName().toLowerCase());
|
||||
if (!resident.getName().equals(player.getName()) && resident.getModes().contains("spy"))
|
||||
Bukkit.getPlayer(resident.getName()).sendMessage(String.format("[SPY-%s] - %s: %s",
|
||||
currentchannel.DisplayName, player.getDisplayName(), message));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
@ -315,8 +254,7 @@ public class ChatProcessing {
|
|||
try {
|
||||
Town town = null;
|
||||
try {
|
||||
town = PluginMain.Instance.TU.getResidentMap()
|
||||
.get(player.getName().toLowerCase()).getTown();
|
||||
town = PluginMain.Instance.TU.getResidentMap().get(player.getName().toLowerCase()).getTown();
|
||||
} catch (NotRegisteredException e) {
|
||||
}
|
||||
if (town == null) {
|
||||
|
@ -331,9 +269,8 @@ public class ChatProcessing {
|
|||
Objective obj = PluginMain.SB.getObjective("town");
|
||||
for (Player p : PluginMain.GetPlayers()) {
|
||||
try {
|
||||
if (PluginMain.Instance.TU.getResidentMap()
|
||||
.get(p.getName().toLowerCase()).getTown()
|
||||
.getName().equals(town.getName()))
|
||||
if (PluginMain.Instance.TU.getResidentMap().get(p.getName().toLowerCase()).getTown().getName()
|
||||
.equals(town.getName()))
|
||||
obj.getScore(p.getName()).setScore(index);
|
||||
else
|
||||
obj.getScore(p.getName()).setScore(-1);
|
||||
|
@ -341,13 +278,8 @@ public class ChatProcessing {
|
|||
obj.getScore(p.getName()).setScore(-1);
|
||||
}
|
||||
}
|
||||
PluginMain.Instance
|
||||
.getServer()
|
||||
.dispatchCommand(
|
||||
PluginMain.Console,
|
||||
String.format(
|
||||
"tellraw @a[score_town=%d,score_town_min=%d] %s",
|
||||
index, index, json.toString()));
|
||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||
String.format("tellraw @a[score_town=%d,score_town_min=%d] %s", index, index, json.toString()));
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
|
||||
|
@ -361,8 +293,7 @@ public class ChatProcessing {
|
|||
try {
|
||||
Town town = null;
|
||||
try {
|
||||
town = PluginMain.Instance.TU.getResidentMap()
|
||||
.get(player.getName().toLowerCase()).getTown();
|
||||
town = PluginMain.Instance.TU.getResidentMap().get(player.getName().toLowerCase()).getTown();
|
||||
} catch (NotRegisteredException e) {
|
||||
}
|
||||
if (town == null) {
|
||||
|
@ -386,22 +317,16 @@ public class ChatProcessing {
|
|||
Objective obj = PluginMain.SB.getObjective("nation");
|
||||
for (Player p : PluginMain.GetPlayers()) {
|
||||
try {
|
||||
if (PluginMain.Instance.TU.getResidentMap()
|
||||
.get(p.getName().toLowerCase()).getTown()
|
||||
.getNation().getName().equals(nation.getName()))
|
||||
if (PluginMain.Instance.TU.getResidentMap().get(p.getName().toLowerCase()).getTown().getNation()
|
||||
.getName().equals(nation.getName()))
|
||||
obj.getScore(p.getName()).setScore(index);
|
||||
else
|
||||
obj.getScore(p.getName()).setScore(-1);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
PluginMain.Instance
|
||||
.getServer()
|
||||
.dispatchCommand(
|
||||
PluginMain.Console,
|
||||
String.format(
|
||||
"tellraw @a[score_nation=%d,score_nation_min=%d] %s",
|
||||
index, index, json.toString()));
|
||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console, String
|
||||
.format("tellraw @a[score_nation=%d,score_nation_min=%d] %s", index, index, json.toString()));
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
|
||||
|
@ -424,13 +349,8 @@ public class ChatProcessing {
|
|||
else
|
||||
obj.getScore(p.getName()).setScore(0);
|
||||
}
|
||||
PluginMain.Instance
|
||||
.getServer()
|
||||
.dispatchCommand(
|
||||
PluginMain.Console,
|
||||
String.format(
|
||||
"tellraw @a[score_admin=%d,score_admin_min=%d] %s",
|
||||
1, 1, json.toString()));
|
||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||
String.format("tellraw @a[score_admin=%d,score_admin_min=%d] %s", 1, 1, json.toString()));
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
|
||||
|
@ -442,8 +362,7 @@ public class ChatProcessing {
|
|||
}
|
||||
} else if (currentchannel.equals(Channel.ModChat)) {
|
||||
try {
|
||||
if (player != null
|
||||
&& !PluginMain.permission.playerInGroup(player, "mod")) {
|
||||
if (player != null && !PluginMain.permission.playerInGroup(player, "mod")) {
|
||||
player.sendMessage("§cYou need to be a mod to use this channel.");
|
||||
return true;
|
||||
}
|
||||
|
@ -454,11 +373,8 @@ public class ChatProcessing {
|
|||
else
|
||||
obj.getScore(p.getName()).setScore(0);
|
||||
}
|
||||
PluginMain.Instance.getServer().dispatchCommand(
|
||||
PluginMain.Console,
|
||||
String.format(
|
||||
"tellraw @a[score_mod=%d,score_mod_min=%d] %s",
|
||||
1, 1, json.toString()));
|
||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||
String.format("tellraw @a[score_mod=%d,score_mod_min=%d] %s", 1, 1, json.toString()));
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
|
||||
|
@ -471,16 +387,10 @@ public class ChatProcessing {
|
|||
} else
|
||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||
String.format("tellraw @a %s", json.toString()));
|
||||
PluginMain.Instance
|
||||
.getServer()
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
String.format("[%s] <%s%s> %s",
|
||||
currentchannel.DisplayName,
|
||||
(player != null ? player.getDisplayName()
|
||||
: sender.getName()),
|
||||
(mp != null ? mp.GetFormattedFlair() : ""),
|
||||
message));
|
||||
PluginMain.Instance.getServer().getConsoleSender()
|
||||
.sendMessage(String.format("[%s] <%s%s> %s", currentchannel.DisplayName,
|
||||
(player != null ? player.getDisplayName() : sender.getName()),
|
||||
(mp != null ? mp.GetFormattedFlair() : ""), message));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,11 +65,9 @@ public class PlayerListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (essentials == null)
|
||||
essentials = ((Essentials) Bukkit.getPluginManager().getPlugin(
|
||||
"Essentials"));
|
||||
essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"));
|
||||
final Player p = event.getPlayer();
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p
|
||||
.getUniqueId());
|
||||
TBMCPlayer mp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
|
||||
if (!mp.FlairState.equals(FlairStates.NoComment)) {
|
||||
PluginMain.ConfirmUserMessage(mp);
|
||||
Timer timer = new Timer();
|
||||
|
@ -83,7 +81,7 @@ public class PlayerListener implements Listener {
|
|||
timer.schedule(tt, 1000);
|
||||
} else {
|
||||
if (mp.GetFlairTime() == 0x00)
|
||||
mp.SetFlair(MaybeOfflinePlayer.FlairTimeNone);
|
||||
mp.SetFlair(TBMCPlayer.FlairTimeNone);
|
||||
Timer timer = new Timer();
|
||||
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
||||
@Override
|
||||
|
@ -103,15 +101,13 @@ public class PlayerListener implements Listener {
|
|||
* ispremium &&
|
||||
*/// Login stuff
|
||||
mp.FlairState.equals(FlairStates.NoComment)) {
|
||||
String json = String
|
||||
.format("[\"\",{\"text\":\"If you're from Reddit and you'd like your /r/TheButton flair displayed ingame, write your Minecraft name to \",\"color\":\"aqua\"},{\"text\":\"[this thread].\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread\",\"color\":\"aqua\"}]}}}]",
|
||||
PluginMain.FlairThreadURL);
|
||||
PluginMain.Instance.getServer().dispatchCommand(
|
||||
PluginMain.Console,
|
||||
String json = String.format(
|
||||
"[\"\",{\"text\":\"If you're from Reddit and you'd like your /r/TheButton flair displayed ingame, write your Minecraft name to \",\"color\":\"aqua\"},{\"text\":\"[this thread].\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread\",\"color\":\"aqua\"}]}}}]",
|
||||
PluginMain.FlairThreadURL);
|
||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||
"tellraw " + mp.PlayerName + " " + json);
|
||||
json = "[\"\",{\"text\":\"If you aren't from Reddit or don't want the flair, type /u ignore to prevent this message after next login.\",\"color\":\"aqua\"}]";
|
||||
PluginMain.Instance.getServer().dispatchCommand(
|
||||
PluginMain.Console,
|
||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||
"tellraw " + mp.PlayerName + " " + json);
|
||||
}
|
||||
}
|
||||
|
@ -218,15 +214,13 @@ public class PlayerListener implements Listener {
|
|||
public static boolean ShowRPTag = false;
|
||||
|
||||
public static Essentials essentials = null;
|
||||
final static String[] LaughStrings = new String[] { "xd", "lel", "lawl",
|
||||
"kek", "lmao", "hue", "hah" };
|
||||
final static String[] LaughStrings = new String[] { "xd", "lel", "lawl", "kek", "lmao", "hue", "hah" };
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
event.setCancelled(ChatProcessing.ProcessChat(event.getPlayer(),
|
||||
event.getMessage()));
|
||||
event.setCancelled(ChatProcessing.ProcessChat(event.getPlayer(), event.getMessage()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -234,53 +228,42 @@ public class PlayerListener implements Listener {
|
|||
if (event.getMessage().length() < 2)
|
||||
return;
|
||||
int index = event.getMessage().indexOf(" ");
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(event
|
||||
.getPlayer().getUniqueId());
|
||||
TBMCPlayer mp = TBMCPlayer.AllPlayers.get(event.getPlayer().getUniqueId());
|
||||
String cmd = "";
|
||||
if (index == -1) {
|
||||
cmd = event.getMessage().substring(1);
|
||||
// System.out.println("cmd: " + cmd);
|
||||
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
|
||||
mp.CurrentChannel = Channel.GlobalChat;
|
||||
event.getPlayer().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ mp.CurrentChannel.DisplayName);
|
||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
||||
event.setCancelled(true);
|
||||
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
|
||||
if (mp.CurrentChannel.equals(Channel.TownChat))
|
||||
mp.CurrentChannel = Channel.GlobalChat;
|
||||
else
|
||||
mp.CurrentChannel = Channel.TownChat;
|
||||
event.getPlayer().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ mp.CurrentChannel.DisplayName);
|
||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
||||
event.setCancelled(true);
|
||||
} else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) {
|
||||
if (mp.CurrentChannel.equals(Channel.NationChat))
|
||||
mp.CurrentChannel = Channel.GlobalChat;
|
||||
else
|
||||
mp.CurrentChannel = Channel.NationChat;
|
||||
event.getPlayer().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ mp.CurrentChannel.DisplayName);
|
||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
||||
event.setCancelled(true);
|
||||
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
|
||||
if (mp.CurrentChannel.equals(Channel.AdminChat))
|
||||
mp.CurrentChannel = Channel.GlobalChat;
|
||||
else
|
||||
mp.CurrentChannel = Channel.AdminChat;
|
||||
event.getPlayer().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ mp.CurrentChannel.DisplayName);
|
||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
||||
event.setCancelled(true);
|
||||
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
|
||||
if (mp.CurrentChannel.equals(Channel.ModChat))
|
||||
mp.CurrentChannel = Channel.GlobalChat;
|
||||
else
|
||||
mp.CurrentChannel = Channel.ModChat;
|
||||
event.getPlayer().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ mp.CurrentChannel.DisplayName);
|
||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
|
@ -317,20 +300,16 @@ public class PlayerListener implements Listener {
|
|||
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
||||
mp.CurrentChannel = c;
|
||||
} else if (cmd.equalsIgnoreCase("tpahere")) {
|
||||
Player player = Bukkit.getPlayer(event.getMessage().substring(
|
||||
index + 1));
|
||||
Player player = Bukkit.getPlayer(event.getMessage().substring(index + 1));
|
||||
if (player != null)
|
||||
player.sendMessage("§b"
|
||||
+ event.getPlayer().getDisplayName()
|
||||
+ " §bis in this world: "
|
||||
player.sendMessage("§b" + event.getPlayer().getDisplayName() + " §bis in this world: "
|
||||
+ event.getPlayer().getWorld().getName());
|
||||
} else if (cmd.equalsIgnoreCase("minecraft:me")) {
|
||||
if (!essentials.getUser(event.getPlayer()).isMuted()) {
|
||||
event.setCancelled(true);
|
||||
String message = event.getMessage().substring(index + 1);
|
||||
for (Player p : PluginMain.GetPlayers())
|
||||
p.sendMessage(String.format("* %s %s", event
|
||||
.getPlayer().getDisplayName(), message));
|
||||
p.sendMessage(String.format("* %s %s", event.getPlayer().getDisplayName(), message));
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@ -384,21 +363,16 @@ public class PlayerListener implements Listener {
|
|||
if (cmd.equalsIgnoreCase("sethome")) {
|
||||
TownyUniverse tu = PluginMain.Instance.TU;
|
||||
try {
|
||||
TownBlock tb = WorldCoord.parseWorldCoord(event.getPlayer())
|
||||
.getTownBlock();
|
||||
TownBlock tb = WorldCoord.parseWorldCoord(event.getPlayer()).getTownBlock();
|
||||
if (tb.hasTown()) {
|
||||
Town town = tb.getTown();
|
||||
if (town.hasNation()) {
|
||||
Resident res = tu.getResidentMap().get(
|
||||
event.getPlayer().getName());
|
||||
Resident res = tu.getResidentMap().get(event.getPlayer().getName());
|
||||
if (res != null && res.hasTown()) {
|
||||
Town town2 = res.getTown();
|
||||
if (town2.hasNation()) {
|
||||
if (town.getNation().getEnemies()
|
||||
.contains(town2.getNation())) {
|
||||
event.getPlayer()
|
||||
.sendMessage(
|
||||
"§cYou cannot set homes in enemy territory.");
|
||||
if (town.getNation().getEnemies().contains(town2.getNation())) {
|
||||
event.getPlayer().sendMessage("§cYou cannot set homes in enemy territory.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -409,31 +383,23 @@ public class PlayerListener implements Listener {
|
|||
} catch (NotRegisteredException e) {
|
||||
return;
|
||||
}
|
||||
} else if (cmd.equalsIgnoreCase("home") || cmd.equalsIgnoreCase("tpa")
|
||||
|| cmd.equalsIgnoreCase("tp")) {
|
||||
MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(event
|
||||
.getPlayer());
|
||||
String currentWorld = event.getPlayer().getLocation().getWorld()
|
||||
.getName();
|
||||
} else if (cmd.equalsIgnoreCase("home") || cmd.equalsIgnoreCase("tpa") || cmd.equalsIgnoreCase("tp")) {
|
||||
MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(event.getPlayer());
|
||||
String currentWorld = event.getPlayer().getLocation().getWorld().getName();
|
||||
Location currentLocation = event.getPlayer().getLocation();
|
||||
TownyUniverse universe = Towny.getPlugin(Towny.class)
|
||||
.getTownyUniverse();
|
||||
if (mgp.isInMinigame()
|
||||
&& mgp.getMinigame().getMechanic().getMechanic()
|
||||
.equals("creativeglobal")) {
|
||||
TownyUniverse universe = Towny.getPlugin(Towny.class).getTownyUniverse();
|
||||
if (mgp.isInMinigame() && mgp.getMinigame().getMechanic().getMechanic().equals("creativeglobal")) {
|
||||
mgp.setAllowTeleport(true);
|
||||
} else if (TownyUniverse.isWarTime()) {
|
||||
War war = universe.getWarEvent();
|
||||
if (war.isWarZone(new WorldCoord(currentWorld, currentLocation
|
||||
.getBlockX(), currentLocation.getBlockZ()))) {
|
||||
event.getPlayer().sendMessage(
|
||||
"§cError: You can't teleport out of a war zone!");
|
||||
if (war.isWarZone(
|
||||
new WorldCoord(currentWorld, currentLocation.getBlockX(), currentLocation.getBlockZ()))) {
|
||||
event.getPlayer().sendMessage("§cError: You can't teleport out of a war zone!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (cmd.toLowerCase().startsWith("un")) {
|
||||
for (HelpTopic ht : PluginMain.Instance.getServer().getHelpMap()
|
||||
.getHelpTopics()) {
|
||||
for (HelpTopic ht : PluginMain.Instance.getServer().getHelpMap().getHelpTopics()) {
|
||||
// event.getPlayer().sendMessage("HT: " + ht.getName());
|
||||
if (ht.getName().equalsIgnoreCase("/" + cmd))
|
||||
return;
|
||||
|
@ -441,27 +407,18 @@ public class PlayerListener implements Listener {
|
|||
if (PluginMain.permission.has(event.getPlayer(), "tbmc.admin")) {
|
||||
String s = cmd.substring(2);
|
||||
Player target = null;
|
||||
target = Bukkit.getPlayer(event.getMessage().substring(
|
||||
index + 1));
|
||||
target = Bukkit.getPlayer(event.getMessage().substring(index + 1));
|
||||
if (target == null) {
|
||||
event.getPlayer().sendMessage(
|
||||
"§cError: Player not found. (/un" + s
|
||||
+ " <player>)");
|
||||
event.getPlayer().sendMessage("§cError: Player not found. (/un" + s + " <player>)");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (target != null) {
|
||||
target.addPotionEffect(new PotionEffect(
|
||||
PotionEffectType.BLINDNESS, 10 * 20, 5, false,
|
||||
false));
|
||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
|
||||
for (Player pl : PluginMain.GetPlayers())
|
||||
pl.sendMessage(event.getPlayer().getDisplayName()
|
||||
+ " un" + s + "'d " + target.getDisplayName());
|
||||
Bukkit.getServer()
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
event.getPlayer().getDisplayName() + " un"
|
||||
+ s + "'d "
|
||||
+ target.getDisplayName());
|
||||
pl.sendMessage(
|
||||
event.getPlayer().getDisplayName() + " un" + s + "'d " + target.getDisplayName());
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(
|
||||
event.getPlayer().getDisplayName() + " un" + s + "'d " + target.getDisplayName());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -469,12 +426,9 @@ public class PlayerListener implements Listener {
|
|||
if (cmd.equalsIgnoreCase("f")) {
|
||||
String[] args = event.getMessage().substring(index + 1).split(" ");
|
||||
if (args.length > 1) {
|
||||
if (args[0].toLowerCase().equals("enemy")
|
||||
&& args[1].equalsIgnoreCase("newhaven")) {
|
||||
if (args[0].toLowerCase().equals("enemy") && args[1].equalsIgnoreCase("newhaven")) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer()
|
||||
.sendMessage(
|
||||
"§cYou are not allowed to set New Haven as your enemy faction.");
|
||||
event.getPlayer().sendMessage("§cYou are not allowed to set New Haven as your enemy faction.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -487,18 +441,15 @@ public class PlayerListener implements Listener {
|
|||
String nwithoutformatting = nickname;
|
||||
int index;
|
||||
while ((index = nwithoutformatting.indexOf("§k")) != -1)
|
||||
nwithoutformatting = nwithoutformatting.replace("§k"
|
||||
+ nwithoutformatting.charAt(index + 2), ""); // Support
|
||||
// for
|
||||
// one
|
||||
// random
|
||||
// char
|
||||
nwithoutformatting = nwithoutformatting.replace("§k" + nwithoutformatting.charAt(index + 2), ""); // Support
|
||||
// for
|
||||
// one
|
||||
// random
|
||||
// char
|
||||
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
||||
nwithoutformatting = nwithoutformatting.replace("§"
|
||||
+ nwithoutformatting.charAt(index + 1), "");
|
||||
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
||||
if (nwithoutformatting.startsWith(name)
|
||||
&& !nwithoutformatting.equals(Bukkit.getPlayer(
|
||||
nicknames.get(nickname)).getName()))
|
||||
&& !nwithoutformatting.equals(Bukkit.getPlayer(nicknames.get(nickname)).getName()))
|
||||
e.getTabCompletions().add(nwithoutformatting);
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +469,7 @@ public class PlayerListener implements Listener {
|
|||
|
||||
static boolean ActiveF = false;
|
||||
static int FCount = 0;
|
||||
static MaybeOfflinePlayer FPlayer = null;
|
||||
static TBMCPlayer FPlayer = null;
|
||||
private Timer Ftimer;
|
||||
public static int AlphaDeaths;
|
||||
|
||||
|
@ -526,8 +477,7 @@ public class PlayerListener implements Listener {
|
|||
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||
if (e.getEntity().getName().equals("Alpha_Bacca44"))
|
||||
AlphaDeaths++;
|
||||
MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e
|
||||
.getEntity());
|
||||
MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e.getEntity());
|
||||
if ((mgp != null && !mgp.isInMinigame()) && new Random().nextBoolean()) { // Don't
|
||||
// store
|
||||
// Fs
|
||||
|
@ -537,12 +487,10 @@ public class PlayerListener implements Listener {
|
|||
Ftimer.cancel();
|
||||
ActiveF = true;
|
||||
FCount = 0;
|
||||
FPlayer = MaybeOfflinePlayer.AllPlayers.get(e.getEntity()
|
||||
.getUniqueId());
|
||||
FPlayer = TBMCPlayer.AllPlayers.get(e.getEntity().getUniqueId());
|
||||
FPlayer.FDeaths++;
|
||||
for (Player p : PluginMain.GetPlayers()) {
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(p
|
||||
.getUniqueId());
|
||||
TBMCPlayer mp = TBMCPlayer.AllPlayers.get(p.getUniqueId());
|
||||
mp.PressedF = false;
|
||||
p.sendMessage("§bPress F to pay respects.§r");
|
||||
}
|
||||
|
@ -553,8 +501,7 @@ public class PlayerListener implements Listener {
|
|||
if (ActiveF) {
|
||||
ActiveF = false;
|
||||
for (Player p : PluginMain.GetPlayers()) {
|
||||
p.sendMessage("§b" + FCount + " "
|
||||
+ (FCount == 1 ? "person" : "people")
|
||||
p.sendMessage("§b" + FCount + " " + (FCount == 1 ? "person" : "people")
|
||||
+ " paid their respects.§r");
|
||||
}
|
||||
}
|
||||
|
@ -567,8 +514,7 @@ public class PlayerListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerItemPickup(PlayerPickupItemEvent e) {
|
||||
// System.out.println("A");
|
||||
MinigamePlayer mp = Minigames.plugin.pdata.getMinigamePlayer(e
|
||||
.getPlayer());
|
||||
MinigamePlayer mp = Minigames.plugin.pdata.getMinigamePlayer(e.getPlayer());
|
||||
// System.out.println("B");
|
||||
|
||||
/*
|
||||
|
@ -576,30 +522,25 @@ public class PlayerListener implements Listener {
|
|||
* mp.getMinigame().getName(false)
|
||||
* .equalsIgnoreCase(Commands.KittyCannonMinigame))) return;
|
||||
*/
|
||||
if (!(mp.isInMinigame() && mp.getMinigame().getName(false)
|
||||
.equalsIgnoreCase(KittycannonCommand.KittyCannonMinigame)))
|
||||
if (!(mp.isInMinigame()
|
||||
&& mp.getMinigame().getName(false).equalsIgnoreCase(KittycannonCommand.KittyCannonMinigame)))
|
||||
return;
|
||||
// System.out.println("C");
|
||||
ItemStack item = e.getItem().getItemStack();
|
||||
if (!item.getType().equals(Material.SKULL_ITEM)
|
||||
&& !item.getType().equals(Material.SKULL))
|
||||
if (!item.getType().equals(Material.SKULL_ITEM) && !item.getType().equals(Material.SKULL))
|
||||
return;
|
||||
// System.out.println("D");
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
if (!meta.getDisplayName().equals("§rOcelot Head")
|
||||
|| !meta.getOwner().equals("MHF_Ocelot"))
|
||||
if (!meta.getDisplayName().equals("§rOcelot Head") || !meta.getOwner().equals("MHF_Ocelot"))
|
||||
return;
|
||||
// System.out.println("E");
|
||||
if (meta.getLore() == null || meta.getLore().size() == 0)
|
||||
return;
|
||||
// System.out.println("F");
|
||||
ItemStack hat = e.getPlayer().getInventory().getHelmet();
|
||||
if (!(hat != null
|
||||
&& (hat.getType().equals(Material.SKULL) || hat.getType()
|
||||
.equals(Material.SKULL_ITEM)) && ((SkullMeta) hat
|
||||
.getItemMeta()).getDisplayName().equals("§rWolf Head")))
|
||||
e.getPlayer().damage(1f * item.getAmount(),
|
||||
Bukkit.getPlayer(meta.getLore().get(0)));
|
||||
if (!(hat != null && (hat.getType().equals(Material.SKULL) || hat.getType().equals(Material.SKULL_ITEM))
|
||||
&& ((SkullMeta) hat.getItemMeta()).getDisplayName().equals("§rWolf Head")))
|
||||
e.getPlayer().damage(1f * item.getAmount(), Bukkit.getPlayer(meta.getLore().get(0)));
|
||||
e.getItem().remove();
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
@ -609,8 +550,7 @@ public class PlayerListener implements Listener {
|
|||
public void onVotifierEvent(VotifierEvent event) {
|
||||
Vote vote = event.getVote();
|
||||
System.out.println("Vote: " + vote);
|
||||
org.bukkit.OfflinePlayer op = Bukkit.getOfflinePlayer(vote
|
||||
.getUsername());
|
||||
org.bukkit.OfflinePlayer op = Bukkit.getOfflinePlayer(vote.getUsername());
|
||||
Player p = Bukkit.getPlayer(vote.getUsername());
|
||||
if (op != null) {
|
||||
PluginMain.economy.depositPlayer(op, 50.0);
|
||||
|
@ -623,29 +563,24 @@ public class PlayerListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
// minecraft:tp @a[x=190,y=-80,z=45,dx=5,dy=50,dz=5] 190 1 45
|
||||
if (e.getPlayer().getWorld().getName().equals("wilds")
|
||||
&& e.getTo().getBlockX() > 100 && e.getTo().getBlockX() < 250
|
||||
&& e.getTo().getBlockZ() > 0 && e.getTo().getBlockZ() < 200
|
||||
if (e.getPlayer().getWorld().getName().equals("wilds") && e.getTo().getBlockX() > 100
|
||||
&& e.getTo().getBlockX() < 250 && e.getTo().getBlockZ() > 0 && e.getTo().getBlockZ() < 200
|
||||
&& e.getTo().getBlockY() < -64) {
|
||||
final Player p = e.getPlayer();
|
||||
p.setVelocity(new Vector(0, 0, 0));
|
||||
p.setFallDistance(0);
|
||||
Bukkit.getServer()
|
||||
.getScheduler()
|
||||
.scheduleSyncDelayedTask(PluginMain.Instance,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
p.setVelocity(new Vector(0, 0, 0));
|
||||
p.setFallDistance(0);
|
||||
p.teleport(new Location(Bukkit
|
||||
.getWorld("wilds"), 190, 1, 50));
|
||||
p.setVelocity(new Vector(0, 0, 0));
|
||||
p.setFallDistance(0);
|
||||
}
|
||||
});
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(PluginMain.Instance, new Runnable() {
|
||||
public void run() {
|
||||
p.setVelocity(new Vector(0, 0, 0));
|
||||
p.setFallDistance(0);
|
||||
p.teleport(new Location(Bukkit.getWorld("wilds"), 190, 1, 50));
|
||||
p.setVelocity(new Vector(0, 0, 0));
|
||||
p.setFallDistance(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.GetFromPlayer(e.getPlayer());
|
||||
TBMCPlayer mp = TBMCPlayer.GetFromPlayer(e.getPlayer());
|
||||
if (mp.ChatOnly)
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
@ -669,32 +604,25 @@ public class PlayerListener implements Listener {
|
|||
* "§cYou are not allowed to teleport to/from No Mans Land."); }
|
||||
*/
|
||||
|
||||
if (MaybeOfflinePlayer.GetFromPlayer(e.getPlayer()).ChatOnly) {
|
||||
if (TBMCPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer()
|
||||
.sendMessage(
|
||||
"§cYou are not allowed to teleport while in chat-only mode.");
|
||||
e.getPlayer().sendMessage("§cYou are not allowed to teleport while in chat-only mode.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||
MinigamePlayer mp = Minigames.plugin.pdata.getMinigamePlayer(e
|
||||
.getPlayer());
|
||||
MinigamePlayer mp = Minigames.plugin.pdata.getMinigamePlayer(e.getPlayer());
|
||||
if (mp == null)
|
||||
return;
|
||||
if (mp.isInMinigame()
|
||||
&& mp.getMinigame().getName(false)
|
||||
.equalsIgnoreCase("twohundred")) {
|
||||
if (mp.isInMinigame() && mp.getMinigame().getName(false).equalsIgnoreCase("twohundred")) {
|
||||
Block block = e.getClickedBlock();
|
||||
if (block == null)
|
||||
return;
|
||||
if (block.getType() == Material.ENDER_CHEST) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage(
|
||||
"§You are not allowed to use enderchests here.");
|
||||
System.out.println(e.getPlayer().getName()
|
||||
+ " tried to use an enderchest in twohundred.");
|
||||
e.getPlayer().sendMessage("§You are not allowed to use enderchests here.");
|
||||
System.out.println(e.getPlayer().getName() + " tried to use an enderchest in twohundred.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -711,27 +639,21 @@ public class PlayerListener implements Listener {
|
|||
cmd = event.getCommand();
|
||||
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
|
||||
ConsoleChannel = Channel.GlobalChat;
|
||||
event.getSender().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ ConsoleChannel.DisplayName);
|
||||
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
|
||||
event.setCommand("dontrunthiscmd");
|
||||
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
|
||||
if (ConsoleChannel.equals(Channel.AdminChat))
|
||||
ConsoleChannel = Channel.GlobalChat;
|
||||
else
|
||||
ConsoleChannel = Channel.AdminChat;
|
||||
event.getSender().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ ConsoleChannel.DisplayName);
|
||||
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
|
||||
event.setCommand("dontrunthiscmd");
|
||||
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
|
||||
if (ConsoleChannel.equals(Channel.ModChat))
|
||||
ConsoleChannel = Channel.GlobalChat;
|
||||
else
|
||||
ConsoleChannel = Channel.ModChat;
|
||||
event.getSender().sendMessage(
|
||||
"§6You are now talking in: §b"
|
||||
+ ConsoleChannel.DisplayName);
|
||||
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
|
||||
event.setCommand("dontrunthiscmd");
|
||||
}
|
||||
} else {
|
||||
|
@ -739,48 +661,42 @@ public class PlayerListener implements Listener {
|
|||
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
|
||||
Channel c = ConsoleChannel;
|
||||
ConsoleChannel = Channel.GlobalChat;
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer()
|
||||
.getConsoleSender(),
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
|
||||
event.getCommand().substring(index + 1));
|
||||
ConsoleChannel = c;
|
||||
event.setCommand("dontrunthiscmd");
|
||||
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
|
||||
Channel c = ConsoleChannel;
|
||||
ConsoleChannel = Channel.TownChat;
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer()
|
||||
.getConsoleSender(),
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
|
||||
event.getCommand().substring(index + 1));
|
||||
ConsoleChannel = c;
|
||||
event.setCommand("dontrunthiscmd");
|
||||
} else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) {
|
||||
Channel c = ConsoleChannel;
|
||||
ConsoleChannel = Channel.NationChat;
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer()
|
||||
.getConsoleSender(),
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
|
||||
event.getCommand().substring(index + 1));
|
||||
ConsoleChannel = c;
|
||||
event.setCommand("dontrunthiscmd");
|
||||
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
|
||||
Channel c = ConsoleChannel;
|
||||
ConsoleChannel = Channel.AdminChat;
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer()
|
||||
.getConsoleSender(),
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
|
||||
event.getCommand().substring(index + 1));
|
||||
ConsoleChannel = c;
|
||||
event.setCommand("dontrunthiscmd");
|
||||
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
|
||||
Channel c = ConsoleChannel;
|
||||
ConsoleChannel = Channel.ModChat;
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer()
|
||||
.getConsoleSender(),
|
||||
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
|
||||
event.getCommand().substring(index + 1));
|
||||
ConsoleChannel = c;
|
||||
event.setCommand("dontrunthiscmd");
|
||||
}
|
||||
}
|
||||
if (cmd.toLowerCase().startsWith("un")) {
|
||||
for (HelpTopic ht : PluginMain.Instance.getServer().getHelpMap()
|
||||
.getHelpTopics()) {
|
||||
for (HelpTopic ht : PluginMain.Instance.getServer().getHelpMap().getHelpTopics()) {
|
||||
// event.getSender().sendMessage("HT: " + ht.getName());
|
||||
if (ht.getName().equalsIgnoreCase("/" + cmd))
|
||||
return;
|
||||
|
@ -789,21 +705,15 @@ public class PlayerListener implements Listener {
|
|||
Player target = null;
|
||||
target = Bukkit.getPlayer(event.getCommand().substring(index + 1));
|
||||
if (target == null) {
|
||||
event.getSender().sendMessage(
|
||||
"§cError: Player not found. (/un" + s + " <player>)");
|
||||
event.getSender().sendMessage("§cError: Player not found. (/un" + s + " <player>)");
|
||||
event.setCommand("dontrunthiscmd");
|
||||
}
|
||||
if (target != null) {
|
||||
target.addPotionEffect(new PotionEffect(
|
||||
PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
|
||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
|
||||
for (Player pl : PluginMain.GetPlayers())
|
||||
pl.sendMessage(event.getSender().getName() + " un" + s
|
||||
+ "'d " + target.getDisplayName());
|
||||
Bukkit.getServer()
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
event.getSender().getName() + " un" + s + "'d "
|
||||
+ target.getDisplayName());
|
||||
pl.sendMessage(event.getSender().getName() + " un" + s + "'d " + target.getDisplayName());
|
||||
Bukkit.getServer().getConsoleSender()
|
||||
.sendMessage(event.getSender().getName() + " un" + s + "'d " + target.getDisplayName());
|
||||
event.setCommand("dontrunthiscmd");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller;
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin.PlayerInfoCommand;
|
||||
|
@ -20,7 +22,7 @@ public class TBMCChatAPI {
|
|||
* @param cmd
|
||||
* The command to add
|
||||
*/
|
||||
public void AddCommand(Plugin plugin, TBMCCommandBase cmd) {
|
||||
public void AddCommand(JavaPlugin plugin, TBMCCommandBase cmd) {
|
||||
CommandCaller.AddCommand(plugin, cmd);
|
||||
}
|
||||
|
||||
|
@ -49,9 +51,4 @@ public class TBMCChatAPI {
|
|||
public void AddPlayerInfoForHover(TBMCPlayer player, String infoline) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public TBMCPlayer GetPlayer(Player player) //TODO: Move to the bucket
|
||||
{ //TODO: Enable offline playerinfo
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
|
@ -57,7 +59,7 @@ public class CommandCaller implements CommandExecutor {
|
|||
if (pc == null)
|
||||
new Exception("Can't find top-level command: " + c.GetCommandPath()).printStackTrace();
|
||||
else
|
||||
pc.setExecutor(cc);
|
||||
pc.setExecutor(instance);
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -67,15 +69,15 @@ public class CommandCaller implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
public static void AddCommand(Plugin plugin, TBMCCommandBase cmd) {
|
||||
public static void AddCommand(JavaPlugin plugin, TBMCCommandBase cmd) {
|
||||
if (instance == null)
|
||||
instance = new CommandCaller();
|
||||
commands.put(cmd.GetCommandPath(), cmd);
|
||||
if (!c.GetCommandPath().contains("/")) // Top-level command
|
||||
if (!cmd.GetCommandPath().contains("/")) // Top-level command
|
||||
{
|
||||
PluginCommand pc = plugin.getCommand(cmd.GetCommandPath());
|
||||
if (pc == null)
|
||||
new Exception("Can't find top-level command: " + c.GetCommandPath()).printStackTrace();
|
||||
new Exception("Can't find top-level command: " + cmd.GetCommandPath()).printStackTrace();
|
||||
else
|
||||
pc.setExecutor(instance);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue