Ran formatter
This commit is contained in:
parent
1f20c06e91
commit
becdd677d1
@ -11,30 +11,35 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
|
|
||||||
import com.nemez.cmdmgr.Command;
|
import com.nemez.cmdmgr.Command;
|
||||||
|
import com.redstoner.annotations.Version;
|
||||||
import com.redstoner.misc.JsonManager;
|
import com.redstoner.misc.JsonManager;
|
||||||
import com.redstoner.misc.Main;
|
import com.redstoner.misc.Main;
|
||||||
import com.redstoner.misc.Utils;
|
import com.redstoner.misc.Utils;
|
||||||
import com.redstoner.modules.Module;
|
import com.redstoner.modules.Module;
|
||||||
|
|
||||||
public class ClearOnJoin implements Module, Listener{
|
@Version(major = 1, minor = 0, revision = 0, compatible = 1)
|
||||||
|
public class ClearOnJoin implements Module, Listener
|
||||||
|
{
|
||||||
boolean enabled = false;
|
boolean enabled = false;
|
||||||
private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json");
|
private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json");
|
||||||
private JSONArray list;
|
private JSONArray list;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Command(hook = "clearonjoin")
|
@Command(hook = "clearonjoin")
|
||||||
public void clearOnJoin(CommandSender sender, String player) {
|
public void clearOnJoin(CommandSender sender, String player)
|
||||||
|
{
|
||||||
list.add("!" + player.toLowerCase());
|
list.add("!" + player.toLowerCase());
|
||||||
saveList();
|
saveList();
|
||||||
Utils.sendMessage(sender, null, player +"'s inventory will be cleared next time he joins.");
|
Utils.sendMessage(sender, null, player + "'s inventory will be cleared next time he joins.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Command(hook = "clearonjoinself")
|
@Command(hook = "clearonjoinself")
|
||||||
public void clearOnJoinSelf(CommandSender sender) {
|
public void clearOnJoinSelf(CommandSender sender)
|
||||||
|
{
|
||||||
String name = sender.getName().toLowerCase();
|
String name = sender.getName().toLowerCase();
|
||||||
if(list.contains(name)) {
|
if (list.contains(name))
|
||||||
|
{
|
||||||
list.remove(name);
|
list.remove(name);
|
||||||
Utils.sendMessage(sender, null, "Your inventory will no longer be cleared apon joining");
|
Utils.sendMessage(sender, null, "Your inventory will no longer be cleared apon joining");
|
||||||
saveList();
|
saveList();
|
||||||
@ -47,14 +52,16 @@ public class ClearOnJoin implements Module, Listener{
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void aponJoin(PlayerJoinEvent e)
|
public void aponJoin(PlayerJoinEvent e)
|
||||||
{
|
{
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
String playerName = player.getName().toLowerCase();
|
String playerName = player.getName().toLowerCase();
|
||||||
if(list.contains(playerName)) {
|
if (list.contains(playerName))
|
||||||
|
{
|
||||||
e.getPlayer().getInventory().clear();
|
e.getPlayer().getInventory().clear();
|
||||||
Utils.sendMessage(e.getPlayer(), null, "Inventory Cleared.");
|
Utils.sendMessage(e.getPlayer(), null, "Inventory Cleared.");
|
||||||
}
|
}
|
||||||
else if(list.contains("!" + playerName)){
|
else if (list.contains("!" + playerName))
|
||||||
|
{
|
||||||
e.getPlayer().getInventory().clear();
|
e.getPlayer().getInventory().clear();
|
||||||
list.remove("!" + playerName);
|
list.remove("!" + playerName);
|
||||||
saveList();
|
saveList();
|
||||||
@ -68,27 +75,32 @@ public class ClearOnJoin implements Module, Listener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable()
|
||||||
|
{
|
||||||
enabled = true;
|
enabled = true;
|
||||||
list = JsonManager.getArray(listLocation);
|
list = JsonManager.getArray(listLocation);
|
||||||
if (list == null) list = new JSONArray();
|
if (list == null)
|
||||||
|
list = new JSONArray();
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(this, Main.plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(this, Main.plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable()
|
||||||
|
{
|
||||||
saveList();
|
saveList();
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enabled() {
|
public boolean enabled()
|
||||||
|
{
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @noformat
|
||||||
@Override
|
@Override
|
||||||
public String getCommandString() {
|
public String getCommandString()
|
||||||
|
{
|
||||||
return "command clearonjoin {\n" +
|
return "command clearonjoin {\n" +
|
||||||
" [string:name] {\n" +
|
" [string:name] {\n" +
|
||||||
" help Clears that players inventory the nect time they join.;\n" +
|
" help Clears that players inventory the nect time they join.;\n" +
|
||||||
@ -102,5 +114,5 @@ public class ClearOnJoin implements Module, Listener{
|
|||||||
" }\n" +
|
" }\n" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
// @format
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user