Logstick stuff

This commit is contained in:
ZeroEpoch1969 2018-06-28 11:06:13 -07:00
parent d7450bf181
commit 650f732dd4
No known key found for this signature in database
GPG key ID: E0AAB104FB9F8FDF
3 changed files with 57 additions and 16 deletions

View file

@ -58,6 +58,9 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
@Getter
@Setter
private Boolean oldTags = null;
@Getter
@Setter
private Boolean logStick = null;
public static final String CONFIG_FILENAME = "admins.yml";
@ -115,6 +118,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
potionSpy = cs.getBoolean("potion_spy", false);
acFormat = cs.getString("acformat", null);
oldTags = cs.getBoolean("oldtags", false);
logStick = cs.getBoolean("logstick", false);
}
@ -134,6 +138,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
cs.set("potion_spy", potionSpy);
cs.set("acformat", acFormat);
cs.set("oldtags", oldTags);
cs.set("logstick", logStick);
}
public boolean isAtLeast(Rank pRank)

View file

@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Manage my admin entry", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | settag <tag> | cleartag | setacformat <format> | clearacformat> | oldtags>")
@CommandParameters(description = "Manage my admin entry", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | settag <tag> | cleartag | setacformat <format> | clearacformat> | oldtags | logstick>")
public class Command_myadmin extends FreedomCommand
{
@ -206,6 +206,14 @@ public class Command_myadmin extends FreedomCommand
msg((target.getOldTags() ? "Enabled" : "Disabled") + " old tags.");
return true;
}
case "logstick":
{
target.setLogStick(!target.getLogStick());
plugin.al.save();
plugin.al.updateTables();
msg((target.getLogStick() ? "Enabled" : "Disabled") + " log-stick lookup.");
return true;
}
default:
{

View file

@ -11,10 +11,12 @@ import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.coreprotect.CoreProtectAPI.ParseResult;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -224,31 +226,57 @@ public class RollbackManager extends FreedomService
if (!event.hasItem()
|| event.getItem().getType() != Material.STICK
|| !plugin.al.isAdmin(player))
|| !plugin.al.isAdmin(player)
|| !plugin.al.getAdmin(player).getLogStick())
{
return;
}
event.setCancelled(true);
final Location location = DepreciationAggregator.getTargetBlock(player, null, 5).getLocation();
final List<RollbackEntry> entries = plugin.rb.getEntriesAtLocation(location);
final Block block = DepreciationAggregator.getTargetBlock(player, null, 5);
if (entries.isEmpty())
if (plugin.cpb.isEnabled())
{
FUtil.playerMsg(player, "No block edits at that location.");
return;
final List<String[]> entries = plugin.cpb.getCoreProtect().getAPI().blockLookup(block, 86400);
if (entries.isEmpty())
{
FUtil.playerMsg(player, "No block edits at that location.");
return;
}
FUtil.playerMsg(player, "Block edits at ("
+ ChatColor.WHITE + "x" + block.getX()
+ ", y" + block.getY()
+ ", z" + block.getZ()
+ ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
for (String[] entry : Lists.reverse(entries))
{
ParseResult parsedEntry = plugin.cpb.getCoreProtect().getAPI().parseResult(entry);
FUtil.playerMsg(player, ChatColor.BLUE + parsedEntry.getActionString() + " of " + StringUtils.capitalize(parsedEntry.getType().name()) + " - " + parsedEntry.getPlayer());
}
}
FUtil.playerMsg(player, "Block edits at ("
+ ChatColor.WHITE + "x" + location.getBlockX()
+ ", y" + location.getBlockY()
+ ", z" + location.getBlockZ()
+ ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
for (RollbackEntry entry : entries)
else
{
FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " "
+ StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data));
final List<RollbackEntry> entries = plugin.rb.getEntriesAtLocation(block.getLocation());
if (entries.isEmpty())
{
FUtil.playerMsg(player, "No block edits at that location.");
return;
}
FUtil.playerMsg(player, "Block edits at ("
+ ChatColor.WHITE + "x" + block.getX()
+ ", y" + block.getY()
+ ", z" + block.getZ()
+ ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
for (RollbackEntry entry : entries)
{
FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " "
+ StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data));
}
}
}