Merge vanish and coreprotect-switch into main

This commit is contained in:
Luna 2022-03-30 20:40:07 -03:00 committed by Business Goose
parent b1882a2a10
commit 522915a76a
No known key found for this signature in database
GPG key ID: 77DCA801362E9645
7 changed files with 979 additions and 1409 deletions

View file

@ -5,7 +5,6 @@ import me.StevenLawson.TotalFreedomMod.ban.BanManager;
import me.StevenLawson.TotalFreedomMod.bridge.WorldEditBridge; import me.StevenLawson.TotalFreedomMod.bridge.WorldEditBridge;
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager; import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
import me.StevenLawson.TotalFreedomMod.util.Utilities; import me.StevenLawson.TotalFreedomMod.util.Utilities;
import me.StevenLawson.TotalFreedomMod.world.RollbackManager;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -48,7 +47,8 @@ public class Command_gtfo extends FreedomCommand {
} }
// rollback // rollback
RollbackManager.rollback(player.getName()); // RollbackManager.rollback(player.getName());
// TODO: Use coreprotect API calls
// deop // deop
player.setOp(false); player.setOp(false);

View file

@ -1,77 +0,0 @@
package me.StevenLawson.TotalFreedomMod.commands;
import me.StevenLawson.TotalFreedomMod.util.Utilities;
import me.StevenLawson.TotalFreedomMod.world.RollbackManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
public class Command_rollback extends FreedomCommand {
@Override
public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length == 0 || args.length > 2) {
return false;
}
if (args.length == 1) {
if ("purgeall".equals(args[0])) {
Utilities.adminAction(sender.getName(), "Purging all rollback history", false);
playerMsg(sender, "Purged all rollback history for " + RollbackManager.purgeEntries() + " players.");
}
else
{
final String playerName = RollbackManager.findPlayer(args[0]);
if (playerName == null)
{
playerMsg(sender, "That player has no entries stored.");
return true;
}
if (RollbackManager.canUndoRollback(playerName))
{
playerMsg(sender, "That player has just been rolled back.");
}
Utilities.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
playerMsg(sender, "Rolled back " + RollbackManager.rollback(playerName) + " edits for " + playerName + ".");
playerMsg(sender, "If this rollback was a mistake, use /rollback undo " + playerName + " within 40 seconds to reverse the rollback.");
}
return true;
}
if (args.length == 2)
{
if ("purge".equalsIgnoreCase(args[0]))
{
final String playerName = RollbackManager.findPlayer(args[1]);
if (playerName == null)
{
playerMsg(sender, "That player has no entries stored.");
return true;
}
playerMsg(sender, "Purged " + RollbackManager.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
return true;
}
if ("undo".equalsIgnoreCase(args[0]))
{
final String playerName = RollbackManager.findPlayer(args[1]);
if (playerName == null)
{
playerMsg(sender, "That player hasn't been rolled back recently.");
return true;
}
Utilities.adminAction(sender.getName(), "Reverting rollback for player: " + playerName, false);
playerMsg(sender, "Reverted " + RollbackManager.undoRollback(playerName) + " edits for " + playerName + ".");
return true;
}
}
return false;
}
}

View file

@ -3,112 +3,109 @@ package me.StevenLawson.TotalFreedomMod.commands;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class Commands { public class Commands {
public static void registerCommands(JavaPlugin plugin) {
public static void registerCommands(JavaPlugin plugin) { plugin.getCommand("adminmode").setExecutor(new Command_adminmode());
plugin.getCommand("adminmode").setExecutor(new Command_adminmode()); plugin.getCommand("adminworld").setExecutor(new Command_adminworld());
plugin.getCommand("adminworld").setExecutor(new Command_adminworld()); plugin.getCommand("blockcmd").setExecutor(new Command_blockcmd());
plugin.getCommand("blockcmd").setExecutor(new Command_blockcmd()); plugin.getCommand("cage").setExecutor(new Command_cage());
plugin.getCommand("cage").setExecutor(new Command_cage()); plugin.getCommand("cake").setExecutor(new Command_cake());
plugin.getCommand("cake").setExecutor(new Command_cake()); plugin.getCommand("cartsit").setExecutor(new Command_cartsit());
plugin.getCommand("cartsit").setExecutor(new Command_cartsit()); plugin.getCommand("cbtool").setExecutor(new Command_cbtool());
plugin.getCommand("cbtool").setExecutor(new Command_cbtool()); plugin.getCommand("cmdlist").setExecutor(new Command_cmdlist());
plugin.getCommand("cmdlist").setExecutor(new Command_cmdlist()); plugin.getCommand("cmdspy").setExecutor(new Command_cmdspy());
plugin.getCommand("cmdspy").setExecutor(new Command_cmdspy()); plugin.getCommand("colorme").setExecutor(new Command_colorme());
plugin.getCommand("colorme").setExecutor(new Command_colorme()); plugin.getCommand("creative").setExecutor(new Command_creative());
plugin.getCommand("creative").setExecutor(new Command_creative()); plugin.getCommand("csay").setExecutor(new Command_csay());
plugin.getCommand("csay").setExecutor(new Command_csay()); plugin.getCommand("deafen").setExecutor(new Command_deafen());
plugin.getCommand("deafen").setExecutor(new Command_deafen()); plugin.getCommand("debug").setExecutor(new Command_debug());
plugin.getCommand("debug").setExecutor(new Command_debug()); plugin.getCommand("denick").setExecutor(new Command_denick());
plugin.getCommand("denick").setExecutor(new Command_denick()); plugin.getCommand("deop").setExecutor(new Command_deop());
plugin.getCommand("deop").setExecutor(new Command_deop()); plugin.getCommand("deopall").setExecutor(new Command_deopall());
plugin.getCommand("deopall").setExecutor(new Command_deopall()); plugin.getCommand("dispfill").setExecutor(new Command_dispfill());
plugin.getCommand("dispfill").setExecutor(new Command_dispfill()); plugin.getCommand("doom").setExecutor(new Command_doom());
plugin.getCommand("doom").setExecutor(new Command_doom()); plugin.getCommand("enchant").setExecutor(new Command_enchant());
plugin.getCommand("enchant").setExecutor(new Command_enchant()); plugin.getCommand("ender").setExecutor(new Command_ender());
plugin.getCommand("ender").setExecutor(new Command_ender()); plugin.getCommand("expel").setExecutor(new Command_expel());
plugin.getCommand("expel").setExecutor(new Command_expel()); plugin.getCommand("findip").setExecutor(new Command_findip());
plugin.getCommand("findip").setExecutor(new Command_findip()); plugin.getCommand("flatlands").setExecutor(new Command_flatlands());
plugin.getCommand("flatlands").setExecutor(new Command_flatlands()); plugin.getCommand("fr").setExecutor(new Command_fr());
plugin.getCommand("fr").setExecutor(new Command_fr()); plugin.getCommand("fuckoff").setExecutor(new Command_fuckoff());
plugin.getCommand("fuckoff").setExecutor(new Command_fuckoff()); plugin.getCommand("gadmin").setExecutor(new Command_gadmin());
plugin.getCommand("gadmin").setExecutor(new Command_gadmin()); plugin.getCommand("gcmd").setExecutor(new Command_gcmd());
plugin.getCommand("gcmd").setExecutor(new Command_gcmd()); plugin.getCommand("glist").setExecutor(new Command_glist());
plugin.getCommand("glist").setExecutor(new Command_glist()); plugin.getCommand("gtfo").setExecutor(new Command_gtfo());
plugin.getCommand("gtfo").setExecutor(new Command_gtfo()); plugin.getCommand("halt").setExecutor(new Command_halt());
plugin.getCommand("halt").setExecutor(new Command_halt()); plugin.getCommand("health").setExecutor(new Command_health());
plugin.getCommand("health").setExecutor(new Command_health()); plugin.getCommand("invis").setExecutor(new Command_invis());
plugin.getCommand("invis").setExecutor(new Command_invis()); plugin.getCommand("jumppads").setExecutor(new Command_jumppads());
plugin.getCommand("jumppads").setExecutor(new Command_jumppads()); plugin.getCommand("kicknoob").setExecutor(new Command_kicknoob());
plugin.getCommand("kicknoob").setExecutor(new Command_kicknoob()); plugin.getCommand("landmine").setExecutor(new Command_landmine());
plugin.getCommand("landmine").setExecutor(new Command_landmine()); plugin.getCommand("lastcmd").setExecutor(new Command_lastcmd());
plugin.getCommand("lastcmd").setExecutor(new Command_lastcmd()); plugin.getCommand("list").setExecutor(new Command_list());
plugin.getCommand("list").setExecutor(new Command_list()); plugin.getCommand("localspawn").setExecutor(new Command_localspawn());
plugin.getCommand("localspawn").setExecutor(new Command_localspawn()); plugin.getCommand("lockup").setExecutor(new Command_lockup());
plugin.getCommand("lockup").setExecutor(new Command_lockup()); plugin.getCommand("logs").setExecutor(new Command_logs());
plugin.getCommand("logs").setExecutor(new Command_logs()); plugin.getCommand("moblimiter").setExecutor(new Command_moblimiter());
plugin.getCommand("moblimiter").setExecutor(new Command_moblimiter()); plugin.getCommand("mp").setExecutor(new Command_mp());
plugin.getCommand("mp").setExecutor(new Command_mp()); plugin.getCommand("mp44").setExecutor(new Command_mp44());
plugin.getCommand("mp44").setExecutor(new Command_mp44()); plugin.getCommand("myadmin").setExecutor(new Command_myadmin());
plugin.getCommand("myadmin").setExecutor(new Command_myadmin()); plugin.getCommand("nether").setExecutor(new Command_nether());
plugin.getCommand("nether").setExecutor(new Command_nether()); plugin.getCommand("nf").setExecutor(new Command_nf());
plugin.getCommand("nf").setExecutor(new Command_nf()); plugin.getCommand("nickclean").setExecutor(new Command_nickclean());
plugin.getCommand("nickclean").setExecutor(new Command_nickclean()); plugin.getCommand("nicknyan").setExecutor(new Command_nicknyan());
plugin.getCommand("nicknyan").setExecutor(new Command_nicknyan()); plugin.getCommand("o").setExecutor(new Command_o());
plugin.getCommand("o").setExecutor(new Command_o()); plugin.getCommand("onlinemode").setExecutor(new Command_onlinemode());
plugin.getCommand("onlinemode").setExecutor(new Command_onlinemode()); plugin.getCommand("op").setExecutor(new Command_op());
plugin.getCommand("op").setExecutor(new Command_op()); plugin.getCommand("opall").setExecutor(new Command_opall());
plugin.getCommand("opall").setExecutor(new Command_opall()); plugin.getCommand("opme").setExecutor(new Command_opme());
plugin.getCommand("opme").setExecutor(new Command_opme()); plugin.getCommand("ops").setExecutor(new Command_ops());
plugin.getCommand("ops").setExecutor(new Command_ops()); plugin.getCommand("orbit").setExecutor(new Command_orbit());
plugin.getCommand("orbit").setExecutor(new Command_orbit()); plugin.getCommand("overlord").setExecutor(new Command_overlord());
plugin.getCommand("overlord").setExecutor(new Command_overlord()); plugin.getCommand("permban").setExecutor(new Command_permban());
plugin.getCommand("permban").setExecutor(new Command_permban()); plugin.getCommand("plugincontrol").setExecutor(new Command_plugincontrol());
plugin.getCommand("plugincontrol").setExecutor(new Command_plugincontrol()); plugin.getCommand("potion").setExecutor(new Command_potion());
plugin.getCommand("potion").setExecutor(new Command_potion()); plugin.getCommand("premium").setExecutor(new Command_premium());
plugin.getCommand("premium").setExecutor(new Command_premium()); plugin.getCommand("protectarea").setExecutor(new Command_protectarea());
plugin.getCommand("protectarea").setExecutor(new Command_protectarea()); plugin.getCommand("purgeall").setExecutor(new Command_purgeall());
plugin.getCommand("purgeall").setExecutor(new Command_purgeall()); plugin.getCommand("qdeop").setExecutor(new Command_qdeop());
plugin.getCommand("qdeop").setExecutor(new Command_qdeop()); plugin.getCommand("qop").setExecutor(new Command_qop());
plugin.getCommand("qop").setExecutor(new Command_qop()); plugin.getCommand("radar").setExecutor(new Command_radar());
plugin.getCommand("radar").setExecutor(new Command_radar()); plugin.getCommand("rank").setExecutor(new Command_rank());
plugin.getCommand("rank").setExecutor(new Command_rank()); plugin.getCommand("rawsay").setExecutor(new Command_rawsay());
plugin.getCommand("rawsay").setExecutor(new Command_rawsay()); plugin.getCommand("rd").setExecutor(new Command_rd());
plugin.getCommand("rd").setExecutor(new Command_rd()); plugin.getCommand("report").setExecutor(new Command_report());
plugin.getCommand("report").setExecutor(new Command_report()); plugin.getCommand("ro").setExecutor(new Command_ro());
plugin.getCommand("ro").setExecutor(new Command_ro()); plugin.getCommand("saconfig").setExecutor(new Command_saconfig());
plugin.getCommand("rollback").setExecutor(new Command_rollback()); plugin.getCommand("say").setExecutor(new Command_say());
plugin.getCommand("saconfig").setExecutor(new Command_saconfig()); plugin.getCommand("setl").setExecutor(new Command_setl());
plugin.getCommand("say").setExecutor(new Command_say()); plugin.getCommand("setlevel").setExecutor(new Command_setlevel());
plugin.getCommand("setl").setExecutor(new Command_setl()); plugin.getCommand("setlever").setExecutor(new Command_setlever());
plugin.getCommand("setlevel").setExecutor(new Command_setlevel()); plugin.getCommand("setspawnworld").setExecutor(new Command_setspawnworld());
plugin.getCommand("setlever").setExecutor(new Command_setlever()); plugin.getCommand("smite").setExecutor(new Command_smite());
plugin.getCommand("setspawnworld").setExecutor(new Command_setspawnworld()); plugin.getCommand("spectator").setExecutor(new Command_spectator());
plugin.getCommand("smite").setExecutor(new Command_smite()); plugin.getCommand("status").setExecutor(new Command_status());
plugin.getCommand("spectator").setExecutor(new Command_spectator()); plugin.getCommand("stfu").setExecutor(new Command_stfu());
plugin.getCommand("status").setExecutor(new Command_status()); plugin.getCommand("stop").setExecutor(new Command_stop());
plugin.getCommand("stfu").setExecutor(new Command_stfu()); plugin.getCommand("survival").setExecutor(new Command_survival());
plugin.getCommand("stop").setExecutor(new Command_stop()); plugin.getCommand("tag").setExecutor(new Command_tag());
plugin.getCommand("survival").setExecutor(new Command_survival()); plugin.getCommand("tagnyan").setExecutor(new Command_tagnyan());
plugin.getCommand("tag").setExecutor(new Command_tag()); plugin.getCommand("tban").setExecutor(new Command_tban());
plugin.getCommand("tagnyan").setExecutor(new Command_tagnyan()); plugin.getCommand("tempban").setExecutor(new Command_tempban());
plugin.getCommand("tban").setExecutor(new Command_tban()); plugin.getCommand("tfbanlist").setExecutor(new Command_tfbanlist());
plugin.getCommand("tempban").setExecutor(new Command_tempban()); plugin.getCommand("tfipbanlist").setExecutor(new Command_tfipbanlist());
plugin.getCommand("tfbanlist").setExecutor(new Command_tfbanlist()); plugin.getCommand("tfm").setExecutor(new Command_tfm());
plugin.getCommand("tfipbanlist").setExecutor(new Command_tfipbanlist()); plugin.getCommand("toggle").setExecutor(new Command_toggle());
plugin.getCommand("tfm").setExecutor(new Command_tfm()); plugin.getCommand("tossmob").setExecutor(new Command_tossmob());
plugin.getCommand("toggle").setExecutor(new Command_toggle()); plugin.getCommand("trail").setExecutor(new Command_trail());
plugin.getCommand("tossmob").setExecutor(new Command_tossmob()); plugin.getCommand("updatetfm").setExecutor(new Command_updatetfm());
plugin.getCommand("trail").setExecutor(new Command_trail()); plugin.getCommand("uuid").setExecutor(new Command_uuid());
plugin.getCommand("updatetfm").setExecutor(new Command_updatetfm()); plugin.getCommand("warn").setExecutor(new Command_warn());
plugin.getCommand("uuid").setExecutor(new Command_uuid()); plugin.getCommand("whitelist").setExecutor(new Command_whitelist());
plugin.getCommand("warn").setExecutor(new Command_warn()); plugin.getCommand("whohas").setExecutor(new Command_whohas());
plugin.getCommand("whitelist").setExecutor(new Command_whitelist()); plugin.getCommand("wildcard").setExecutor(new Command_wildcard());
plugin.getCommand("whohas").setExecutor(new Command_whohas()); plugin.getCommand("wipeflatlands").setExecutor(new Command_wipeflatlands());
plugin.getCommand("wildcard").setExecutor(new Command_wildcard()); plugin.getCommand("wipeuserdata").setExecutor(new Command_wipeuserdata());
plugin.getCommand("wipeflatlands").setExecutor(new Command_wipeflatlands()); plugin.getCommand("whoami").setExecutor(new Command_whoami());
plugin.getCommand("wipeuserdata").setExecutor(new Command_wipeuserdata()); plugin.getCommand("resetplayer").setExecutor(new Command_resetplayer());
plugin.getCommand("whoami").setExecutor(new Command_whoami()); }
plugin.getCommand("resetplayer").setExecutor(new Command_resetplayer());
plugin.getCommand("vanish").setExecutor(new Command_vanish());
}
} }

View file

@ -8,7 +8,6 @@ import me.StevenLawson.TotalFreedomMod.player.HeartBeat;
import me.StevenLawson.TotalFreedomMod.player.PlayerData; import me.StevenLawson.TotalFreedomMod.player.PlayerData;
import me.StevenLawson.TotalFreedomMod.util.Utilities; import me.StevenLawson.TotalFreedomMod.util.Utilities;
import me.StevenLawson.TotalFreedomMod.world.ProtectedArea; import me.StevenLawson.TotalFreedomMod.world.ProtectedArea;
import me.StevenLawson.TotalFreedomMod.world.RollbackManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -251,24 +250,6 @@ public class BlockListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRollbackBlockBreak(BlockBreakEvent event)
{
if (!AdminList.isSuperAdmin(event.getPlayer()))
{
RollbackManager.blockBreak(event);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRollbackBlockPlace(BlockPlaceEvent event)
{
if (!AdminList.isSuperAdmin(event.getPlayer()))
{
RollbackManager.blockPlace(event);
}
}
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(BlockFromToEvent event) public void onBlockFromTo(BlockFromToEvent event)
{ {

View file

@ -1,316 +0,0 @@
package me.StevenLawson.TotalFreedomMod.world;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import me.StevenLawson.TotalFreedomMod.Log;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.util.DeprecationUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class RollbackManager
{
private static final Map<String, List<RollbackEntry>> PLAYER_HISTORY = new HashMap<String, List<RollbackEntry>>();
private static final List<String> REMOVE_ROLLBACK_HISTORY = new ArrayList<String>();
private RollbackManager()
{
throw new AssertionError();
}
public static void blockPlace(org.bukkit.event.block.BlockPlaceEvent event)
{
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_PLACE));
}
public static void blockBreak(org.bukkit.event.block.BlockBreakEvent event)
{
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_BREAK));
}
private static void storeEntry(Player player, RollbackEntry entry)
{
List<RollbackEntry> playerEntryList = getEntriesByPlayer(player.getName());
if (playerEntryList != null)
{
playerEntryList.add(0, entry);
}
}
// May return null
public static String findPlayer(String partial)
{
partial = partial.toLowerCase();
for (String player : PLAYER_HISTORY.keySet())
{
if (player.toLowerCase().equals(partial))
{
return player;
}
}
for (String player : PLAYER_HISTORY.keySet())
{
if (player.toLowerCase().contains(partial))
{
return player;
}
}
return null;
}
public static int purgeEntries()
{
Iterator<List<RollbackEntry>> it = PLAYER_HISTORY.values().iterator();
while (it.hasNext())
{
List<RollbackEntry> playerEntryList = it.next();
if (playerEntryList != null)
{
playerEntryList.clear();
}
}
return PLAYER_HISTORY.size();
}
public static int purgeEntries(String playerName)
{
List<RollbackEntry> playerEntryList = getEntriesByPlayer(playerName);
if (playerEntryList == null)
{
return 0;
}
int count = playerEntryList.size();
playerEntryList.clear();
return count;
}
public static boolean canRollback(String playerName)
{
return PLAYER_HISTORY.containsKey(playerName.toLowerCase()) && !PLAYER_HISTORY.get(playerName.toLowerCase()).isEmpty();
}
public static boolean canUndoRollback(String playerName)
{
return REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase());
}
public static int rollback(final String playerName)
{
final List<RollbackEntry> entries = getEntriesByPlayer(playerName);
if (entries == null)
{
return 0;
}
int count = entries.size();
for (RollbackEntry entry : entries)
{
if (entry != null)
{
entry.restore();
}
}
if (!REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase()))
{
REMOVE_ROLLBACK_HISTORY.add(playerName.toLowerCase());
}
new BukkitRunnable()
{
@Override
public void run()
{
if (REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase()))
{
REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase());
purgeEntries(playerName);
}
}
}.runTaskLater(TotalFreedomMod.plugin, 40L * 20L);
return count;
}
public static int undoRollback(String playerName)
{
final List<RollbackEntry> entries = getEntriesByPlayer(playerName);
if (entries == null)
{
return 0;
}
final int count = entries.size();
final ListIterator<RollbackEntry> it = entries.listIterator(count);
while (it.hasPrevious())
{
RollbackEntry entry = it.previous();
if (entry != null)
{
entry.redo();
}
}
REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase());
return count;
}
public static List<RollbackEntry> getEntriesAtLocation(final Location location)
{
final int testX = location.getBlockX();
final short testY = (short) location.getBlockY();
final int testZ = location.getBlockZ();
final String testWorldName = location.getWorld().getName();
List<RollbackEntry> entries = new ArrayList<RollbackEntry>();
for (String playername : PLAYER_HISTORY.keySet())
{
for (RollbackEntry entry : PLAYER_HISTORY.get(playername.toLowerCase()))
{
if (testX == entry.x && testY == entry.y && testZ == entry.z && testWorldName.equals(entry.worldName))
{
entries.add(0, entry);
}
}
}
return entries;
}
private static List<RollbackEntry> getEntriesByPlayer(String playerName)
{
playerName = playerName.toLowerCase();
List<RollbackEntry> playerEntryList = PLAYER_HISTORY.get(playerName.toLowerCase());
if (playerEntryList == null)
{
playerEntryList = new ArrayList<RollbackEntry>();
PLAYER_HISTORY.put(playerName.toLowerCase(), playerEntryList);
}
return playerEntryList;
}
public enum EntryType
{
BLOCK_PLACE("placed"),
BLOCK_BREAK("broke");
private final String action;
EntryType(String action)
{
this.action = action;
}
@Override
public String toString()
{
return this.action;
}
}
public static class RollbackEntry
{
// Use of primitives to decrease overhead
public final String author;
public final String worldName;
public final int x;
public final short y;
public final int z;
public final byte data;
public final Material blockMaterial;
private final boolean isBreak;
private RollbackEntry(String author, Block block, EntryType entryType)
{
final Location location = block.getLocation();
this.x = location.getBlockX();
this.y = (short) location.getBlockY();
this.z = location.getBlockZ();
this.worldName = location.getWorld().getName();
this.author = author;
if (entryType == EntryType.BLOCK_BREAK)
{
this.blockMaterial = block.getType();
this.data = DeprecationUtil.getData_Block(block);
this.isBreak = true;
}
else
{
this.blockMaterial = block.getType();
this.data = DeprecationUtil.getData_Block(block);
this.isBreak = false;
}
}
public Location getLocation()
{
try
{
return new Location(Bukkit.getWorld(worldName), x, (int) y, z);
}
catch (Exception ex)
{
Log.warning("Could not get location of rollback entry at (" + worldName + ":" + x + "," + y + "," + x + ")!");
}
return null;
}
public Material getMaterial()
{
return blockMaterial;
}
public EntryType getType()
{
return (isBreak ? EntryType.BLOCK_BREAK : EntryType.BLOCK_PLACE);
}
public void restore()
{
final Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
if (isBreak)
{
block.setType(getMaterial());
DeprecationUtil.setData_Block(block, data);
}
else
{
block.setType(Material.AIR);
}
}
public void redo()
{
final Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
if (isBreak)
{
block.setType(Material.AIR);
}
else
{
block.setType(getMaterial());
DeprecationUtil.setData_Block(block, data);
}
}
}
}

View file

@ -287,10 +287,6 @@ commands:
description: 'Mutes a player with brute force.' description: 'Mutes a player with brute force.'
usage: '/<command> [<player> [-s] | list | purge | all]' usage: '/<command> [<player> [-s] | list | purge | all]'
aliases: 'mute' aliases: 'mute'
rollback:
description: 'Issues a rollback on a player'
usage: '/<command> <[partialname] | undo [partialname] purge [partialname] | purgeall>'
aliases: 'rb'
nickclean: nickclean:
description: 'Essentials Interface Command - Remove distracting things from nicknames of all players on server.' description: 'Essentials Interface Command - Remove distracting things from nicknames of all players on server.'
usage: '/<command>' usage: '/<command>'