diff options
author | kukelekuuk00 <kukelekuuk00@radthorne.info> | 2013-02-19 21:33:04 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-02-19 22:43:23 +0000 |
commit | fd36e064ab221d22ef334e30b753a2b77be43aff (patch) | |
tree | e1d89785cfcbf4878a3ee62caf1550b9072c9854 | |
parent | c6bdb15c69efd6c08ef97fb354e1e22bafd91fdb (diff) | |
download | Essentials-fd36e064ab221d22ef334e30b753a2b77be43aff.tar Essentials-fd36e064ab221d22ef334e30b753a2b77be43aff.tar.gz Essentials-fd36e064ab221d22ef334e30b753a2b77be43aff.tar.lz Essentials-fd36e064ab221d22ef334e30b753a2b77be43aff.tar.xz Essentials-fd36e064ab221d22ef334e30b753a2b77be43aff.zip |
Added /essentials cleanup <days> [money] [homes] [bans]
Delete userdata of players offline for over <days> and with less money than [money], less homes than [homes] and less bans than [bans].
-rw-r--r-- | Essentials/src/com/earth2me/essentials/UserData.java | 2 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandessentials.java | 165 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_cs.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_es.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_fi.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_it.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_pl.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_pt.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_se.properties | 2 |
15 files changed, 137 insertions, 56 deletions
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 13a8a9eb5..1769c0f03 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -631,7 +631,7 @@ public abstract class UserData extends PlayerExtension implements IConf public String getBanReason() { - return config.getString("ban.reason"); + return config.getString("ban.reason", ""); } public void setBanReason(String reason) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index 8598a31e9..6a3c9d28c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -2,13 +2,19 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; +import com.earth2me.essentials.UserMap; +import com.earth2me.essentials.Util; import com.earth2me.essentials.metrics.Metrics; +import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.bukkit.Instrument; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Note; import org.bukkit.Server; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; @@ -50,7 +56,12 @@ public class Commandessentials extends EssentialsCommand { run_optout(server, sender, commandLabel, args); } - else { + else if (args[0].equalsIgnoreCase("cleanup")) + { + run_cleanup(server, sender, commandLabel, args); + } + else + { run_reload(server, sender, commandLabel, args); } } @@ -100,51 +111,33 @@ public class Commandessentials extends EssentialsCommand private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - final Map<String, Byte> noteMap = new HashMap<String, Byte>(); - noteMap.put("1F#", (byte)0x0); - noteMap.put("1G", (byte)0x1); - noteMap.put("1G#", (byte)0x2); - noteMap.put("1A", (byte)0x3); - noteMap.put("1A#", (byte)0x4); - noteMap.put("1B", (byte)0x5); - noteMap.put("1C", (byte)0x6); - noteMap.put("1C#", (byte)0x7); - noteMap.put("1D", (byte)0x8); - noteMap.put("1D#", (byte)0x9); - noteMap.put("1E", (byte)0xA); - noteMap.put("1F", (byte)0xB); - noteMap.put("2F#", (byte)(0x0 + 0xC)); - noteMap.put("2G", (byte)(0x1 + 0xC)); - noteMap.put("2G#", (byte)(0x2 + 0xC)); - noteMap.put("2A", (byte)(0x3 + 0xC)); - noteMap.put("2A#", (byte)(0x4 + 0xC)); - noteMap.put("2B", (byte)(0x5 + 0xC)); - noteMap.put("2C", (byte)(0x6 + 0xC)); - noteMap.put("2C#", (byte)(0x7 + 0xC)); - noteMap.put("2D", (byte)(0x8 + 0xC)); - noteMap.put("2D#", (byte)(0x9 + 0xC)); - noteMap.put("2E", (byte)(0xA + 0xC)); - noteMap.put("2F", (byte)(0xB + 0xC)); - if (!noteBlocks.isEmpty()) - { - return; - } + final Map<String, Float> noteMap = new HashMap<String, Float>(); + noteMap.put("1F#", 0.5f); + noteMap.put("1G", 0.53f); + noteMap.put("1G#", 0.56f); + noteMap.put("1A", 0.6f); + noteMap.put("1A#", 0.63f); + noteMap.put("1B", 0.67f); + noteMap.put("1C", 0.7f); + noteMap.put("1C#", 0.76f); + noteMap.put("1D", 0.8f); + noteMap.put("1D#", 0.84f); + noteMap.put("1E", 0.9f); + noteMap.put("1F", 0.94f); + noteMap.put("2F#", 1.0f); + noteMap.put("2G", 1.06f); + noteMap.put("2G#", 1.12f); + noteMap.put("2A", 1.18f); + noteMap.put("2A#",1.26f); + noteMap.put("2B", 1.34f); + noteMap.put("2C", 1.42f); + noteMap.put("2C#", 1.5f); + noteMap.put("2D", 1.6f); + noteMap.put("2D#", 1.68f); + noteMap.put("2E", 1.78f); + noteMap.put("2F", 1.88f); final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C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,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,"; final String[] tune = tuneStr.split(","); - for (Player player : server.getOnlinePlayers()) - { - final Location loc = player.getLocation(); - loc.add(0, 3, 0); - while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0) - { - loc.add(0, 1, 0); - } - if (loc.getBlock().getTypeId() == 0) - { - noteBlocks.put(player, loc.getBlock()); - loc.getBlock().setType(Material.NOTE_BLOCK); - } - } taskid = ess.scheduleSyncRepeatingTask(new Runnable() { int i = 0; @@ -158,19 +151,13 @@ public class Commandessentials extends EssentialsCommand { Commandessentials.this.stopTune(); } - if (note.isEmpty()) + if (note.isEmpty() || note == null) { return; } - Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks; for (Player onlinePlayer : server.getOnlinePlayers()) - { - final Block block = noteBlocks.get(onlinePlayer); - if (block == null || block.getType() != Material.NOTE_BLOCK) - { - continue; - } - onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note)); + { + onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.NOTE_PIANO, 1, noteMap.get(note)); } } }, 20, 2); @@ -192,9 +179,15 @@ public class Commandessentials extends EssentialsCommand private void run_moo(final Server server, final CommandSender sender, final String command, final String args[]) { if(sender instanceof ConsoleCommandSender) + { sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } ); + } else + { sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } ); + Player player = (Player)sender; + player.playSound(player.getLocation(), Sound.COW_IDLE, 1, 1.0f); + } } private void run_optout(final Server server, final CommandSender sender, final String command, final String args[]) @@ -203,9 +196,12 @@ public class Commandessentials extends EssentialsCommand try { sender.sendMessage("Essentials collects simple metrics to highlight which features to concentrate work on in the future."); - if (metrics.isOptOut()) { + if (metrics.isOptOut()) + { metrics.enable(); - } else { + } + else + { metrics.disable(); } sender.sendMessage("Anonymous Metrics are now: " + (metrics.isOptOut() ? "disabled" : "enabled")); @@ -215,4 +211,63 @@ public class Commandessentials extends EssentialsCommand sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage()); } } + private void run_cleanup(final Server server, final CommandSender sender, final String command, final String args[]) throws Exception + { + + if (args.length < 2 || !Util.isInt(args[1])) + { + throw new NotEnoughArgumentsException("/<command> cleanup <days> [money] [homes] [bans]"); + } + sender.sendMessage(_("cleaning")); + + final int daysArg = Integer.parseInt(args[1]); + final double moneyArg = args.length >= 3 ? Double.parseDouble(args[2].replaceAll("[^0-9\\.]", "")) : 0; + final int homesArg = args.length >= 4 && Util.isInt(args[3]) ? Integer.parseInt(args[3]) : 0; + final int bansArg = args.length >= 5 && Util.isInt(args[4]) ? Integer.parseInt(args[4]) : 0; + final UserMap userMap = ess.getUserMap(); + + + ess.runTaskAsynchronously( new Runnable() + { + @Override + public void run() + { + for (String u : userMap.getAllUniqueUsers()) + { + final User user = ess.getUserMap().getUser(u); + if (user == null) + { + continue; + } + int ban = user.getBanReason().equals("") ? 0 : 1; + if (!(ban <= bansArg)) + { + continue; + } + long lastLogout = user.getLastLogout(); + long timeNow = System.currentTimeMillis(); + long timeDiff = timeNow - lastLogout; + long milliDays = daysArg * 24 * 60 * 60; + if (!(timeDiff >= milliDays)) + { + continue; + } + int homes = user.getHomes().size(); + if (!(homes <= homesArg)) + { + continue; + } + double money = user.getMoney(); + if (!(money <= moneyArg)) + { + continue; + } + user.reset(); + } + userMap.reloadConfig(); + sender.sendMessage(_("cleaned")); + } + }); + + } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 6496a5cd2..83bcac5fb 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a74You are not allowed to spawn the item\u00a7c {0}\u00a74. chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Command {0} failed: commandHelpFailedForPlugin=Error getting help for plugin: {0} commandNotLoaded=\u00a74Command {0} is improperly loaded. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 9312984c5..229022490 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -39,6 +39,8 @@ canTalkAgain=\u00a77Muzes opet mluvit. cantFindGeoIpDB=Nemohu najit GeoIP databazi! cantReadGeoIpDB=Nemohu precist GeoIP databazi! cantSpawnItem=\u00a7cNejsi dovoleny spawnout item: {0} +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index b31781330..ba420af02 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cDu har ikke tilladelse til at skabe tingen.{0} chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Kommandoen {0} fejlede: commandHelpFailedForPlugin=Fejl ved hentning af hj\u00e6lp til: {0} commandNotLoaded=\u00a7cKommando {0} er ikke indl\u00e6st korrekt. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index dabbef8f7..bf593d93f 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cDu darfst {0} nicht erzeugen. chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Befehl {0} scheiterte: commandHelpFailedForPlugin=Fehler beim Abrufen der Hilfe f\u00fcr: {0} commandNotLoaded=\u00a7cBefehl {0} ist nicht richtig geladen. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 2b521da1c..1781761c2 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a74You are not allowed to spawn the item\u00a7c {0}\u00a74. chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Command {0} failed: commandHelpFailedForPlugin=Error getting help for plugin: {0} commandNotLoaded=\u00a74Command {0} is improperly loaded. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index d36db5964..a764eca24 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cNo tienes acceso para producir este objeto {0} chatTypeAdmin= chatTypeLocal= chatTypeSpy=[Espia] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Comando {0} fallado: commandHelpFailedForPlugin=Error obteniendo ayuda para: {0} commandNotLoaded=\u00a7cComando {0} esta cargado incorrectamente. diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index 6d2fea177..66f6ff6c3 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cSinulla ei ole oikeutta luoda tavaraa {0} chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Komento {0} ep\u00e4onnistui: commandHelpFailedForPlugin=Virhe haettaessa apua komennoista: {0} commandNotLoaded=\u00a7cKomento {0} on v\u00e4\u00e4rin ladattu. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index ddca65337..4db002785 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cVous n''avez pas le droit de faire appara\u00eetre {0} chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=\u00c9chec de la commande {0} : commandHelpFailedForPlugin=Erreur d''obtention d''aide pour : {0} commandNotLoaded=\u00a7cLa commande {0} a \u00e9t\u00e9 mal charg\u00e9e. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 73d268799..5bae0171c 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cNon sei abilitato a generare l''oggetto {0} chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Comando {0} fallito: commandHelpFailedForPlugin=Errore nella guida di: {0} commandNotLoaded=\u00a7cIl comando {0} non e'' stato caricato correttamente. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 175e19a81..a7c814498 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cJe bent niet bevoegd om {0} te spawnen. chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Gebruikersbestanden opgeschoont. +cleaning=Opschonen van gebruikersbestanden. commandFailed=Opdracht {0} is mislukt: commandHelpFailedForPlugin=Fout bij het \u200b\u200bkrijgen van hulp voor: {0} commandNotLoaded=\u00a7cOpdracht {0} is fout geladen. diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index 6d0f6bf13..9f0052e93 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cNie mozesz stworzyc przedmiotu {0}. chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Szpieg] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Komenda {0} zawiodla. commandHelpFailedForPlugin=Blad podczas uzyskiwania pomocy dla: {0} commandNotLoaded=\u00a7cKomenda {0} nie jest zaladowana! diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index c4eb6d44c..86ee24189 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cVoc\u00ea nao tem permissao de pegar este item {0} chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Comando {0} falhou: commandHelpFailedForPlugin=Erro ao obter ajuda para: {0} commandNotLoaded=\u00a7cCommando {0} provavelmente esta carregado. diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties index e910a5cc3..8f0d5f944 100644 --- a/Essentials/src/messages_se.properties +++ b/Essentials/src/messages_se.properties @@ -39,6 +39,8 @@ cantSpawnItem=\u00a7cDu har inte beh\u00f6righet att spawna {0} chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] +cleaned=Userfiles Cleaned. +cleaning=Cleaning userfiles. commandFailed=Kommando {0} misslyckades: commandHelpFailedForPlugin=Kunde inte hitta hj\u00e4lp f\u00f6r: {0} commandNotLoaded=\u00a7cKommando {0} \u00e4r felaktigt laddat. |