Merge branch 'development' into FS-307

This commit is contained in:
Video 2021-06-17 05:56:56 -06:00 committed by GitHub
commit 721f4f9fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 149 additions and 61 deletions

View File

@ -85,6 +85,10 @@ public class AutoEject extends FreedomService
player.kickPlayer(kickMessage); player.kickPlayer(kickMessage);
break; break;
} }
default:
{
FLog.warning("Unrecognized EjectMethod " + method.name() + " found, defaulting to STRIKE_THREE");
}
case STRIKE_THREE: case STRIKE_THREE:
{ {
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage)); plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));

View File

@ -25,11 +25,6 @@ public class CommandSpy extends FreedomService
{ {
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy()) if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
{ {
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
{
continue;
}
if (player != event.getPlayer()) if (player != event.getPlayer())
{ {
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage()); FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());

View File

@ -43,6 +43,7 @@ public class IndefiniteBan implements IConfig
@Override @Override
public void saveTo(ConfigurationSection cs) public void saveTo(ConfigurationSection cs)
{ {
// The indefinite ban list is only intended to be modified manually. It is not intended to save.
} }
@Override @Override

View File

@ -171,6 +171,11 @@ public class BlockBlocker extends FreedomService
} }
break; break;
} }
default:
{
// Do nothing
break;
}
} }
if (Groups.BANNERS.contains(event.getBlockPlaced().getType())) if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))

View File

@ -36,10 +36,9 @@ public class InteractBlocker extends FreedomService
break; break;
} }
case LEFT_CLICK_AIR: default:
case LEFT_CLICK_BLOCK:
{ {
// // Do nothing
break; break;
} }
} }
@ -158,6 +157,11 @@ public class InteractBlocker extends FreedomService
event.setCancelled(true); event.setCancelled(true);
break; break;
} }
default:
{
// Do nothing
break;
}
} }
} }
} }

View File

@ -83,6 +83,10 @@ public class Command_cage extends FreedomCommand
msg("Invalid block!", ChatColor.RED); msg("Invalid block!", ChatColor.RED);
break; break;
} }
default:
{
return false;
}
} }
} }

View File

@ -64,6 +64,12 @@ public class Command_entitywipe extends FreedomCommand
return true; return true;
} }
if (type == EntityType.PLAYER)
{
msg("Player entities cannot be purged.", ChatColor.RED);
return true;
}
if (!getAllEntities().contains(type)) if (!getAllEntities().contains(type))
{ {
msg(FUtil.formatName(type.name()) + " is an entity, however: it is a mob.", ChatColor.RED); msg(FUtil.formatName(type.name()) + " is an entity, however: it is a mob.", ChatColor.RED);

View File

@ -35,8 +35,8 @@ public class Command_manageshop extends FreedomCommand
} }
switch (args[1]) switch (args[1])
{ {
case "add": case "add":
{
try try
{ {
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2]))); int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
@ -75,7 +75,9 @@ public class Command_manageshop extends FreedomCommand
msg("Invalid number: " + args[2], ChatColor.RED); msg("Invalid number: " + args[2], ChatColor.RED);
return true; return true;
} }
}
case "remove": case "remove":
{
try try
{ {
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2]))); int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
@ -122,7 +124,9 @@ public class Command_manageshop extends FreedomCommand
msg("Invalid number: " + args[2], ChatColor.RED); msg("Invalid number: " + args[2], ChatColor.RED);
return true; return true;
} }
}
case "set": case "set":
{
try try
{ {
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2]))); int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
@ -148,6 +152,11 @@ public class Command_manageshop extends FreedomCommand
return true; return true;
} }
} }
default:
{
return false;
}
}
} }
else if (args[0].equals("items")) else if (args[0].equals("items"))
{ {

View File

@ -116,9 +116,13 @@ public class Command_notes extends FreedomCommand
msg("Cleared " + count + " notes.", ChatColor.GREEN); msg("Cleared " + count + " notes.", ChatColor.GREEN);
return true; return true;
} }
}
default:
{
return false; return false;
} }
}
}
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)

View File

@ -29,6 +29,7 @@ public class Command_potion extends FreedomCommand
switch (args.length) switch (args.length)
{ {
case 1: case 1:
{
if (args[0].equalsIgnoreCase("list")) if (args[0].equalsIgnoreCase("list"))
{ {
List<String> potionEffectTypeNames = new ArrayList<>(); List<String> potionEffectTypeNames = new ArrayList<>();
@ -58,8 +59,10 @@ public class Command_potion extends FreedomCommand
} }
} }
} }
}
case 2: case 2:
{
if (args[0].equalsIgnoreCase("clear")) if (args[0].equalsIgnoreCase("clear"))
{ {
Player target = playerSender; Player target = playerSender;
@ -95,9 +98,11 @@ public class Command_potion extends FreedomCommand
msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player " + target.getName() + "." : "from yourself."), ChatColor.AQUA); msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player " + target.getName() + "." : "from yourself."), ChatColor.AQUA);
} }
break; break;
}
case 4: case 4:
case 5: case 5:
{
if (args[0].equalsIgnoreCase("add")) if (args[0].equalsIgnoreCase("add"))
{ {
Player target = playerSender; Player target = playerSender;
@ -167,9 +172,12 @@ public class Command_potion extends FreedomCommand
+ (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA); + (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
} }
break; break;
}
default: default:
{
return false; return false;
} }
}
return true; return true;
} }
@ -179,14 +187,17 @@ public class Command_potion extends FreedomCommand
switch (args.length) switch (args.length)
{ {
case 1: case 1:
{
List<String> arguments = new ArrayList<>(Arrays.asList("list", "clear", "add")); List<String> arguments = new ArrayList<>(Arrays.asList("list", "clear", "add"));
if (plugin.al.isAdmin(sender)) if (plugin.al.isAdmin(sender))
{ {
arguments.add("clearall"); arguments.add("clearall");
} }
return arguments; return arguments;
}
case 2: case 2:
{
if (args[0].equals("clear")) if (args[0].equals("clear"))
{ {
if (plugin.al.isAdmin(sender)) if (plugin.al.isAdmin(sender))
@ -199,22 +210,28 @@ public class Command_potion extends FreedomCommand
return getAllPotionTypes(); return getAllPotionTypes();
} }
break; break;
}
case 3: case 3:
{
if (args[0].equals("add")) if (args[0].equals("add"))
{ {
return Collections.singletonList("<duration>"); return Collections.singletonList("<duration>");
} }
break; break;
}
case 4: case 4:
{
if (args[0].equals("add")) if (args[0].equals("add"))
{ {
return Collections.singletonList("<amplifier>"); return Collections.singletonList("<amplifier>");
} }
break; break;
}
case 5: case 5:
{
if (plugin.al.isAdmin(sender)) if (plugin.al.isAdmin(sender))
{ {
if (args[0].equals("add")) if (args[0].equals("add"))
@ -225,6 +242,12 @@ public class Command_potion extends FreedomCommand
break; break;
} }
default:
{
break;
}
}
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -105,6 +105,11 @@ public class Command_tag extends FreedomCommand
} }
return true; return true;
} }
default:
{
return false;
}
} }
} }
else if (args.length >= 2) else if (args.length >= 2)
@ -279,6 +284,11 @@ public class Command_tag extends FreedomCommand
msg("Tag set to '" + outputTag + ChatColor.GRAY + "'." + (save ? " (Saved)" : "") + from + to); msg("Tag set to '" + outputTag + ChatColor.GRAY + "'." + (save ? " (Saved)" : "") + from + to);
return true; return true;
} }
default:
{
return false;
}
} }
} }
return false; return false;

View File

@ -16,6 +16,12 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]") @CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]")
public class Command_toggle extends FreedomCommand public class Command_toggle extends FreedomCommand
{ {
private final List<String> toggles = Arrays.asList(
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "structureblocks", "jigsaws", "grindstones",
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
"landmines", "tossmob", "gravity");
@Override @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)
@ -23,38 +29,10 @@ public class Command_toggle extends FreedomCommand
if (args.length == 0) if (args.length == 0)
{ {
msg("Available toggles: "); msg("Available toggles: ");
msg("- waterplace"); for (String toggle : toggles)
msg("- fireplace"); {
msg("- lavaplace"); msg("- " + toggle);
msg("- fluidspread"); }
msg("- lavadmg");
msg("- firespread");
msg("- frostwalk");
msg("- firework");
msg("- prelog");
msg("- lockdown");
msg("- petprotect");
msg("- entitywipe");
msg("- nonuke [range] [count]");
msg("- explosives [radius]");
msg("- unsafeenchs");
msg("- bells");
msg("- armorstands");
msg("- structureblocks");
msg("- jigsaws");
msg("- grindstones");
msg("- jukeboxes");
msg("- spawners");
msg("- 4chan");
msg("- beehives");
msg("- respawnanchors");
msg("- autotp");
msg("- autoclear");
msg("- minecarts");
msg("- landmines");
msg("- mp44");
msg("- tossmob");
msg("- gravity");
return false; return false;
} }
@ -304,6 +282,16 @@ public class Command_toggle extends FreedomCommand
toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY); toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
break; break;
} }
default:
{
msg("Available toggles: ");
for (String toggle : toggles)
{
msg("- " + toggle);
}
return false;
}
} }
return true; return true;
} }

View File

@ -1,6 +1,9 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -53,15 +56,16 @@ public class Command_warn extends FreedomCommand
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60); player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
msg(ChatColor.GREEN + "You have successfully warned " + player.getName()); msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
plugin.pl.getPlayer(player).incrementWarnings(quiet);
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.WARN, warnReason));
if (quiet) if (quiet)
{ {
msg("Warned " + player.getName() + " quietly"); msg("You have successfully warned " + player.getName() + " quietly.");
return true;
} }
else
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason); {
String adminNotice = ChatColor.RED + String adminNotice = ChatColor.RED +
sender.getName() + sender.getName() +
" - " + " - " +
@ -71,7 +75,9 @@ public class Command_warn extends FreedomCommand
ChatColor.YELLOW + ChatColor.YELLOW +
warnReason; warnReason;
plugin.al.messageAllAdmins(adminNotice); plugin.al.messageAllAdmins(adminNotice);
plugin.pl.getPlayer(player).incrementWarnings();
msg("You have successfully warned " + player.getName() + ".");
}
return true; return true;
} }
} }

View File

@ -128,7 +128,7 @@ public class ItemFun extends FreedomService
LivingEntity livingEntity = (LivingEntity)event.getRightClicked(); LivingEntity livingEntity = (LivingEntity)event.getRightClicked();
EntityType entityType = livingEntity.getType(); EntityType entityType = livingEntity.getType();
if (!(entityType == fPlayer.mobThrowerCreature())) if (entityType != fPlayer.mobThrowerCreature())
{ {
return; return;
} }
@ -304,6 +304,11 @@ public class ItemFun extends FreedomService
} }
break; break;
} }
default:
{
// Do nothing
break;
}
} }
} }

View File

@ -73,7 +73,7 @@ public class Landminer extends FreedomService
continue; continue;
} }
if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius))) if (player.getLocation().distanceSquared(location) > (landmine.radius * landmine.radius))
{ {
break; break;
} }

View File

@ -79,12 +79,21 @@ public class Module_list extends HTTPDModule
switch (admin.getRank()) switch (admin.getRank())
{ {
case ADMIN: case ADMIN:
{
admins.add(player.getName()); admins.add(player.getName());
break; break;
}
case SENIOR_ADMIN: case SENIOR_ADMIN:
{
senioradmins.add(player.getName()); senioradmins.add(player.getName());
break; break;
} }
default:
{
// Do nothing
break;
}
}
} }
} }

View File

@ -51,12 +51,21 @@ public class Module_players extends HTTPDModule
switch (admin.getRank()) switch (admin.getRank())
{ {
case ADMIN: case ADMIN:
{
admins.add(username); admins.add(username);
break; break;
}
case SENIOR_ADMIN: case SENIOR_ADMIN:
{
senioradmins.add(username); senioradmins.add(username);
break; break;
} }
default:
{
// Do nothing
break;
}
}
} }
masterbuilders.addAll(plugin.pl.getMasterBuilderNames()); masterbuilders.addAll(plugin.pl.getMasterBuilderNames());

View File

@ -429,14 +429,19 @@ public class FPlayer
this.warningCount = warningCount; this.warningCount = warningCount;
} }
public void incrementWarnings() public void incrementWarnings(boolean quiet)
{ {
this.warningCount++; this.warningCount++;
if (this.warningCount % 2 == 0) if (this.warningCount % 2 == 0)
{ {
Player p = getPlayer(); Player p = getPlayer();
if (!quiet)
{
p.getWorld().strikeLightning(p.getLocation()); p.getWorld().strikeLightning(p.getLocation());
}
FUtil.playerMsg(p, ChatColor.RED + "You have been warned at least twice now, make sure to read the rules at " + ConfigEntry.SERVER_BAN_URL.getString()); FUtil.playerMsg(p, ChatColor.RED + "You have been warned at least twice now, make sure to read the rules at " + ConfigEntry.SERVER_BAN_URL.getString());
} }
} }

View File

@ -7,5 +7,6 @@ public enum PunishmentType
KICK, KICK,
TEMPBAN, TEMPBAN,
BAN, BAN,
DOOM DOOM,
WARN
} }