Removed reload command and fixed errors
This commit is contained in:
parent
c810053558
commit
fe51c015db
12 changed files with 102 additions and 173 deletions
|
@ -14,7 +14,6 @@ import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
@ -68,9 +67,7 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLoad(TBMCPlayerLoadEvent e) {
|
public void onPlayerLoad(TBMCPlayerLoadEvent e) {
|
||||||
YamlConfiguration yc = e.GetPlayerConfig();
|
|
||||||
ChatPlayer cp = e.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
ChatPlayer cp = e.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
||||||
short tcp = (short) yc.getInt("flairtime");
|
|
||||||
cp.FlairUpdate();
|
cp.FlairUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +184,7 @@ public class PlayerListener implements Listener {
|
||||||
if (event.getMessage().length() < 2)
|
if (event.getMessage().length() < 2)
|
||||||
return;
|
return;
|
||||||
int index = event.getMessage().indexOf(" ");
|
int index = event.getMessage().indexOf(" ");
|
||||||
ChatPlayer mp = ChatPlayer.OnlinePlayers.get(event.getPlayer().getUniqueId());
|
ChatPlayer mp = TBMCPlayer.getPlayer(event.getPlayer()).asPluginPlayer(ChatPlayer.class);
|
||||||
String cmd = "";
|
String cmd = "";
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
cmd = event.getMessage().substring(1);
|
cmd = event.getMessage().substring(1);
|
||||||
|
@ -366,10 +363,10 @@ public class PlayerListener implements Listener {
|
||||||
Ftimer.cancel();
|
Ftimer.cancel();
|
||||||
ActiveF = true;
|
ActiveF = true;
|
||||||
FCount = 0;
|
FCount = 0;
|
||||||
FPlayer = ChatPlayer.OnlinePlayers.get(e.getEntity().getUniqueId());
|
FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId()).asPluginPlayer(ChatPlayer.class);
|
||||||
FPlayer.FDeaths++;
|
FPlayer.setFDeaths(FPlayer.getFDeaths() + 1);
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : PluginMain.GetPlayers()) {
|
||||||
ChatPlayer mp = ChatPlayer.OnlinePlayers.get(p.getUniqueId());
|
ChatPlayer mp = TBMCPlayer.getPlayerAs(p.getUniqueId(), ChatPlayer.class);
|
||||||
mp.PressedF = false;
|
mp.PressedF = false;
|
||||||
p.sendMessage("§bPress F to pay respects.§r");
|
p.sendMessage("§bPress F to pay respects.§r");
|
||||||
}
|
}
|
||||||
|
@ -430,14 +427,14 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent e) {
|
public void onPlayerMove(PlayerMoveEvent e) {
|
||||||
ChatPlayer mp = ChatPlayer.GetFromPlayer(e.getPlayer());
|
ChatPlayer mp = TBMCPlayer.getPlayerAs(e.getPlayer(), ChatPlayer.class);
|
||||||
if (mp.ChatOnly)
|
if (mp.ChatOnly)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent e) {
|
public void onPlayerTeleport(PlayerTeleportEvent e) {
|
||||||
if (ChatPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) {
|
if (TBMCPlayer.getPlayerAs(e.getPlayer(), ChatPlayer.class).ChatOnly) {
|
||||||
e.setCancelled(true);
|
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.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.htmlcleaner.TagNode;
|
||||||
import buttondevteam.chat.commands.CommandCaller;
|
import buttondevteam.chat.commands.CommandCaller;
|
||||||
import buttondevteam.chat.commands.YeehawCommand;
|
import buttondevteam.chat.commands.YeehawCommand;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
|
@ -70,7 +71,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
TBMCChatAPI.AddCommands(this, YeehawCommand.class);
|
TBMCChatAPI.AddCommands(this, YeehawCommand.class);
|
||||||
Console = this.getServer().getConsoleSender();
|
Console = this.getServer().getConsoleSender();
|
||||||
LoadFiles(false);
|
LoadFiles();
|
||||||
|
|
||||||
SB = PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard(); // Main can be detected with @a[score_...]
|
SB = PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard(); // Main can be detected with @a[score_...]
|
||||||
if (SB.getObjective("town") == null)
|
if (SB.getObjective("town") == null)
|
||||||
|
@ -138,19 +139,20 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
ign = ign.trim();
|
ign = ign.trim();
|
||||||
if (PlayersWithFlairs.contains(ign))
|
if (PlayersWithFlairs.contains(ign))
|
||||||
continue;
|
continue;
|
||||||
ChatPlayer mp = ChatPlayer.getFromName(ign); // Loads player file
|
try (ChatPlayer mp = TBMCPlayer.getFromName(ign).asPluginPlayer(ChatPlayer.class)) { // Loads player file
|
||||||
if (mp == null)
|
if (mp == null)
|
||||||
continue;
|
continue;
|
||||||
/*
|
/*
|
||||||
* if (!JoinedBefore(mp, 2015, 6, 5)) continue;
|
* if (!JoinedBefore(mp, 2015, 6, 5)) continue;
|
||||||
*/
|
*/
|
||||||
if (!mp.UserNames.contains(author))
|
if (!mp.getUserNames().contains(author))
|
||||||
mp.UserNames.add(author);
|
mp.getUserNames().add(author);
|
||||||
if (mp.FlairState.equals(FlairStates.NoComment)) {
|
if (mp.getFlairState().equals(FlairStates.NoComment)) {
|
||||||
mp.FlairState = FlairStates.Commented;
|
mp.setFlairState(FlairStates.Commented);
|
||||||
ConfirmUserMessage(mp);
|
ConfirmUserMessage(mp);
|
||||||
} else
|
} else
|
||||||
PlayersWithFlairs.add(ign);
|
PlayersWithFlairs.add(ign);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
|
@ -169,8 +171,9 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadFlair(ChatPlayer mp) throws MalformedURLException, IOException {
|
public void DownloadFlair(ChatPlayer mp) throws MalformedURLException, IOException {
|
||||||
String[] flairdata = TBMCCoreAPI.DownloadString("http://karmadecay.com/thebutton-data.php?users=" + mp.UserName)
|
String[] flairdata = TBMCCoreAPI
|
||||||
.replace("\"", "").split(":");
|
.DownloadString("http://karmadecay.com/thebutton-data.php?users=" + mp.getUserName()).replace("\"", "")
|
||||||
|
.split(":");
|
||||||
String flair;
|
String flair;
|
||||||
if (flairdata.length > 1)
|
if (flairdata.length > 1)
|
||||||
flair = flairdata[1];
|
flair = flairdata[1];
|
||||||
|
@ -181,14 +184,14 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
flairclass = flairdata[2];
|
flairclass = flairdata[2];
|
||||||
else
|
else
|
||||||
flairclass = "unknown";
|
flairclass = "unknown";
|
||||||
SetFlair(mp, flair, flairclass, mp.UserName);
|
SetFlair(mp, flair, flairclass, mp.getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Exception LastException;
|
public static Exception LastException;
|
||||||
|
|
||||||
private void SetFlair(ChatPlayer p, String text, String flairclass, String username) {
|
private void SetFlair(ChatPlayer p, String text, String flairclass, String username) {
|
||||||
p.UserName = username;
|
p.setUserName(username);
|
||||||
p.FlairState = FlairStates.Recognised;
|
p.setFlairState(FlairStates.Recognised);
|
||||||
switch (flairclass) {
|
switch (flairclass) {
|
||||||
case "cheater":
|
case "cheater":
|
||||||
p.SetFlair(Short.parseShort(text), true);
|
p.SetFlair(Short.parseShort(text), true);
|
||||||
|
@ -205,20 +208,20 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
p.SetFlair(ChatPlayer.FlairTimeCantPress);
|
p.SetFlair(ChatPlayer.FlairTimeCantPress);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
p.FlairState = FlairStates.Commented; // Flair unknown
|
p.setFlairState(FlairStates.Commented); // Flair unknown
|
||||||
p.SetFlair(ChatPlayer.FlairTimeNone);
|
p.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (CheckForJoinDate(p)) {
|
if (CheckForJoinDate(p)) {
|
||||||
p.FlairState = FlairStates.Commented; // Flair unknown
|
p.setFlairState(FlairStates.Commented); // Flair unknown
|
||||||
p.SetFlair(ChatPlayer.FlairTimeNone);
|
p.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
} else {
|
} else {
|
||||||
p.SetFlair(ChatPlayer.FlairTimeCantPress);
|
p.SetFlair(ChatPlayer.FlairTimeCantPress);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
p.FlairState = FlairStates.Commented; // Flair unknown
|
p.setFlairState(FlairStates.Commented); // Flair unknown
|
||||||
p.SetFlair(ChatPlayer.FlairTimeNone);
|
p.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -235,7 +238,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean JoinedBefore(ChatPlayer mp, int year, int month, int day) throws Exception {
|
public static boolean JoinedBefore(ChatPlayer mp, int year, int month, int day) throws Exception {
|
||||||
URL url = new URL("https://www.reddit.com/u/" + mp.UserName);
|
URL url = new URL("https://www.reddit.com/u/" + mp.getUserName());
|
||||||
URLConnection con = url.openConnection();
|
URLConnection con = url.openConnection();
|
||||||
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
||||||
InputStream in = con.getInputStream();
|
InputStream in = con.getInputStream();
|
||||||
|
@ -253,9 +256,9 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConfirmUserMessage(ChatPlayer mp) {
|
public static void ConfirmUserMessage(ChatPlayer mp) {
|
||||||
Player p = Bukkit.getPlayer(mp.UUID);
|
Player p = Bukkit.getPlayer(mp.getUuid());
|
||||||
if (mp.FlairState.equals(FlairStates.Commented) && p != null)
|
if (mp.getFlairState().equals(FlairStates.Commented) && p != null)
|
||||||
if (mp.UserNames.size() > 1)
|
if (mp.getUserNames().size() > 1)
|
||||||
p.sendMessage(
|
p.sendMessage(
|
||||||
"§9Multiple Reddit users commented your name. You can select with /u accept.§r §6Type /u accept or /u ignore§r");
|
"§9Multiple Reddit users commented your name. You can select with /u accept.§r §6Type /u accept or /u ignore§r");
|
||||||
else
|
else
|
||||||
|
@ -269,12 +272,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
public static ArrayList<String> AnnounceMessages = new ArrayList<>();
|
public static ArrayList<String> AnnounceMessages = new ArrayList<>();
|
||||||
public static int AnnounceTime = 15 * 60 * 1000;
|
public static int AnnounceTime = 15 * 60 * 1000;
|
||||||
|
|
||||||
public static void LoadFiles(boolean reload) {
|
public static void LoadFiles() {
|
||||||
if (reload) {
|
|
||||||
PluginMain.Instance.getLogger().info("Cleanup for reloading...");
|
|
||||||
ChatPlayer.OnlinePlayers.clear();
|
|
||||||
AnnounceMessages.clear();
|
|
||||||
}
|
|
||||||
PluginMain.Instance.getLogger().info("Loading files...");
|
PluginMain.Instance.getLogger().info("Loading files...");
|
||||||
try {
|
try {
|
||||||
File file = new File("TBMC/chatsettings.yml");
|
File file = new File("TBMC/chatsettings.yml");
|
||||||
|
|
|
@ -5,25 +5,24 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import buttondevteam.chat.ChatPlayer;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
|
||||||
public final class ChatonlyCommand extends TBMCCommandBase {
|
public final class ChatonlyCommand extends TBMCCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
return new String[]{
|
return new String[] { "§6---- Chat-only mode ----", //
|
||||||
"§6---- Chat-only mode ----",
|
"This mode makes you invincible but unable to move, teleport or interact with the world in any way", //
|
||||||
"This mode makes you invincible but unable to move, teleport or interact with the world in any way",
|
"It was designed for chat clients", //
|
||||||
"It was designed for chat clients",
|
"Once enabled, the only way of disabling it is by relogging to the server" //
|
||||||
"Once enabled, the only way of disabling it is by relogging to the server"
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
Player player=(Player)sender;
|
Player player = (Player) sender;
|
||||||
ChatPlayer p = ChatPlayer.OnlinePlayers.get(player
|
ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class);
|
||||||
.getUniqueId());
|
|
||||||
p.ChatOnly = true;
|
p.ChatOnly = true;
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
player.sendMessage("§bChat-only mode enabled. You are now invincible.");
|
player.sendMessage("§bChat-only mode enabled. You are now invincible.");
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import buttondevteam.chat.ChatPlayer;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
|
||||||
public final class OOCCommand extends TBMCCommandBase {
|
public final class OOCCommand extends TBMCCommandBase {
|
||||||
|
@ -21,12 +22,13 @@ public final class OOCCommand extends TBMCCommandBase {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ChatPlayer.GetFromPlayer(player).RPMode = false;
|
final ChatPlayer cp = TBMCPlayer.getPlayerAs(player, ChatPlayer.class);
|
||||||
|
cp.RPMode = false;
|
||||||
String message = "";
|
String message = "";
|
||||||
for (String arg : args)
|
for (String arg : args)
|
||||||
message += arg + " ";
|
message += arg + " ";
|
||||||
player.chat(message.substring(0, message.length() - 1));
|
player.chat(message.substring(0, message.length() - 1));
|
||||||
ChatPlayer.GetFromPlayer(player).RPMode = true;
|
cp.RPMode = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,35 +9,36 @@ import buttondevteam.chat.ChatPlayer;
|
||||||
import buttondevteam.chat.FlairStates;
|
import buttondevteam.chat.FlairStates;
|
||||||
import buttondevteam.chat.PlayerJoinTimerTask;
|
import buttondevteam.chat.PlayerJoinTimerTask;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
|
||||||
public class AcceptCommand extends UCommandBase {
|
public class AcceptCommand extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
return new String[] { "§6---- Accept flair ----",
|
return new String[] { "§6---- Accept flair ----", //
|
||||||
"Accepts a flair from Reddit",
|
"Accepts a flair from Reddit", //
|
||||||
"Use /u accept <username> if you commented from multiple accounts" };
|
"Use /u accept <username> if you commented from multiple accounts" //
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
ChatPlayer p = ChatPlayer.GetFromPlayer(player);
|
ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class);
|
||||||
if (args.length < 1 && p.UserNames.size() > 1) {
|
if (args.length < 1 && p.getUserNames().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();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("§6Usernames:");
|
sb.append("§6Usernames:");
|
||||||
for (String username : p.UserNames)
|
for (String username : p.getUserNames())
|
||||||
sb.append(" ").append(username);
|
sb.append(" ").append(username);
|
||||||
player.sendMessage(sb.toString());
|
player.sendMessage(sb.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (p.FlairState.equals(FlairStates.NoComment)
|
if (p.getFlairState().equals(FlairStates.NoComment) || p.getUserNames().size() == 0) {
|
||||||
|| p.UserNames.size() == 0) {
|
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/ChromaGamers§r");
|
||||||
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length > 0 && !p.UserNames.contains(args[0])) {
|
if (args.length > 0 && !p.getUserNames().contains(args[0])) {
|
||||||
player.sendMessage("§cError: Unknown name: " + args[0] + "§r");
|
player.sendMessage("§cError: Unknown name: " + args[0] + "§r");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,14 +47,14 @@ public class AcceptCommand extends UCommandBase {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((args.length > 0 ? args[0] : p.UserNames.get(0)).equals(p.UserName)) {
|
if ((args.length > 0 ? args[0] : p.getUserNames().get(0)).equals(p.getUserName())) {
|
||||||
player.sendMessage("§cYou already have this user's flair.§r");
|
player.sendMessage("§cYou already have this user's flair.§r");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
p.UserName = args[0];
|
p.setUserName(args[0]);
|
||||||
else
|
else
|
||||||
p.UserName = p.UserNames.get(0);
|
p.setUserName(p.getUserNames().get(0));
|
||||||
|
|
||||||
player.sendMessage("§bObtaining flair...");
|
player.sendMessage("§bObtaining flair...");
|
||||||
p.Working = true;
|
p.Working = true;
|
||||||
|
@ -65,18 +66,20 @@ public class AcceptCommand extends UCommandBase {
|
||||||
PluginMain.Instance.DownloadFlair(mp);
|
PluginMain.Instance.DownloadFlair(mp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
player.sendMessage("Sorry, but an error occured while trying to get your flair. Please contact a mod.");
|
player.sendMessage(
|
||||||
|
"Sorry, but an error occured while trying to get your flair. Please contact a mod.");
|
||||||
mp.Working = false;
|
mp.Working = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mp.FlairState.equals(FlairStates.Commented)) {
|
if (mp.getFlairState().equals(FlairStates.Commented)) {
|
||||||
player.sendMessage("Sorry, but your flair isn't recorded. Please ask an admin to set it for you. Also, prepare a comment on /r/thebutton, if possible.");
|
player.sendMessage(
|
||||||
|
"Sorry, but your flair isn't recorded. Please ask an admin to set it for you. Also, prepare a comment on /r/thebutton, if possible.");
|
||||||
mp.Working = false;
|
mp.Working = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String flair = mp.GetFormattedFlair();
|
String flair = mp.GetFormattedFlair();
|
||||||
mp.FlairState = FlairStates.Accepted;
|
mp.setFlairState(FlairStates.Accepted);
|
||||||
PluginMain.ConfirmUserMessage(mp);
|
PluginMain.ConfirmUserMessage(mp);
|
||||||
player.sendMessage("§bYour flair has been set:§r " + flair);
|
player.sendMessage("§bYour flair has been set:§r " + flair);
|
||||||
mp.Working = false;
|
mp.Working = false;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||||
import buttondevteam.chat.ChatPlayer;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.chat.formatting.ChatFormatter;
|
import buttondevteam.chat.formatting.ChatFormatter;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
|
||||||
public class CCommand extends UCommandBase {
|
public class CCommand extends UCommandBase {
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ public class CCommand extends UCommandBase {
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
ChatPlayer p = ChatPlayer.GetFromPlayer(player);
|
ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class);
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
if (PluginMain.permission.has(player, "tbmc.rainbow")) {
|
if (PluginMain.permission.has(player, "tbmc.rainbow")) {
|
||||||
p.RainbowPresserColorMode = !p.RainbowPresserColorMode;
|
p.RainbowPresserColorMode = !p.RainbowPresserColorMode;
|
||||||
|
|
|
@ -5,13 +5,13 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import buttondevteam.chat.ChatPlayer;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
import buttondevteam.chat.FlairStates;
|
import buttondevteam.chat.FlairStates;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
|
||||||
public final class IgnoreCommand extends UCommandBase {
|
public final class IgnoreCommand extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
return new String[] {
|
return new String[] { "§6---- Ignore flair ----",
|
||||||
"§6---- Ignore flair ----",
|
|
||||||
"Stop the \"write your name in the thread\" message from showing up",
|
"Stop the \"write your name in the thread\" message from showing up",
|
||||||
"Use /u ignore <username> if you commented from multiple accounts" };
|
"Use /u ignore <username> if you commented from multiple accounts" };
|
||||||
}
|
}
|
||||||
|
@ -19,19 +19,19 @@ public final class IgnoreCommand extends UCommandBase {
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
ChatPlayer p = ChatPlayer.GetFromPlayer(player);
|
ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class);
|
||||||
if (p.FlairState.equals(FlairStates.Accepted)) {
|
if (p.getFlairState().equals(FlairStates.Accepted)) {
|
||||||
player.sendMessage("§cYou can only ignore the \"write your name in the thread\" message.");
|
player.sendMessage("§cYou can only ignore the \"write your name in the thread\" message.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (p.FlairState.equals(FlairStates.Commented)) {
|
if (p.getFlairState().equals(FlairStates.Commented)) {
|
||||||
player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you.");
|
player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!p.FlairState.equals(FlairStates.Ignored)) {
|
if (!p.getFlairState().equals(FlairStates.Ignored)) {
|
||||||
p.FlairState = FlairStates.Ignored;
|
p.setFlairState(FlairStates.Ignored);
|
||||||
p.SetFlair(ChatPlayer.FlairTimeNone);
|
p.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
p.UserName = "";
|
p.setUserName("");
|
||||||
player.sendMessage("§bYou have ignored the message.§r");
|
player.sendMessage("§bYou have ignored the message.§r");
|
||||||
} else
|
} else
|
||||||
player.sendMessage("§cYou already ignored the message.§r");
|
player.sendMessage("§cYou already ignored the message.§r");
|
||||||
|
|
|
@ -3,13 +3,13 @@ package buttondevteam.chat.commands.ucmds;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import buttondevteam.chat.ChatPlayer;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
|
||||||
public class NameCommand extends UCommandBase {
|
public class NameCommand extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
return new String[] {
|
return new String[] { "§6---- Get username ----",
|
||||||
"§6---- Get username ----",
|
|
||||||
"This command allows you to see the Reddit username of a player if they have one associated",
|
"This command allows you to see the Reddit username of a player if they have one associated",
|
||||||
"Usage: /u name <playername>" };
|
"Usage: /u name <playername>" };
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,12 @@ public class NameCommand extends UCommandBase {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ChatPlayer mp = ChatPlayer.getFromName(args[0]);
|
ChatPlayer mp = TBMCPlayer.getFromName(args[0]).asPluginPlayer(ChatPlayer.class);
|
||||||
if (mp == null) {
|
if (mp == null) {
|
||||||
sender.sendMessage("§cUnknown user: "
|
sender.sendMessage("§cUnknown user: " + args[0]);
|
||||||
+ args[0]);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.sendMessage("§bUsername of " + args[0] + ": " + mp.UserName);
|
sender.sendMessage("§bUsername of " + args[0] + ": " + mp.getUserName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
package buttondevteam.chat.commands.ucmds.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import buttondevteam.chat.ChatPlayer;
|
|
||||||
import buttondevteam.chat.PluginMain;
|
|
||||||
|
|
||||||
public class ConfirmCommand extends AdminCommandBase {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] GetHelpText(String alias) {
|
|
||||||
return new String[] { "§6--- Confirm reload ----", "Use this after using /u admin reload and /u admin save" };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
|
||||||
if (ReloadCommand.Reloader == sender) {
|
|
||||||
try {
|
|
||||||
if (sender != PluginMain.Console)
|
|
||||||
PluginMain.Console.sendMessage("§6-- Reloading The Button Minecraft plugin...§r");
|
|
||||||
sender.sendMessage("§6-- Reloading The Button Minecraft plugin...§r");
|
|
||||||
PluginMain.LoadFiles(true);
|
|
||||||
// TODO: Add players online
|
|
||||||
for (Player p : PluginMain.GetPlayers())
|
|
||||||
ChatPlayer.GetFromPlayer(p); // TODO: Reload other TBMC plugin data?
|
|
||||||
if (sender != PluginMain.Console)
|
|
||||||
PluginMain.Console.sendMessage("§6-- Reloading done!§r");
|
|
||||||
sender.sendMessage("§6-- Reloading done!§r");
|
|
||||||
ReloadCommand.Reloader = null;
|
|
||||||
} catch (Exception e) {
|
|
||||||
PluginMain.Instance.getLogger().warning("Error!\n" + e);
|
|
||||||
if (sender != PluginMain.Console)
|
|
||||||
sender.sendMessage("§cAn error occured. See console for details.§r");
|
|
||||||
PluginMain.LastException = e;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
sender.sendMessage("§cYou need to do /u admin reload first.§r");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetAdminCommandPath() {
|
|
||||||
return "confirm";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,6 +3,7 @@ package buttondevteam.chat.commands.ucmds.admin;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import buttondevteam.chat.ChatPlayer;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
|
||||||
public class PlayerInfoCommand extends AdminCommandBase {
|
public class PlayerInfoCommand extends AdminCommandBase {
|
||||||
|
|
||||||
|
@ -18,18 +19,24 @@ public class PlayerInfoCommand extends AdminCommandBase {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ChatPlayer p = ChatPlayer.getFromName(args[0]);
|
ChatPlayer p = TBMCPlayer.getFromName(args[0]).asPluginPlayer(ChatPlayer.class);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
sender.sendMessage("§cPlayer not found: " + args[0] + "§r");
|
sender.sendMessage("§cPlayer not found: " + args[0] + "§r");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("§6Usernames:");
|
sb.append("§6Usernames:");
|
||||||
for (String username : p.UserNames)
|
for (String username : p.getUserNames())
|
||||||
sb.append(" ").append(username);
|
sb.append(" ").append(username);
|
||||||
sender.sendMessage(new String[] { "Player name: " + p.PlayerName, "User flair: " + p.GetFormattedFlair(),
|
sender.sendMessage(new String[] { //
|
||||||
"Username: " + p.UserName, "Flair state: " + p.FlairState, sb.toString(), "FCount: " + p.FCount,
|
"Player name: " + p.getPlayerName(), //
|
||||||
"FDeaths: " + p.FDeaths });
|
"User flair: " + p.GetFormattedFlair(), //
|
||||||
|
"Username: " + p.getUserName(), //
|
||||||
|
"Flair state: " + p.getFlairState(), //
|
||||||
|
sb.toString(), //
|
||||||
|
"FCount: " + p.getFCount(), //
|
||||||
|
"FDeaths: " + p.getFDeaths() //
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
package buttondevteam.chat.commands.ucmds.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public final class ReloadCommand extends AdminCommandBase {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] GetHelpText(String alias) {
|
|
||||||
return new String[] { "§6---- Reload plugin ----", "This command allows you to reload the plugin's config",
|
|
||||||
"This isn't the same as reloading the server, and should not cause any issues with other plugins",
|
|
||||||
"Save the config by using /u admin save before you reload it",
|
|
||||||
"Because of this, you'll need to confirm the reload with /u admin confirm" };
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandSender Reloader;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
|
||||||
Reloader = sender;
|
|
||||||
sender.sendMessage(
|
|
||||||
"§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when ready.§r");
|
|
||||||
sender.sendMessage("§bNote that this command may not set players up correctly as of now.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetAdminCommandPath() {
|
|
||||||
return "reload";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import buttondevteam.chat.ChatPlayer;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
import buttondevteam.chat.FlairStates;
|
import buttondevteam.chat.FlairStates;
|
||||||
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
|
||||||
public class SetFlairCommand extends AdminCommandBase {
|
public class SetFlairCommand extends AdminCommandBase {
|
||||||
|
|
||||||
|
@ -52,18 +53,18 @@ public class SetFlairCommand extends AdminCommandBase {
|
||||||
sender.sendMessage("§cUnknown value for cheater parameter. Run without args to see usage.");
|
sender.sendMessage("§cUnknown value for cheater parameter. Run without args to see usage.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ChatPlayer mp = ChatPlayer.GetFromPlayer(p);
|
ChatPlayer mp = TBMCPlayer.getPlayerAs(p, ChatPlayer.class);
|
||||||
mp.SetFlair(flairtime, cheater);
|
mp.SetFlair(flairtime, cheater);
|
||||||
mp.FlairState = FlairStates.Accepted;
|
mp.setFlairState(FlairStates.Accepted);
|
||||||
if (args.length < 4)
|
if (args.length < 4)
|
||||||
mp.UserName = "";
|
mp.setUserName("");
|
||||||
else {
|
else {
|
||||||
mp.UserName = args[3];
|
mp.setUserName(args[3]);
|
||||||
if (!mp.UserNames.contains(args[3]))
|
if (!mp.getUserNames().contains(args[3]))
|
||||||
mp.UserNames.add(args[3]);
|
mp.getUserNames().add(args[3]);
|
||||||
}
|
}
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
"§bThe flair has been set. Player: " + mp.PlayerName + " Flair: " + mp.GetFormattedFlair() + "§r");
|
"§bThe flair has been set. Player: " + mp.getPlayerName() + " Flair: " + mp.GetFormattedFlair() + "§r");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue