got bored

This commit is contained in:
ZeroEpoch1969 2020-04-23 04:18:03 -07:00
parent dd5e256c84
commit c49abd1f4a
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3
44 changed files with 278 additions and 1399 deletions

View File

@ -57,14 +57,7 @@ public class Muter extends FreedomService
return;
}
if (fPlayer.isQuietMuted())
{
FSync.playerMsg(event.getPlayer(), event.getFormat());
event.setCancelled(true);
return;
}
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
event.setCancelled(true);
}

View File

@ -5,7 +5,6 @@ import java.io.InputStream;
import java.util.Properties;
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.amp.AMP;
import me.totalfreedom.totalfreedommod.banning.BanManager;
import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.banning.VPNBanList;
@ -47,7 +46,6 @@ import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
import me.totalfreedom.totalfreedommod.shop.Shop;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -107,7 +105,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public VPNBanList vn;
public ProtectArea pa;
public GameRuleHandler gr;
public RollbackManager rb;
public CommandSpy cs;
public Cager ca;
public Freezer fm;
@ -145,7 +142,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public CoreProtectBridge cpb;
public WorldEditBridge web;
public WorldGuardBridge wgb;
public AMP amp;
@Override
public void load()
@ -229,7 +225,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
ew = services.registerService(EntityWiper.class);
// Single admin utils
rb = services.registerService(RollbackManager.class);
cs = services.registerService(CommandSpy.class);
ca = services.registerService(Cager.class);
fm = services.registerService(Freezer.class);
@ -269,7 +264,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
ldb = bridges.registerService(LibsDisguisesBridge.class);
web = bridges.registerService(WorldEditBridge.class);
wgb = bridges.registerService(WorldGuardBridge.class);
amp = bridges.registerService(AMP.class);
bridges.start();
timer.update();

View File

@ -1,48 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
public class AMP extends FreedomService
{
public AMPManager ampManager;
public Boolean enabled = false;
public AMP(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
if (!plugin.config.getBoolean(ConfigEntry.AMP_ENABLED))
{
return;
}
ampManager = new AMPManager(plugin, plugin.config.getString(ConfigEntry.AMP_URL), plugin.config.getString(ConfigEntry.AMP_USERNAME), plugin.config.getString(ConfigEntry.AMP_PASSWORD));
LoginCallback callback = new LoginCallback()
{
@Override
public void loginDone(boolean success)
{
enabled = success;
}
};
ampManager.connectAsync(callback);
}
public void restartServer()
{
ampManager.restartAsync();
}
@Override
protected void onStop()
{
}
}

View File

@ -1,28 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
public enum AMPEndpoints
{
LOGIN("/API/Core/Login", "{username:\"%s\", password:\"%s\", token:\"\", rememberMe:false}"),
RESTART("/API/Core/Restart", "{SESSIONID:\"%s\"}");
private final String text;
private final String parameters;
AMPEndpoints(String text, String parameters)
{
this.text = text;
this.parameters = parameters;
}
@Override
public String toString()
{
return text;
}
public String getParameters()
{
return parameters;
}
}

View File

@ -1,171 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
import com.google.gson.Gson;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.scheduler.BukkitRunnable;
public class AMPManager
{
private TotalFreedomMod plugin;
private String url, username, password;
private String sessionID;
public AMPManager(TotalFreedomMod plugin, String url, String username, String password)
{
this.plugin = plugin;
this.url = url;
this.username = username;
this.password = password;
}
public void connectAsync(final LoginCallback callback)
{
new BukkitRunnable()
{
@Override
public void run()
{
String apiEndpoint = url + AMPEndpoints.LOGIN.toString();
String body = String.format(AMPEndpoints.LOGIN.getParameters(), username, password);
try
{
LoginResult resp = new Gson().fromJson(postRequestToEndpoint(apiEndpoint, body), LoginResult.class);
if (!resp.getSuccess())
{
FLog.severe("AMP login unsuccessful. Check if login details are correct.");
sessionID = "";
callback.loginDone(false);
return;
}
sessionID = resp.getSessionID();
callback.loginDone(true);
}
catch (IOException ex)
{
FLog.severe("Could not login to AMP. Check if URL is correct. Stacktrace: " + ex.getMessage());
sessionID = "";
callback.loginDone(false);
}
}
}.runTaskAsynchronously(plugin);
}
public void restartAsync()
{
new BukkitRunnable()
{
@Override
public void run()
{
final String apiEndpoint = url + AMPEndpoints.RESTART.toString();
final String body = String.format(AMPEndpoints.RESTART.getParameters(), sessionID);
try
{
String resp = postRequestToEndpoint(apiEndpoint, body);
if (resp.contains("Unauthorized Access"))
{
//try connecting one more time
LoginCallback callback = new LoginCallback()
{
@Override
public void loginDone(boolean success)
{
if (!success)
{
FLog.severe("Failed to connect to AMP. Did the panel go down? Were panel user details changed/deleted? Check for more info above. Connection was successful when plugin started, but unsuccessful now." +
" Using server.shutdown() instead.");
plugin.getServer().shutdown();
return;
}
try
{
String response = postRequestToEndpoint(apiEndpoint, body);
if (response.contains("Unauthorized Access"))
{
FLog.severe("Contact a developer. Panel gives Session ID but trying to use it gives a no perms error. The panel user set in config doesn't" +
" have perms to restart server. Using server.shutdown() instead. ");
plugin.getServer().shutdown();
}
}
catch (IOException e)
{
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace" + e.getMessage());
plugin.getServer().shutdown();
}
}
};
plugin.amp.ampManager.connectAsync(callback);
}
}
catch (IOException ex)
{
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace: " + ex.getMessage());
plugin.getServer().shutdown();
}
}
}.runTaskAsynchronously(plugin);
}
private String postRequestToEndpoint(String endpoint, String body) throws IOException
{
URL url = new URL(endpoint);
if (endpoint.startsWith("https://"))
{
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(body);
outputStream.flush();
outputStream.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null)
{
response.append(inputLine);
}
in.close();
return response.toString();
}
else
{
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(body);
outputStream.flush();
outputStream.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null)
{
response.append(inputLine);
}
in.close();
return response.toString();
}
}
}

View File

@ -1,6 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
public interface LoginCallback
{
void loginDone(boolean success);
}

View File

@ -1,49 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
public class LoginResult
{
@SerializedName("result")
@Expose
@Getter
@Setter
private Integer result;
@SerializedName("success")
@Expose
@Getter
@Setter
private Boolean success;
@SerializedName("permissions")
@Expose
@Getter
@Setter
private List<String> permissions = null;
@SerializedName("sessionID")
@Expose
@Getter
@Setter
private String sessionID;
@SerializedName("rememberMeToken")
@Expose
@Getter
@Setter
private String rememberMeToken;
@SerializedName("gravatarHash")
@Expose
@Getter
@Setter
private String gravatarHash;
@SerializedName("username")
@Expose
@Getter
@Setter
private String username;
private final static long serialVersionUID = -523050232433919883L;
}

View File

@ -127,6 +127,24 @@ public class BukkitTelnetBridge extends FreedomService
return bukkitTelnetPlugin;
}
public List<Admin> getConnectedAdmins()
{
List<Admin> admins = new ArrayList<>();
final BukkitTelnet telnet = getBukkitTelnetPlugin();
if (telnet != null)
{
for (ClientSession session : telnet.appender.getSessions())
{
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
if (admin != null && !admins.contains(admin))
{
admins.add(admin);
}
}
}
return admins;
}
public void killTelnetSessions(final String name)
{
try

View File

@ -219,14 +219,7 @@ public class CoreProtectBridge extends FreedomService
// This exits for flatlands wipes
if (shutdown)
{
if (plugin.amp.enabled)
{
plugin.amp.restartServer();
}
else
{
server.shutdown();
}
server.shutdown();
}
}
}

View File

@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@ -19,11 +18,9 @@ import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb]", aliases = "gtfo")
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
public class Command_ban extends FreedomCommand
{
@ -35,6 +32,34 @@ public class Command_ban extends FreedomCommand
return false;
}
String reason = null;
Boolean silent = false;
Boolean cancelRollback = false;
if (args.length >= 2)
{
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
{
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
{
cancelRollback = true;
}
if (args[args.length - 1].equalsIgnoreCase("-q"))
{
silent = true;
}
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
}
final String username;
final List<String> ips = new ArrayList<>();
@ -56,7 +81,7 @@ public class Command_ban extends FreedomCommand
{
final PlayerData entry = plugin.pl.getData(player);
username = player.getName();
//ips.addAll(entry.getIps());
//ips.addAll(entry.getIps());/
ips.add(Ips.getIp(player));
// Deop
@ -68,14 +93,17 @@ public class Command_ban extends FreedomCommand
// Clear inventory
player.getInventory().clear();
// Strike with lightning
final Location targetPos = player.getLocation();
for (int x = -1; x <= 1; x++)
if (!silent)
{
for (int z = -1; z <= 1; z++)
// Strike with lightning
final Location targetPos = player.getLocation();
for (int x = -1; x <= 1; x++)
{
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
targetPos.getWorld().strikeLightning(strike_pos);
for (int z = -1; z <= 1; z++)
{
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
targetPos.getWorld().strikeLightning(strike_pos);
}
}
}
@ -83,77 +111,13 @@ public class Command_ban extends FreedomCommand
player.setHealth(0.0);
}
String reason = null;
Boolean cancelRollback = false;
Boolean epicFail = false;
if (args.length >= 2)
{
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
{
cancelRollback = true;
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
if (args[args.length - 1].equalsIgnoreCase("-ef"))
{
epicFail = true;
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
}
// Checks if CoreProtect is loaded and installed, and skips the rollback and uses CoreProtect directly
if (!cancelRollback)
{
if (!plugin.cpb.isEnabled())
{
// Undo WorldEdits
try
{
plugin.web.undo(player, 15);
}
catch (NoClassDefFoundError | NullPointerException ex)
{
}
// Rollback
plugin.rb.rollback(username);
}
else
{
plugin.cpb.rollback(username);
}
plugin.cpb.rollback(username);
}
if (epicFail)
{
for (int i = 0; i < 25; i++)
{
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
new BukkitRunnable()
{
public void run()
{
for (int i = 0; i < 8; i++)
{
player.getWorld().strikeLightning(player.getLocation());
//FUtil.
}
}
}.runTaskLater(plugin, 2L * 20L);
}
return true;
}
if (player != null)
if (player != null && !silent)
{
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
}
@ -166,16 +130,20 @@ public class Command_ban extends FreedomCommand
}
plugin.bm.addBan(ban);
// Broadcast
final StringBuilder bcast = new StringBuilder()
.append("Banning: ")
.append(username);
if (reason != null)
if (!silent)
{
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
// Broadcast
final StringBuilder bcast = new StringBuilder()
.append("Banning: ")
.append(username);
if (reason != null)
{
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
}
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
}
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
// Kick player and handle others on IP
if (player != null)

View File

@ -67,7 +67,7 @@ public class Command_blockedit extends FreedomCommand
int counter = 0;
for (final Player player : this.server.getOnlinePlayers())
{
if (!plugin.al.isAdmin((CommandSender)player))
if (!plugin.al.isAdmin(player))
{
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setEditBlocked(true);
@ -82,7 +82,7 @@ public class Command_blockedit extends FreedomCommand
final boolean smite = args[0].equals("-s");
if (smite)
{
args = (String[])ArrayUtils.subarray((Object[])args, 1, args.length);
args = (String[])ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1)
{
return false;
@ -99,7 +99,7 @@ public class Command_blockedit extends FreedomCommand
String reason = null;
if (args.length > 1)
{
reason = StringUtils.join((Object[])args, " ", 1, args.length);
reason = StringUtils.join(args, " ", 1, args.length);
}
final FPlayer pd = plugin.pl.getPlayer(player2);
@ -112,7 +112,7 @@ public class Command_blockedit extends FreedomCommand
}
else
{
if (plugin.al.isAdmin((CommandSender)player2))
if (plugin.al.isAdmin(player2))
{
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
return true;

View File

@ -16,12 +16,12 @@ public class Command_cartsit extends FreedomCommand
{
Player targetPlayer = playerSender;
if (args.length == 1)
if (args.length == 1 && plugin.al.isAdmin(sender))
{
targetPlayer = getPlayer(args[0]);
if (targetPlayer == null || plugin.al.vanished.contains(targetPlayer) && !plugin.al.isAdmin(sender))
if (targetPlayer == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
@ -36,11 +36,6 @@ public class Command_cartsit extends FreedomCommand
return true;
}
}
else if (targetPlayer != playerSender && !isAdmin(sender))
{
sender.sendMessage("Only admins can select another player as a /cartsit target.");
return true;
}
if (targetPlayer.isInsideVehicle())
{

View File

@ -1,113 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.lang.reflect.Field;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "For developers only - debug things via reflection.", usage = "/<command>")
public class Command_debug extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 3)
{
return false;
}
try
{
String className = args[0];
String fieldName = args[1];
String newValue = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
if (className.equalsIgnoreCase("_"))
{
className = "me.totalfreedom.totalfreedommod.TotalFreedomMod";
}
setStaticValue(className, fieldName, newValue);
sender.sendMessage("Debug: OK");
}
catch (Exception ex)
{
sender.sendMessage(ex.getMessage());
}
return true;
}
public static void setStaticValue(final String className, final String fieldName, final String newValueString) throws Exception
{
Class<?> forName = Class.forName(className);
if (forName != null)
{
final Field field = forName.getDeclaredField(fieldName);
if (field != null)
{
Object newValue;
Class<?> type = field.getType();
if (type.isPrimitive())
{
if (type.getName().equals("int"))
{
newValue = Integer.parseInt(newValueString);
}
else if (type.getName().equals("double"))
{
newValue = Double.parseDouble(newValueString);
}
else if (type.getName().equals("boolean"))
{
newValue = Boolean.parseBoolean(newValueString);
}
else
{
throw new Exception("Unknown primitive field type.");
}
}
else
{
if (type.isAssignableFrom(Integer.class))
{
newValue = new Integer(newValueString);
}
else if (type.isAssignableFrom(Double.class))
{
newValue = new Double(newValueString);
}
else if (type.isAssignableFrom(Boolean.class))
{
newValue = Boolean.valueOf(newValueString);
}
else if (type.isAssignableFrom(String.class))
{
newValue = newValueString;
}
else
{
throw new Exception("Unknown complex field type.");
}
}
field.setAccessible(true);
final Object oldValue = field.get(Class.forName(className));
if (oldValue != null)
{
field.set(oldValue, newValue);
}
field.setAccessible(false);
}
}
}
}

View File

@ -98,7 +98,7 @@ public class Command_enchant extends FreedomCommand
try
{
ench = Enchantment.getByName(args[1]);
ench = Enchantment.getByName(args[1].toUpperCase());
}
catch (Exception ex)
{

View File

@ -1,30 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Lists all possible enchantments.", usage = "/<command>")
public class Command_enchantments extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
String list = "All possible enchantments: ";
for (Enchantment enchantment : Enchantment.values())
{
list += enchantment.getName() + ", ";
}
// Remove extra comma at the end of the list
list = list.substring(0, list.length() - 2);
msg(list);
return true;
}
}

View File

@ -6,8 +6,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Go to \"The End\".", usage = "/<command>", aliases = "end")
public class Command_ender extends FreedomCommand
@CommandParameters(description = "Go to \"The End\".", usage = "/<command>")
public class Command_end extends FreedomCommand
{
@Override

View File

@ -1,150 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Executive only commands - more items will be added shortly!", usage = "/<command> [hell: <username>]", aliases = "exec")
public class Command_executive extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!FUtil.isExecutive(sender.getName()))
{
msg("You aren't an executive, have a cookie instead!");
if (!senderIsConsole)
{
final int firstEmpty = playerSender.getInventory().firstEmpty();
final ItemStack cakeItem = new ItemStack(Material.COOKIE);
playerSender.getInventory().setItem(firstEmpty, cakeItem);
}
else
{
msg("Sorry, you're not an in-game player, so it's impossible to give you a cookie :(");
}
return true;
}
if (args.length > 0)
{
switch (args[0])
{
case "hell":
{
if (args.length == 2)
{
if (getPlayer(args[1]) == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
final Player player = getPlayer(args[1]);
FUtil.adminAction(sender.getName(), "Calling Satan to open the gates of hell for " + player.getName(), true);
FUtil.bcastMsg(player.getName() + " is going to have a bad time!", ChatColor.RED);
final String IP = player.getAddress().getAddress().getHostAddress().trim();
if (plugin.al.isAdmin(player))
{
Admin admin = plugin.al.getAdmin(player);
admin.setActive(false);
plugin.al.save();
plugin.al.updateTables();
}
player.setVelocity(new Vector(0, Math.max(1.0, Math.min(150, 30)), 0));
player.setWhitelisted(false);
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
player.closeInventory();
player.getInventory().clear();
player.setFireTicks(10000);
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_DEATH, 100, -1f);
player.getEnderChest().clear();
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, null));
new BukkitRunnable()
{
@Override
public void run()
{
player.getWorld().strikeLightning(player.getLocation());
}
}.runTaskLater(plugin, 20L * 2L);
new BukkitRunnable()
{
@Override
public void run()
{
player.getWorld().strikeLightning(player.getLocation());
}
}.runTaskLater(plugin, 20L * 2L);
FUtil.bcastMsg("The gates to hell have opened, let the wrath of " + sender.getName() + " condem " + player.getName() + "!", ChatColor.RED);
player.setFireTicks(10000);
final CommandSender cSender = sender;
new BukkitRunnable()
{
@Override
public void run()
{
banPlayer(player.getName(), "Get your fucking shit together and then call back kthx", true, false);
FUtil.adminAction(cSender.getName(), "Has sent " + player.getName() + " to hell, IP: " + IP, true);
player.kickPlayer(ChatColor.RED + "Welcome to hell you fucking cuck");
}
}.runTaskLater(plugin, 40L * 4L);
return true;
}
else
{
return false;
}
}
}
return false;
}
return false;
}
public void banPlayer(String playerName, String reason, Boolean silent, Boolean kick)
{
PlayerData playerData = plugin.pl.getData(playerName);
final List<String> ips = new ArrayList<>();
ips.addAll(playerData.getIps());
String username;
final Player player = getPlayer(args[1]);
username = playerName;
if (!silent)
{
FUtil.adminAction(sender.getName(), "Banning " + username, true);
msg(sender, player.getName() + " has been banned and IP is: " + ips);
}
Ban ban = Ban.forPlayerName(username, sender, null, reason);
for (String ip : ips)
{
ban.addIp(ip);
ban.addIp(FUtil.getFuzzyIp(ip));
}
plugin.bm.addBan(ban);
if (player != null && kick)
{
player.kickPlayer(ban.bakeKickMessage(Ips.getIp(player)));
}
}
}

View File

@ -21,11 +21,11 @@ public class Command_invsee extends FreedomCommand
return false;
}
Player player = getPlayer(args[0]);
Player player = getPlayer(args[0], true);
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
if (player == null)
{
msg("This player is not online.");
msg(PLAYER_NOT_FOUND);
return false;
}

View File

@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.rank.Rank;
@ -49,6 +50,11 @@ public class Command_list extends FreedomCommand
listFilter = ListFilter.VANISHED_ADMINS;
break;
}
case "-t":
{
listFilter = ListFilter.TELNET_SESSIONS;
break;
}
case "-i":
{
listFilter = ListFilter.IMPOSTORS;
@ -71,49 +77,65 @@ public class Command_list extends FreedomCommand
}
StringBuilder onlineStats = new StringBuilder();
StringBuilder onlineUsers = new StringBuilder();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - plugin.al.vanished.size())
.append(ChatColor.BLUE)
.append(" out of a maximum ")
.append(ChatColor.RED)
.append(server.getMaxPlayers())
.append(ChatColor.BLUE)
.append(" players online.");
List<String> n = new ArrayList<>();
for (Player p : server.getOnlinePlayers())
{
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
{
continue;
}
if (listFilter == ListFilter.ADMINS && plugin.al.vanished.contains(p))
{
continue;
}
if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.vanished.contains(p))
{
continue;
}
if (listFilter == ListFilter.IMPOSTORS && !plugin.al.isAdminImpostor(p))
{
continue;
}
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(p.getName().toLowerCase()))
{
continue;
}
if (listFilter == ListFilter.PLAYERS && plugin.al.vanished.contains(p))
{
continue;
}
final Displayable display = plugin.rm.getDisplay(p);
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldTags())
List<String> n = new ArrayList<>();
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender) && plugin.al.getAdmin(sender).getRank().isAtLeast(Rank.TELNET_ADMIN))
{
List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
.append(ChatColor.BLUE)
.append(" admins connected to telnet.");
for (Admin admin : connectedAdmins)
{
n.add(getOldPrefix(display) + p.getName());
n.add(plugin.rm.getDisplay(admin).getColoredTag() + admin.getName());
}
else
}
else
{
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - plugin.al.vanished.size())
.append(ChatColor.BLUE)
.append(" out of a maximum ")
.append(ChatColor.RED)
.append(server.getMaxPlayers())
.append(ChatColor.BLUE)
.append(" players online.");
for (Player p : server.getOnlinePlayers())
{
n.add(display.getColoredTag() + p.getName());
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
{
continue;
}
if (listFilter == ListFilter.ADMINS && plugin.al.vanished.contains(p))
{
continue;
}
if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.vanished.contains(p))
{
continue;
}
if (listFilter == ListFilter.IMPOSTORS && !plugin.al.isAdminImpostor(p))
{
continue;
}
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(p.getName().toLowerCase()))
{
continue;
}
if (listFilter == ListFilter.PLAYERS && plugin.al.vanished.contains(p))
{
continue;
}
final Displayable display = plugin.rm.getDisplay(p);
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldTags())
{
n.add(getOldPrefix(display) + p.getName());
}
else
{
n.add(display.getColoredTag() + p.getName());
}
}
}
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
@ -158,6 +180,7 @@ public class Command_list extends FreedomCommand
PLAYERS,
ADMINS,
VANISHED_ADMINS,
TELNET_SESSIONS,
FAMOUS_PLAYERS,
IMPOSTORS
}

View File

@ -18,7 +18,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [[-s | -q] <player> [reason] | list | purge | all]", aliases = "stfu")
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
public class Command_mute extends FreedomCommand
{
@ -129,16 +129,21 @@ public class Command_mute extends FreedomCommand
if (!playerdata.isMuted())
{
playerdata.setMuted(true);
player.sendTitle(ChatColor.RED + "You've been muted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
if (reason != null)
{
msg(player, ChatColor.RED + "Reason: " + ChatColor.YELLOW + reason);
}
if (quiet)
{
playerdata.setMuted(true);
playerdata.setQuietMuted(true);
msg("Muted " + player.getName() + " quietly");
return true;
}
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
playerdata.setMuted(true);
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
if (smite)
{
@ -146,11 +151,6 @@ public class Command_mute extends FreedomCommand
}
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
player.sendTitle(ChatColor.RED + "You've been muted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
if (reason != null)
{
msg(player, ChatColor.RED + "Reason: " + ChatColor.YELLOW + reason);
}
msg("Muted " + player.getName());
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.MUTE, reason));

View File

@ -142,16 +142,23 @@ public class Command_myadmin extends FreedomCommand
return false;
}
String msg = StringUtils.join(args, " ", 1, args.length);
if (!msg.contains("%rank%") && !msg.contains("%coloredrank%"))
String message = StringUtils.join(args, " ", 1, args.length);
if (!message.contains("%rank%") && !message.contains("%coloredrank%"))
{
msg("Your login message must contain your rank. Use either %rank% or %coloredrank% to specify where you want the rank", ChatColor.RED);
return true;
}
int length = message.replace("%name%", "").replace("%rank%", "").replace("%coloredrank%", "").length();
if (length > 64)
{
msg("Your login message cannot be more than 64 characters (excluding your rank and your name)", ChatColor.RED);
return true;
}
String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
FUtil.adminAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
target.setLoginMessage(msg);
target.setLoginMessage(message);
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
msg("> " + ChatColor.AQUA + (msg.contains("%name%") ? "" : target.getName() + " is ") + FUtil.colorize(msg).replace("%name%", targetPlayer.getName()).replace("%rank%", plugin.rm.getDisplay(target).getName()).replace("%coloredrank%", plugin.rm.getDisplay(target).getColoredName()));
msg("> " + previewMessage);
plugin.al.save();
plugin.al.updateTables();
return true;

View File

@ -100,7 +100,7 @@ public class Command_notes extends FreedomCommand
}
else
{
msg("No note with the ID of " + args[2] + "exists.", ChatColor.RED);
msg("No note with the ID of " + args[2] + " exists.", ChatColor.RED);
}
return true;
}

View File

@ -60,9 +60,9 @@ public class Command_potion extends FreedomCommand
if (args.length == 2)
{
target = getPlayer(args[1]);
target = getPlayer(args[1], true);
if (target == null || plugin.al.vanished.contains(target) && !plugin.al.isAdmin(sender))
if (target == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;

View File

@ -35,9 +35,9 @@ public class Command_rank extends FreedomCommand
return false;
}
final Player player = getPlayer(args[0]);
final Player player = getPlayer(args[0], true);
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;

View File

@ -15,7 +15,6 @@ public class Command_reactionbar extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.sh.reactionString.isEmpty())
{
ActionBarAPI.sendActionBar(playerSender, ChatColor.BOLD + plugin.sh.reactionString, 15 * 20);

View File

@ -21,9 +21,9 @@ public class Command_report extends FreedomCommand
return false;
}
Player player = getPlayer(args[0]);
Player player = getPlayer(args[0], true);
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
if (player == null)
{
msg(PLAYER_NOT_FOUND);
return true;

View File

@ -1,35 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Kicks everyone and restarts the server.", usage = "/<command>")
public class Command_restart extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.amp.enabled)
{
msg(ChatColor.RED + "AMP integration is not enabled. Please use /stop instead.");
return true;
}
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
for (Player player : server.getOnlinePlayers())
{
player.kickPlayer(ChatColor.LIGHT_PURPLE + "Server is going offline, come back in about 20 seconds.");
}
plugin.amp.restartServer();
return true;
}
}

View File

@ -83,8 +83,8 @@ public class Command_ride extends FreedomCommand
}
}
final Player player = getPlayer(args[0]);
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
final Player player = getPlayer(args[0], true);
if (player == null)
{
msg(PLAYER_NOT_FOUND);
return true;

View File

@ -156,10 +156,13 @@ public class Command_ro extends FreedomCommand
if (data instanceof Waterlogged)
{
Waterlogged waterloggedData = (Waterlogged)data;
waterloggedData.setWaterlogged(false);
block.setBlockData(waterloggedData);
affected++;
continue;
if (waterloggedData.isWaterlogged())
{
waterloggedData.setWaterlogged(false);
block.setBlockData(waterloggedData);
affected++;
continue;
}
}
block.setType(toMaterial);
affected++;

View File

@ -1,85 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | undo [partialname] purge [partialname] | purgeall>", aliases = "rb")
public class Command_rollback extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, 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]))
{
FUtil.adminAction(sender.getName(), "Purging all rollback history", false);
msg("Purged all rollback history for " + plugin.rb.purgeEntries() + " players.");
}
else
{
final String playerName = plugin.rb.findPlayer(args[0]);
if (playerName == null)
{
msg("That player has no entries stored.");
return true;
}
if (plugin.rb.canUndoRollback(playerName))
{
msg("That player has just been rolled back.");
}
FUtil.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
msg("Rolled back " + plugin.rb.rollback(playerName) + " edits for " + playerName + ".");
msg("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 = plugin.rb.findPlayer(args[1]);
if (playerName == null)
{
msg("That player has no entries stored.");
return true;
}
msg("Purged " + plugin.rb.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
return true;
}
if ("undo".equalsIgnoreCase(args[0]))
{
final String playerName = plugin.rb.findPlayer(args[1]);
if (playerName == null)
{
msg("That player hasn't been rolled back recently.");
return true;
}
FUtil.adminAction(sender.getName(), "Reverting rollback for player: " + playerName, false);
msg("Reverted " + plugin.rb.undoRollback(playerName) + " edits for " + playerName + ".");
return true;
}
}
return false;
}
}

View File

@ -5,6 +5,7 @@ import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -15,7 +16,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason]")
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-q]")
public class Command_smite extends FreedomCommand
{
@ -27,21 +28,37 @@ public class Command_smite extends FreedomCommand
return false;
}
final Player player = getPlayer(args[0]);
String reason = null;
if (args.length > 1)
Boolean silent = false;
if (args.length >= 2)
{
reason = StringUtils.join(args, " ", 1, args.length);
if (args[args.length - 1].equalsIgnoreCase("-q"))
{
if (args[args.length - 1].equalsIgnoreCase("-q"))
{
silent = true;
}
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
smite(sender, player, reason);
smite(sender, player, reason, silent);
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
@ -50,10 +67,15 @@ public class Command_smite extends FreedomCommand
public static void smite(CommandSender sender, Player player)
{
smite(sender, player, null);
smite(sender, player, null, false);
}
public static void smite(CommandSender sender, Player player, String reason)
{
smite(sender, player, reason, false);
}
public static void smite(CommandSender sender, Player player, String reason, Boolean silent)
{
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
@ -62,7 +84,11 @@ public class Command_smite extends FreedomCommand
{
FUtil.bcastMsg(" Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
}
FUtil.bcastMsg(" Smitten by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
if (!silent)
{
FUtil.bcastMsg(" Smitten by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
}
// Deop
player.setOp(false);

View File

@ -10,11 +10,9 @@ import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r[estore]]")
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r]")
public class Command_unban extends FreedomCommand
{
@ -26,7 +24,6 @@ public class Command_unban extends FreedomCommand
String username;
final List<String> ips = new ArrayList<>();
final PlayerData entry = plugin.pl.getData(args[0]);
final Player player = getPlayer(args[0]);
if (entry == null)
{
@ -38,30 +35,14 @@ public class Command_unban extends FreedomCommand
ips.addAll(entry.getIps());
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
playerMsg(sender, ChatColor.GRAY + username + " has been unbanned and IP is: " + StringUtils.join(ips, ", "));
msg(username + " has been unbanned along with the following IPs: " + StringUtils.join(ips, ", "));
plugin.bm.removeBan(plugin.bm.getByUsername(username));
if (args.length >= 2)
{
if (args[1].equalsIgnoreCase("-r") || args[1].equalsIgnoreCase("-restore"))
if (args[1].equalsIgnoreCase("-r"))
{
if (!plugin.cpb.isEnabled())
{
// Redo WorldEdits
try
{
plugin.web.redo(player, 15);
}
catch (NoClassDefFoundError | NullPointerException ex)
{
}
// Rollback
plugin.rb.undoRollback(username);
}
else
{
plugin.cpb.restore(username);
}
plugin.cpb.restore(username);
msg("Restored edits for: " + username);
}
}

View File

@ -5,13 +5,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -58,11 +54,12 @@ public class Command_unmute extends FreedomCommand
if (playerdata.isMuted())
{
if (quiet || playerdata.isQuietMuted())
playerdata.setMuted(false);
msg(player, "You have been unmuted.", ChatColor.RED);
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
if (quiet)
{
playerdata.setMuted(false);
playerdata.setQuietMuted(false);
msg("Unmuted " + player.getName() + " quietly");
return true;
}
@ -78,7 +75,6 @@ public class Command_unmute extends FreedomCommand
msg(ChatColor.RED + "That player is not muted.");
}
return true;
}

View File

@ -62,8 +62,10 @@ public class Command_vanish extends FreedomCommand
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player))
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has unvanished and is now visible to everyone." );
player.showPlayer(plugin, playerSender);
{
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has unvanished and is now visible to everyone.");
player.showPlayer(plugin, playerSender);
}
}
plugin.esb.setVanished(playerSender.getName(), false);
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));

View File

@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -27,9 +28,11 @@ public class Command_wipeflatlands extends FreedomCommand
FUtil.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY);
World flatlands = plugin.wm.flatlands.getWorld();
if (plugin.wgb.isEnabled())
{
plugin.wgb.wipeRegions(plugin.wm.flatlands.getWorld());
plugin.wgb.wipeRegions(flatlands);
}
for (Player player : server.getOnlinePlayers())
@ -37,13 +40,13 @@ public class Command_wipeflatlands extends FreedomCommand
player.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes.");
}
if (!plugin.amp.enabled)
if (plugin.cpb.isEnabled())
{
server.shutdown();
plugin.cpb.clearDatabase(flatlands, true);
}
else
{
plugin.amp.restartServer();
server.shutdown();
}
return true;

View File

@ -71,12 +71,6 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
}
}
/*@Override
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
{
return null;
}*/
// Doesn't need to do any starts-with checks
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
return null;
}
@ -85,7 +79,8 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
{
List<String> options = getTabCompleteOptions(sender, command, alias, args);
if (options == null) {
if (options == null)
{
return null;
}
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
@ -140,6 +135,16 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
return Players.getPlayer(name);
}
protected Player getPlayer(String name, Boolean nullVanished)
{
Player player = Players.getPlayer(name);
if (nullVanished && plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
return null;
}
return Players.getPlayer(name);
}
protected void msg(final CommandSender sender, final String message, final ChatColor color)
{
if (sender == null)

View File

@ -150,12 +150,7 @@ public enum ConfigEntry
VOTING_INFO(List.class, "votinginfo"),
MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"),
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
TOGGLE_CHAT(Boolean.class, "toggle_chat"),
//
AMP_ENABLED(Boolean.class, "amp.enabled"),
AMP_USERNAME(String.class, "amp.username"),
AMP_PASSWORD(String.class, "amp.password"),
AMP_URL(String.class, "amp.url");
TOGGLE_CHAT(Boolean.class, "toggle_chat");
//
private final Class<?> type;
private final String configName;

View File

@ -37,10 +37,13 @@ public class Module_players extends HTTPDModule
// All online players
for (Player player : Bukkit.getOnlinePlayers())
{
players.add(player.getName());
if (plugin.al.isAdmin(player) && !plugin.al.isAdminImpostor(player))
if (!plugin.al.vanished.contains(player))
{
onlineadmins.add(player.getName());
players.add(player.getName());
if (plugin.al.isAdmin(player) && !plugin.al.isAdminImpostor(player))
{
onlineadmins.add(player.getName());
}
}
}

View File

@ -76,9 +76,6 @@ public class FPlayer
@Getter
@Setter
private boolean invSee = false;
@Setter
@Getter
private boolean quietMuted = false;
public FPlayer(TotalFreedomMod plugin, Player player)
{

View File

@ -239,17 +239,8 @@ public class RankManager extends FreedomService
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.mbl.isMasterBuilder(player))
{
final Displayable display = getDisplay(player);
String loginMsg = display.getColoredLoginMessage();
if (isAdmin)
{
Admin admin = plugin.al.getAdmin(player);
if (admin.hasLoginMessage())
{
loginMsg = ChatUtils.colorize(admin.getLoginMessage()).replace("%rank%", plugin.rm.getDisplay(admin).getName()).replace("%coloredrank%", plugin.rm.getDisplay(admin).getColoredName());
}
}
FUtil.bcastMsg(ChatColor.AQUA + (loginMsg.contains("%name%") ? "" : player.getName() + " is ") + FUtil.colorize(loginMsg).replace("%name%", player.getName()));
FUtil.bcastMsg(craftLoginMessage(player, null));
plugin.pl.getPlayer(player).setTag(display.getColoredTag());
if (isAdmin)
@ -279,4 +270,26 @@ public class RankManager extends FreedomService
}
}
}
public String craftLoginMessage(Player player, String message)
{
Displayable display = plugin.rm.getDisplay(player);
String loginMessage = ChatColor.AQUA + player.getName() + " is " + display.getColoredLoginMessage();
if (plugin.al.isAdmin(player))
{
Admin admin = plugin.al.getAdmin(player);
if (admin.hasLoginMessage())
{
if (message == null)
{
message = admin.getLoginMessage();
}
loginMessage = FUtil.colorize(ChatColor.AQUA + (message.contains("%name%") ? "" : player.getName() + " is ")
+ FUtil.colorize(message).replace("%name%", player.getName())
.replace("%rank%", display.getName())
.replace("%coloredrank%", display.getColoredName()));
}
}
return loginMessage;
}
}

View File

@ -1,20 +0,0 @@
package me.totalfreedom.totalfreedommod.rollback;
public enum EntryType
{
BLOCK_PLACE("placed"),
BLOCK_BREAK("broke");
private final String action;
private EntryType(String action)
{
this.action = action;
}
@Override
public String toString()
{
return action;
}
}

View File

@ -1,98 +0,0 @@
package me.totalfreedom.totalfreedommod.rollback;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
public 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 BlockData data;
public final Material blockMaterial;
private final boolean isBreak;
public 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 = block.getBlockData();
this.isBreak = true;
}
else
{
this.blockMaterial = block.getType();
this.data = block.getBlockData();
this.isBreak = false;
}
}
public Location getLocation()
{
try
{
return new Location(Bukkit.getWorld(worldName), x, (int)y, z);
}
catch (Exception ex)
{
FLog.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());
block.setBlockData(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());
block.setBlockData(data);
}
}
}

View File

@ -1,295 +0,0 @@
package me.totalfreedom.totalfreedommod.rollback;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
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.lang.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;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class RollbackManager extends FreedomService
{
private static final Map<String, List<RollbackEntry>> history = Maps.newHashMap();
private static final List<String> removeHistory = Lists.newArrayList();
public RollbackManager(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void blockPlace(BlockPlaceEvent event)
{
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_PLACE));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void blockBreak(BlockBreakEvent event)
{
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_BREAK));
}
private void storeEntry(Player player, RollbackEntry entry)
{
List<RollbackEntry> playerEntryList = getEntriesByPlayer(player.getName());
if (playerEntryList != null)
{
playerEntryList.add(0, entry);
}
}
// May return null
public String findPlayer(String partial)
{
partial = partial.toLowerCase();
for (String player : history.keySet())
{
if (player.toLowerCase().equals(partial))
{
return player;
}
}
for (String player : history.keySet())
{
if (player.toLowerCase().contains(partial))
{
return player;
}
}
return null;
}
public int purgeEntries()
{
Iterator<List<RollbackEntry>> it = history.values().iterator();
while (it.hasNext())
{
List<RollbackEntry> playerEntryList = it.next();
if (playerEntryList != null)
{
playerEntryList.clear();
}
}
return history.size();
}
public int purgeEntries(String playerName)
{
List<RollbackEntry> playerEntryList = getEntriesByPlayer(playerName);
if (playerEntryList == null)
{
return 0;
}
int count = playerEntryList.size();
playerEntryList.clear();
return count;
}
public boolean canRollback(String playerName)
{
return history.containsKey(playerName.toLowerCase()) && !history.get(playerName.toLowerCase()).isEmpty();
}
public boolean canUndoRollback(String playerName)
{
return removeHistory.contains(playerName.toLowerCase());
}
public 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 (!removeHistory.contains(playerName.toLowerCase()))
{
removeHistory.add(playerName.toLowerCase());
}
new BukkitRunnable()
{
@Override
public void run()
{
if (removeHistory.contains(playerName.toLowerCase()))
{
removeHistory.remove(playerName.toLowerCase());
purgeEntries(playerName);
}
}
}.runTaskLater(plugin, 40L * 20L);
return count;
}
public 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();
}
}
if (removeHistory.contains(playerName.toLowerCase()))
{
removeHistory.remove(playerName.toLowerCase());
}
return count;
}
public 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<>();
for (String playername : history.keySet())
{
for (RollbackEntry entry : history.get(playername.toLowerCase()))
{
if (testX == entry.x && testY == entry.y && testZ == entry.z && testWorldName.equals(entry.worldName))
{
entries.add(0, entry);
}
}
}
return entries;
}
@EventHandler(ignoreCancelled = false)
public void onPlayerInteract(PlayerInteractEvent event)
{
final Player player = event.getPlayer();
if (!event.hasItem()
|| event.getItem().getType() != Material.STICK
|| !plugin.al.isAdmin(player)
|| !plugin.al.getAdmin(player).getLogStick())
{
return;
}
event.setCancelled(true);
final Block block = DepreciationAggregator.getTargetBlock(player, null, 5);
if (plugin.cpb.isEnabled())
{
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());
}
}
else
{
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 == null ? "" : ":" + entry.data));
}
}
}
private List<RollbackEntry> getEntriesByPlayer(String playerName)
{
playerName = playerName.toLowerCase();
List<RollbackEntry> playerEntryList = history.get(playerName.toLowerCase());
if (playerEntryList == null)
{
playerEntryList = new ArrayList<>();
history.put(playerName.toLowerCase(), playerEntryList);
}
return playerEntryList;
}
}

View File

@ -482,10 +482,3 @@ autokick:
# Blocked Chat Codes - Use &code,&code2,&code3 (No spaces)
blocked_chatcodes: '&0,&k,&m,&n'
# AMP Integration, used to restart server (optional, without it, have to start server manually after stop)
amp:
enabled: false
username: username
password: password
url: url