sIgNifICanT buG FixEs (#105)

- Ignore totalfreedom.iml (people who clone from Git get this instead of TotalFreedomMod)
- Essentials check before running /denick
- Revise grammar in /invis
- WorldEdit check for /setl (since W/E is no longer a required dependency)
- WorldEdit check for /gtfo
- WorldEdit check for /unban
- Refactor -> LibsDisguiseBridge: isPluginEnabled -> isEnabled
- Remove unneccesary ChatColor in /wiperegions
- Use BlockData in Trailer
- Revise /wiewarps grammar
This commit is contained in:
Telesphoreo 2018-07-28 00:11:48 -07:00 committed by Seth
parent ed9200689c
commit 9c2f181ab9
24 changed files with 141 additions and 110 deletions

3
.gitignore vendored
View File

@ -21,6 +21,9 @@ manifest.mf
*.iws
/.idea
# Ignore this file for people who clone from Git
totalfreedom.iml
# Maven excludes
/target

View File

@ -10,7 +10,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.15.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
@ -26,6 +25,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-LibsDisguises:c213295f95" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.4.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT" level="project" />

View File

@ -124,5 +124,4 @@ public class AntiSpam extends FreedomService
event.setCancelled(true);
}
}
}

View File

@ -51,7 +51,6 @@ public class AutoKick extends FreedomService
private void autoKickCheck()
{
final boolean doAwayKickCheck
= plugin.esb.isEssentialsEnabled()
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);

View File

@ -1,17 +1,18 @@
package me.totalfreedom.totalfreedommod;
import java.text.DecimalFormat;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.projectiles.ProjectileSource;
import java.text.DecimalFormat;
public class Monitors extends FreedomService
{

View File

@ -14,6 +14,7 @@ import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.freeze.Freezer;
import me.totalfreedom.totalfreedommod.fun.*;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderWorldRestrictions;
import me.totalfreedom.totalfreedommod.player.PlayerList;
@ -153,6 +154,8 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
backups.createBackups(AdminList.CONFIG_FILENAME);
backups.createBackups(PermbanList.CONFIG_FILENAME);
backups.createBackups(MasterBuilder.CONFIG_FILENAME);
backups.createBackups(PunishmentList.CONFIG_FILENAME);
config = new MainConfig(this);
config.load();
@ -340,5 +343,4 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
{
return new CleanroomChunkGenerator(id);
}
}

View File

@ -98,7 +98,7 @@ public class CoreProtectBridge extends FreedomService
return coreProtect != null && coreProtect.isEnabled();
}
// Rollback the specifed player's edits that were in the last 24 hours.
// Rollback the specified player's edits that were in the last 24 hours.
public void rollback(final String name)
{
final CoreProtectAPI coreProtect = getCoreProtectAPI();
@ -118,7 +118,7 @@ public class CoreProtectBridge extends FreedomService
}.runTaskAsynchronously(plugin);
}
// Reverts a rollback for the specifed player's edits that were in the last 24 hours.
// Reverts a rollback for the specified player's edits that were in the last 24 hours.
public void restore(final String name)
{
final CoreProtectAPI coreProtect = getCoreProtectAPI();
@ -207,8 +207,8 @@ public class CoreProtectBridge extends FreedomService
return;
}
/* As CoreProtect doesn't have an api method for deleting all of the data for a specific world
we have to do this manually via sql */
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
we have to do this manually via SQL */
File databaseFile = getDatabase();
Connection connection = null;
try

View File

@ -7,6 +7,7 @@ import me.totalfreedom.libsdisguise.TF_DisguiseAPI;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.coreprotect.CoreProtect;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -124,15 +125,10 @@ public class LibsDisguisesBridge extends FreedomService
return !DisallowedDisguises.disabled;
}
public boolean isPluginEnabled()
public boolean isEnabled()
{
Plugin ld = getLibsDisguisesPlugin();
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
if (ld == null)
{
return false;
}
return ld.isEnabled();
return libsDisguises != null && libsDisguises.isEnabled();
}
}

View File

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.bridge;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import me.totalfreedom.totalfreedommod.FreedomService;
@ -14,7 +15,7 @@ public class WorldEditBridge extends FreedomService
private final WorldEditListener listener;
//
private WorldEditPlugin worldedit = null;
private WorldEditPlugin worldeditPlugin = null;
public WorldEditBridge(TotalFreedomMod plugin)
{
@ -34,6 +35,30 @@ public class WorldEditBridge extends FreedomService
listener.unregister();
}
private WorldEditPlugin getWorldEditPlugin()
{
if (worldeditPlugin == null)
{
try
{
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
if (we != null)
{
if (we instanceof WorldEditPlugin)
{
worldeditPlugin = (WorldEditPlugin) we;
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return worldeditPlugin;
}
public void undo(Player player, int count)
{
try
@ -80,30 +105,6 @@ public class WorldEditBridge extends FreedomService
}
}
private WorldEditPlugin getWorldEditPlugin()
{
if (worldedit == null)
{
try
{
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
if (we != null)
{
if (we instanceof WorldEditPlugin)
{
worldedit = (WorldEditPlugin) we;
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return worldedit;
}
public void setLimit(Player player, int limit)
{
try
@ -158,4 +159,21 @@ public class WorldEditBridge extends FreedomService
return null;
}
}
public boolean isWorldEditEnabled()
{
try
{
WorldEditPlugin worldedit = getWorldEditPlugin();
if (worldedit != null)
{
return worldedit.isEnabled();
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return false;
}
}

View File

@ -39,12 +39,9 @@ public class WorldGuardBridge extends FreedomService
try
{
final Plugin worldGuard = server.getPluginManager().getPlugin("WorldGuard");
if (worldGuard != null)
if (worldGuard != null && worldGuard instanceof WorldGuardPlugin)
{
if (worldGuard instanceof WorldGuardPlugin)
{
worldGuardPlugin = (WorldGuardPlugin) worldGuard;
}
worldGuardPlugin = (WorldGuardPlugin) worldGuard;
}
}
catch (Exception ex)
@ -72,9 +69,20 @@ public class WorldGuardBridge extends FreedomService
return false;
}
public boolean isPluginEnabled() {
Plugin wr = getWorldGuardPlugin();
return wr != null && wr.isEnabled();
public boolean isPluginEnabled()
{
try
{
WorldGuardPlugin wg = getWorldGuardPlugin();
if (wg != null)
{
return wg.isEnabled();
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return false;
}
}

View File

@ -14,6 +14,12 @@ public class Command_denick extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.esb.isEssentialsEnabled())
{
msg("Essentials is not enabled on this server.");
return true;
}
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
for (Player player : server.getOnlinePlayers())

View File

@ -16,7 +16,7 @@ public class Command_disguisetoggle extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.ldb.isPluginEnabled())
if (!plugin.ldb.isEnabled())
{
msg(ChatColor.RED + "LibsDisguises is not enabled.");
return true;

View File

@ -2,12 +2,11 @@ package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@ -17,6 +16,9 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans a player", usage = "/<command> <username> [reason] [-nrb]", aliases = "ban")
public class Command_gtfo extends FreedomCommand
@ -103,7 +105,10 @@ public class Command_gtfo extends FreedomCommand
// Undo WorldEdits
try
{
plugin.web.undo(player, 15);
if (plugin.web.isWorldEditEnabled())
{
plugin.web.undo(player, 15);
}
}
catch (NoClassDefFoundError | NullPointerException ex)
{

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
@ -10,11 +8,13 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.List;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally clears) invisisible players", usage = "/<command> (clear)")
@CommandParameters(description = "Shows (optionally clears) invisible players", usage = "/<command> (clear)")
public class Command_invis extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -24,7 +24,7 @@ public class Command_invis extends FreedomCommand
{
if (args[0].equalsIgnoreCase("clear"))
{
FUtil.adminAction(sender.getName(), "Clearing all invis potion effect from all players", true);
FUtil.adminAction(sender.getName(), "Clearing all invisibility potion effects from all players", true);
clear = true;
}
else
@ -51,18 +51,17 @@ public class Command_invis extends FreedomCommand
if (players.isEmpty())
{
sender.sendMessage("There are no invisible players");
msg("There are no invisible players");
return true;
}
if (clear)
{
sender.sendMessage("Cleared " + clears + " players");
msg("Cleared " + clears + " players");
}
else
{
sender.sendMessage("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
msg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
}
return true;
}
}
}

View File

@ -41,7 +41,6 @@ public class Command_nickclean extends FreedomCommand
}
}
}
return true;
}
}

View File

@ -146,7 +146,6 @@ public class Command_plugincontrol extends FreedomCommand
}
}
}
return null;
}
}

View File

@ -8,13 +8,17 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Sets everyone's Worldedit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
@CommandParameters(description = "Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
public class Command_setlimit extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.web.isWorldEditEnabled())
{
msg("WorldEdit is not enabled on this server.");
return true;
}
int amount = 100000;
if (args.length > 0)
{
@ -28,7 +32,7 @@ public class Command_setlimit extends FreedomCommand
return true;
}
}
FUtil.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to " + amount + ".", true);
FUtil.adminAction(sender.getName(), "Setting everyone's WorldEdit block modification limit to " + amount + ".", true);
for (final Player player : server.getOnlinePlayers())
{
plugin.web.setLimit(player, amount);

View File

@ -48,7 +48,10 @@ public class Command_unban extends FreedomCommand
// Redo WorldEdits
try
{
plugin.web.redo(player, 15);
if (plugin.web.isWorldEditEnabled())
{
plugin.web.redo(player, 15);
}
}
catch (NoClassDefFoundError | NullPointerException ex)
{

View File

@ -15,7 +15,7 @@ public class Command_undisguiseall extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.ldb.isPluginEnabled())
if (!plugin.ldb.isEnabled())
{
msg("LibsDisguises is not enabled.");
return true;

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
@ -10,23 +9,27 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Wipe all WorldGuard regions for a specified world.", usage = "/<command> <world>", aliases = "wiperegions")
public class Command_wiperegions extends FreedomCommand {
@CommandParameters(description = "Wipe all WorldGuard regions for a specified world.", usage = "/<command> <world>")
public class Command_wiperegions extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.wgb.isPluginEnabled())
{
msg("WorldGuard is not enabled.", ChatColor.GRAY);
msg("WorldGuard is not enabled.");
return true;
}
if (args.length != 1) {
if (args.length != 1)
{
return false;
}
World world = server.getWorld(args[0]);
if (world == null)
{
msg("World : \"" + args[0] + "\" not found.", ChatColor.GRAY);
msg("World : \"" + args[0] + "\" not found.");
return true;
}
if (world.equals(plugin.wm.adminworld.getWorld()))
@ -40,7 +43,7 @@ public class Command_wiperegions extends FreedomCommand {
}
else
{
msg(ChatColor.RED + "No regions have been found for world: \"" + world.getName() + "\".");
msg(ChatColor.RED + "No regions were found in: \"" + world.getName() + "\".");
return true;
}
}

View File

@ -1,24 +1,25 @@
package me.totalfreedom.totalfreedommod.command;
import java.io.File;
import com.earth2me.essentials.Essentials;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.earth2me.essentials.Essentials;
import java.io.File;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes essentials warps", usage = "/<command>")
@CommandParameters(description = "Removes Essentials warps", usage = "/<command>")
public class Command_wipewarps extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.esb.isEssentialsEnabled())
{
msg("Essentials is not enabled on this server");
msg("Essentials is not enabled on this server.");
return true;
}

View File

@ -7,6 +7,7 @@ import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -66,7 +67,7 @@ public class Trailer extends FreedomService
}
fromBlock.setType(MaterialGroup.WOOL_COLORS.get(random.nextInt(MaterialGroup.WOOL_COLORS.size())));
byte data = DepreciationAggregator.getData_Block(fromBlock);
BlockData data = fromBlock.getBlockData();
Material material = Material.getMaterial(String.valueOf(fromBlock.getType()));
for (int x = -1; x <= 1; x++)
{

View File

@ -56,6 +56,11 @@ public class PlayerData implements ConfigLoadable, ConfigSavable, Validatable
cs.set("last_join", lastJoinUnix);
}
public String getUsername()
{
return username;
}
public List<String> getIps()
{
return Collections.unmodifiableList(ips);

View File

@ -24,26 +24,6 @@ public class DepreciationAggregator
return server.getOfflinePlayer(name);
}
public static byte getData_MaterialData(MaterialData md)
{
return md.getData();
}
public static void setData_MaterialData(MaterialData md, byte data)
{
md.setData(data);
}
public static byte getData_Block(Block block)
{
return block.getData();
}
public static org.bukkit.material.Lever makeLeverWithData(byte data)
{
return new org.bukkit.material.Lever(Material.LEVER, data);
}
public static String getName_EntityType(EntityType et)
{
return et.getName();