mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-10-31 15:59:40 +01:00
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].
This commit is contained in:
parent
ff02f0e270
commit
8710a133ce
@ -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)
|
||||
|
@ -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#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,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,,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,,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,,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,,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"));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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]
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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!
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user