This commit is contained in:
ZeroEpoch1969 2020-03-09 18:58:45 -07:00
parent ecc907b535
commit c94ce6b276
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3
10 changed files with 206 additions and 19 deletions

View File

@ -1,5 +1,7 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -29,6 +31,8 @@ public class LoginProcess extends FreedomService
public static final int MIN_USERNAME_LENGTH = 2; public static final int MIN_USERNAME_LENGTH = 2;
public static final int MAX_USERNAME_LENGTH = 20; public static final int MAX_USERNAME_LENGTH = 20;
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$"); public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
// //
@Getter @Getter
@Setter @Setter
@ -195,18 +199,18 @@ public class LoginProcess extends FreedomService
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60); player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
player.setOp(true); player.setOp(true);
if (ConfigEntry.ALLOW_TPR_ON_JOIN.getBoolean()) if (TELEPORT_ON_JOIN.contains(player.getName()))
{ {
int x = FUtil.random(-10000, 10000); int x = FUtil.random(-10000, 10000);
int z = FUtil.random(-10000, 10000); int z = FUtil.random(-10000, 10000);
int y = player.getWorld().getHighestBlockYAt(x, z); int y = player.getWorld().getHighestBlockYAt(x, z);
Location location = new Location(player.getLocation().getWorld(), x, y, z); Location location = new Location(player.getLocation().getWorld(), x, y, z);
player.teleport(location); player.teleport(location);
player.sendMessage(ChatColor.GOLD + "You have been teleported to a random location automatically."); player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
return; return;
} }
if (ConfigEntry.ALLOW_CLEAR_ON_JOIN.getBoolean()) if (CLEAR_ON_JOIN.contains(player.getName()))
{ {
player.getInventory().clear(); player.getInventory().clear();
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically."); player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");

View File

@ -8,6 +8,7 @@ import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.amp.AMP; import me.totalfreedom.totalfreedommod.amp.AMP;
import me.totalfreedom.totalfreedommod.banning.BanManager; import me.totalfreedom.totalfreedommod.banning.BanManager;
import me.totalfreedom.totalfreedommod.banning.PermbanList; import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.banning.VPNBanList;
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker; import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
import me.totalfreedom.totalfreedommod.blocking.EditBlocker; import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
import me.totalfreedom.totalfreedommod.blocking.EventBlocker; import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
@ -99,6 +100,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public PunishmentList pul; public PunishmentList pul;
public BanManager bm; public BanManager bm;
public PermbanList pm; public PermbanList pm;
public VPNBanList vn;
public ProtectArea pa; public ProtectArea pa;
public GameRuleHandler gr; public GameRuleHandler gr;
public RollbackManager rb; public RollbackManager rb;
@ -174,6 +176,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true); backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
backups.createBackups(AdminList.CONFIG_FILENAME); backups.createBackups(AdminList.CONFIG_FILENAME);
backups.createBackups(PermbanList.CONFIG_FILENAME); backups.createBackups(PermbanList.CONFIG_FILENAME);
backups.createBackups(VPNBanList.CONFIG_FILENAME);
backups.createBackups(MasterBuilder.CONFIG_FILENAME); backups.createBackups(MasterBuilder.CONFIG_FILENAME);
backups.createBackups(PunishmentList.CONFIG_FILENAME); backups.createBackups(PunishmentList.CONFIG_FILENAME);
@ -210,6 +213,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
pul = services.registerService(PunishmentList.class); pul = services.registerService(PunishmentList.class);
bm = services.registerService(BanManager.class); bm = services.registerService(BanManager.class);
pm = services.registerService(PermbanList.class); pm = services.registerService(PermbanList.class);
vn = services.registerService(VPNBanList.class);
pa = services.registerService(ProtectArea.class); pa = services.registerService(ProtectArea.class);
gr = services.registerService(GameRuleHandler.class); gr = services.registerService(GameRuleHandler.class);
snp = services.registerService(SignBlocker.class); snp = services.registerService(SignBlocker.class);

View File

@ -0,0 +1,76 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Sets;
import java.util.Set;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
public class VPNBanList extends FreedomService
{
public static final String CONFIG_FILENAME = "vpnbans.yml";
@Getter
private final Set<String> vpnIps = Sets.newHashSet();
public VPNBanList(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
vpnIps.clear();
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
config.load();
for (String name : config.getKeys(false))
{
vpnIps.addAll(config.getStringList(name));
}
FLog.info("Loaded " + vpnIps.size() + " VPN ips.");
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent event)
{
final String ip = Ips.getIp(event);
// Permbanned IPs
for (String testIp : getVPNIps())
{
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
ChatColor.RED + "Your IP address is detected as a VPN\n"
+ "If you believe this is an error, release procedures are available at\n"
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
return;
}
}
}
public Set<String> getVPNIps()
{
return this.vpnIps;
}
}

View File

@ -0,0 +1,37 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
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 = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
public class Command_autoclear extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
boolean enabled = plugin.lp.CLEAR_ON_JOIN.contains(args[0]);
if (enabled)
{
plugin.lp.CLEAR_ON_JOIN.remove(args[0]);
}
else
{
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
}
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " have their inventory cleared when they join", ChatColor.GREEN);
return true;
}
}

View File

@ -0,0 +1,37 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
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 = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
public class Command_autotp extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
boolean enabled = plugin.lp.TELEPORT_ON_JOIN.contains(args[0]);
if (enabled)
{
plugin.lp.TELEPORT_ON_JOIN.remove(args[0]);
}
else
{
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
}
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " be automatically teleported when they join", ChatColor.GREEN);
return true;
}
}

View File

@ -39,8 +39,6 @@ public class Command_toggle extends FreedomCommand
msg("- unsafeenchs"); msg("- unsafeenchs");
msg("- bells"); msg("- bells");
msg("- armorstands"); msg("- armorstands");
msg("- clearonjoin");
msg("- tpronjoin");
msg("- structureblocks"); msg("- structureblocks");
msg("- jigsaws"); msg("- jigsaws");
msg("- grindstones"); msg("- grindstones");
@ -180,16 +178,6 @@ public class Command_toggle extends FreedomCommand
toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS); toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS);
return true; return true;
} }
else if (args[0].equalsIgnoreCase("clearonjoin"))
{
toggle("The clearing of inventories on join is", ConfigEntry.ALLOW_CLEAR_ON_JOIN);
return true;
}
else if (args[0].equalsIgnoreCase("tpronjoin"))
{
toggle("The random teleporting of players on join is", ConfigEntry.ALLOW_TPR_ON_JOIN);
return true;
}
else if (args[0].equalsIgnoreCase("structureblocks")) else if (args[0].equalsIgnoreCase("structureblocks"))
{ {
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS); toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
@ -244,7 +232,7 @@ public class Command_toggle extends FreedomCommand
return Arrays.asList( return Arrays.asList(
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk", "waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs", "firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
"bells", "armorstands", "clearonjoin", "tpronjoin", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives"); "bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives");
} }
return Collections.emptyList(); return Collections.emptyList();

View File

@ -0,0 +1,35 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
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 = "Manage banned VPN ips.", usage = "/<command> reload")
public class Command_vpnbanlist extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (!args[0].equalsIgnoreCase("reload"))
{
return false;
}
msg("Reloading VPN ban list...", ChatColor.RED);
plugin.vn.stop();
plugin.vn.start();
msg("Reloaded VPN ban list.");
msg(plugin.vn.getVPNIps().size() + " IPs loaded");
return true;
}
}

View File

@ -25,8 +25,6 @@ public enum ConfigEntry
ALLOW_BELLS(Boolean.class, "allow.bells"), ALLOW_BELLS(Boolean.class, "allow.bells"),
ALLOW_ARMOR_STANDS(Boolean.class, "allow.armorstands"), ALLOW_ARMOR_STANDS(Boolean.class, "allow.armorstands"),
ALLOW_MINECARTS(Boolean.class, "allow.minecarts"), ALLOW_MINECARTS(Boolean.class, "allow.minecarts"),
ALLOW_CLEAR_ON_JOIN(Boolean.class, "allow.clearonjoin"),
ALLOW_TPR_ON_JOIN(Boolean.class, "allow.tpronjoin"),
ALLOW_STRUCTURE_BLOCKS(Boolean.class, "allow.structureblocks"), ALLOW_STRUCTURE_BLOCKS(Boolean.class, "allow.structureblocks"),
ALLOW_JIGSAWS(Boolean.class, "allow.jigsaws"), ALLOW_JIGSAWS(Boolean.class, "allow.jigsaws"),
ALLOW_GRINDSTONES(Boolean.class, "allow.grindstones"), ALLOW_GRINDSTONES(Boolean.class, "allow.grindstones"),

View File

@ -145,7 +145,6 @@ allow:
armorstands: true armorstands: true
minecarts: false minecarts: false
clearonjoin: false clearonjoin: false
tpronjoin: false
structureblocks: false structureblocks: false
jigsaws: false jigsaws: false
grindstones: false grindstones: false

View File

@ -0,0 +1,9 @@
#
# TotalFreedomMod 5.2 VPN Bans
#
badnetwork1:
- 123.123.123.123
- 321.321.321.321
badnetwork2:
- 111.111.111.111