mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
things
This commit is contained in:
parent
ecc907b535
commit
c94ce6b276
@ -1,5 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -29,6 +31,8 @@ public class LoginProcess extends FreedomService
|
||||
public static final int MIN_USERNAME_LENGTH = 2;
|
||||
public static final int MAX_USERNAME_LENGTH = 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
|
||||
@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.setOp(true);
|
||||
|
||||
if (ConfigEntry.ALLOW_TPR_ON_JOIN.getBoolean())
|
||||
if (TELEPORT_ON_JOIN.contains(player.getName()))
|
||||
{
|
||||
int x = FUtil.random(-10000, 10000);
|
||||
int z = FUtil.random(-10000, 10000);
|
||||
int y = player.getWorld().getHighestBlockYAt(x, z);
|
||||
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||
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;
|
||||
}
|
||||
|
||||
if (ConfigEntry.ALLOW_CLEAR_ON_JOIN.getBoolean())
|
||||
if (CLEAR_ON_JOIN.contains(player.getName()))
|
||||
{
|
||||
player.getInventory().clear();
|
||||
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
||||
|
@ -8,6 +8,7 @@ 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;
|
||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||
@ -99,6 +100,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
public PunishmentList pul;
|
||||
public BanManager bm;
|
||||
public PermbanList pm;
|
||||
public VPNBanList vn;
|
||||
public ProtectArea pa;
|
||||
public GameRuleHandler gr;
|
||||
public RollbackManager rb;
|
||||
@ -174,6 +176,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||
backups.createBackups(AdminList.CONFIG_FILENAME);
|
||||
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
||||
backups.createBackups(VPNBanList.CONFIG_FILENAME);
|
||||
backups.createBackups(MasterBuilder.CONFIG_FILENAME);
|
||||
backups.createBackups(PunishmentList.CONFIG_FILENAME);
|
||||
|
||||
@ -210,6 +213,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
pul = services.registerService(PunishmentList.class);
|
||||
bm = services.registerService(BanManager.class);
|
||||
pm = services.registerService(PermbanList.class);
|
||||
vn = services.registerService(VPNBanList.class);
|
||||
pa = services.registerService(ProtectArea.class);
|
||||
gr = services.registerService(GameRuleHandler.class);
|
||||
snp = services.registerService(SignBlocker.class);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -39,8 +39,6 @@ public class Command_toggle extends FreedomCommand
|
||||
msg("- unsafeenchs");
|
||||
msg("- bells");
|
||||
msg("- armorstands");
|
||||
msg("- clearonjoin");
|
||||
msg("- tpronjoin");
|
||||
msg("- structureblocks");
|
||||
msg("- jigsaws");
|
||||
msg("- grindstones");
|
||||
@ -180,16 +178,6 @@ public class Command_toggle extends FreedomCommand
|
||||
toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS);
|
||||
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"))
|
||||
{
|
||||
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
|
||||
@ -244,7 +232,7 @@ public class Command_toggle extends FreedomCommand
|
||||
return Arrays.asList(
|
||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||
"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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -25,8 +25,6 @@ public enum ConfigEntry
|
||||
ALLOW_BELLS(Boolean.class, "allow.bells"),
|
||||
ALLOW_ARMOR_STANDS(Boolean.class, "allow.armorstands"),
|
||||
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_JIGSAWS(Boolean.class, "allow.jigsaws"),
|
||||
ALLOW_GRINDSTONES(Boolean.class, "allow.grindstones"),
|
||||
|
@ -145,7 +145,6 @@ allow:
|
||||
armorstands: true
|
||||
minecarts: false
|
||||
clearonjoin: false
|
||||
tpronjoin: false
|
||||
structureblocks: false
|
||||
jigsaws: false
|
||||
grindstones: false
|
||||
|
9
src/main/resources/vpnbans.yml
Normal file
9
src/main/resources/vpnbans.yml
Normal file
@ -0,0 +1,9 @@
|
||||
#
|
||||
# TotalFreedomMod 5.2 VPN Bans
|
||||
#
|
||||
|
||||
badnetwork1:
|
||||
- 123.123.123.123
|
||||
- 321.321.321.321
|
||||
badnetwork2:
|
||||
- 111.111.111.111
|
Loading…
Reference in New Issue
Block a user