Added /tableflip, /unflip, /chatonly and the ability to unlaugh the console
This commit is contained in:
parent
e8ebd8c41e
commit
53d8567148
7 changed files with 217 additions and 175 deletions
Binary file not shown.
13
plugin.yml
13
plugin.yml
|
@ -17,10 +17,17 @@ commands:
|
|||
description: Unlaugh the last laugh.
|
||||
mwiki:
|
||||
description: Search the wiki.
|
||||
usage: "&vUsage: /mwiki [query]&r"
|
||||
usage: "&cUsage: /mwiki [query]&r"
|
||||
dontrunthiscmd:
|
||||
warmode:
|
||||
description: Toggles war mode
|
||||
tableflip:
|
||||
description: Flip a table.
|
||||
usage: "&cUsage: /tableflip [message]&r"
|
||||
unflip:
|
||||
description: Unflip a flip.
|
||||
usage: "&cUsage: /unflip [message]&r"
|
||||
chatonly:
|
||||
description: Enable chat only mode. Useful for chat clients.
|
||||
usage: "&cUsage: /chatonly&r"
|
||||
author: NorbiPeti
|
||||
depend: [Essentials, Towny, Minigames, Votifier, Factions, WorldGuard, WorldEdit, ProtocolLib, FastLogin, Vault, AuthMe]
|
||||
permissions:
|
||||
|
|
|
@ -26,6 +26,11 @@ public class ChatProcessing {
|
|||
PlayerListener.essentials = (Essentials) (Bukkit.getPluginManager()
|
||||
.getPlugin("Essentials"));
|
||||
Player player = (sender instanceof Player ? (Player) sender : null);
|
||||
|
||||
if (player != null
|
||||
&& PlayerListener.essentials.getUser(player).isMuted())
|
||||
return true;
|
||||
|
||||
MaybeOfflinePlayer mp = null;
|
||||
if (player != null) {
|
||||
mp = MaybeOfflinePlayer.AllPlayers.get(player.getUniqueId());
|
||||
|
@ -41,16 +46,28 @@ public class ChatProcessing {
|
|||
}
|
||||
|
||||
String msg = message.toLowerCase();
|
||||
if (player != null && msg.contains("lol")) {
|
||||
Commands.Lastlol = MaybeOfflinePlayer.AllPlayers.get(player
|
||||
.getUniqueId());
|
||||
Commands.Lastlolornot = true;
|
||||
if (msg.contains("lol")) {
|
||||
if (player != null) {
|
||||
Commands.Lastlol = player;
|
||||
Commands.Lastlolornot = true;
|
||||
Commands.Lastlolconsole = false;
|
||||
} else {
|
||||
Commands.Lastlolornot = true;
|
||||
Commands.Lastlolconsole = true;
|
||||
Commands.Lastlol = null;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < PlayerListener.LaughStrings.length; i++) {
|
||||
if (msg.contains(PlayerListener.LaughStrings[i])) {
|
||||
Commands.Lastlol = MaybeOfflinePlayer.AllPlayers.get(player
|
||||
.getUniqueId());
|
||||
Commands.Lastlolornot = false;
|
||||
if (player != null) {
|
||||
Commands.Lastlol = player;
|
||||
Commands.Lastlolornot = false;
|
||||
Commands.Lastlolconsole = false;
|
||||
} else {
|
||||
Commands.Lastlolornot = false;
|
||||
Commands.Lastlolconsole = true;
|
||||
Commands.Lastlol = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +76,7 @@ public class ChatProcessing {
|
|||
: mp.CurrentChannel);
|
||||
|
||||
String colormode = currentchannel.Color;
|
||||
if (mp.OtherColorMode.length() > 0)
|
||||
if (mp != null && mp.OtherColorMode.length() > 0)
|
||||
colormode = mp.OtherColorMode;
|
||||
if (message.startsWith(">"))
|
||||
colormode = "green"; // If greentext, ignore channel or player
|
||||
|
@ -99,11 +116,7 @@ public class ChatProcessing {
|
|||
hadurls = true;
|
||||
} catch (MalformedURLException e) {
|
||||
}
|
||||
if (mp != null && mp.RainbowPresserColorMode) { // TODO:
|
||||
// Rainbow
|
||||
// mode
|
||||
// for
|
||||
// console
|
||||
if (mp != null && mp.RainbowPresserColorMode) {
|
||||
if (item.startsWith(RainbowPresserColors[rpc])) { // Prevent
|
||||
// words
|
||||
// being
|
||||
|
@ -196,16 +209,16 @@ public class ChatProcessing {
|
|||
}
|
||||
}
|
||||
|
||||
if (player != null
|
||||
&& PlayerListener.essentials.getUser(player).isMuted())
|
||||
return true;
|
||||
|
||||
StringBuilder json = new StringBuilder();
|
||||
json.append("[\"\",");
|
||||
json.append(String
|
||||
.format("{\"text\":\"[%s]%s\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Copy message\",\"color\":\"blue\"}},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"%s\"}},",
|
||||
currentchannel.DisplayName,
|
||||
(mp != null && !mp.RPMode ? "[OOC]" : ""), suggestmsg));
|
||||
.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()),
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package tk.sznp.thebuttonautoflair;
|
||||
|
||||
import me.steffansk1997.OreRegenerator.OreRegenerator;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
|
@ -19,10 +18,6 @@ import org.bukkit.potion.PotionEffectType;
|
|||
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
import au.com.mineauz.minigames.MinigamePlayer;
|
||||
import au.com.mineauz.minigames.Minigames;
|
||||
|
@ -37,8 +32,9 @@ import java.util.Timer;
|
|||
|
||||
public class Commands implements CommandExecutor {
|
||||
|
||||
public static MaybeOfflinePlayer Lastlol = null;
|
||||
public static Player Lastlol = null;
|
||||
public static boolean Lastlolornot;
|
||||
public static boolean Lastlolconsole;
|
||||
|
||||
// This method is called, when somebody uses our command
|
||||
@Override
|
||||
|
@ -55,9 +51,9 @@ public class Commands implements CommandExecutor {
|
|||
switch (args[0].toLowerCase()) {
|
||||
case "accept": {
|
||||
if (args.length < 2 && p.UserNames.size() > 1) {
|
||||
player.sendMessage("§9Multiple users commented your name. §bPlease pick one using /u accept <username>");
|
||||
player.sendMessage("§9Multiple users commented your name. §bPlease pick one using /u accept <username>");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("§6Usernames:");
|
||||
sb.append("§6Usernames:");
|
||||
for (String username : p.UserNames)
|
||||
sb.append(" ").append(username);
|
||||
player.sendMessage(sb.toString());
|
||||
|
@ -65,22 +61,22 @@ public class Commands implements CommandExecutor {
|
|||
}
|
||||
if (p.FlairState.equals(FlairStates.NoComment)
|
||||
|| p.UserNames.size() == 0) {
|
||||
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r");
|
||||
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r");
|
||||
return true;
|
||||
}
|
||||
if (args.length > 1 && !p.UserNames.contains(args[1])) {
|
||||
player.sendMessage("§cError: Unknown name: " + args[1]
|
||||
+ "§r");
|
||||
player.sendMessage("§cError: Unknown name: " + args[1]
|
||||
+ "§r");
|
||||
return true;
|
||||
}
|
||||
if (p.Working) {
|
||||
player.sendMessage("§cError: Something is already in progress.§r");
|
||||
player.sendMessage("§cError: Something is already in progress.§r");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((args.length > 1 ? args[1] : p.UserNames.get(0))
|
||||
.equals(p.UserName)) {
|
||||
player.sendMessage("§cYou already have this user's flair.§r");
|
||||
player.sendMessage("§cYou already have this user's flair.§r");
|
||||
return true;
|
||||
}
|
||||
if (args.length > 1)
|
||||
|
@ -88,7 +84,7 @@ public class Commands implements CommandExecutor {
|
|||
else
|
||||
p.UserName = p.UserNames.get(0);
|
||||
|
||||
player.sendMessage("§bObtaining flair...");
|
||||
player.sendMessage("§bObtaining flair...");
|
||||
p.Working = true;
|
||||
Timer timer = new Timer();
|
||||
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
||||
|
@ -113,7 +109,7 @@ public class Commands implements CommandExecutor {
|
|||
String flair = mp.GetFormattedFlair();
|
||||
mp.FlairState = FlairStates.Accepted;
|
||||
PluginMain.ConfirmUserMessage(mp);
|
||||
player.sendMessage("§bYour flair has been set:§r "
|
||||
player.sendMessage("§bYour flair has been set:§r "
|
||||
+ flair);
|
||||
mp.Working = false;
|
||||
}
|
||||
|
@ -124,7 +120,7 @@ public class Commands implements CommandExecutor {
|
|||
}
|
||||
case "ignore": {
|
||||
if (p.FlairState.equals(FlairStates.Accepted)) {
|
||||
player.sendMessage("§cSorry, but ignoring the flair is no longer possible. As with the original Button, you can't undo what already happened.");
|
||||
player.sendMessage("§cSorry, but ignoring the flair is no longer possible. As with the original Button, you can't undo what already happened.");
|
||||
return true;
|
||||
}
|
||||
if (p.FlairState.equals(FlairStates.Commented)) {
|
||||
|
@ -135,9 +131,9 @@ public class Commands implements CommandExecutor {
|
|||
p.FlairState = FlairStates.Ignored;
|
||||
p.SetFlairTime("");
|
||||
p.UserName = "";
|
||||
player.sendMessage("§bYou have removed your flair. You can still use /u accept to get one.§r");
|
||||
player.sendMessage("§bYou have removed your flair. You can still use /u accept to get one.§r");
|
||||
} else
|
||||
player.sendMessage("§cYou already removed your flair.§r");
|
||||
player.sendMessage("§cYou already removed your flair.§r");
|
||||
break;
|
||||
}
|
||||
case "admin": // 2015.08.09.
|
||||
|
@ -154,16 +150,16 @@ public class Commands implements CommandExecutor {
|
|||
break;
|
||||
case "name": {
|
||||
if (args.length == 1) {
|
||||
player.sendMessage("§cUsage: /u name <playername>§r");
|
||||
player.sendMessage("§cUsage: /u name <playername>§r");
|
||||
break;
|
||||
}
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer
|
||||
.GetFromName(args[1]);
|
||||
if (mp == null) {
|
||||
player.sendMessage("§cUnknown user: " + args[1]);
|
||||
player.sendMessage("§cUnknown user: " + args[1]);
|
||||
break;
|
||||
}
|
||||
player.sendMessage("§bUsername of " + args[1] + ": "
|
||||
player.sendMessage("§bUsername of " + args[1] + ": "
|
||||
+ mp.UserName);
|
||||
break;
|
||||
}
|
||||
|
@ -190,11 +186,11 @@ public class Commands implements CommandExecutor {
|
|||
p.RainbowPresserColorMode = !p.RainbowPresserColorMode;
|
||||
p.OtherColorMode = "";
|
||||
if (p.RainbowPresserColorMode)
|
||||
player.sendMessage("§eRainbow colors §aenabled.");
|
||||
player.sendMessage("§eRainbow colors §aenabled.");
|
||||
else
|
||||
player.sendMessage("§eRainbow colors §cdisabled.");
|
||||
player.sendMessage("§eRainbow colors §cdisabled.");
|
||||
} else {
|
||||
player.sendMessage("§cYou don't have permission for this command. Donate to get it!");
|
||||
player.sendMessage("§cYou don't have permission for this command. Donate to get it!");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
@ -203,12 +199,12 @@ public class Commands implements CommandExecutor {
|
|||
p.OtherColorMode = args[1];
|
||||
if (p.OtherColorMode.length() > 0)
|
||||
player.sendMessage(String.format(
|
||||
"§eMessage color set to %s",
|
||||
"§eMessage color set to %s",
|
||||
p.OtherColorMode));
|
||||
else
|
||||
player.sendMessage("§eMessage color reset.");
|
||||
player.sendMessage("§eMessage color reset.");
|
||||
} else {
|
||||
player.sendMessage("§cYou don't have permission for this command.");
|
||||
player.sendMessage("§cYou don't have permission for this command.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -234,31 +230,44 @@ public class Commands implements CommandExecutor {
|
|||
}
|
||||
case "unlaugh":
|
||||
case "unlol": {
|
||||
Player p = null;
|
||||
if (Lastlol != null
|
||||
&& (p = Bukkit.getPlayer(Lastlol.UUID)) != null) {
|
||||
p.addPotionEffect(new PotionEffect(
|
||||
if (Lastlol != null) {
|
||||
Lastlol.addPotionEffect(new PotionEffect(
|
||||
PotionEffectType.BLINDNESS, 10 * 20, 5, false,
|
||||
false));
|
||||
for (Player pl : PluginMain.GetPlayers())
|
||||
pl.sendMessage(player.getDisplayName()
|
||||
+ (Lastlolornot ? " unlolled " : " unlaughed ")
|
||||
+ p.getDisplayName());
|
||||
+ Lastlol.getDisplayName());
|
||||
Bukkit.getServer()
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
player.getDisplayName()
|
||||
+ (Lastlolornot ? " unlolled "
|
||||
: " unlaughed ")
|
||||
+ p.getDisplayName());
|
||||
+ Lastlol.getDisplayName());
|
||||
Lastlol = null;
|
||||
} else if (Lastlolconsole) {
|
||||
for (Player pl : PluginMain.GetPlayers())
|
||||
pl.sendMessage(player.getDisplayName()
|
||||
+ (Lastlolornot ? " unlolled " : " unlaughed ")
|
||||
+ Bukkit.getServer().getConsoleSender()
|
||||
.getName());
|
||||
Bukkit.getServer()
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
player.getDisplayName()
|
||||
+ (Lastlolornot ? " unlolled "
|
||||
: " unlaughed ")
|
||||
+ Bukkit.getServer()
|
||||
.getConsoleSender()
|
||||
.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "yeehaw": {
|
||||
for (Player p : PluginMain.GetPlayers()) {
|
||||
p.playSound(p.getLocation(), "tbmc.yeehaw", 1f, 1f);
|
||||
p.sendMessage("§b* " + p.getDisplayName() + " YEEHAWs.");
|
||||
p.sendMessage("§b* " + p.getDisplayName() + " YEEHAWs.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -266,25 +275,28 @@ public class Commands implements CommandExecutor {
|
|||
DoMWiki(player, args);
|
||||
return true;
|
||||
}
|
||||
case "warmode": {
|
||||
ApplicableRegionSet ars = ((WorldGuardPlugin) Bukkit
|
||||
.getPluginManager().getPlugin("WorldGuard"))
|
||||
.getRegionManager(player.getWorld())
|
||||
.getApplicableRegions(player.getLocation());
|
||||
for (ProtectedRegion pr : ars) {
|
||||
if (pr.getFlag(OreRegenerator.FLAG_REGENORES) == StateFlag.State.ALLOW) {
|
||||
pr.setFlag(OreRegenerator.FLAG_REGENORES,
|
||||
StateFlag.State.DENY);
|
||||
sender.sendMessage("§eWarmode §cdisabled §ein "
|
||||
+ pr.getId());
|
||||
} else {
|
||||
pr.setFlag(OreRegenerator.FLAG_REGENORES,
|
||||
StateFlag.State.ALLOW);
|
||||
sender.sendMessage("§eWarmode §aenabled §ein "
|
||||
+ pr.getId());
|
||||
}
|
||||
break;
|
||||
case "tableflip": {
|
||||
String msg = "(╯°□°)╯︵ ┻━┻";
|
||||
if (args.length > 0) {
|
||||
msg = args[0] + " " + msg;
|
||||
}
|
||||
player.chat(msg);
|
||||
return true;
|
||||
}
|
||||
case "unflip": {
|
||||
String msg = "┬─┬ ノ( ゜-゜ノ)";
|
||||
if (args.length > 0) {
|
||||
msg = args[0] + "" + msg;
|
||||
}
|
||||
player.chat(msg);
|
||||
return true;
|
||||
}
|
||||
case "chatonly": {
|
||||
MaybeOfflinePlayer p = MaybeOfflinePlayer.AllPlayers.get(player
|
||||
.getUniqueId());
|
||||
p.ChatOnly = true;
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
player.sendMessage("§bChat-only mode enabled. You are now invincible.");
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
|
@ -305,17 +317,15 @@ public class Commands implements CommandExecutor {
|
|||
switch (cmd.getName()) {
|
||||
case "unlaugh":
|
||||
case "unlol": {
|
||||
Player p = null;
|
||||
if (Lastlol != null
|
||||
&& (p = Bukkit.getPlayer(Lastlol.UUID)) != null) {
|
||||
p.addPotionEffect(new PotionEffect(
|
||||
if (Lastlol != null) {
|
||||
Lastlol.addPotionEffect(new PotionEffect(
|
||||
PotionEffectType.BLINDNESS, 10 * 20, 5, false,
|
||||
false));
|
||||
for (Player pl : PluginMain.GetPlayers())
|
||||
pl.sendMessage(Bukkit.getServer().getConsoleSender()
|
||||
.getName()
|
||||
+ (Lastlolornot ? " unlolled " : " unlaughed ")
|
||||
+ p.getDisplayName());
|
||||
+ Lastlol.getDisplayName());
|
||||
Bukkit.getServer()
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
|
@ -323,7 +333,7 @@ public class Commands implements CommandExecutor {
|
|||
.getName()
|
||||
+ (Lastlolornot ? " unlolled "
|
||||
: " unlaughed ")
|
||||
+ p.getDisplayName());
|
||||
+ Lastlol.getDisplayName());
|
||||
Lastlol = null;
|
||||
}
|
||||
return true;
|
||||
|
@ -336,7 +346,7 @@ public class Commands implements CommandExecutor {
|
|||
private static void DoReload(Player player) {
|
||||
try {
|
||||
PluginMain.Console
|
||||
.sendMessage("§6-- Reloading The Button Minecraft plugin...§r");
|
||||
.sendMessage("§6-- Reloading The Button Minecraft plugin...§r");
|
||||
PluginMain.LoadFiles(true); // 2015.08.09.
|
||||
for (Player p : PluginMain.GetPlayers()) {
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p
|
||||
|
@ -345,21 +355,21 @@ public class Commands implements CommandExecutor {
|
|||
|| mp.FlairState.equals(FlairStates.Commented)) {
|
||||
PluginMain.ConfirmUserMessage(mp);
|
||||
}
|
||||
String msg = "§bNote: The auto-flair plugin has been reloaded. You might need to wait 10s to have your flair.§r"; // 2015.08.09.
|
||||
String msg = "§bNote: The auto-flair plugin has been reloaded. You might need to wait 10s to have your flair.§r"; // 2015.08.09.
|
||||
p.sendMessage(msg); // 2015.08.09.
|
||||
}
|
||||
PluginMain.Console.sendMessage("§6-- Reloading done!§r");
|
||||
PluginMain.Console.sendMessage("§6-- Reloading done!§r");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error!\n" + e);
|
||||
if (player != null)
|
||||
player.sendMessage("§cAn error occured. See console for details.§r");
|
||||
player.sendMessage("§cAn error occured. See console for details.§r");
|
||||
PluginMain.LastException = e; // 2015.08.09.
|
||||
}
|
||||
}
|
||||
|
||||
private static Player ReloadPlayer; // 2015.08.09.
|
||||
|
||||
private static String DoAdminUsage = "§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair|updateplugin|togglerpshow|toggledebug|savepos|loadpos§r";
|
||||
private static String DoAdminUsage = "§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair|updateplugin|togglerpshow|toggledebug|savepos|loadpos§r";
|
||||
|
||||
private static void DoAdmin(Player player, String[] args) {
|
||||
if (player == null || PluginMain.permission.has(player, "tbmc.admin")) {
|
||||
|
@ -374,7 +384,7 @@ public class Commands implements CommandExecutor {
|
|||
ReloadPlayer = player; // 2015.08.09.
|
||||
SendMessage(
|
||||
player,
|
||||
"§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
||||
"§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
||||
break;
|
||||
case "playerinfo":
|
||||
DoPlayerInfo(player, args);
|
||||
|
@ -387,12 +397,12 @@ public class Commands implements CommandExecutor {
|
|||
DoReload(player); // 2015.08.09.
|
||||
else
|
||||
SendMessage(player,
|
||||
"§cYou need to do /u admin reload first.§r");
|
||||
"§cYou need to do /u admin reload first.§r");
|
||||
break;
|
||||
case "save":
|
||||
PluginMain.SaveFiles(); // 2015.08.09.
|
||||
SendMessage(player,
|
||||
"§bSaved files. Now you can edit them and reload if you want.§r");
|
||||
"§bSaved files. Now you can edit them and reload if you want.§r");
|
||||
break;
|
||||
case "setflair":
|
||||
DoSetFlair(player, args);
|
||||
|
@ -423,19 +433,19 @@ public class Commands implements CommandExecutor {
|
|||
return;
|
||||
}
|
||||
} else
|
||||
player.sendMessage("§cYou don't have permission to use this command.§r");
|
||||
player.sendMessage("§cYou don't have permission to use this command.§r");
|
||||
}
|
||||
|
||||
private static void DoPlayerInfo(Player player, String[] args) { // 2015.08.09.
|
||||
// args[0] is "admin" - args[1] is "playerinfo"
|
||||
if (args.length == 2) {
|
||||
String message = "§cUsage: /u admin playerinfo <player>§r";
|
||||
String message = "§cUsage: /u admin playerinfo <player>§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
MaybeOfflinePlayer p = MaybeOfflinePlayer.GetFromName(args[2]);
|
||||
if (p == null) {
|
||||
String message = "§cPlayer not found: " + args[2] + "§r";
|
||||
String message = "§cPlayer not found: " + args[2] + "§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
|
@ -444,7 +454,7 @@ public class Commands implements CommandExecutor {
|
|||
SendMessage(player, "Username: " + p.UserName);
|
||||
SendMessage(player, "Flair state: " + p.FlairState);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("§6Usernames:");
|
||||
sb.append("§6Usernames:");
|
||||
for (String username : p.UserNames)
|
||||
sb.append(" ").append(username);
|
||||
SendMessage(player, sb.toString());
|
||||
|
@ -474,15 +484,15 @@ public class Commands implements CommandExecutor {
|
|||
targetplayer.FlairState = FlairStates.Accepted;
|
||||
targetplayer.UserName = "";
|
||||
SendMessage(player,
|
||||
"§bThe flair has been set. Player: "
|
||||
"§bThe flair has been set. Player: "
|
||||
+ targetplayer.PlayerName + " Flair: "
|
||||
+ targetplayer.GetFormattedFlair() + "§r");
|
||||
+ targetplayer.GetFormattedFlair() + "§r");
|
||||
} else {
|
||||
SendMessage(
|
||||
player,
|
||||
"§cSorry, but you can't change an existing flair. (Use -- as time to set non-presser or can't press)");
|
||||
"§cSorry, but you can't change an existing flair. (Use -- as time to set non-presser or can't press)");
|
||||
SendMessage(Bukkit.getPlayer(targetplayer.UUID),
|
||||
"§cYour flair cannot be changed.");
|
||||
"§cYour flair cannot be changed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -490,12 +500,12 @@ public class Commands implements CommandExecutor {
|
|||
// args[0] is "admin" - args[1] is "setflair"
|
||||
if (args.length < 4) {
|
||||
SendMessage(player,
|
||||
"§cUsage: /u admin setflair <playername> <flaircolor> [number]");
|
||||
"§cUsage: /u admin setflair <playername> <flaircolor> [number]");
|
||||
return;
|
||||
}
|
||||
Player p = Bukkit.getPlayer(args[2]);
|
||||
if (p == null) {
|
||||
SendMessage(player, "§cPLayer not found.&r");
|
||||
SendMessage(player, "§cPLayer not found.&r");
|
||||
return;
|
||||
}
|
||||
short flaircolor = 0x00;
|
||||
|
@ -503,7 +513,7 @@ public class Commands implements CommandExecutor {
|
|||
flaircolor = Short.parseShort(args[3], 16);
|
||||
} catch (Exception e) {
|
||||
SendMessage(player,
|
||||
"§cFlaircolor must be a hexadecimal number (don't include &).");
|
||||
"§cFlaircolor must be a hexadecimal number (don't include &).");
|
||||
return;
|
||||
}
|
||||
SetPlayerFlair(player,
|
||||
|
@ -535,14 +545,14 @@ public class Commands implements CommandExecutor {
|
|||
if (player == null || player.isOp()
|
||||
|| player.getName().equals("NorbiPeti")) {
|
||||
if (args.length == 1) {
|
||||
String message = "§cUsage: /u announce add|remove|settime|list|edit§r";
|
||||
String message = "§cUsage: /u announce add|remove|settime|list|edit§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "add":
|
||||
if (args.length < 3) {
|
||||
SendMessage(player, "§cUsage: /u announce add <message>");
|
||||
SendMessage(player, "§cUsage: /u announce add <message>");
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -551,13 +561,13 @@ public class Commands implements CommandExecutor {
|
|||
if (i != args.length - 1)
|
||||
sb.append(" ");
|
||||
}
|
||||
String finalmessage = sb.toString().replace('&', '§');
|
||||
String finalmessage = sb.toString().replace('&', '§');
|
||||
PluginMain.AnnounceMessages.add(finalmessage);
|
||||
SendMessage(player, "§bAnnouncement added.§r");
|
||||
SendMessage(player, "§bAnnouncement added.§r");
|
||||
break;
|
||||
case "remove":
|
||||
if (args.length < 3) {
|
||||
SendMessage(player, "§cUsage: /u announce remove <index>");
|
||||
SendMessage(player, "§cUsage: /u announce remove <index>");
|
||||
return;
|
||||
}
|
||||
PluginMain.AnnounceMessages.remove(Integer.parseInt(args[2]));
|
||||
|
@ -565,33 +575,33 @@ public class Commands implements CommandExecutor {
|
|||
case "settime":
|
||||
if (args.length < 3) {
|
||||
SendMessage(player,
|
||||
"§cUsage: /u announce settime <minutes>");
|
||||
"§cUsage: /u announce settime <minutes>");
|
||||
return;
|
||||
}
|
||||
PluginMain.AnnounceTime = Integer.parseInt(args[2]) * 60 * 1000;
|
||||
SendMessage(player, "Time set between announce messages");
|
||||
break;
|
||||
case "list":
|
||||
SendMessage(player, "§bList of announce messages:§r");
|
||||
SendMessage(player, "§bFormat: [index] message§r");
|
||||
SendMessage(player, "§bList of announce messages:§r");
|
||||
SendMessage(player, "§bFormat: [index] message§r");
|
||||
int i = 0;
|
||||
for (String message : PluginMain.AnnounceMessages)
|
||||
SendMessage(player, "[" + i++ + "] " + message);
|
||||
SendMessage(player,
|
||||
"§bCurrent wait time between announcements: "
|
||||
"§bCurrent wait time between announcements: "
|
||||
+ PluginMain.AnnounceTime / 60 / 1000
|
||||
+ " minute(s)§r");
|
||||
+ " minute(s)§r");
|
||||
break;
|
||||
case "edit":
|
||||
if (commandblock == null) {
|
||||
SendMessage(
|
||||
player,
|
||||
"§cError: This command can only be used from a command block. Use /u announce remove.");
|
||||
"§cError: This command can only be used from a command block. Use /u announce remove.");
|
||||
break;
|
||||
}
|
||||
if (args.length < 4) {
|
||||
commandblock
|
||||
.sendMessage("§cUsage: /u announce edit <index> <message>");
|
||||
.sendMessage("§cUsage: /u announce edit <index> <message>");
|
||||
return;
|
||||
}
|
||||
StringBuilder sb1 = new StringBuilder();
|
||||
|
@ -600,7 +610,7 @@ public class Commands implements CommandExecutor {
|
|||
if (i1 != args.length - 1)
|
||||
sb1.append(" ");
|
||||
}
|
||||
String finalmessage1 = sb1.toString().replace('&', '§');
|
||||
String finalmessage1 = sb1.toString().replace('&', '§');
|
||||
int index = Integer.parseInt(args[2]);
|
||||
if (index > 100)
|
||||
break;
|
||||
|
@ -611,7 +621,7 @@ public class Commands implements CommandExecutor {
|
|||
commandblock.sendMessage("Announcement edited.");
|
||||
break;
|
||||
default:
|
||||
String message = "§cUsage: /u announce add|remove|settime|list|edit§r";
|
||||
String message = "§cUsage: /u announce add|remove|settime|list|edit§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
|
@ -622,7 +632,7 @@ public class Commands implements CommandExecutor {
|
|||
private static void DoSaveLoadPos(Player player, String[] args) { // 2015.08.09.
|
||||
// args[0] is "admin" - args[1] is "savepos|loadpos"
|
||||
if (args.length == 2) {
|
||||
String message = "§cUsage: /u admin savepos|loadpos <player>§r";
|
||||
String message = "§cUsage: /u admin savepos|loadpos <player>§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
|
@ -632,14 +642,14 @@ public class Commands implements CommandExecutor {
|
|||
} catch (Exception e) {
|
||||
}
|
||||
if (!MaybeOfflinePlayer.AllPlayers.containsKey(p.getUniqueId())) {
|
||||
String message = "§cPlayer not found: " + args[2] + "§r";
|
||||
String message = "§cPlayer not found: " + args[2] + "§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(p
|
||||
.getUniqueId());
|
||||
if (p == null) {
|
||||
String message = "§cPlayer is not online: " + args[2] + "§r";
|
||||
String message = "§cPlayer is not online: " + args[2] + "§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
|
@ -649,7 +659,7 @@ public class Commands implements CommandExecutor {
|
|||
if (mp.SavedLocation != null)
|
||||
p.teleport(mp.SavedLocation);
|
||||
} else {
|
||||
String message = "§cUsage: /u admin savepos|loadpos <player>§r";
|
||||
String message = "§cUsage: /u admin savepos|loadpos <player>§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
|
@ -660,7 +670,7 @@ public class Commands implements CommandExecutor {
|
|||
private static void DoUpdateDynmap(Player player, String[] args) {
|
||||
// args[0] is "admin" - args[1] is "updatedynmap"
|
||||
if (args.length == 2) {
|
||||
String message = "§cUsage: /u admin updatedynmap <password>§r";
|
||||
String message = "§cUsage: /u admin updatedynmap <password>§r";
|
||||
SendMessage(player, message);
|
||||
return;
|
||||
}
|
||||
|
@ -673,14 +683,14 @@ public class Commands implements CommandExecutor {
|
|||
private static void DoKittyCannon(Player player, String[] args) {
|
||||
if (player == null) {
|
||||
SendMessage(player,
|
||||
"§cThis command can only be used by a player.§r");
|
||||
"§cThis command can only be used by a player.§r");
|
||||
return;
|
||||
}
|
||||
MinigamePlayer mp = Minigames.plugin.pdata.getMinigamePlayer(player);
|
||||
if (!(mp.isInMinigame() && mp.getMinigame().getName(false)
|
||||
.equalsIgnoreCase(Commands.KittyCannonMinigame))) {
|
||||
SendMessage(player,
|
||||
"§cYou can only use KittyCannon in it's minigame!");
|
||||
"§cYou can only use KittyCannon in it's minigame!");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -711,7 +721,7 @@ public class Commands implements CommandExecutor {
|
|||
final ItemStack head = new ItemStack(
|
||||
Material.SKULL_ITEM, 1, (short) 3, (byte) 3);
|
||||
SkullMeta im = (SkullMeta) head.getItemMeta();
|
||||
im.setDisplayName("§rOcelot Head");
|
||||
im.setDisplayName("§rOcelot Head");
|
||||
im.setOwner("MHF_Ocelot");
|
||||
im.setLore(lore);
|
||||
head.setItemMeta(im);
|
||||
|
@ -729,10 +739,10 @@ public class Commands implements CommandExecutor {
|
|||
query = query.trim();
|
||||
if (args.length == 0)
|
||||
SendMessage(player,
|
||||
"§bMinecraft Wiki link: http://minecraft.gamepedia.com/");
|
||||
"§bMinecraft Wiki link: http://minecraft.gamepedia.com/");
|
||||
else
|
||||
SendMessage(player,
|
||||
"§bMinecraft Wiki link: http://minecraft.gamepedia.com/index.php?search="
|
||||
"§bMinecraft Wiki link: http://minecraft.gamepedia.com/index.php?search="
|
||||
+ query + "&title=Special%3ASearch&go=Go");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class MaybeOfflinePlayer {
|
|||
public int FDeaths;
|
||||
public boolean RainbowPresserColorMode = false;
|
||||
public String OtherColorMode = "";
|
||||
public boolean ChatOnly = false;
|
||||
|
||||
public UUID UUID;
|
||||
|
||||
|
@ -132,4 +133,8 @@ public class MaybeOfflinePlayer {
|
|||
public String GetFlairTime() {
|
||||
return FlairTime;
|
||||
}
|
||||
|
||||
public static MaybeOfflinePlayer GetFromPlayer(Player p) {
|
||||
return MaybeOfflinePlayer.AllPlayers.get(p.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ import java.util.TimerTask;
|
|||
import java.util.UUID;
|
||||
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -149,31 +151,32 @@ public class PlayerListener implements Listener {
|
|||
PluginMain.permission.playerAdd(event.getPlayer(),
|
||||
"authme.player.*");
|
||||
}
|
||||
|
||||
if(ispremium)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskLater(PluginMain.Instance, new Runnable(){
|
||||
public void run()
|
||||
{
|
||||
AuthMe.getInstance().api.forceLogout(p);
|
||||
}
|
||||
}, 100);
|
||||
Bukkit.getScheduler().runTaskLater(PluginMain.Instance, new Runnable(){
|
||||
public void run()
|
||||
{
|
||||
AuthMe.getInstance().api.forceLogin(p);
|
||||
}
|
||||
}, 120);
|
||||
|
||||
if (ispremium) {
|
||||
Bukkit.getScheduler().runTaskLater(PluginMain.Instance,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
AuthMe.getInstance().api.forceLogout(p);
|
||||
}
|
||||
}, 100);
|
||||
Bukkit.getScheduler().runTaskLater(PluginMain.Instance,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
AuthMe.getInstance().api.forceLogin(p);
|
||||
}
|
||||
}, 120);
|
||||
} else if (!mp.FlairState.equals(FlairStates.Accepted)
|
||||
&& !mp.FlairState.equals(FlairStates.Commented)) {
|
||||
String json = String
|
||||
.format("[\"\",{\"text\":\"Welcome! You appear to log in from a non-premium account. Please verify your /r/thebutton flair to play, \",\"color\":\"aqua\"},{\"text\":\"[here].\",\"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);
|
||||
}
|
||||
else if(!mp.FlairState.equals(FlairStates.Accepted) && !mp.FlairState
|
||||
.equals(FlairStates.Commented))
|
||||
{
|
||||
String json = String
|
||||
.format("[\"\",{\"text\":\"Welcome! You appear to log in from a non-premium account. Please verify your /r/thebutton flair to play, \",\"color\":\"aqua\"},{\"text\":\"[here].\",\"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);
|
||||
|
||||
if (mp.ChatOnly) {
|
||||
mp.ChatOnly = false;
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,19 +405,19 @@ public class PlayerListener implements Listener {
|
|||
|| cmd.equalsIgnoreCase("tp")) {
|
||||
MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(event
|
||||
.getPlayer());
|
||||
String currentWorld = event.getPlayer().getLocation().getWorld().getName();
|
||||
String currentWorld = event.getPlayer().getLocation().getWorld()
|
||||
.getName();
|
||||
Location currentLocation = event.getPlayer().getLocation();
|
||||
TownyUniverse universe = Towny.getPlugin(Towny.class).getTownyUniverse();
|
||||
TownyUniverse universe = Towny.getPlugin(Towny.class)
|
||||
.getTownyUniverse();
|
||||
if (mgp.isInMinigame()
|
||||
&& mgp.getMinigame().getMechanic().getMechanic()
|
||||
.equals("creativeglobal")) {
|
||||
mgp.setAllowTeleport(true);
|
||||
}
|
||||
else if (TownyUniverse.isWarTime())
|
||||
{
|
||||
} else if (TownyUniverse.isWarTime()) {
|
||||
War war = universe.getWarEvent();
|
||||
if (war.isWarZone(new WorldCoord(currentWorld, currentLocation.getBlockX(), currentLocation.getBlockZ())))
|
||||
{
|
||||
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);
|
||||
|
@ -590,9 +593,7 @@ public class PlayerListener implements Listener {
|
|||
e.getPlayer().damage(1f * item.getAmount(),
|
||||
Bukkit.getPlayer(meta.getLore().get(0)));
|
||||
e.getItem().remove();
|
||||
// System.out.println("G");
|
||||
e.setCancelled(true); // TODO: /tableflip /unflip with spam detection
|
||||
// System.out.println("H");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -611,18 +612,6 @@ public class PlayerListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @EventHandler public void onPlayerLogin(PlayerLoginEvent e) {
|
||||
* System.out.println("Result:" + e.getResult());
|
||||
* System.out.println("Kick message: " + e.getKickMessage()); }
|
||||
*/
|
||||
|
||||
/*
|
||||
* @EventHandler public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e) {
|
||||
* System.out.println("Pre - LoginResult:" + e.getLoginResult());
|
||||
* System.out.println("Pre - Kick message: " + e.getKickMessage()); }
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
// minecraft:tp @a[x=190,y=-80,z=45,dx=5,dy=50,dz=5] 190 1 45
|
||||
|
@ -647,6 +636,10 @@ public class PlayerListener implements Listener {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
MaybeOfflinePlayer mp=MaybeOfflinePlayer.GetFromPlayer(e.getPlayer());
|
||||
if(mp.ChatOnly)
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
@ -665,6 +658,12 @@ public class PlayerListener implements Listener {
|
|||
e.getPlayer().sendMessage(
|
||||
"§cYou are not allowed to teleport to/from No Mans Land.");
|
||||
}
|
||||
|
||||
if(MaybeOfflinePlayer.GetFromPlayer(e.getPlayer()).ChatOnly)
|
||||
{
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage("§cYou are not allowed to teleport while in chat-only mode.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -94,10 +94,18 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
|||
this.getCommand("mwiki").setExecutor(comm);
|
||||
this.getCommand("mwiki").setUsage(
|
||||
this.getCommand("mwiki").getUsage().replace('&', '§'));
|
||||
this.getCommand("warmode").setExecutor(comm);
|
||||
Instance = this; // 2015.08.08.
|
||||
Console = this.getServer().getConsoleSender(); // 2015.08.12.
|
||||
LoadFiles(false); // 2015.08.09.
|
||||
this.getCommand("tableflip").setExecutor(comm);
|
||||
this.getCommand("tableflip").setUsage(
|
||||
this.getCommand("tableflip").getUsage().replace('&', '§'));
|
||||
this.getCommand("unflip").setExecutor(comm);
|
||||
this.getCommand("unflip").setUsage(
|
||||
this.getCommand("unflip").getUsage().replace('&', '§'));
|
||||
this.getCommand("chatonly").setExecutor(comm);
|
||||
this.getCommand("chatonly").setUsage(
|
||||
this.getCommand("chatonly").getUsage().replace('&', '§'));
|
||||
Instance = this;
|
||||
Console = this.getServer().getConsoleSender();
|
||||
LoadFiles(false);
|
||||
|
||||
SB = PluginMain.Instance.getServer().getScoreboardManager()
|
||||
.getMainScoreboard(); // Main can be detected with @a[score_...]
|
||||
|
|
Loading…
Reference in a new issue