mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
SQL DB is a WIP
This commit is contained in:
parent
43ee17807a
commit
4ddcc3b8d7
@ -26,7 +26,8 @@ public class EntityWiper extends FreedomService
|
|||||||
EntityType.PAINTING,
|
EntityType.PAINTING,
|
||||||
EntityType.BOAT,
|
EntityType.BOAT,
|
||||||
EntityType.LEASH_HITCH,
|
EntityType.LEASH_HITCH,
|
||||||
EntityType.ITEM_FRAME
|
EntityType.ITEM_FRAME,
|
||||||
|
EntityType.MINECART
|
||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,7 +53,7 @@ public class Fuckoff extends FreedomService
|
|||||||
|
|
||||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||||
{
|
{
|
||||||
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
onlinePlayer.setVelocity(onlinePlayer.getLocation().toVector().subtract(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ 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 (TELEPORT_ON_JOIN.contains(player.getName()))
|
if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
|
||||||
{
|
{
|
||||||
int x = FUtil.randomInteger(-10000, 10000);
|
int x = FUtil.randomInteger(-10000, 10000);
|
||||||
int z = FUtil.randomInteger(-10000, 10000);
|
int z = FUtil.randomInteger(-10000, 10000);
|
||||||
@ -210,7 +210,7 @@ public class LoginProcess extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLEAR_ON_JOIN.contains(player.getName()))
|
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
||||||
{
|
{
|
||||||
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.");
|
||||||
|
@ -45,6 +45,8 @@ public class Muter extends FreedomService
|
|||||||
|
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
|
FLog.info("checking mute");
|
||||||
|
|
||||||
if (!fPlayer.isMuted())
|
if (!fPlayer.isMuted())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -7,7 +7,6 @@ import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
|||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
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;
|
||||||
@ -47,6 +46,7 @@ import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||||
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
@ -95,6 +95,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public AntiSpam as;
|
public AntiSpam as;
|
||||||
public PlayerList pl;
|
public PlayerList pl;
|
||||||
public Shop sh;
|
public Shop sh;
|
||||||
|
public SQLite sql;
|
||||||
public Announcer an;
|
public Announcer an;
|
||||||
public ChatManager cm;
|
public ChatManager cm;
|
||||||
public Discord dc;
|
public Discord dc;
|
||||||
@ -102,7 +103,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public BanManager bm;
|
public BanManager bm;
|
||||||
public PermbanList pm;
|
public PermbanList pm;
|
||||||
public PermissionManager pem;
|
public PermissionManager pem;
|
||||||
public VPNBanList vn;
|
|
||||||
public ProtectArea pa;
|
public ProtectArea pa;
|
||||||
public GameRuleHandler gr;
|
public GameRuleHandler gr;
|
||||||
public CommandSpy cs;
|
public CommandSpy cs;
|
||||||
@ -177,9 +177,9 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
backups.createBackups(AdminList.CONFIG_FILENAME);
|
backups.createBackups(AdminList.CONFIG_FILENAME);
|
||||||
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
||||||
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
||||||
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);
|
||||||
|
backups.createBackups("");
|
||||||
|
|
||||||
config = new MainConfig(this);
|
config = new MainConfig(this);
|
||||||
config.load();
|
config.load();
|
||||||
@ -193,6 +193,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
sf = services.registerService(SavedFlags.class);
|
sf = services.registerService(SavedFlags.class);
|
||||||
wm = services.registerService(WorldManager.class);
|
wm = services.registerService(WorldManager.class);
|
||||||
lv = services.registerService(LogViewer.class);
|
lv = services.registerService(LogViewer.class);
|
||||||
|
sql = services.registerService(SQLite.class);
|
||||||
al = services.registerService(AdminList.class);
|
al = services.registerService(AdminList.class);
|
||||||
acl = services.registerService(ActivityLog.class);
|
acl = services.registerService(ActivityLog.class);
|
||||||
rm = services.registerService(RankManager.class);
|
rm = services.registerService(RankManager.class);
|
||||||
@ -217,7 +218,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
bm = services.registerService(BanManager.class);
|
bm = services.registerService(BanManager.class);
|
||||||
pm = services.registerService(PermbanList.class);
|
pm = services.registerService(PermbanList.class);
|
||||||
pem = services.registerService(PermissionManager.class);
|
pem = services.registerService(PermissionManager.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);
|
||||||
|
@ -1,30 +1,26 @@
|
|||||||
package me.totalfreedom.totalfreedommod.admin;
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
public class Admin
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
private String configKey;
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String name;
|
private String name;
|
||||||
@ -68,14 +64,28 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
public Admin(Player player)
|
public Admin(Player player)
|
||||||
{
|
{
|
||||||
this.configKey = player.getName().toLowerCase();
|
|
||||||
this.name = player.getName();
|
this.name = player.getName();
|
||||||
this.ips.add(Ips.getIp(player));
|
this.ips.add(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Admin(String configKey)
|
public Admin(String username, List<String> ips, Rank rank, Boolean active, Date lastLogin, String loginMessage, String tag, String discordID, List<String> backupCodes, Boolean commandSpy, Boolean potionSpy, String acFormat, Boolean oldTags, Boolean logStick)
|
||||||
{
|
{
|
||||||
this.configKey = configKey;
|
this.name = username;
|
||||||
|
this.active = active;
|
||||||
|
this.rank = rank;
|
||||||
|
this.ips.clear();
|
||||||
|
this.ips.addAll(ips);
|
||||||
|
this.lastLogin = lastLogin;
|
||||||
|
this.loginMessage = loginMessage;
|
||||||
|
this.tag = tag;
|
||||||
|
this.discordID = discordID;
|
||||||
|
this.backupCodes.clear();
|
||||||
|
this.backupCodes.addAll(backupCodes);
|
||||||
|
this.commandSpy = commandSpy;
|
||||||
|
this.potionSpy = potionSpy;
|
||||||
|
this.acFormat = acFormat;
|
||||||
|
this.oldTags = oldTags;
|
||||||
|
this.logStick = logStick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -94,59 +104,39 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||||
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
||||||
.append("- Old Tags: ").append(oldTags).append("\n")
|
.append("- Old Tags: ").append(oldTags).append("\n")
|
||||||
.append("- Log Stick: ").append(logStick)
|
.append("- Log Stick: ").append(logStick).append("\n")
|
||||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
|
.append("- Backup Codes: ").append(backupCodes.size()).append("/10");
|
||||||
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFrom(Player player)
|
public void loadFrom(Player player)
|
||||||
{
|
{
|
||||||
configKey = player.getName().toLowerCase();
|
|
||||||
name = player.getName();
|
name = player.getName();
|
||||||
ips.clear();
|
ips.clear();
|
||||||
ips.add(Ips.getIp(player));
|
ips.add(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Map<String, Object> toSQLStorable()
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
{
|
||||||
name = cs.getString("username", configKey);
|
Map<String, Object> map = new HashMap<String, Object>()
|
||||||
active = cs.getBoolean("active", true);
|
{{
|
||||||
rank = Rank.findRank(cs.getString("rank"));
|
put("username", name);
|
||||||
ips.clear();
|
put("active", active);
|
||||||
ips.addAll(cs.getStringList("ips"));
|
put("rank", rank.toString());
|
||||||
backupCodes.clear();
|
put("ips", FUtil.listToString(ips));
|
||||||
backupCodes.addAll(cs.getStringList("backupCodes"));
|
put("backup_codes", FUtil.listToString(backupCodes));
|
||||||
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
|
put("last_login", lastLogin.getTime());
|
||||||
loginMessage = cs.getString("login_message", null);
|
put("login_message", loginMessage);
|
||||||
discordID = cs.getString("discord_id", null);
|
put("discord_id", discordID);
|
||||||
tag = cs.getString("tag", null);
|
put("tag", tag);
|
||||||
commandSpy = cs.getBoolean("command_spy", false);
|
put("command_spy", commandSpy);
|
||||||
potionSpy = cs.getBoolean("potion_spy", false);
|
put("potion_spy", potionSpy);
|
||||||
acFormat = cs.getString("acformat", null);
|
put("ac_format", acFormat);
|
||||||
oldTags = cs.getBoolean("oldtags", false);
|
put("old_tags", oldTags);
|
||||||
logStick = cs.getBoolean("logstick", false);
|
put("log_stick", logStick);
|
||||||
}
|
}};
|
||||||
|
return map;
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
Validate.isTrue(isValid(), "Could not save admin entry: " + name + ". Entry not valid!");
|
|
||||||
cs.set("username", name);
|
|
||||||
cs.set("active", active);
|
|
||||||
cs.set("rank", rank.toString());
|
|
||||||
cs.set("ips", Lists.newArrayList(ips));
|
|
||||||
cs.set("backupCodes", Lists.newArrayList(backupCodes));
|
|
||||||
cs.set("last_login", FUtil.dateToString(lastLogin));
|
|
||||||
cs.set("login_message", loginMessage);
|
|
||||||
cs.set("discord_id", discordID);
|
|
||||||
cs.set("tag", tag);
|
|
||||||
cs.set("command_spy", commandSpy);
|
|
||||||
cs.set("potion_spy", potionSpy);
|
|
||||||
cs.set("acformat", acFormat);
|
|
||||||
cs.set("oldtags", oldTags);
|
|
||||||
cs.set("logstick", logStick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(Rank pRank)
|
public boolean isAtLeast(Rank pRank)
|
||||||
@ -225,11 +215,9 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
return configKey != null
|
return name != null
|
||||||
&& name != null
|
|
||||||
&& rank != null
|
&& rank != null
|
||||||
&& !ips.isEmpty()
|
&& !ips.isEmpty()
|
||||||
&& lastLogin != null;
|
&& lastLogin != null;
|
||||||
|
@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod.admin;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,7 +22,6 @@ import net.pravian.aero.config.YamlConfig;
|
|||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ public class AdminList extends FreedomService
|
|||||||
public static final String CONFIG_FILENAME = "admins.yml";
|
public static final String CONFIG_FILENAME = "admins.yml";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<String, Admin> allAdmins = Maps.newHashMap(); // Includes disabled admins
|
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||||
// Only active admins below
|
// Only active admins below
|
||||||
@Getter
|
@Getter
|
||||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||||
@ -69,7 +70,6 @@ public class AdminList extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
@ -77,47 +77,40 @@ public class AdminList extends FreedomService
|
|||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
allAdmins.clear();
|
allAdmins.clear();
|
||||||
for (String key : config.getKeys(false))
|
try
|
||||||
{
|
{
|
||||||
ConfigurationSection section = config.getConfigurationSection(key);
|
ResultSet adminSet = plugin.sql.getAdminList();
|
||||||
if (section == null)
|
|
||||||
{
|
{
|
||||||
logger.warning("Invalid admin list format: " + key);
|
while (adminSet.next())
|
||||||
continue;
|
{
|
||||||
|
String name = adminSet.getString("username");
|
||||||
|
List<String> ips = FUtil.stringToList(adminSet.getString("ips"));
|
||||||
|
Rank rank = Rank.findRank(adminSet.getString("rank"));
|
||||||
|
Boolean active = adminSet.getBoolean("active");;
|
||||||
|
Date lastLogin = new Date(adminSet.getLong("last_login"));
|
||||||
|
String loginMessage = adminSet.getString("login_message");
|
||||||
|
String tag = adminSet.getString("tag");
|
||||||
|
String discordID = adminSet.getString("discord_id");
|
||||||
|
List<String> backupCodes = FUtil.stringToList(adminSet.getString("backup_codes"));
|
||||||
|
Boolean commandSpy = adminSet.getBoolean("command_spy");
|
||||||
|
Boolean potionSpy = adminSet.getBoolean("potion_spy");
|
||||||
|
String acFormat = adminSet.getString("ac_format");
|
||||||
|
Boolean oldTags = adminSet.getBoolean("old_tags");
|
||||||
|
Boolean logStick = adminSet.getBoolean("log_stick");
|
||||||
|
Admin admin = new Admin(name, ips, rank, active, lastLogin, loginMessage, tag, discordID, backupCodes, commandSpy, potionSpy, acFormat, oldTags, logStick);
|
||||||
|
allAdmins.add(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = new Admin(key);
|
|
||||||
admin.loadFrom(section);
|
|
||||||
|
|
||||||
if (!admin.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Could not load admin: " + key + ". Missing details!");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
allAdmins.put(key, admin);
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get adminlist: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTables();
|
updateTables();
|
||||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
// Clear the config
|
|
||||||
for (String key : config.getKeys(false))
|
|
||||||
{
|
|
||||||
config.set(key, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Admin admin : allAdmins.values())
|
|
||||||
{
|
|
||||||
admin.saveTo(config.createSection(admin.getConfigKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void messageAllAdmins(String message)
|
public void messageAllAdmins(String message)
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
@ -194,7 +187,7 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
// Add the new IP if we have to
|
// Add the new IP if we have to
|
||||||
admin.addIp(ip);
|
admin.addIp(ip);
|
||||||
save();
|
save(admin);
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
return admin;
|
return admin;
|
||||||
@ -206,8 +199,9 @@ public class AdminList extends FreedomService
|
|||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
// Set the new username
|
// Set the new username
|
||||||
|
String oldName = admin.getName();
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
save();
|
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +247,7 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
admin.setLastLogin(new Date());
|
admin.setLastLogin(new Date());
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
save();
|
save(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdminImpostor(Player player)
|
public boolean isAdminImpostor(Player player)
|
||||||
@ -281,19 +275,16 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!admin.isValid())
|
if (!admin.isValid())
|
||||||
{
|
{
|
||||||
logger.warning("Could not add admin: " + admin.getConfigKey() + " Admin is missing details!");
|
logger.warning("Could not add admin: " + admin.getName() + " Admin is missing details!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String key = admin.getConfigKey();
|
|
||||||
|
|
||||||
// Store admin, update views
|
// Store admin, update views
|
||||||
allAdmins.put(key, admin);
|
allAdmins.add(admin);
|
||||||
updateTables();
|
updateTables();
|
||||||
|
|
||||||
// Save admin
|
// Save admin
|
||||||
admin.saveTo(config.createSection(key));
|
plugin.sql.addAdmin(admin);
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -309,15 +300,14 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove admin, update views
|
// Remove admin, update views
|
||||||
if (allAdmins.remove(admin.getConfigKey()) == null)
|
if (!allAdmins.remove(admin))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
updateTables();
|
updateTables();
|
||||||
|
|
||||||
// 'Unsave' admin
|
// Unsave admin
|
||||||
config.set(admin.getConfigKey(), null);
|
plugin.sql.removeAdmin(admin);
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -328,7 +318,7 @@ public class AdminList extends FreedomService
|
|||||||
nameTable.clear();
|
nameTable.clear();
|
||||||
ipTable.clear();
|
ipTable.clear();
|
||||||
|
|
||||||
for (Admin admin : allAdmins.values())
|
for (Admin admin : allAdmins)
|
||||||
{
|
{
|
||||||
if (!admin.isActive())
|
if (!admin.isActive())
|
||||||
{
|
{
|
||||||
@ -358,9 +348,29 @@ public class AdminList extends FreedomService
|
|||||||
return ipTable.keySet();
|
return ipTable.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(Admin admin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
|
||||||
|
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
||||||
|
{
|
||||||
|
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
||||||
|
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null)
|
||||||
|
{
|
||||||
|
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to save admin: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void deactivateOldEntries(boolean verbose)
|
public void deactivateOldEntries(boolean verbose)
|
||||||
{
|
{
|
||||||
for (Admin admin : allAdmins.values())
|
for (Admin admin : allAdmins)
|
||||||
{
|
{
|
||||||
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
||||||
{
|
{
|
||||||
@ -381,9 +391,9 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
|
save(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -14,16 +15,13 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
import net.pravian.aero.base.Validatable;
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
public class Ban implements Validatable
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
@ -53,22 +51,19 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
|
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this(username,
|
this(username,
|
||||||
new String[]
|
Arrays.asList(ip),
|
||||||
{
|
|
||||||
ip
|
|
||||||
},
|
|
||||||
by,
|
by,
|
||||||
at,
|
at,
|
||||||
expire,
|
expire,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String[] ips, String by, Date at, Date expire, String reason)
|
public Ban(String username, List<String> ips, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
if (ips != null)
|
if (ips != null)
|
||||||
{
|
{
|
||||||
this.ips.addAll(Arrays.asList(ips));
|
this.ips.addAll(ips);
|
||||||
}
|
}
|
||||||
dedupeIps();
|
dedupeIps();
|
||||||
this.by = by;
|
this.by = by;
|
||||||
@ -86,10 +81,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, new String[]
|
return new Ban(null, Arrays.asList(Ips.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
{
|
|
||||||
Ips.getIp(player)
|
|
||||||
}, by.getName(), Date.from(Instant.now()), expiry, reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
@ -107,7 +99,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player,
|
return new Ban(player,
|
||||||
(String[])null,
|
new ArrayList<String>(),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
@ -171,7 +163,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String bakeKickMessage(String ip)
|
public String bakeKickMessage()
|
||||||
{
|
{
|
||||||
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
||||||
|
|
||||||
@ -203,9 +195,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
message.append("\n").append(ChatColor.RED).append("IP Address: ").append(ChatColor.GOLD)
|
|
||||||
.append(ip);
|
|
||||||
|
|
||||||
return message.toString();
|
return message.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,31 +235,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
this.username = cs.getString("username", null);
|
|
||||||
this.ips.clear();
|
|
||||||
this.ips.addAll(cs.getStringList("ips"));
|
|
||||||
this.by = cs.getString("by", null);
|
|
||||||
this.at = FUtil.stringToDate(cs.getString("at", null));
|
|
||||||
this.reason = cs.getString("reason", null);
|
|
||||||
this.expiryUnix = cs.getLong("expiry_unix", 0);
|
|
||||||
dedupeIps();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
dedupeIps();
|
|
||||||
cs.set("username", username);
|
|
||||||
cs.set("ips", ips.isEmpty() ? null : ips);
|
|
||||||
cs.set("by", by);
|
|
||||||
cs.set("at", FUtil.dateToString(at));
|
|
||||||
cs.set("reason", reason);
|
|
||||||
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,12 @@ package me.totalfreedom.totalfreedommod.banning;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -15,7 +19,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -30,42 +33,39 @@ public class BanManager extends FreedomService
|
|||||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||||
public static final String CONFIG_FILENAME = "bans.yml";
|
|
||||||
|
|
||||||
//
|
//
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
public BanManager(TotalFreedomMod plugin)
|
public BanManager(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.config = new YamlConfig(plugin, "bans.yml");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
config.load();
|
|
||||||
|
|
||||||
bans.clear();
|
bans.clear();
|
||||||
for (String id : config.getKeys(false))
|
try
|
||||||
{
|
{
|
||||||
if (!config.isConfigurationSection(id))
|
ResultSet banSet = plugin.sql.getBanList();
|
||||||
{
|
{
|
||||||
FLog.warning("Could not load username ban: " + id + ". Invalid format!");
|
while (banSet.next())
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ban ban = new Ban();
|
|
||||||
ban.loadFrom(config.getConfigurationSection(id));
|
|
||||||
|
|
||||||
if (!ban.isValid())
|
|
||||||
{
|
{
|
||||||
FLog.warning("Not adding username ban: " + id + ". Missing information.");
|
String name = banSet.getString("name");
|
||||||
continue;
|
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
|
||||||
}
|
String by = banSet.getString("by");
|
||||||
|
Date at = new Date(banSet.getLong("at"));
|
||||||
|
Date expires = new Date(banSet.getLong("expires"));
|
||||||
|
String reason = banSet.getString("reason");
|
||||||
|
Ban ban = new Ban(name, ips, by, at, expires, reason);
|
||||||
bans.add(ban);
|
bans.add(ban);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load ban list: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// Remove expired bans, repopulate ipBans and nameBans,
|
// Remove expired bans, repopulate ipBans and nameBans,
|
||||||
updateViews();
|
updateViews();
|
||||||
@ -81,8 +81,6 @@ public class BanManager extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
saveAll();
|
|
||||||
logger.info("Saved " + bans.size() + " player bans");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Ban> getAllBans()
|
public Set<Ban> getAllBans()
|
||||||
@ -100,21 +98,6 @@ public class BanManager extends FreedomService
|
|||||||
return Collections.unmodifiableCollection(nameBans.values());
|
return Collections.unmodifiableCollection(nameBans.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAll()
|
|
||||||
{
|
|
||||||
// Remove expired
|
|
||||||
updateViews();
|
|
||||||
|
|
||||||
config.clear();
|
|
||||||
for (Ban ban : bans)
|
|
||||||
{
|
|
||||||
ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save config
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ban getByIp(String ip)
|
public Ban getByIp(String ip)
|
||||||
{
|
{
|
||||||
final Ban directBan = ipBans.get(ip);
|
final Ban directBan = ipBans.get(ip);
|
||||||
@ -168,7 +151,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -181,7 +163,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -199,12 +180,16 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
public boolean addBan(Ban ban)
|
public boolean addBan(Ban ban)
|
||||||
{
|
{
|
||||||
|
if (getByUsername(ban.getUsername()) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
if (bans.add(ban))
|
if (bans.add(ban))
|
||||||
{
|
{
|
||||||
saveAll();
|
plugin.sql.addBan(ban);
|
||||||
|
updateViews();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
updateViews();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -213,23 +198,20 @@ public class BanManager extends FreedomService
|
|||||||
{
|
{
|
||||||
if (bans.remove(ban))
|
if (bans.remove(ban))
|
||||||
{
|
{
|
||||||
saveAll();
|
plugin.sql.removeBan(ban);
|
||||||
|
updateViews();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
updateViews();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int purge()
|
public int purge()
|
||||||
{
|
{
|
||||||
config.clear();
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
int size = bans.size();
|
int size = bans.size();
|
||||||
bans.clear();
|
bans.clear();
|
||||||
updateViews();
|
updateViews();
|
||||||
|
plugin.sql.truncate("bans");
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +230,7 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
if (ban != null && !ban.isExpired())
|
if (ban != null && !ban.isExpired())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage(ip));
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,11 +259,12 @@ public class BanManager extends FreedomService
|
|||||||
private void updateViews()
|
private void updateViews()
|
||||||
{
|
{
|
||||||
// Remove expired bans
|
// Remove expired bans
|
||||||
for (Iterator<Ban> it = bans.iterator(); it.hasNext(); )
|
for (Ban ban : new ArrayList<>(bans))
|
||||||
{
|
{
|
||||||
if (it.next().isExpired())
|
if (ban.isExpired())
|
||||||
{
|
{
|
||||||
it.remove();
|
bans.remove(ban);
|
||||||
|
plugin.sql.removeBan(ban);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -48,11 +48,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
case LAVA:
|
case LAVA:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||||
@ -62,11 +58,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case WATER:
|
case WATER:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||||
@ -77,11 +69,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case FIRE:
|
case FIRE:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||||
@ -89,14 +77,6 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TNT:
|
|
||||||
{
|
|
||||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STRUCTURE_BLOCK:
|
case STRUCTURE_BLOCK:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
||||||
@ -152,7 +132,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Bee hives are disabled.");
|
player.sendMessage(ChatColor.GRAY + "Beehives are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -164,9 +144,9 @@ public class BlockBlocker extends FreedomService
|
|||||||
Skull skull = (Skull) event.getBlockPlaced().getState();
|
Skull skull = (Skull) event.getBlockPlaced().getState();
|
||||||
if (skull.hasOwner())
|
if (skull.hasOwner())
|
||||||
{
|
{
|
||||||
if (skull.getOwner().contains("§"))
|
if (skull.getOwner().contains("\u00A7"))
|
||||||
{
|
{
|
||||||
skull.setOwner(skull.getOwner().replace("§", ""));
|
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
|
||||||
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
||||||
if (meta != null)
|
if (meta != null)
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
||||||
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||||
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||||
connection = DriverManager.getConnection("jdbc:mysql://" + url);
|
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
||||||
final Statement statement = connection.createStatement();
|
final Statement statement = connection.createStatement();
|
||||||
statement.setQueryTimeout(30);
|
statement.setQueryTimeout(30);
|
||||||
|
|
||||||
@ -196,6 +196,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the world ID is not null
|
// Ensure the world ID is not null
|
||||||
|
|
||||||
if (worldID == null)
|
if (worldID == null)
|
||||||
{
|
{
|
||||||
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
||||||
|
@ -149,7 +149,7 @@ public class Command_ban extends FreedomCommand
|
|||||||
// Kick player and handle others on IP
|
// Kick player and handle others on IP
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.kickPlayer(ban.bakeKickMessage(Ips.getIp(player)));
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (Ips.getIp(p).equals(Ips.getIp(player)))
|
if (Ips.getIp(p).equals(Ips.getIp(player)))
|
||||||
|
@ -16,7 +16,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | off | <partialname> [head | block] [playername | blockname]")
|
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||||
public class Command_cage extends FreedomCommand
|
public class Command_cage extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,14 +26,8 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String skullName = null;
|
String skullName = null;
|
||||||
if ("off".equals(args[0]) && sender instanceof Player)
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
|
||||||
playerdata.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ("purge".equals(args[0]))
|
if ("purge".equals(args[0]))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
||||||
@ -44,13 +38,24 @@ public class Command_cage extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = getPlayer(args[0]);
|
Player player = getPlayer(args[0]);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (fPlayer.getCageData().isCaged())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||||
|
playerdata.getCageData().setCaged(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Material outerMaterial = Material.GLASS;
|
Material outerMaterial = Material.GLASS;
|
||||||
Material innerMaterial = Material.AIR;
|
Material innerMaterial = Material.AIR;
|
||||||
if (args.length >= 2 && args[1] != null)
|
if (args.length >= 2 && args[1] != null)
|
||||||
@ -58,12 +63,6 @@ public class Command_cage extends FreedomCommand
|
|||||||
final String s = args[1];
|
final String s = args[1];
|
||||||
switch (s)
|
switch (s)
|
||||||
{
|
{
|
||||||
case "off":
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
|
||||||
fPlayer.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head":
|
case "head":
|
||||||
{
|
{
|
||||||
outerMaterial = Material.PLAYER_HEAD;
|
outerMaterial = Material.PLAYER_HEAD;
|
||||||
@ -91,6 +90,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
||||||
|
|
||||||
if (skullName != null)
|
if (skullName != null)
|
||||||
{
|
{
|
||||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
||||||
@ -99,7 +99,9 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
if (outerMaterial == Material.PLAYER_HEAD)
|
if (outerMaterial == Material.PLAYER_HEAD)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||||
@ -130,7 +132,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!args[0].equals("purge"))
|
if (!args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
return Arrays.asList("off", "head", "block");
|
return Arrays.asList("head", "block");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.length == 3)
|
else if (args.length == 3)
|
||||||
|
@ -17,7 +17,7 @@ public class Command_cmdspy extends FreedomCommand
|
|||||||
|
|
||||||
Admin admin = plugin.al.getAdmin(playerSender);
|
Admin admin = plugin.al.getAdmin(playerSender);
|
||||||
admin.setCommandSpy(!admin.getCommandSpy());
|
admin.setCommandSpy(!admin.getCommandSpy());
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class Command_doom extends FreedomCommand
|
|||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the admin list", true);
|
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the admin list", true);
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
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, blockHostConsole = true)
|
|
||||||
@CommandParameters(description = "Send a chat message as the specified player.", usage = "/<command> <fromname> <outmessage>")
|
|
||||||
public class Command_gchat extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FUtil.isExecutive(sender.getName()) && plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
msg("Only Executives may use this command on admins", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String outMessage = StringUtils.join(args, " ", 1, args.length);
|
|
||||||
msg("Sending message as " + player.getName() + ": " + outMessage);
|
|
||||||
player.chat(outMessage);
|
|
||||||
msg("Message sent.");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
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;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
|
||||||
@CommandParameters(description = "Send a command as the specified player.", usage = "/<command> <fromname> <outcommand>")
|
|
||||||
public class Command_gcmd extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FUtil.isExecutive(sender.getName()) && plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
msg("Only Executives may use this command on admins", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String outCommand = StringUtils.join(args, " ", 1, args.length);
|
|
||||||
|
|
||||||
if (plugin.cb.isCommandBlocked(outCommand, sender))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
msg("Sending command as " + player.getName() + ": " + outCommand);
|
|
||||||
if (server.dispatchCommand(player, outCommand))
|
|
||||||
{
|
|
||||||
msg("Command sent.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Unknown error sending command.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
msg("Error sending command: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -104,7 +104,7 @@ public class Command_glist extends FreedomCommand
|
|||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.kickPlayer(playerBan.bakeKickMessage(Ips.getIp(player)));
|
player.kickPlayer(playerBan.bakeKickMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, null));
|
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, null));
|
||||||
@ -149,7 +149,7 @@ public class Command_glist extends FreedomCommand
|
|||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.kickPlayer(nameBan.bakeKickMessage(Ips.getIp(player)));
|
player.kickPlayer(nameBan.bakeKickMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,202 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "HubWorld management stuff",
|
||||||
|
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
||||||
|
aliases = "hw,hub")
|
||||||
|
public class Command_hubworld extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
private enum CommandMode
|
||||||
|
{
|
||||||
|
TELEPORT, TIME, WEATHER
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
CommandMode commandMode = null;
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.TELEPORT;
|
||||||
|
}
|
||||||
|
else if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if ("time".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.TIME;
|
||||||
|
}
|
||||||
|
else if ("weather".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.WEATHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandMode == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (commandMode)
|
||||||
|
{
|
||||||
|
case TELEPORT:
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player) || playerSender == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
World hubWorld = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
hubWorld = plugin.wm.hubworld.getWorld();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hubWorld == null || playerSender.getWorld() == hubWorld)
|
||||||
|
{
|
||||||
|
msg("Going to the main world.");
|
||||||
|
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Going to the hub world");
|
||||||
|
plugin.wm.hubworld.sendToWorld(playerSender);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TIME:
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
|
||||||
|
if (timeOfDay != null)
|
||||||
|
{
|
||||||
|
plugin.wm.hubworld.setTimeOfDay(timeOfDay);
|
||||||
|
msg("Hub world time set to: " + timeOfDay.name());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WEATHER:
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
|
||||||
|
if (weatherMode != null)
|
||||||
|
{
|
||||||
|
plugin.wm.hubworld.setWeatherMode(weatherMode);
|
||||||
|
msg("Hub world weather set to: " + weatherMode.name());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Invalid weather mode. Can be: off, rain, storm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (PermissionDeniedException ex)
|
||||||
|
{
|
||||||
|
if (ex.getMessage().isEmpty())
|
||||||
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
return Arrays.asList("time", "weather");
|
||||||
|
}
|
||||||
|
else if (args.length == 2)
|
||||||
|
{
|
||||||
|
if (args[0].equals("time"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("morning", "noon", "evening", "night");
|
||||||
|
}
|
||||||
|
else if (args[0].equals("weather"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("off", "rain", "storm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Redo this properly
|
||||||
|
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
|
||||||
|
{
|
||||||
|
throw new PermissionDeniedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PermissionDeniedException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private PermissionDeniedException()
|
||||||
|
{
|
||||||
|
super("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private PermissionDeniedException(String string)
|
||||||
|
{
|
||||||
|
super(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,7 +16,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggles jumppads on/off, view the status of jumppads, or make them sideways.", usage = "/<command> <on | off | info | sideways <on | off>>", aliases = "launchpads,jp")
|
@CommandParameters(description = "Toggles jumppads on/off, view the status of jumppads, or make them sideways.", usage = "/<command> <on | off | info | sideways <on | off>>", aliases = "launchpads,jp")
|
||||||
public class Command_jumppads extends FreedomCommand
|
public class Command_jumppads extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -95,7 +96,7 @@ public class Command_list extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - plugin.al.vanished.size())
|
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size())
|
||||||
.append(ChatColor.BLUE)
|
.append(ChatColor.BLUE)
|
||||||
.append(" out of a maximum ")
|
.append(" out of a maximum ")
|
||||||
.append(ChatColor.RED)
|
.append(ChatColor.RED)
|
||||||
|
@ -10,13 +10,14 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "This is evil, and I never should have wrote it - blocks specified player's input.", usage = "/<command> <all | purge | <<partialname> on | off>>")
|
@CommandParameters(description = "This is evil, and I never should have wrote it - blocks specified player's input.", usage = "/<command> <all | purge | <<partialname> on | off> [-q]>")
|
||||||
public class Command_lockup extends FreedomCommand
|
public class Command_lockup extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@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)
|
||||||
{
|
{
|
||||||
|
Boolean silent = (args[args.length - 1].equalsIgnoreCase("-q"));
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("all"))
|
if (args[0].equalsIgnoreCase("all"))
|
||||||
@ -56,7 +57,10 @@ public class Command_lockup extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
||||||
|
}
|
||||||
startLockup(player);
|
startLockup(player);
|
||||||
msg("Locked up " + player.getName() + ".");
|
msg("Locked up " + player.getName() + ".");
|
||||||
}
|
}
|
||||||
@ -70,7 +74,10 @@ public class Command_lockup extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
||||||
|
}
|
||||||
cancelLockup(player);
|
cancelLockup(player);
|
||||||
msg("Unlocked " + player.getName() + ".");
|
msg("Unlocked " + player.getName() + ".");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
target.clearIPs();
|
target.clearIPs();
|
||||||
target.addIp(targetIp);
|
target.addIp(targetIp);
|
||||||
|
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
|
|
||||||
msg(counter + " IPs removed.");
|
msg(counter + " IPs removed.");
|
||||||
@ -127,7 +127,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Removing a supered IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
FUtil.adminAction(sender.getName(), "Removing a supered IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
||||||
|
|
||||||
target.removeIp(args[1]);
|
target.removeIp(args[1]);
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
|
|
||||||
msg("Removed IP " + args[1]);
|
msg("Removed IP " + args[1]);
|
||||||
@ -159,7 +159,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
target.setLoginMessage(message);
|
target.setLoginMessage(message);
|
||||||
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
|
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
|
||||||
msg("> " + previewMessage);
|
msg("> " + previewMessage);
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Clearing personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
FUtil.adminAction(sender.getName(), "Clearing personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||||
target.setLoginMessage(null);
|
target.setLoginMessage(null);
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
{
|
{
|
||||||
String format = StringUtils.join(args, " ", 1, args.length);
|
String format = StringUtils.join(args, " ", 1, args.length);
|
||||||
target.setAcFormat(format);
|
target.setAcFormat(format);
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY);
|
msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY);
|
||||||
String example = format.replace("%name%", "ExampleAdmin").replace("%rank%", Rank.TELNET_ADMIN.getAbbr()).replace("%rankcolor%", Rank.TELNET_ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog.");
|
String example = format.replace("%name%", "ExampleAdmin").replace("%rank%", Rank.TELNET_ADMIN.getAbbr()).replace("%rankcolor%", Rank.TELNET_ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog.");
|
||||||
@ -198,7 +198,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
case "clearacformat":
|
case "clearacformat":
|
||||||
{
|
{
|
||||||
target.setAcFormat(null);
|
target.setAcFormat(null);
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
msg("Cleared admin chat format.", ChatColor.GRAY);
|
msg("Cleared admin chat format.", ChatColor.GRAY);
|
||||||
return true;
|
return true;
|
||||||
@ -206,7 +206,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
case "oldtags":
|
case "oldtags":
|
||||||
{
|
{
|
||||||
target.setOldTags(!target.getOldTags());
|
target.setOldTags(!target.getOldTags());
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
msg((target.getOldTags() ? "Enabled" : "Disabled") + " old tags.");
|
msg((target.getOldTags() ? "Enabled" : "Disabled") + " old tags.");
|
||||||
return true;
|
return true;
|
||||||
@ -214,7 +214,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
case "logstick":
|
case "logstick":
|
||||||
{
|
{
|
||||||
target.setLogStick(!target.getLogStick());
|
target.setLogStick(!target.getLogStick());
|
||||||
plugin.al.save();
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
msg((target.getLogStick() ? "Enabled" : "Disabled") + " log-stick lookup.");
|
msg((target.getLogStick() ? "Enabled" : "Disabled") + " log-stick lookup.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,6 +18,8 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
public class Command_plugincontrol extends FreedomCommand
|
public class Command_plugincontrol extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final List<String> UNTOUCHABLE_PLUGINS = Arrays.asList(plugin.getName(), "BukkitTelnet");
|
||||||
|
|
||||||
@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)
|
||||||
{
|
{
|
||||||
@ -88,9 +90,9 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.getName().equals(plugin.getName()))
|
if (UNTOUCHABLE_PLUGINS.contains(target.getName()))
|
||||||
{
|
{
|
||||||
msg("You cannot disable " + plugin.getName());
|
msg("You cannot disable " + target.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,9 +117,9 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.getName().equals(plugin.getName()))
|
if (UNTOUCHABLE_PLUGINS.contains(target.getName()))
|
||||||
{
|
{
|
||||||
msg("Use /tfm reload to reload instead.");
|
msg("You cannot reload " + target.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,9 +158,12 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
{
|
{
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
for (Plugin plugin : server.getPluginManager().getPlugins())
|
for (Plugin plugin : server.getPluginManager().getPlugins())
|
||||||
|
{
|
||||||
|
if (!UNTOUCHABLE_PLUGINS.contains(plugin.getName()))
|
||||||
{
|
{
|
||||||
names.add(plugin.getName());
|
names.add(plugin.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
names.remove(plugin.getName());
|
names.remove(plugin.getName());
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(
|
@CommandParameters(
|
||||||
description = "Manipulate your potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
description = "Manipulate your potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
||||||
usage = "/<command> <list | clear [target name] | add <type> <duration> <amplifier> [target name]>")
|
usage = "/<command> <list | clear [target name] | add <type> <duration> <amplifier> [target name]>",
|
||||||
|
aliases="effect")
|
||||||
public class Command_potion extends FreedomCommand
|
public class Command_potion extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public class Command_potionspy extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(playerSender);
|
Admin admin = plugin.al.getAdmin(playerSender);
|
||||||
admin.setPotionSpy(!admin.getPotionSpy());
|
admin.setPotionSpy(!admin.getPotionSpy());
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
msg("PotionSpy is now " + (admin.getPotionSpy() ? "enabled." : "disabled."));
|
msg("PotionSpy is now " + (admin.getPotionSpy() ? "enabled." : "disabled."));
|
||||||
return true;
|
return true;
|
||||||
|
@ -99,7 +99,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Setting " + admin.getName() + "'s rank to " + rank.getName(), true);
|
FUtil.adminAction(sender.getName(), "Setting " + admin.getName() + "'s rank to " + rank.getName(), true);
|
||||||
|
|
||||||
admin.setRank(rank);
|
admin.setRank(rank);
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
|
|
||||||
Player player = getPlayer(admin.getName());
|
Player player = getPlayer(admin.getName());
|
||||||
if (player != null)
|
if (player != null)
|
||||||
@ -175,7 +175,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
// Find the old admin entry
|
// Find the old admin entry
|
||||||
String name = player != null ? player.getName() : args[1];
|
String name = player != null ? player.getName() : args[1];
|
||||||
Admin admin = null;
|
Admin admin = null;
|
||||||
for (Admin loopAdmin : plugin.al.getAllAdmins().values())
|
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||||
{
|
{
|
||||||
if (loopAdmin.getName().equalsIgnoreCase(name))
|
if (loopAdmin.getName().equalsIgnoreCase(name))
|
||||||
{
|
{
|
||||||
@ -204,11 +204,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||||
plugin.al.addAdmin(new Admin(player));
|
admin = new Admin(player);
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
plugin.rm.updateDisplay(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to find discord account
|
// Attempt to find discord account
|
||||||
if (plugin.mbl.isMasterBuilder(player))
|
if (plugin.mbl.isMasterBuilder(player))
|
||||||
@ -224,6 +220,8 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
admin.setDiscordID(vPlayer.getDiscordId());
|
admin.setDiscordID(vPlayer.getDiscordId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plugin.al.addAdmin(admin);
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
}
|
}
|
||||||
else // Existing admin
|
else // Existing admin
|
||||||
{
|
{
|
||||||
@ -231,7 +229,9 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
|
String oldName = admin.getName();
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
|
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||||
admin.addIp(Ips.getIp(player));
|
admin.addIp(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
plugin.al.verifiedNoAdminIps.remove(player.getName());
|
plugin.al.verifiedNoAdminIps.remove(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
@ -339,7 +339,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
|
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ public class Command_tag extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(player);
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
admin.setTag(tag);
|
admin.setTag(tag);
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
}
|
}
|
||||||
else if (plugin.mbl.isMasterBuilder(player))
|
else if (plugin.mbl.isMasterBuilder(player))
|
||||||
|
@ -69,7 +69,7 @@ public class Command_tempban extends FreedomCommand
|
|||||||
}
|
}
|
||||||
message.append(" until ").append(date_format.format(expires));
|
message.append(" until ").append(date_format.format(expires));
|
||||||
|
|
||||||
String reason = "Banned by " + sender.getName();
|
String reason = null;
|
||||||
if (args.length >= 3)
|
if (args.length >= 3)
|
||||||
{
|
{
|
||||||
reason = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ") + " (" + sender.getName() + ")";
|
reason = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ") + " (" + sender.getName() + ")";
|
||||||
@ -95,7 +95,7 @@ public class Command_tempban extends FreedomCommand
|
|||||||
ban.addIp(ip);
|
ban.addIp(ip);
|
||||||
}
|
}
|
||||||
plugin.bm.addBan(ban);
|
plugin.bm.addBan(ban);
|
||||||
player.kickPlayer(sender.getName() + " - " + message.toString());
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ public class Command_toggle extends FreedomCommand
|
|||||||
msg("- spawners");
|
msg("- spawners");
|
||||||
msg("- 4chan");
|
msg("- 4chan");
|
||||||
msg("- beehives");
|
msg("- beehives");
|
||||||
|
msg("- autotp");
|
||||||
|
msg("- autoclear");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +215,16 @@ public class Command_toggle extends FreedomCommand
|
|||||||
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
|
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("autotp"))
|
||||||
|
{
|
||||||
|
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("autoclear"))
|
||||||
|
{
|
||||||
|
toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -232,7 +244,8 @@ 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", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives");
|
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
|
||||||
|
"autotp", "autoclear");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -31,7 +31,7 @@ public class Command_unlinkdiscord extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
admin.setDiscordID(null);
|
admin.setDiscordID(null);
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [-q] <player>")
|
@CommandParameters(description = "Unmutes a player", usage = "/<command> [-q] <player>")
|
||||||
public class Command_unmute extends FreedomCommand
|
public class Command_unmute extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ public class Command_verify extends FreedomCommand
|
|||||||
|
|
||||||
admin.setActive(true);
|
admin.setActive(true);
|
||||||
admin.setLastLogin(new Date());
|
admin.setLastLogin(new Date());
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
plugin.rm.updateDisplay(playerSender);
|
plugin.rm.updateDisplay(playerSender);
|
||||||
playerSender.setOp(true);
|
playerSender.setOp(true);
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
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 = "Reload the banned VPN IP list.", 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -31,6 +31,8 @@ public enum ConfigEntry
|
|||||||
ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"),
|
ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"),
|
||||||
ALLOW_SPAWNERS(Boolean.class, "allow.spawners"),
|
ALLOW_SPAWNERS(Boolean.class, "allow.spawners"),
|
||||||
ALLOW_BEEHIVES(Boolean.class, "allow.beehives"),
|
ALLOW_BEEHIVES(Boolean.class, "allow.beehives"),
|
||||||
|
AUTO_TP(Boolean.class, "allow.auto_tp"),
|
||||||
|
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
|
||||||
//
|
//
|
||||||
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
|
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
|
||||||
//
|
//
|
||||||
|
@ -184,7 +184,7 @@ public class Discord extends FreedomService
|
|||||||
PrivateChannel privateChannel = user.openPrivateChannel().complete();
|
PrivateChannel privateChannel = user.openPrivateChannel().complete();
|
||||||
privateChannel.sendMessage("Do not share these codes with anyone as they can be used to impose as you.").addFile(file).complete();
|
privateChannel.sendMessage("Do not share these codes with anyone as they can be used to impose as you.").addFile(file).complete();
|
||||||
admin.setBackupCodes(encryptedCodes);
|
admin.setBackupCodes(encryptedCodes);
|
||||||
plugin.al.save();
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
file.delete();
|
file.delete();
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,7 +23,7 @@ public class PrivateMessageListener extends ListenerAdapter
|
|||||||
Admin admin = Discord.ADMIN_LINK_CODES.get(code);
|
Admin admin = Discord.ADMIN_LINK_CODES.get(code);
|
||||||
name = admin.getName();
|
name = admin.getName();
|
||||||
admin.setDiscordID(event.getMessage().getAuthor().getId());
|
admin.setDiscordID(event.getMessage().getAuthor().getId());
|
||||||
TotalFreedomMod.plugin().al.save();
|
TotalFreedomMod.plugin().al.save(admin);
|
||||||
TotalFreedomMod.plugin().al.updateTables();
|
TotalFreedomMod.plugin().al.updateTables();
|
||||||
Discord.ADMIN_LINK_CODES.remove(code);
|
Discord.ADMIN_LINK_CODES.remove(code);
|
||||||
Discord.syncRoles(admin);
|
Discord.syncRoles(admin);
|
||||||
|
@ -24,7 +24,6 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_permbans;
|
|||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_vpnbans;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -70,7 +69,6 @@ public class HTTPDaemon extends FreedomService
|
|||||||
module("players", Module_players.class, false);
|
module("players", Module_players.class, false);
|
||||||
module("punishments", Module_punishments.class, true);
|
module("punishments", Module_punishments.class, true);
|
||||||
module("schematic", Module_schematic.class, true);
|
module("schematic", Module_schematic.class, true);
|
||||||
module("vpnbans", Module_vpnbans.class, true);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,10 @@ public class Module_admins extends HTTPDModule
|
|||||||
@Override
|
@Override
|
||||||
public NanoHTTPD.Response getResponse()
|
public NanoHTTPD.Response getResponse()
|
||||||
{
|
{
|
||||||
File adminFile = new File(plugin.getDataFolder(), Admin.CONFIG_FILENAME);
|
|
||||||
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"Error 404: Not Found - i have to re-work this");
|
||||||
|
/*File adminFile = new File(plugin.getDataFolder(), Admin.CONFIG_FILENAME);
|
||||||
if (adminFile.exists())
|
if (adminFile.exists())
|
||||||
{
|
{
|
||||||
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||||
@ -36,7 +39,7 @@ public class Module_admins extends HTTPDModule
|
|||||||
{
|
{
|
||||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAuthorized(String remoteAddress)
|
private boolean isAuthorized(String remoteAddress)
|
||||||
|
@ -18,7 +18,9 @@ public class Module_bans extends HTTPDModule
|
|||||||
@Override
|
@Override
|
||||||
public NanoHTTPD.Response getResponse()
|
public NanoHTTPD.Response getResponse()
|
||||||
{
|
{
|
||||||
File banFile = new File(plugin.getDataFolder(), BanManager.CONFIG_FILENAME);
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"Error 404: Not Found - i have to re-work this");
|
||||||
|
/*File banFile = new File(plugin.getDataFolder(), BanManager.CONFIG_FILENAME);
|
||||||
if (banFile.exists())
|
if (banFile.exists())
|
||||||
{
|
{
|
||||||
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||||
@ -37,7 +39,7 @@ public class Module_bans extends HTTPDModule
|
|||||||
{
|
{
|
||||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAuthorized(String remoteAddress)
|
private boolean isAuthorized(String remoteAddress)
|
||||||
|
@ -21,6 +21,7 @@ import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
|||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||||
|
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
@ -269,8 +270,9 @@ public class Module_schematic extends HTTPDModule
|
|||||||
|
|
||||||
private boolean isAuthorized(String remoteAddress)
|
private boolean isAuthorized(String remoteAddress)
|
||||||
{
|
{
|
||||||
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
Admin adminEntry = plugin.al.getEntryByIp(remoteAddress);
|
||||||
return entry != null && entry.isActive();
|
MasterBuilder masterBuilderEntry = plugin.mbl.getEntryByIp(remoteAddress);
|
||||||
|
return ((adminEntry != null && adminEntry.isActive()) || masterBuilderEntry != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SchematicTransferException extends Exception
|
private static class SchematicTransferException extends Exception
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.VPNBanList;
|
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
|
||||||
|
|
||||||
public class Module_vpnbans extends HTTPDModule
|
|
||||||
{
|
|
||||||
|
|
||||||
public Module_vpnbans(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
|
||||||
{
|
|
||||||
super(plugin, session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NanoHTTPD.Response getResponse()
|
|
||||||
{
|
|
||||||
File vpnbanFile = new File(plugin.getDataFolder(), VPNBanList.CONFIG_FILENAME);
|
|
||||||
|
|
||||||
if (vpnbanFile.exists())
|
|
||||||
{
|
|
||||||
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), VPNBanList.CONFIG_FILENAME));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
|
||||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,4 +19,6 @@ public interface Displayable
|
|||||||
|
|
||||||
public String getColoredLoginMessage();
|
public String getColoredLoginMessage();
|
||||||
|
|
||||||
|
public boolean hasTeam();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ import org.bukkit.ChatColor;
|
|||||||
public enum Rank implements Displayable
|
public enum Rank implements Displayable
|
||||||
{
|
{
|
||||||
|
|
||||||
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW),
|
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW, false),
|
||||||
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE),
|
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE, false),
|
||||||
OP("an", "Op", Type.PLAYER, "OP", ChatColor.GREEN),
|
OP("an", "Operator", Type.PLAYER, "OP", ChatColor.GREEN, false),
|
||||||
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA),
|
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA, true),
|
||||||
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN),
|
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN, true),
|
||||||
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD),
|
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD, true),
|
||||||
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE),
|
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false),
|
||||||
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE);
|
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false);
|
||||||
@Getter
|
@Getter
|
||||||
private final Type type;
|
private final Type type;
|
||||||
@Getter
|
@Getter
|
||||||
@ -27,8 +27,10 @@ public enum Rank implements Displayable
|
|||||||
private final String coloredTag;
|
private final String coloredTag;
|
||||||
@Getter
|
@Getter
|
||||||
private final ChatColor color;
|
private final ChatColor color;
|
||||||
|
@Getter
|
||||||
|
private final boolean hasTeam;
|
||||||
|
|
||||||
private Rank(String determiner, String name, Type type, String abbr, ChatColor color)
|
private Rank(String determiner, String name, Type type, String abbr, ChatColor color, Boolean hasTeam)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -37,6 +39,7 @@ public enum Rank implements Displayable
|
|||||||
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
||||||
this.coloredTag = abbr.isEmpty() ? "" : ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
this.coloredTag = abbr.isEmpty() ? "" : ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.hasTeam = hasTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -51,6 +54,12 @@ public enum Rank implements Displayable
|
|||||||
return determiner + " " + color + ChatColor.ITALIC + name;
|
return determiner + " " + color + ChatColor.ITALIC + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTeam()
|
||||||
|
{
|
||||||
|
return hasTeam;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAbbr()
|
public String getAbbr()
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ import me.totalfreedom.totalfreedommod.admin.Admin;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.util.ChatUtils;
|
import net.pravian.aero.util.ChatUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -16,6 +17,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
public class RankManager extends FreedomService
|
public class RankManager extends FreedomService
|
||||||
{
|
{
|
||||||
@ -175,6 +178,7 @@ public class RankManager extends FreedomService
|
|||||||
fPlayer.setTag(null);
|
fPlayer.setTag(null);
|
||||||
player.setPlayerListName(null);
|
player.setPlayerListName(null);
|
||||||
}
|
}
|
||||||
|
updatePlayerTeam(player);
|
||||||
plugin.pem.setPermissions(player);
|
plugin.pem.setPermissions(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,25 +245,8 @@ public class RankManager extends FreedomService
|
|||||||
final Displayable display = getDisplay(player);
|
final Displayable display = getDisplay(player);
|
||||||
|
|
||||||
FUtil.bcastMsg(craftLoginMessage(player, null));
|
FUtil.bcastMsg(craftLoginMessage(player, null));
|
||||||
plugin.pl.getPlayer(player).setTag(display.getColoredTag());
|
|
||||||
|
|
||||||
if (isAdmin)
|
updateDisplay(player);
|
||||||
{
|
|
||||||
Admin admin = plugin.al.getAdmin(player);
|
|
||||||
if (admin.getTag() != null)
|
|
||||||
{
|
|
||||||
plugin.pl.getPlayer(player).setTag(FUtil.colorize(admin.getTag()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String displayName = display.getColor() + player.getName();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.pv.isPlayerImpostor(player) && target.getEnabled())
|
if (!plugin.pv.isPlayerImpostor(player) && target.getEnabled())
|
||||||
@ -292,4 +279,28 @@ public class RankManager extends FreedomService
|
|||||||
}
|
}
|
||||||
return loginMessage;
|
return loginMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updatePlayerTeam(Player player)
|
||||||
|
{
|
||||||
|
FLog.info("Updating team data...");
|
||||||
|
Displayable display = getDisplay(player);
|
||||||
|
Scoreboard scoreboard = server.getScoreboardManager().getMainScoreboard();
|
||||||
|
Team team = scoreboard.getPlayerTeam(player);
|
||||||
|
if (team != null && !display.hasTeam())
|
||||||
|
{
|
||||||
|
FLog.info("Removing from team");
|
||||||
|
team.removePlayer(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
team = scoreboard.getTeam(display.toString());
|
||||||
|
if (team == null)
|
||||||
|
{
|
||||||
|
FLog.info("Creating team...");
|
||||||
|
team = scoreboard.registerNewTeam(display.toString());
|
||||||
|
FLog.info("Created team " + team.getName());
|
||||||
|
team.setColor(display.getColor());
|
||||||
|
}
|
||||||
|
team.addPlayer(player);
|
||||||
|
FLog.info("Added player to team");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@ import org.bukkit.ChatColor;
|
|||||||
public enum Title implements Displayable
|
public enum Title implements Displayable
|
||||||
{
|
{
|
||||||
|
|
||||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB"),
|
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB", false),
|
||||||
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, "VA"),
|
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, "VA", false),
|
||||||
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, "Asst Exec"),
|
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, "Asst Exec", false),
|
||||||
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec"),
|
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec", true),
|
||||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev"),
|
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev", true),
|
||||||
OWNER("the", "Owner", ChatColor.DARK_RED, "Owner");
|
OWNER("the", "Owner", ChatColor.DARK_RED, "Owner", true);
|
||||||
|
|
||||||
private final String determiner;
|
private final String determiner;
|
||||||
@Getter
|
@Getter
|
||||||
@ -24,8 +24,10 @@ public enum Title implements Displayable
|
|||||||
private final String coloredTag;
|
private final String coloredTag;
|
||||||
@Getter
|
@Getter
|
||||||
private final ChatColor color;
|
private final ChatColor color;
|
||||||
|
@Getter
|
||||||
|
private final boolean hasTeam;
|
||||||
|
|
||||||
private Title(String determiner, String name, ChatColor color, String tag)
|
private Title(String determiner, String name, ChatColor color, String tag, Boolean hasTeam)
|
||||||
{
|
{
|
||||||
this.determiner = determiner;
|
this.determiner = determiner;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -33,6 +35,7 @@ public enum Title implements Displayable
|
|||||||
this.abbr = tag;
|
this.abbr = tag;
|
||||||
this.tag = "[" + tag + "]";
|
this.tag = "[" + tag + "]";
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.hasTeam = hasTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,6 +44,12 @@ public enum Title implements Displayable
|
|||||||
return color + name;
|
return color + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTeam()
|
||||||
|
{
|
||||||
|
return hasTeam;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColoredLoginMessage()
|
public String getColoredLoginMessage()
|
||||||
{
|
{
|
||||||
|
301
src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java
Normal file
301
src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.sql;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
|
||||||
|
public class SQLite extends FreedomService
|
||||||
|
{
|
||||||
|
private final String FILE_NAME = "database.db";
|
||||||
|
|
||||||
|
private Connection connection;
|
||||||
|
|
||||||
|
public SQLite(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
connect();
|
||||||
|
checkTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder() + "/" + FILE_NAME);
|
||||||
|
FLog.info("Successfully connected to the database.");
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to connect to the database: " + e.getMessage());
|
||||||
|
FLog.info("Successfully disconnected from the database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (connection != null)
|
||||||
|
{
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to disconnect from the database: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkTables()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DatabaseMetaData meta = connection.getMetaData();
|
||||||
|
if (!tableExists(meta, "bans"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().execute("CREATE TABLE `bans` ( `name` VARCHAR NOT NULL, `ips` VARCHAR, `by` VARCHAR NOT NULL, `at` LONG NOT NULL, `expires` LONG, `reason` VARCHAR );");
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to create the bans table: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tableExists(meta, "admins"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().execute("CREATE TABLE `admins` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `rank` VARCHAR NOT NULL, `active` BOOLEAN NOT NULL, `last_login` LONG NOT NULL, `login_message` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `backup_codes` VARCHAR, `command_spy` BOOLEAN NOT NULL, `potion_spy` BOOLEAN NOT NULL, `ac_format` VARCHAR, `old_tags` BOOLEAN NOT NULL, `log_stick` BOOLEAN NOT NULL, `discord_chat` BOOLEAN NOT NULL);");
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to create the admins table: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to check tables on database: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void truncate(String table)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().execute("TRUNCATE TABLE " + table);
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to truncate " + table + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultSet getBanList() throws SQLException
|
||||||
|
{
|
||||||
|
return connection.createStatement().executeQuery("SELECT * FROM bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ResultSet getAdminList() throws SQLException
|
||||||
|
{
|
||||||
|
return connection.createStatement().executeQuery("SELECT * FROM admins");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminValue(Admin admin, String key, Object value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Object[] data = {key, admin.getName()};
|
||||||
|
PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE admins SET {0}=? WHERE username=''{1}''", data));
|
||||||
|
statement = setUnknownType(statement, 1, value);
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to update value: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAdminName(String oldName, String newName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE admins SET username=? WHERE username=''{0}''", oldName));
|
||||||
|
statement = setUnknownType(statement, 1, newName);
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to update value: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreparedStatement setUnknownType(PreparedStatement statement, int index, Object value) throws SQLException
|
||||||
|
{
|
||||||
|
if (value.getClass().equals(String.class))
|
||||||
|
{
|
||||||
|
String v = (String)value;
|
||||||
|
statement.setString(index, v);
|
||||||
|
}
|
||||||
|
else if (value.getClass().equals(Integer.class))
|
||||||
|
{
|
||||||
|
int v = (int)value;
|
||||||
|
statement.setInt(index, v);
|
||||||
|
}
|
||||||
|
else if (value.getClass().equals(Boolean.class))
|
||||||
|
{
|
||||||
|
boolean v = (boolean)value;
|
||||||
|
statement.setBoolean(index, v);
|
||||||
|
}
|
||||||
|
else if (value.getClass().equals(Long.class))
|
||||||
|
{
|
||||||
|
long v = (long)value;
|
||||||
|
statement.setLong(index, v);
|
||||||
|
}
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getValue(ResultSet resultSet, String key, Object value) throws SQLException
|
||||||
|
{
|
||||||
|
Object result = null;
|
||||||
|
if (value instanceof String)
|
||||||
|
{
|
||||||
|
result = resultSet.getString(key);
|
||||||
|
}
|
||||||
|
else if (value instanceof Integer)
|
||||||
|
{
|
||||||
|
result = resultSet.getInt(key);
|
||||||
|
}
|
||||||
|
else if (value instanceof Boolean)
|
||||||
|
{
|
||||||
|
result = resultSet.getBoolean(key);
|
||||||
|
}
|
||||||
|
else if (value instanceof Long)
|
||||||
|
{
|
||||||
|
result = resultSet.getLong(key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAdmin(Admin admin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO admins VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
statement.setString(1, admin.getName());
|
||||||
|
statement.setString(2, FUtil.listToString(admin.getIps()));
|
||||||
|
statement.setString(3, admin.getRank().toString());
|
||||||
|
statement.setBoolean(4, admin.isActive());
|
||||||
|
statement.setLong(5, admin.getLastLogin().getTime());
|
||||||
|
statement.setString(6, admin.getLoginMessage());
|
||||||
|
statement.setString(7, admin.getTag());
|
||||||
|
statement.setString(8, admin.getDiscordID());
|
||||||
|
statement.setString(9, FUtil.listToString(admin.getBackupCodes()));
|
||||||
|
statement.setBoolean(10, admin.getCommandSpy());
|
||||||
|
statement.setBoolean(11, admin.getPotionSpy());
|
||||||
|
statement.setString(12, admin.getAcFormat());
|
||||||
|
statement.setBoolean(13, admin.getOldTags());
|
||||||
|
statement.setBoolean(14, admin.getLogStick());
|
||||||
|
statement.executeUpdate();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to add admin: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultSet getAdminByName(String name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet resultSet = connection.createStatement().executeQuery(MessageFormat.format("SELECT * FROM admins WHERE username=''{0}''", name));
|
||||||
|
if (resultSet.next())
|
||||||
|
{
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get admin by name: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAdmin(Admin admin)
|
||||||
|
{
|
||||||
|
Object[] data = {admin.getName(), FUtil.listToString(admin.getBackupCodes())};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans where name=''{0}'' and ips=''{1}''", data));
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to remove admin: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBan(Ban ban)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO bans VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
|
statement.setString(1, ban.getUsername());
|
||||||
|
statement.setString(2, FUtil.listToString(ban.getIps()));
|
||||||
|
statement.setString(3, ban.getBy());
|
||||||
|
statement.setLong(4, ban.getAt().getTime());
|
||||||
|
statement.setLong(5, ban.getExpiryUnix());
|
||||||
|
statement.setString(6, ban.getReason());
|
||||||
|
statement.executeUpdate();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to add ban: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBan(Ban ban)
|
||||||
|
{
|
||||||
|
Object[] data = {ban.getUsername(), String.join(", ", ban.getIps())};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans where name=''{0}'' and ips=''{1}''", data));
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to remove ban: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean tableExists(DatabaseMetaData meta, String name) throws SQLException
|
||||||
|
{
|
||||||
|
return meta.getTables(null, null, name, null).next();
|
||||||
|
}
|
||||||
|
}
|
@ -52,7 +52,7 @@ public class FUtil
|
|||||||
//
|
//
|
||||||
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
|
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
|
||||||
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
|
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
|
||||||
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "Demonic_Mario", "OxLemonxO");
|
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "Demonic_Mario");
|
||||||
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||||
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
||||||
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
||||||
@ -156,6 +156,25 @@ public class FUtil
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String listToString(List<String> list)
|
||||||
|
{
|
||||||
|
if (list.size() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.join(", ", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> stringToList(String string)
|
||||||
|
{
|
||||||
|
if (string == null)
|
||||||
|
{
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Arrays.asList(string.split(", "));
|
||||||
|
}
|
||||||
public static List<String> getAllMaterialNames()
|
public static List<String> getAllMaterialNames()
|
||||||
{
|
{
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.world;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.WorldType;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public final class HubWorld extends CustomWorld
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String GENERATION_PARAMETERS = ConfigEntry.FLATLANDS_GENERATE_PARAMS.getString();
|
||||||
|
//
|
||||||
|
private WorldWeather weather = WorldWeather.OFF;
|
||||||
|
private WorldTime time = WorldTime.INHERIT;
|
||||||
|
|
||||||
|
public HubWorld()
|
||||||
|
{
|
||||||
|
super("hubworld");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendToWorld(Player player)
|
||||||
|
{
|
||||||
|
super.sendToWorld(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected World generateWorld()
|
||||||
|
{
|
||||||
|
final WorldCreator worldCreator = new WorldCreator(getName());
|
||||||
|
worldCreator.generateStructures(false);
|
||||||
|
worldCreator.type(WorldType.NORMAL);
|
||||||
|
worldCreator.environment(World.Environment.NORMAL);
|
||||||
|
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
|
||||||
|
|
||||||
|
final World world = server.createWorld(worldCreator);
|
||||||
|
|
||||||
|
world.setSpawnFlags(false, false);
|
||||||
|
world.setSpawnLocation(0, 50, 0);
|
||||||
|
|
||||||
|
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
|
||||||
|
welcomeSignBlock.setType(Material.OAK_SIGN);
|
||||||
|
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign)welcomeSignBlock.getState();
|
||||||
|
|
||||||
|
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)welcomeSign.getData();
|
||||||
|
signData.setFacingDirection(BlockFace.NORTH);
|
||||||
|
|
||||||
|
welcomeSign.setLine(0, ChatColor.GREEN + "Hub World");
|
||||||
|
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
|
||||||
|
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
|
||||||
|
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
|
||||||
|
welcomeSign.update();
|
||||||
|
|
||||||
|
plugin.gr.commitGameRules();
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldWeather getWeatherMode()
|
||||||
|
{
|
||||||
|
return weather;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeatherMode(final WorldWeather weatherMode)
|
||||||
|
{
|
||||||
|
this.weather = weatherMode;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
weatherMode.setWorldToWeather(getWorld());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldTime getTimeOfDay()
|
||||||
|
{
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeOfDay(final WorldTime timeOfDay)
|
||||||
|
{
|
||||||
|
this.time = timeOfDay;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
timeOfDay.setWorldToTime(getWorld());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import com.sk89q.worldguard.protection.flags.Flag;
|
|||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -162,7 +163,7 @@ public class WorldRestrictions extends FreedomService
|
|||||||
|
|
||||||
RegionManager regionManager = plugin.wgb.getRegionManager(world);
|
RegionManager regionManager = plugin.wgb.getRegionManager(world);
|
||||||
|
|
||||||
ProtectedRegion region = regionManager.getRegion("__global__");
|
GlobalProtectedRegion region = new GlobalProtectedRegion("__global__");
|
||||||
|
|
||||||
region.setFlags(flags);
|
region.setFlags(flags);
|
||||||
|
|
||||||
|
@ -179,6 +179,8 @@ allow:
|
|||||||
jukeboxes: false
|
jukeboxes: false
|
||||||
spawners: false
|
spawners: false
|
||||||
beehives: false
|
beehives: false
|
||||||
|
auto_tp: false
|
||||||
|
auto_clear: false
|
||||||
|
|
||||||
# Blocked commands:
|
# Blocked commands:
|
||||||
#
|
#
|
||||||
@ -221,7 +223,6 @@ blocked_commands:
|
|||||||
- 'n:b:/ban-ip:_'
|
- 'n:b:/ban-ip:_'
|
||||||
- 'n:b:/pardon-ip:_'
|
- 'n:b:/pardon-ip:_'
|
||||||
- 'n:b:/toggledownfall:_'
|
- 'n:b:/toggledownfall:_'
|
||||||
- 'n:b:/effect:Please use /potion to set effects.'
|
|
||||||
- 'n:b:/enderchest:_'
|
- 'n:b:/enderchest:_'
|
||||||
- 'n:b:/spreadplayers:_'
|
- 'n:b:/spreadplayers:_'
|
||||||
- 'n:b:/execute:_'
|
- 'n:b:/execute:_'
|
||||||
@ -233,9 +234,6 @@ blocked_commands:
|
|||||||
- 'n:b:/skinrestorer:_'
|
- 'n:b:/skinrestorer:_'
|
||||||
- 'n:b:/packet:_'
|
- 'n:b:/packet:_'
|
||||||
- 'n:b:/thaw:_'
|
- 'n:b:/thaw:_'
|
||||||
- 'n:b:/pp largeexplode:You may not use this particle! Please use another.'
|
|
||||||
- 'n:b:/pp hugeexplosion:You may not use this particle! Please use another.'
|
|
||||||
- 'n:b:/pp barrier:You may not use this particle! Please use another.'
|
|
||||||
- 'n:b:/setjail:_'
|
- 'n:b:/setjail:_'
|
||||||
- 'n:b:/function:_'
|
- 'n:b:/function:_'
|
||||||
- 'n:b:/data:_'
|
- 'n:b:/data:_'
|
||||||
|
@ -68,6 +68,8 @@ master_builders:
|
|||||||
- "worldedit.green"
|
- "worldedit.green"
|
||||||
- "worldedit.extinguish"
|
- "worldedit.extinguish"
|
||||||
- "worldedit.thaw"
|
- "worldedit.thaw"
|
||||||
|
- "worldguard.region.bypass.hubworld"
|
||||||
|
- "worldguard.region.bypass.masterbuilderworld"
|
||||||
|
|
||||||
# Super Admin permission nodes
|
# Super Admin permission nodes
|
||||||
super_admins:
|
super_admins:
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#
|
|
||||||
# TotalFreedomMod 5.5 VPN Bans
|
|
||||||
#
|
|
||||||
|
|
||||||
badnetwork1:
|
|
||||||
- 123.123.123.123
|
|
||||||
- 321.321.321.321
|
|
||||||
badnetwork2:
|
|
||||||
- 111.111.111.111
|
|
Loading…
Reference in New Issue
Block a user