mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
1.16, overhaul of player data
This commit is contained in:
parent
4ddcc3b8d7
commit
eb58419a3a
@ -51,16 +51,18 @@
|
|||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
|
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.16.1-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-LibsDisguises:11aea9b3cd" level="project" />
|
<orderEntry type="library" name="Maven: com.github.libraryaddict:LibsDisguises:31672fce7b" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" name="Maven: org.ow2.asm:asm:7.3.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
|
<orderEntry type="library" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.16-R0.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.1.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.1.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.1.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.1.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.1.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.1.0" level="project" />
|
||||||
@ -109,7 +111,6 @@
|
|||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.1.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.1.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
||||||
@ -142,21 +143,20 @@
|
|||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.2" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.2" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.16.1-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
|
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:8.0.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:7.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:8.0.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:8.0.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
|
<orderEntry type="library" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.vexsoftware:votifier:v1.9" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.vexsoftware:votifier:v1.9" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.16.1-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ConnorLinfoot:ActionBarAPI:5b2d642d3d" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ConnorLinfoot:ActionBarAPI:5b2d642d3d" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.goldtreeservers:worldguardextraflags:4.0.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.goldtreeservers:worldguardextraflags:4.0.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.boydti:fawe-api:17.07.12-6b6f285-750-13.7.8" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.boydti:fawe-api:17.07.12-6b6f285-750-13.7.8" level="project" />
|
||||||
|
20
pom.xml
20
pom.xml
@ -138,7 +138,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.15-R0.1-SNAPSHOT</version>
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -157,10 +157,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TFPatches</groupId>
|
<groupId>com.github.libraryaddict</groupId>
|
||||||
<artifactId>TF-LibsDisguises</artifactId>
|
<artifactId>LibsDisguises</artifactId>
|
||||||
<version>11aea9b3cd</version>
|
<version>31672fce7b</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -201,7 +200,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
<groupId>com.destroystokyo.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.15.1-R0.1-SNAPSHOT</version>
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -218,6 +217,13 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.ConnorLinfoot</groupId>
|
<groupId>com.github.ConnorLinfoot</groupId>
|
||||||
<artifactId>ActionBarAPI</artifactId>
|
<artifactId>ActionBarAPI</artifactId>
|
||||||
@ -376,7 +382,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>2.4.3</version>
|
<version>3.2.4</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
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;
|
||||||
|
@ -10,12 +10,9 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AntiSpam extends FreedomService
|
public class AntiSpam extends FreedomService
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.Period;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
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.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -41,7 +39,7 @@ public class ChatManager extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -66,9 +64,9 @@ public class ChatManager extends FreedomService
|
|||||||
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ShopData data = plugin.sh.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
plugin.sh.save(data);
|
plugin.pl.save(data);
|
||||||
plugin.sh.reactionString = "";
|
plugin.sh.reactionString = "";
|
||||||
Date currentTime = new Date();
|
Date currentTime = new Date();
|
||||||
long seconds = (currentTime.getTime() - plugin.sh.reactionStartTime.getTime()) / 1000;
|
long seconds = (currentTime.getTime() - plugin.sh.reactionStartTime.getTime()) / 1000;
|
||||||
@ -82,7 +80,7 @@ public class ChatManager extends FreedomService
|
|||||||
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
playerMsg(player, "Chat is currently disabled.", ChatColor.RED);
|
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class Fuckoff extends FreedomService
|
|||||||
|
|
||||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||||
{
|
{
|
||||||
onlinePlayer.setVelocity(onlinePlayer.getLocation().toVector().subtract(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
fuckoffPlayer.setVelocity(onlinePlayer.getLocation().toVector().subtract(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,13 @@ import java.util.List;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_vanish;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -194,7 +193,7 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
final VPlayer verificationPlayer = plugin.pv.getVerificationPlayer(player);
|
final PlayerData playerData = plugin.pl.getData(player);
|
||||||
|
|
||||||
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);
|
||||||
@ -210,6 +209,12 @@ public class LoginProcess extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!playerData.hasVerification() && !playerData.getIps().contains(Ips.getIp(player)))
|
||||||
|
{
|
||||||
|
playerData.addIp(Ips.getIp(player));
|
||||||
|
plugin.pl.save(playerData);
|
||||||
|
}
|
||||||
|
|
||||||
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
||||||
{
|
{
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
@ -237,35 +242,20 @@ public class LoginProcess extends FreedomService
|
|||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
if (plugin.mbl.isMasterBuilder(player))
|
fPlayer.setTag(FUtil.colorize(playerData.getTag()));
|
||||||
|
int noteCount = playerData.getNotes().size();
|
||||||
|
if (noteCount != 0)
|
||||||
{
|
{
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
|
||||||
if (masterBuilder.getTag() != null)
|
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
||||||
|
.tooltip("Click here to view them.")
|
||||||
|
.runCommand("/notes " + player.getName() + " list");
|
||||||
|
FLog.info(noteMessage);
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
fPlayer.setTag(FUtil.colorize(masterBuilder.getTag()));
|
if (plugin.al.isAdminImpostor(p))
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
|
||||||
if (vPlayer.getEnabled() && vPlayer.getTag() != null)
|
|
||||||
{
|
|
||||||
fPlayer.setTag(FUtil.colorize(vPlayer.getTag()));
|
|
||||||
}
|
|
||||||
int noteCount = vPlayer.getNotes().size();
|
|
||||||
if (noteCount != 0)
|
|
||||||
{
|
|
||||||
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
|
|
||||||
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
|
||||||
.tooltip("Click here to view them.")
|
|
||||||
.runCommand("/notes " + player.getName() + " list");
|
|
||||||
FLog.info(noteMessage);
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdminImpostor(p))
|
notice.send(p);
|
||||||
{
|
|
||||||
notice.send(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@ import ca.momothereal.mojangson.value.MojangsonCompound;
|
|||||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagList;
|
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
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;
|
||||||
@ -137,7 +137,7 @@ public class MovementValidator extends FreedomService
|
|||||||
|
|
||||||
private Boolean exploitItem(ItemStack item)
|
private Boolean exploitItem(ItemStack item)
|
||||||
{
|
{
|
||||||
net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||||
MojangsonCompound compound = new MojangsonCompound();
|
MojangsonCompound compound = new MojangsonCompound();
|
||||||
boolean foundNegative = false;
|
boolean foundNegative = false;
|
||||||
@ -174,7 +174,7 @@ public class MovementValidator extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
|
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.getTag() == null)
|
if (stack.getTag() == null)
|
||||||
{
|
{
|
||||||
|
@ -38,15 +38,13 @@ public class Muter extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
FLog.info("checking mute");
|
|
||||||
|
|
||||||
if (!fPlayer.isMuted())
|
if (!fPlayer.isMuted())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -4,15 +4,15 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
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.minecraft.server.v1_15_R1.EntityPlayer;
|
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||||
|
|
||||||
public class ServerInterface extends FreedomService
|
public class ServerInterface extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String COMPILE_NMS_VERSION = "v1_15_R1";
|
public static final String COMPILE_NMS_VERSION = "v1_16_R1";
|
||||||
|
|
||||||
public ServerInterface(TotalFreedomMod plugin)
|
public ServerInterface(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
|
@ -33,16 +33,12 @@ import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
|||||||
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MP44;
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MobStacker;
|
import me.totalfreedom.totalfreedommod.fun.MobStacker;
|
||||||
import me.totalfreedom.totalfreedommod.fun.RealTimer;
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
|
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
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;
|
||||||
@ -126,12 +122,9 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public Jumppads jp;
|
public Jumppads jp;
|
||||||
public Trailer tr;
|
public Trailer tr;
|
||||||
public HTTPDaemon hd;
|
public HTTPDaemon hd;
|
||||||
public MasterBuilderList mbl;
|
|
||||||
public WorldRestrictions wr;
|
public WorldRestrictions wr;
|
||||||
public SignBlocker snp;
|
public SignBlocker snp;
|
||||||
public PlayerVerification pv;
|
|
||||||
public EntityWiper ew;
|
public EntityWiper ew;
|
||||||
public RealTimer rt;
|
|
||||||
//public HubWorldRestrictions hwr;
|
//public HubWorldRestrictions hwr;
|
||||||
//
|
//
|
||||||
// Bridges
|
// Bridges
|
||||||
@ -174,12 +167,10 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
|
|
||||||
BackupManager backups = new BackupManager(this);
|
BackupManager backups = new BackupManager(this);
|
||||||
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||||
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(MasterBuilder.CONFIG_FILENAME);
|
|
||||||
backups.createBackups(PunishmentList.CONFIG_FILENAME);
|
backups.createBackups(PunishmentList.CONFIG_FILENAME);
|
||||||
backups.createBackups("");
|
backups.createBackups("database.db");
|
||||||
|
|
||||||
config = new MainConfig(this);
|
config = new MainConfig(this);
|
||||||
config.load();
|
config.load();
|
||||||
@ -207,7 +198,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
lp = services.registerService(LoginProcess.class);
|
lp = services.registerService(LoginProcess.class);
|
||||||
nu = services.registerService(AntiNuke.class);
|
nu = services.registerService(AntiNuke.class);
|
||||||
as = services.registerService(AntiSpam.class);
|
as = services.registerService(AntiSpam.class);
|
||||||
mbl = services.registerService(MasterBuilderList.class);
|
|
||||||
wr = services.registerService(WorldRestrictions.class);
|
wr = services.registerService(WorldRestrictions.class);
|
||||||
pl = services.registerService(PlayerList.class);
|
pl = services.registerService(PlayerList.class);
|
||||||
sh = services.registerService(Shop.class);
|
sh = services.registerService(Shop.class);
|
||||||
@ -239,7 +229,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
|
|
||||||
mv = services.registerService(MovementValidator.class);
|
mv = services.registerService(MovementValidator.class);
|
||||||
sp = services.registerService(ServerPing.class);
|
sp = services.registerService(ServerPing.class);
|
||||||
pv = services.registerService(PlayerVerification.class);
|
|
||||||
|
|
||||||
// Fun
|
// Fun
|
||||||
cul = services.registerService(CurseListener.class);
|
cul = services.registerService(CurseListener.class);
|
||||||
@ -249,8 +238,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
mp = services.registerService(MP44.class);
|
mp = services.registerService(MP44.class);
|
||||||
jp = services.registerService(Jumppads.class);
|
jp = services.registerService(Jumppads.class);
|
||||||
tr = services.registerService(Trailer.class);
|
tr = services.registerService(Trailer.class);
|
||||||
rt = services.registerService(RealTimer.class);
|
|
||||||
|
|
||||||
// HTTPD
|
// HTTPD
|
||||||
hd = services.registerService(HTTPDaemon.class);
|
hd = services.registerService(HTTPDaemon.class);
|
||||||
services.start();
|
services.start();
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
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.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -12,6 +13,7 @@ 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.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -31,7 +33,6 @@ public class Admin
|
|||||||
private Rank rank = Rank.SUPER_ADMIN;
|
private Rank rank = Rank.SUPER_ADMIN;
|
||||||
@Getter
|
@Getter
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
private final List<String> backupCodes = Lists.newArrayList();
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Date lastLogin = new Date();
|
private Date lastLogin = new Date();
|
||||||
@ -40,12 +41,6 @@ public class Admin
|
|||||||
private String loginMessage = null;
|
private String loginMessage = null;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String discordID = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String tag = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean commandSpy = false;
|
private Boolean commandSpy = false;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -60,32 +55,33 @@ public class Admin
|
|||||||
@Setter
|
@Setter
|
||||||
private Boolean logStick = false;
|
private Boolean logStick = false;
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "admins.yml";
|
|
||||||
|
|
||||||
public Admin(Player player)
|
public Admin(Player player)
|
||||||
{
|
{
|
||||||
this.name = player.getName();
|
this.name = player.getName();
|
||||||
this.ips.add(Ips.getIp(player));
|
this.ips.add(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
public Admin(ResultSet resultSet)
|
||||||
{
|
{
|
||||||
this.name = username;
|
try
|
||||||
this.active = active;
|
{
|
||||||
this.rank = rank;
|
this.name = resultSet.getString("username");
|
||||||
this.ips.clear();
|
this.active = resultSet.getBoolean("active");
|
||||||
this.ips.addAll(ips);
|
this.rank = Rank.findRank(resultSet.getString("rank"));
|
||||||
this.lastLogin = lastLogin;
|
this.ips.clear();
|
||||||
this.loginMessage = loginMessage;
|
this.ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
||||||
this.tag = tag;
|
this.lastLogin = new Date(resultSet.getLong("last_login"));
|
||||||
this.discordID = discordID;
|
this.loginMessage = resultSet.getString("login_message");
|
||||||
this.backupCodes.clear();
|
this.commandSpy = resultSet.getBoolean("command_spy");
|
||||||
this.backupCodes.addAll(backupCodes);
|
this.potionSpy = resultSet.getBoolean("potion_spy");
|
||||||
this.commandSpy = commandSpy;
|
this.acFormat = resultSet.getString("ac_format");
|
||||||
this.potionSpy = potionSpy;
|
this.oldTags = resultSet.getBoolean("old_tags");
|
||||||
this.acFormat = acFormat;
|
this.logStick = resultSet.getBoolean("log_stick");
|
||||||
this.oldTags = oldTags;
|
}
|
||||||
this.logStick = logStick;
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load admin: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,13 +95,10 @@ public class Admin
|
|||||||
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
||||||
.append("- Rank: ").append(rank.getName()).append("\n")
|
.append("- Rank: ").append(rank.getName()).append("\n")
|
||||||
.append("- Is Active: ").append(active).append("\n")
|
.append("- Is Active: ").append(active).append("\n")
|
||||||
.append("- Discord ID: ").append(discordID).append("\n")
|
|
||||||
.append("- Tag: ").append(tag).append("\n").append(ChatColor.GRAY)
|
|
||||||
.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("\n")
|
.append("- Log Stick: ").append(logStick).append("\n");
|
||||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10");
|
|
||||||
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
@ -125,11 +118,8 @@ public class Admin
|
|||||||
put("active", active);
|
put("active", active);
|
||||||
put("rank", rank.toString());
|
put("rank", rank.toString());
|
||||||
put("ips", FUtil.listToString(ips));
|
put("ips", FUtil.listToString(ips));
|
||||||
put("backup_codes", FUtil.listToString(backupCodes));
|
|
||||||
put("last_login", lastLogin.getTime());
|
put("last_login", lastLogin.getTime());
|
||||||
put("login_message", loginMessage);
|
put("login_message", loginMessage);
|
||||||
put("discord_id", discordID);
|
|
||||||
put("tag", tag);
|
|
||||||
put("command_spy", commandSpy);
|
put("command_spy", commandSpy);
|
||||||
put("potion_spy", potionSpy);
|
put("potion_spy", potionSpy);
|
||||||
put("ac_format", acFormat);
|
put("ac_format", acFormat);
|
||||||
@ -179,22 +169,6 @@ public class Admin
|
|||||||
ips.clear();
|
ips.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getBackupCodes()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(backupCodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackupCodes(List<String> codes)
|
|
||||||
{
|
|
||||||
backupCodes.clear();
|
|
||||||
backupCodes.addAll(codes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBackupCode(String code)
|
|
||||||
{
|
|
||||||
backupCodes.remove(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(boolean active)
|
public void setActive(boolean active)
|
||||||
{
|
{
|
||||||
this.active = active;
|
this.active = active;
|
||||||
|
@ -18,7 +18,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
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.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -27,9 +26,6 @@ import org.bukkit.plugin.ServicePriority;
|
|||||||
|
|
||||||
public class AdminList extends FreedomService
|
public class AdminList extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "admins.yml";
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||||
// Only active admins below
|
// Only active admins below
|
||||||
@ -40,30 +36,16 @@ public class AdminList extends FreedomService
|
|||||||
public final List<String> verifiedNoAdmins = new ArrayList<>();
|
public final List<String> verifiedNoAdmins = new ArrayList<>();
|
||||||
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
||||||
public static ArrayList<Player> vanished = new ArrayList<>();
|
public static ArrayList<Player> vanished = new ArrayList<>();
|
||||||
//
|
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
public AdminList(TotalFreedomMod plugin)
|
public AdminList(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
|
||||||
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
|
|
||||||
server.getServicesManager().register(Function.class, new Function<Player, Boolean>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Boolean apply(Player player)
|
|
||||||
{
|
|
||||||
return isAdmin(player);
|
|
||||||
}
|
|
||||||
}, plugin, ServicePriority.Normal);
|
|
||||||
|
|
||||||
deactivateOldEntries(false);
|
deactivateOldEntries(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +56,6 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
config.load();
|
|
||||||
|
|
||||||
allAdmins.clear();
|
allAdmins.clear();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -83,28 +63,14 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
while (adminSet.next())
|
while (adminSet.next())
|
||||||
{
|
{
|
||||||
String name = adminSet.getString("username");
|
Admin admin = new Admin(adminSet);
|
||||||
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);
|
allAdmins.add(admin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
FLog.severe("Failed to get adminlist: " + e.getMessage());
|
FLog.severe("Failed to load adminlist: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTables();
|
updateTables();
|
||||||
|
@ -9,7 +9,6 @@ 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.Date;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -180,10 +179,23 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
public boolean addBan(Ban ban)
|
public boolean addBan(Ban ban)
|
||||||
{
|
{
|
||||||
if (getByUsername(ban.getUsername()) != null)
|
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
|
||||||
{
|
{
|
||||||
removeBan(ban);
|
removeBan(ban);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
for (String ip : ban.getIps())
|
||||||
|
{
|
||||||
|
if (getByIp(ip) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bans.add(ban))
|
if (bans.add(ban))
|
||||||
{
|
{
|
||||||
plugin.sql.addBan(ban);
|
plugin.sql.addBan(ban);
|
||||||
@ -246,14 +258,19 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unban admins
|
// Unban admins
|
||||||
for (String storedIp : data.getIps())
|
Ban ban = getByUsername(player.getName());
|
||||||
|
if (ban != null)
|
||||||
{
|
{
|
||||||
unbanIp(storedIp);
|
removeBan(ban);
|
||||||
unbanIp(FUtil.getFuzzyIp(storedIp));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ban = getByIp(Ips.getIp(player));
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unbanUsername(player.getName());
|
|
||||||
player.setOp(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateViews()
|
private void updateViews()
|
||||||
|
@ -68,6 +68,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FIRE:
|
case FIRE:
|
||||||
|
case SOUL_FIRE:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
{
|
{
|
||||||
@ -173,13 +174,10 @@ public class BlockBlocker extends FreedomService
|
|||||||
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
||||||
{
|
{
|
||||||
Banner banner = (Banner) event.getBlockPlaced().getState();
|
Banner banner = (Banner) event.getBlockPlaced().getState();
|
||||||
List<Pattern> patterns = banner.getPatterns();
|
List<Pattern> patterns = banner.getPatterns();;
|
||||||
Banner handBanner = (Banner) (((Block) event.getItemInHand()).getState());
|
|
||||||
List<Pattern> handPatterns = banner.getPatterns();
|
|
||||||
if (patterns.size() >= 2)
|
if (patterns.size() >= 2)
|
||||||
{
|
{
|
||||||
banner.setPatterns(patterns.subList(0, 2));
|
banner.setPatterns(patterns.subList(0, 2));
|
||||||
handBanner.setPatterns(handPatterns.subList(0, 2));
|
|
||||||
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,15 +56,9 @@ public class InteractBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onRightClickBell(PlayerInteractEvent event)
|
public void onRightClickBell(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock() != null)
|
if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.BELL) && !ConfigEntry.ALLOW_BELLS.getBoolean())
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock().getType().equals(Material.BELL))
|
event.setCancelled(true);
|
||||||
{
|
|
||||||
if (!ConfigEntry.ALLOW_BELLS.getBoolean())
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,12 +83,14 @@ public class InteractBlocker extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Groups.BED_COLORS.contains(event.getMaterial()) && event.getClickedBlock().getBiome().equals(Biome.NETHER))
|
// TODO: lookup new biomes that have bed explosions in 1.16
|
||||||
|
|
||||||
|
/*if (Groups.BED_COLORS.contains(event.getMaterial()) && event.getClickedBlock().getBiome().equals(Biome.NETHER))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "You can't sleep in hell.");
|
player.sendMessage(ChatColor.RED + "You can't sleep in hell.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
switch (event.getMaterial())
|
switch (event.getMaterial())
|
||||||
{
|
{
|
||||||
|
@ -2,11 +2,11 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
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;
|
||||||
@ -43,7 +43,7 @@ public class SignBlocker extends FreedomService
|
|||||||
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||||
{
|
{
|
||||||
ItemStack sign = event.getItemInHand();
|
ItemStack sign = event.getItemInHand();
|
||||||
net.minecraft.server.v1_15_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
net.minecraft.server.v1_16_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||||
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||||
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||||
String line1 = bet.getString("Text1");
|
String line1 = bet.getString("Text1");
|
||||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.bridge;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
@ -108,18 +107,25 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockedDisguises.disabled = !state;
|
if (state)
|
||||||
|
{
|
||||||
|
server.getPluginManager().disablePlugin(libsDisguises);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
server.getPluginManager().disablePlugin(libsDisguises);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisguisesEnabled()
|
public boolean isDisguisesEnabled()
|
||||||
{
|
{
|
||||||
return !BlockedDisguises.disabled;
|
return !getLibsDisguisesPlugin().isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
return libsDisguises != null && libsDisguises.isEnabled();
|
return libsDisguises != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -74,7 +74,7 @@ public class Command_ban extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = entry.getUsername();
|
username = entry.getName();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -48,14 +48,6 @@ public class Command_cage extends FreedomCommand
|
|||||||
|
|
||||||
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)
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
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.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Clears the chat for players who are not opt-out.", usage = "/<command>", aliases = "cc")
|
@CommandParameters(description = "Clears the chat for players who are not opt-out.", usage = "/<command>", aliases = "cc")
|
||||||
public class Command_clearchat extends FreedomCommand
|
public class Command_clearchat extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -19,51 +15,12 @@ public class Command_clearchat extends FreedomCommand
|
|||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (plugin.al.isAdmin(playerSender))
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
if (!plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
boolean optedOut = false;
|
IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
optedOut = true;
|
|
||||||
}
|
|
||||||
else if (plugin.mbl.isMasterBuilder(player) && plugin.mbl.getMasterBuilder(player).isClearChatOptOut())
|
|
||||||
{
|
|
||||||
optedOut = true;
|
|
||||||
}
|
|
||||||
else if (plugin.pv.getVerificationPlayer(player).getEnabled() && plugin.pv.getVerificationPlayer(player).isClearChatOptOut())
|
|
||||||
{
|
|
||||||
optedOut = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!optedOut)
|
|
||||||
{
|
|
||||||
IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
|
||||||
}
|
|
||||||
else if (plugin.mbl.isMasterBuilder(playerSender))
|
|
||||||
{
|
|
||||||
MasterBuilder mb = plugin.mbl.getMasterBuilder(playerSender);
|
|
||||||
mb.setClearChatOptOut(!mb.isClearChatOptOut());
|
|
||||||
msg((mb.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
}
|
|
||||||
else if (plugin.pv.getVerificationPlayer(playerSender).getEnabled())
|
|
||||||
{
|
|
||||||
VPlayer vp = plugin.pv.getVerificationPlayer(playerSender);
|
|
||||||
vp.setClearChatOptOut(!vp.isClearChatOptOut());
|
|
||||||
msg((vp.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
|
||||||
plugin.pv.saveVerificationData(vp);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Only Master Builders, admins, and players with verification enabled can opt-out of clear chat.", ChatColor.RED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
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.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows the amount of coins you have or another player", usage = "/<command> [playername]")
|
@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/<command> [playername]")
|
||||||
public class Command_coins extends FreedomCommand
|
public class Command_coins extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ public class Command_coins extends FreedomCommand
|
|||||||
p = playerSender;
|
p = playerSender;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ShopData sd = plugin.sh.getData(p);
|
PlayerData playerData = plugin.pl.getData(p);
|
||||||
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
|
||||||
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 org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -21,7 +20,7 @@ public class Command_disguisetoggle extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), (BlockedDisguises.disabled ? "Enabling" : "Disabling") + " disguises", false);
|
FUtil.adminAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
|
||||||
|
|
||||||
if (plugin.ldb.isDisguisesEnabled())
|
if (plugin.ldb.isDisguisesEnabled())
|
||||||
{
|
{
|
||||||
@ -33,7 +32,7 @@ public class Command_disguisetoggle extends FreedomCommand
|
|||||||
plugin.ldb.setDisguisesEnabled(true);
|
plugin.ldb.setDisguisesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Disguises are now " + (BlockedDisguises.disabled ? "disabled." : "enabled."));
|
msg("Disguises are now " + (plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SENIOR_CONSOLE, source = SourceType.ONLY_CONSOLE)
|
||||||
|
@CommandParameters(description = "Adds or removes donators", usage = "/<command> <mode> <name> <ip> <package> [forum_user]")
|
||||||
|
public class Command_donator extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (!FUtil.isFromHostConsole(sender.getName()) && !ConfigEntry.SERVER_OWNERS.getStringList().contains(sender.getName()))
|
||||||
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean mode = args[0].equals("add");
|
||||||
|
String name = args[1];
|
||||||
|
String ip = args[2];
|
||||||
|
String pkg = args[3];
|
||||||
|
String forum_id = null;
|
||||||
|
|
||||||
|
if (args.length > 4)
|
||||||
|
{
|
||||||
|
forum_id = args[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData player = plugin.pl.getData(name);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
player = plugin.pl.getDataByIp(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.setDonator(mode);
|
||||||
|
plugin.pl.save(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forum_id != null && !forum_id.equals("0"))
|
||||||
|
{
|
||||||
|
String baseurl = ConfigEntry.DONATION_PROBOARDS_URL.getString();
|
||||||
|
String group_id = ConfigEntry.DONATION_GROUP_ID.getString();
|
||||||
|
String session_id = ConfigEntry.DONATION_SESSION_ID.getString();
|
||||||
|
String csrf_token = ConfigEntry.DONATION_CSRF_TOKEN.getString();
|
||||||
|
if (baseurl == null || group_id == null || session_id == null || csrf_token == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String url = baseurl + "/user/group_members/" + (mode ? "adding" : "remove");
|
||||||
|
List<String> headers = Arrays.asList("Cookie:session_id=" + session_id, "X-Requested-With:XMLHttpRequest");
|
||||||
|
String payload = "group_id=" + group_id + "&user_ids[]=" + forum_id + "&csrf_token=" + csrf_token;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String result = FUtil.postRequestToEndpoint(url, "POST", headers, payload);
|
||||||
|
msg(result);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -55,7 +55,7 @@ public class Command_doom extends FreedomCommand
|
|||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
plugin.dc.syncRoles(admin);
|
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ public class Command_fireball 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)
|
||||||
{
|
{
|
||||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getFireBall());
|
playerSender.getInventory().addItem(plugin.sh.getFireBall());
|
||||||
msg("You have been given a Fire Ball", ChatColor.GREEN);
|
msg("You have been given a Fire Ball", ChatColor.GREEN);
|
||||||
|
@ -1,211 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.UUID;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
|
||||||
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
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 = "Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci, fr, smite.",
|
|
||||||
usage = "/<command> [list | [<kick | nameban | ipban | ban | op | deop | ci | fr | smite> <targethash>] ]")
|
|
||||||
//codebeat:disable
|
|
||||||
//basically a deprecated command that still exists
|
|
||||||
public class Command_gadmin extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
private enum GadminMode
|
|
||||||
{
|
|
||||||
|
|
||||||
LIST("list"),
|
|
||||||
KICK("kick"),
|
|
||||||
NAMEBAN("nameban"),
|
|
||||||
IPBAN("ipban"),
|
|
||||||
BAN("ban"),
|
|
||||||
OP("op"),
|
|
||||||
DEOP("deop"),
|
|
||||||
CI("ci"),
|
|
||||||
FR("fr"),
|
|
||||||
SMITE("smite");
|
|
||||||
private final String modeName;
|
|
||||||
|
|
||||||
private GadminMode(String command)
|
|
||||||
{
|
|
||||||
this.modeName = command;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModeName()
|
|
||||||
{
|
|
||||||
return modeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GadminMode findMode(String needle)
|
|
||||||
{
|
|
||||||
for (final GadminMode mode : GadminMode.values())
|
|
||||||
{
|
|
||||||
if (needle.equalsIgnoreCase(mode.getModeName()))
|
|
||||||
{
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPlayerHash(Player player)
|
|
||||||
{
|
|
||||||
return UUID.nameUUIDFromBytes(player.getName().toLowerCase().getBytes(StandardCharsets.UTF_8)).toString().substring(0, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (args.length == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final GadminMode mode = GadminMode.findMode(args[0].toLowerCase());
|
|
||||||
if (mode == null)
|
|
||||||
{
|
|
||||||
msg("Invalid mode: " + args[0], ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Iterator<? extends Player> it = server.getOnlinePlayers().iterator();
|
|
||||||
|
|
||||||
if (mode == GadminMode.LIST)
|
|
||||||
{
|
|
||||||
msg("[ Real Name ] : [ Display Name ] - Hash:");
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
final Player player = it.next();
|
|
||||||
sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
|
|
||||||
player.getName(),
|
|
||||||
ChatColor.stripColor(player.getDisplayName()),
|
|
||||||
getPlayerHash(player)));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player target = null;
|
|
||||||
while (it.hasNext() && target == null)
|
|
||||||
{
|
|
||||||
final Player player = it.next();
|
|
||||||
final String hash = getPlayerHash(player);
|
|
||||||
|
|
||||||
if (hash.equalsIgnoreCase(args[1]))
|
|
||||||
{
|
|
||||||
target = player;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
msg("Invalid player hash: " + args[1], ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case KICK:
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), String.format("Kicking: %s.", target.getName()), false);
|
|
||||||
target.kickPlayer("Kicked by Administrator");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NAMEBAN:
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s.", target.getName()), true);
|
|
||||||
plugin.bm.addBan(Ban.forPlayerName(target, sender, null, null));
|
|
||||||
target.kickPlayer("Username banned by Administrator.");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IPBAN:
|
|
||||||
{
|
|
||||||
String ip = target.getAddress().getAddress().getHostAddress();
|
|
||||||
String[] ip_parts = ip.split("\\.");
|
|
||||||
if (ip_parts.length == 4)
|
|
||||||
{
|
|
||||||
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
|
||||||
}
|
|
||||||
FUtil.adminAction(sender.getName(), String.format("Banning IP: %s.", ip), true);
|
|
||||||
plugin.bm.addBan(Ban.forPlayerIp(ip, sender, null, null));
|
|
||||||
|
|
||||||
target.kickPlayer("IP address banned by Administrator.");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BAN:
|
|
||||||
{
|
|
||||||
String ip = target.getAddress().getAddress().getHostAddress();
|
|
||||||
String[] ip_parts = ip.split("\\.");
|
|
||||||
if (ip_parts.length == 4)
|
|
||||||
{
|
|
||||||
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
|
||||||
}
|
|
||||||
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", target.getName(), ip), true);
|
|
||||||
|
|
||||||
plugin.bm.addBan(Ban.forPlayer(target, sender));
|
|
||||||
|
|
||||||
target.kickPlayer("IP and username banned by Administrator.");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case OP:
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), String.format("Opping %s.", target.getName()), false);
|
|
||||||
target.setOp(true);
|
|
||||||
target.sendMessage(FreedomCommand.YOU_ARE_OP);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DEOP:
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), String.format("Deopping %s.", target.getName()), false);
|
|
||||||
target.setOp(false);
|
|
||||||
target.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CI:
|
|
||||||
{
|
|
||||||
target.getInventory().clear();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FR:
|
|
||||||
{
|
|
||||||
FreezeData fd = plugin.pl.getPlayer(target).getFreezeData();
|
|
||||||
fd.setFrozen(!fd.isFrozen());
|
|
||||||
|
|
||||||
msg(target.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
|
||||||
target.sendMessage(ChatColor.AQUA + "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SMITE:
|
|
||||||
{
|
|
||||||
Command_smite.smite(sender, target);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -25,25 +24,6 @@ public class Command_glist 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)
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
if ("purge".equals(args[0]))
|
|
||||||
{
|
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
|
||||||
plugin.pl.purgeAllData();
|
|
||||||
msg("Purged playerbase.");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -71,13 +51,13 @@ public class Command_glist extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = entry.getUsername();
|
username = entry.getName();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final PlayerData entry = plugin.pl.getData(player);
|
final PlayerData entry = plugin.pl.getData(player);
|
||||||
username = entry.getUsername();
|
username = entry.getName();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Toggles the glowing outline effect because y'all lazy as fuck", usage = "/<command>")
|
||||||
|
public class Command_glow extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
boolean glowing = false;
|
||||||
|
if (playerSender.getPotionEffect(PotionEffectType.GLOWING) != null)
|
||||||
|
{
|
||||||
|
playerSender.removePotionEffect(PotionEffectType.GLOWING);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PotionEffect glow = new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false);
|
||||||
|
playerSender.addPotionEffect(glow);
|
||||||
|
glowing = true;
|
||||||
|
}
|
||||||
|
msg("You " + (glowing ? "are now" : "no longer") + " glowing.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ public class Command_grapplinghook 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)
|
||||||
{
|
{
|
||||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getGrapplingHook());
|
playerSender.getInventory().addItem(plugin.sh.getGrapplingHook());
|
||||||
msg("You have been given a Grappling Hook", ChatColor.GREEN);
|
msg("You have been given a Grappling Hook", ChatColor.GREEN);
|
||||||
|
@ -15,7 +15,7 @@ public class Command_lightningrod 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)
|
||||||
{
|
{
|
||||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getLightningRod());
|
playerSender.getInventory().addItem(plugin.sh.getLightningRod());
|
||||||
msg("You have been given a Lightning Rod", ChatColor.GREEN);
|
msg("You have been given a Lightning Rod", ChatColor.GREEN);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -11,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/<command>")
|
@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/<command> [<name> <id>]")
|
||||||
public class Command_linkdiscord extends FreedomCommand
|
public class Command_linkdiscord extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -24,64 +22,37 @@ public class Command_linkdiscord extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.length > 1 && plugin.al.isAdmin(playerSender))
|
||||||
|
{
|
||||||
|
PlayerData playerData = plugin.pl.getData(args[0]);
|
||||||
|
if (playerData == null)
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerData.setDiscordID(args[1]);
|
||||||
|
msg("Linked " + args[0] + "'s discord account.", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
|
|
||||||
if (plugin.al.isAdmin(playerSender))
|
PlayerData data = plugin.pl.getData(playerSender);
|
||||||
|
if (data.getDiscordID() != null)
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(playerSender);
|
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
||||||
if (admin.getDiscordID() != null)
|
return true;
|
||||||
{
|
|
||||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Discord.ADMIN_LINK_CODES.containsValue(admin))
|
|
||||||
{
|
|
||||||
code = Discord.getCodeForAdmin(admin);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
code = plugin.dc.generateCode(5);
|
|
||||||
Discord.ADMIN_LINK_CODES.put(code, admin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (plugin.mbl.isMasterBuilder(playerSender))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(playerSender);
|
|
||||||
if (masterBuilder.getDiscordID() != null)
|
|
||||||
{
|
|
||||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Discord.MASTER_BUILDER_LINK_CODES.containsValue(masterBuilder))
|
if (Discord.LINK_CODES.containsValue(data))
|
||||||
{
|
{
|
||||||
code = Discord.getCodeForMasterBuilder(masterBuilder);
|
code = Discord.getCode(data);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
code = plugin.dc.generateCode(5);
|
|
||||||
Discord.MASTER_BUILDER_LINK_CODES.put(code, masterBuilder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
code = plugin.dc.generateCode(5);
|
||||||
if (data.getDiscordId() != null)
|
Discord.LINK_CODES.put(code, data);
|
||||||
{
|
|
||||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Discord.PLAYER_LINK_CODES.containsValue(data))
|
|
||||||
{
|
|
||||||
code = Discord.getCodeForPlayer(data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
code = plugin.dc.generateCode(5);
|
|
||||||
Discord.PLAYER_LINK_CODES.put(code, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
msg("Your linking code is " + ChatColor.AQUA + code, ChatColor.GREEN);
|
msg("Your linking code is " + ChatColor.AQUA + code, ChatColor.GREEN);
|
||||||
msg("Take this code and DM the server bot (" + plugin.dc.formatBotTag() + ") the code (do not put anything else in the message, only the code)");
|
msg("Take this code and DM the server bot (" + plugin.dc.formatBotTag() + ") the code (do not put anything else in the message, only the code)");
|
||||||
|
@ -10,7 +10,7 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
|||||||
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 org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -48,21 +48,21 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ShopData shopData = plugin.sh.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
shopData.setCoins(shopData.getCoins() + amount);
|
playerData.setCoins(playerData.getCoins() + amount);
|
||||||
plugin.sh.save(shopData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
|
msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
ShopData shopData = plugin.sh.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
shopData.setCoins(shopData.getCoins() + amount);
|
playerData.setCoins(playerData.getCoins() + amount);
|
||||||
plugin.sh.save(shopData);
|
plugin.pl.save(playerData);
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
@ -85,29 +85,29 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ShopData shopData = plugin.sh.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
shopData.setCoins(shopData.getCoins() + amount);
|
playerData.setCoins(playerData.getCoins() + amount);
|
||||||
if (shopData.getCoins() < 0)
|
if (playerData.getCoins() < 0)
|
||||||
{
|
{
|
||||||
shopData.setCoins(0);
|
playerData.setCoins(0);
|
||||||
}
|
}
|
||||||
plugin.sh.save(shopData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
|
msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
|
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
ShopData shopData = plugin.sh.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
shopData.setCoins(shopData.getCoins() - amount);
|
playerData.setCoins(playerData.getCoins() - amount);
|
||||||
if (shopData.getCoins() < 0)
|
if (playerData.getCoins() < 0)
|
||||||
{
|
{
|
||||||
shopData.setCoins(0);
|
playerData.setCoins(0);
|
||||||
}
|
}
|
||||||
plugin.sh.save(shopData);
|
plugin.pl.save(playerData);
|
||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
|
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
@ -128,9 +128,9 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ShopData shopData = plugin.sh.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
shopData.setCoins(amount);
|
playerData.setCoins(amount);
|
||||||
plugin.sh.save(shopData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully set " + player.getName() + "'s coins to " + amount, ChatColor.GREEN);
|
msg("Successfully set " + player.getName() + "'s coins to " + amount, ChatColor.GREEN);
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
|
||||||
return true;
|
return true;
|
||||||
@ -171,9 +171,9 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopData shopData = plugin.sh.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
shopData.giveItem(item);
|
playerData.giveItem(item);
|
||||||
plugin.sh.save(shopData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully gave the " + item.getName() + " to " + player.getName(), ChatColor.GREEN);
|
msg("Successfully gave the " + item.getName() + " to " + player.getName(), ChatColor.GREEN);
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
|
||||||
return true;
|
return true;
|
||||||
@ -194,9 +194,9 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopData shopData = plugin.sh.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
shopData.removeItem(item);
|
playerData.removeItem(item);
|
||||||
plugin.sh.save(shopData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully took the " + item.getName() + " from " + player.getName(), ChatColor.GREEN);
|
msg("Successfully took the " + item.getName() + " from " + player.getName(), ChatColor.GREEN);
|
||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
|
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Manually verify someone", usage = "/<command> <playername>", aliases="mv")
|
||||||
|
public class Command_manuallyverify extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!plugin.dc.enabled)
|
||||||
|
{
|
||||||
|
msg("The Discord verification system is currently disabled", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.pl.isImposter(player))
|
||||||
|
{
|
||||||
|
msg("That player is not an impostor.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
|
||||||
|
player.setOp(true);
|
||||||
|
player.sendMessage(YOU_ARE_OP);
|
||||||
|
|
||||||
|
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
|
||||||
|
{
|
||||||
|
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
|
||||||
|
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.pl.verify(player, null);
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "seth's personal command", usage = "/<command> <players>")
|
||||||
|
public class Command_massmurder extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.SERVER_OWNERS.getStringList().contains(playerSender.getName()))
|
||||||
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (String name : args)
|
||||||
|
{
|
||||||
|
Player player = getPlayer(name);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.setHealth(0);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Mass murdered a school of " + count);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +1,19 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
||||||
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.util.Ips;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
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.OP, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "List, add, or remove master builders, reload the master builder list, or view the info of master builders.", usage = "/<command> <list | reload | | <add | remove | info> <username>>")
|
@CommandParameters(description = "List, add, or remove master builders, reload the master builder list, or view the info of master builders.", usage = "/<command> <list | <<add | remove> <username>>>")
|
||||||
public class Command_mbconfig extends FreedomCommand
|
public class Command_mbconfig extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -33,50 +29,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
{
|
{
|
||||||
case "list":
|
case "list":
|
||||||
{
|
{
|
||||||
msg("Master Builders: " + StringUtils.join(plugin.mbl.getMasterBuilderNames(), ", "), ChatColor.GOLD);
|
msg("Master Builders: " + StringUtils.join(plugin.pl.getMasterBuilderNames(), ", "), ChatColor.GOLD);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "reload":
|
|
||||||
{
|
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Reloading the Master Builder list", true);
|
|
||||||
plugin.mbl.load();
|
|
||||||
msg("Master Builder list reloaded!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "info":
|
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkRank(Rank.SUPER_ADMIN);
|
|
||||||
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(args[1]);
|
|
||||||
|
|
||||||
if (masterBuilder == null)
|
|
||||||
{
|
|
||||||
final Player player = getPlayer(args[1]);
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
masterBuilder = plugin.mbl.getMasterBuilder(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (masterBuilder == null)
|
|
||||||
{
|
|
||||||
msg("Master Builder not found: " + args[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg(masterBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,89 +40,43 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkConsole();
|
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||||
checkRank(Rank.TELNET_ADMIN);
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
|
||||||
// Player already on the list?
|
|
||||||
final Player player = getPlayer(args[1]);
|
final Player player = getPlayer(args[1]);
|
||||||
if (player != null && plugin.mbl.isMasterBuilder(player))
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
|
||||||
|
if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the Master Builder list", true);
|
||||||
|
player.setOp(true);
|
||||||
|
player.sendMessage(YOU_ARE_OP);
|
||||||
|
|
||||||
|
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
|
||||||
|
{
|
||||||
|
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
|
||||||
|
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
|
||||||
|
}
|
||||||
|
plugin.pl.verify(player, null);
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
}
|
||||||
|
else if (!data.isMasterBuilder())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
|
||||||
|
data.setMasterBuilder(true);
|
||||||
|
data.setVerification(true);
|
||||||
|
plugin.pl.save(data);
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
msg("That player is already on the Master Builder list.");
|
msg("That player is already on the Master Builder list.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the entry
|
|
||||||
String name = player != null ? player.getName() : args[1];
|
|
||||||
MasterBuilder masterBuilder = null;
|
|
||||||
for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
|
|
||||||
{
|
|
||||||
if (loopMasterBuilder.getName().equalsIgnoreCase(name))
|
|
||||||
{
|
|
||||||
masterBuilder = loopMasterBuilder;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (masterBuilder == null) // New entry
|
|
||||||
{
|
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
|
||||||
if (!FUtil.canManageMasterBuilders(sender.getName()))
|
|
||||||
{
|
|
||||||
noPerms();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
|
|
||||||
plugin.mbl.addMasterBuilder(new MasterBuilder(player));
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
plugin.rm.updateDisplay(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // Existing admin
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Readding " + masterBuilder.getName() + " to the Master Builder list", true);
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
masterBuilder.setName(player.getName());
|
|
||||||
masterBuilder.addIp(Ips.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
masterBuilder.setLastLogin(new Date());
|
|
||||||
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
plugin.rm.updateDisplay(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
|
||||||
if (fPlayer.getFreezeData().isFrozen())
|
|
||||||
{
|
|
||||||
fPlayer.getFreezeData().setFrozen(false);
|
|
||||||
msg(player.getPlayer(), "You have been unfrozen.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!player.isOp())
|
|
||||||
{
|
|
||||||
player.setOp(true);
|
|
||||||
player.sendMessage(YOU_ARE_OP);
|
|
||||||
}
|
|
||||||
plugin.pv.removeEntry(player.getName()); // master builders can't have player verification entries
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "remove":
|
case "remove":
|
||||||
{
|
{
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
@ -177,28 +84,28 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkConsole();
|
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
|
||||||
if (!FUtil.canManageMasterBuilders(sender.getName()))
|
|
||||||
{
|
{
|
||||||
noPerms();
|
return noPerms();
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = getPlayer(args[1]);
|
Player player = getPlayer(args[1]);
|
||||||
MasterBuilder masterBuilder = player != null ? plugin.mbl.getMasterBuilder(player) : plugin.mbl.getEntryByName(args[1]);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
|
||||||
if (masterBuilder == null)
|
if (!data.isMasterBuilder())
|
||||||
{
|
{
|
||||||
msg("Master Builder not found: " + args[1]);
|
msg("Master Builder not found: " + args[1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing " + masterBuilder.getName() + " from the Master Builder list", true);
|
FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
|
||||||
plugin.mbl.removeMasterBuilder(masterBuilder);
|
data.setMasterBuilder(false);
|
||||||
if (player != null)
|
if (data.getDiscordID() == null)
|
||||||
{
|
{
|
||||||
plugin.rm.updateDisplay(player);
|
data.setVerification(false);
|
||||||
}
|
}
|
||||||
|
plugin.pl.save(data);
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,17 +122,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
List<String> arguments = new ArrayList<>();
|
return Arrays.asList("list");
|
||||||
arguments.add("list");
|
|
||||||
if (plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
arguments.add("info");
|
|
||||||
}
|
|
||||||
return arguments;
|
|
||||||
}
|
|
||||||
else if (args.length == 2 && args[0].equals("info") && plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
return plugin.al.getActiveAdminNames();
|
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -233,17 +130,20 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
return Arrays.asList("add", "remove", "reload", "list", "info");
|
return Arrays.asList("add", "remove", "list");
|
||||||
}
|
}
|
||||||
else if (args.length == 2)
|
else if (args.length == 2)
|
||||||
{
|
{
|
||||||
if (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))
|
if (args[0].equals("add"))
|
||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
|
else if (args[0].equals("remove"))
|
||||||
|
{
|
||||||
|
return plugin.pl.getMasterBuilderNames();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,15 +4,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
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.minecraft.server.v1_15_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagInt;
|
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagList;
|
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagString;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -189,7 +186,7 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
|
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.getTag() == null)
|
if (stack.getTag() == null)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
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.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
@ -16,7 +17,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setacformat <format> | clearacformat> | oldtags | logstick | syncroles | genbackupcodes>")
|
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setacformat <format> | clearacformat> | oldtags | logstick | syncroles>")
|
||||||
public class Command_myadmin extends FreedomCommand
|
public class Command_myadmin extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -86,6 +87,8 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
plugin.al.save(target);
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
|
|
||||||
|
plugin.pl.syncIps(target);
|
||||||
|
|
||||||
msg(counter + " IPs removed.");
|
msg(counter + " IPs removed.");
|
||||||
msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
|
msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
|
||||||
return true;
|
return true;
|
||||||
@ -130,6 +133,8 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
plugin.al.save(target);
|
plugin.al.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
|
|
||||||
|
plugin.pl.syncIps(target);
|
||||||
|
|
||||||
msg("Removed IP " + args[1]);
|
msg("Removed IP " + args[1]);
|
||||||
msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
|
msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
|
||||||
return true;
|
return true;
|
||||||
@ -173,17 +178,6 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "settag":
|
|
||||||
{
|
|
||||||
msg("Please use /tag set to set your tag.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "cleartag":
|
|
||||||
{
|
|
||||||
msg("Please use /tag off to remove your tag.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "setacformat":
|
case "setacformat":
|
||||||
{
|
{
|
||||||
String format = StringUtils.join(args, " ", 1, args.length);
|
String format = StringUtils.join(args, " ", 1, args.length);
|
||||||
@ -229,12 +223,13 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
msg("Role syncing is not enabled.", ChatColor.RED);
|
msg("Role syncing is not enabled.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean synced = plugin.dc.syncRoles(target);
|
PlayerData playerData = plugin.pl.getData(target.getName());
|
||||||
if (target.getDiscordID() == null)
|
if (playerData.getDiscordID() == null)
|
||||||
{
|
{
|
||||||
msg("Please run /linkdiscord first!", ChatColor.RED);
|
msg("Please run /linkdiscord first!", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
boolean synced = plugin.dc.syncRoles(target, playerData.getDiscordID());
|
||||||
if (synced)
|
if (synced)
|
||||||
{
|
{
|
||||||
msg("Successfully synced your roles.", ChatColor.GREEN);
|
msg("Successfully synced your roles.", ChatColor.GREEN);
|
||||||
@ -249,29 +244,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "genbackupcodes":
|
case "genbackupcodes":
|
||||||
if (!plugin.dc.enabled)
|
msg("Moved to /pv genbackupcodes", ChatColor.RED);
|
||||||
{
|
|
||||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (target.getDiscordID() == null || target.getDiscordID().isEmpty())
|
|
||||||
{
|
|
||||||
msg("Discord verification is not enabled for you.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Generating backup codes...", ChatColor.GREEN);
|
|
||||||
|
|
||||||
boolean generated = plugin.dc.sendBackupCodes(target);
|
|
||||||
|
|
||||||
if (generated)
|
|
||||||
{
|
|
||||||
msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -290,7 +263,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> singleArguments = Arrays.asList("clearips", "setlogin", "setacformat");
|
List<String> singleArguments = Arrays.asList("clearips", "setlogin", "setacformat");
|
||||||
List<String> doubleArguments = Arrays.asList("clearip", "clearlogin", "clearacformat", "oldtags", "logstick", "syncroles", "genbackupcodes");
|
List<String> doubleArguments = Arrays.asList("clearip", "clearlogin", "clearacformat", "oldtags", "logstick", "syncroles");
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
|
@ -1,237 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
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.OP, source = SourceType.ONLY_IN_GAME)
|
|
||||||
@CommandParameters(description = "Manage your Master Builder entry", usage = "/<command> [-o <masterbuilder>] <clearips | clearip <ip> | genbackupcodes>", aliases = "mymb")
|
|
||||||
public class Command_mymasterbuilder extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player init = null;
|
|
||||||
MasterBuilder target = plugin.mbl.getMasterBuilder(playerSender);
|
|
||||||
Player targetPlayer = playerSender;
|
|
||||||
|
|
||||||
// -o switch
|
|
||||||
if (args[0].equals("-o"))
|
|
||||||
{
|
|
||||||
if (!FUtil.canManageMasterBuilders(playerSender.getName()))
|
|
||||||
{
|
|
||||||
return noPerms();
|
|
||||||
}
|
|
||||||
init = playerSender;
|
|
||||||
targetPlayer = getPlayer(args[1]);
|
|
||||||
if (targetPlayer == null)
|
|
||||||
{
|
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
target = plugin.mbl.getMasterBuilder(playerSender);
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
msg("That player is not a Master Builder", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shift 2
|
|
||||||
args = Arrays.copyOfRange(args, 2, args.length);
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final String targetIp = Ips.getIp(targetPlayer);
|
|
||||||
|
|
||||||
switch (args[0])
|
|
||||||
{
|
|
||||||
case "clearips":
|
|
||||||
{
|
|
||||||
if (args.length != 1)
|
|
||||||
{
|
|
||||||
return false; // Double check: the player might mean "clearip"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (init == null)
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Clearing my IPs", false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "' IPs", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int counter = target.getIps().size() - 1;
|
|
||||||
target.clearIPs();
|
|
||||||
target.addIp(targetIp);
|
|
||||||
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
|
|
||||||
msg(counter + " IPs removed.");
|
|
||||||
msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "clearip":
|
|
||||||
{
|
|
||||||
if (args.length != 2)
|
|
||||||
{
|
|
||||||
return false; // Double check: the player might mean "clearips"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!target.getIps().contains(args[1]))
|
|
||||||
{
|
|
||||||
if (init == null)
|
|
||||||
{
|
|
||||||
msg("That IP is not registered to you.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("That IP does not belong to that player.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetIp.equals(args[1]))
|
|
||||||
{
|
|
||||||
if (init == null)
|
|
||||||
{
|
|
||||||
msg("You cannot remove your current IP.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("You cannot remove that Master Builders's current IP.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing an IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
|
||||||
|
|
||||||
target.removeIp(args[1]);
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
|
|
||||||
msg("Removed IP " + args[1]);
|
|
||||||
msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "genbackupcodes":
|
|
||||||
if (!plugin.dc.enabled)
|
|
||||||
{
|
|
||||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (target.getDiscordID() == null || target.getDiscordID().isEmpty())
|
|
||||||
{
|
|
||||||
msg("Discord verification is not enabled for you.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Generating backup codes...", ChatColor.GREEN);
|
|
||||||
|
|
||||||
boolean generated = plugin.dc.sendBackupCodes(target);
|
|
||||||
|
|
||||||
if (generated)
|
|
||||||
{
|
|
||||||
msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!plugin.mbl.isMasterBuilder(playerSender) && !FUtil.canManageMasterBuilders(playerSender.getName()))
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> singleArguments = Arrays.asList("clearips");
|
|
||||||
List<String> doubleArguments = Arrays.asList("clearip", "genbackupcodes");
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
List<String> options = new ArrayList<>();
|
|
||||||
options.add("-o");
|
|
||||||
options.addAll(singleArguments);
|
|
||||||
options.addAll(doubleArguments);
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
else if (args.length == 2)
|
|
||||||
{
|
|
||||||
if (args[0].equals("-o"))
|
|
||||||
{
|
|
||||||
return FUtil.getPlayerList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (doubleArguments.contains(args[0]))
|
|
||||||
{
|
|
||||||
if (args[0].equals("clearip"))
|
|
||||||
{
|
|
||||||
if (args[0].equals("clearip"))
|
|
||||||
{
|
|
||||||
List<String> ips = plugin.mbl.getMasterBuilder(sender).getIps();
|
|
||||||
ips.remove(Ips.getIp(playerSender));
|
|
||||||
return ips;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.length == 3)
|
|
||||||
{
|
|
||||||
if (args[0].equals("-o"))
|
|
||||||
{
|
|
||||||
List<String> options = new ArrayList<>();
|
|
||||||
options.addAll(singleArguments);
|
|
||||||
options.addAll(doubleArguments);
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.length == 4)
|
|
||||||
{
|
|
||||||
if (args[0].equals("-o") && args[2].equals("clearip"))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(args[1]);
|
|
||||||
if (masterBuilder != null)
|
|
||||||
{
|
|
||||||
return masterBuilder.getIps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FUtil.getPlayerList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,7 +12,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 = "Essentials Interface Command - Remove illegal chatcodes from nicknames of all players on server.", usage = "/<command>", aliases = "nc")
|
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/<command> [player]", aliases = "nc")
|
||||||
public class Command_nickclean extends FreedomCommand
|
public class Command_nickclean extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -25,21 +25,43 @@ public class Command_nickclean extends FreedomCommand
|
|||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
|
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
|
||||||
|
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Cleaning " + player.getName() + "'s nickname", false);
|
||||||
|
cleanNickname(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
|
||||||
for (final Player player : server.getOnlinePlayers())
|
for (final Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final String playerName = player.getName();
|
cleanNickname(player);
|
||||||
final String nickName = plugin.esb.getNickname(playerName);
|
|
||||||
if (nickName != null && !nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
|
|
||||||
{
|
|
||||||
final Matcher matcher = REGEX.matcher(nickName);
|
|
||||||
if (matcher.find())
|
|
||||||
{
|
|
||||||
final String newNickName = matcher.replaceAll("");
|
|
||||||
msg(ChatColor.RESET + playerName + ": \"" + nickName + ChatColor.RESET + "\" -> \"" + newNickName + ChatColor.RESET + "\".");
|
|
||||||
plugin.esb.setNickname(playerName, newNickName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanNickname(Player player)
|
||||||
|
{
|
||||||
|
final String playerName = player.getName();
|
||||||
|
final String nickName = plugin.esb.getNickname(playerName);
|
||||||
|
if (nickName != null && !nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
|
||||||
|
{
|
||||||
|
final Matcher matcher = REGEX.matcher(nickName);
|
||||||
|
if (matcher.find())
|
||||||
|
{
|
||||||
|
final String newNickName = matcher.replaceAll("");
|
||||||
|
msg(ChatColor.RESET + playerName + ": \"" + nickName + ChatColor.RESET + "\" -> \"" + newNickName + ChatColor.RESET + "\".");
|
||||||
|
plugin.esb.setNickname(playerName, newNickName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
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 org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -28,7 +26,7 @@ public class Command_notes extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VPlayer vPlayer;
|
PlayerData playerData;
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final Player player = getPlayer(args[0]);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
@ -41,23 +39,21 @@ public class Command_notes extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vPlayer = plugin.pv.getVerificationPlayer(entry.getUsername());
|
playerData = plugin.pl.getData(entry.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vPlayer = plugin.pv.getVerificationPlayer(player);
|
playerData = plugin.pl.getData(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equals("list"))
|
if (args[1].equals("list"))
|
||||||
{
|
{
|
||||||
final StringBuilder noteList = new StringBuilder();
|
final StringBuilder noteList = new StringBuilder();
|
||||||
noteList.append(ChatColor.GREEN + "Player notes for " + vPlayer.getName() + ":");
|
noteList.append(ChatColor.GREEN + "Player notes for " + playerData.getName() + ":");
|
||||||
int id = 1;
|
int id = 1;
|
||||||
for (Map<?, ?> noteMap : vPlayer.getNotes())
|
for (String note : playerData.getNotes())
|
||||||
{
|
{
|
||||||
String admin = String.valueOf(noteMap.keySet().toArray()[0]);
|
String noteLine = id + ". " + note;
|
||||||
String note = String.valueOf(noteMap.get(admin));
|
|
||||||
String noteLine = id + ". " + admin + ": " + note;
|
|
||||||
noteList.append("\n" + ChatColor.GOLD + noteLine);
|
noteList.append("\n" + ChatColor.GOLD + noteLine);
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
@ -70,9 +66,9 @@ public class Command_notes extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String note = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
||||||
vPlayer.addNote(sender.getName(), note);
|
playerData.addNote(note);
|
||||||
plugin.pv.saveVerificationData(vPlayer);
|
plugin.pl.save(playerData);
|
||||||
msg("Note added.", ChatColor.GREEN);
|
msg("Note added.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -93,9 +89,9 @@ public class Command_notes extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
id--;
|
id--;
|
||||||
if (vPlayer.removeNote(id))
|
if (playerData.removeNote(id))
|
||||||
{
|
{
|
||||||
plugin.pv.saveVerificationData(vPlayer);
|
plugin.pl.save(playerData);
|
||||||
msg("Note removed.");
|
msg("Note removed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -106,9 +102,9 @@ public class Command_notes extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (args[1].equals("clear"))
|
else if (args[1].equals("clear"))
|
||||||
{
|
{
|
||||||
int count = vPlayer.getNotes().size();
|
int count = playerData.getNotes().size();
|
||||||
vPlayer.clearNotes();
|
playerData.clearNotes();
|
||||||
plugin.pv.saveVerificationData(vPlayer);
|
plugin.pl.save(playerData);
|
||||||
msg("Cleared " + count + " notes.", ChatColor.GREEN);
|
msg("Cleared " + count + " notes.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -13,13 +13,13 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Manage your verification", usage = "/<command> <enable | disable | clearips | status | genbackupcodes>", aliases = "playerverification,pv")
|
@CommandParameters(description = "Manage your verification", usage = "/<command> <enable | disable | clearips | clearip <ip> | status | genbackupcodes>", aliases = "playerverify,pv")
|
||||||
public class Command_playerverify extends FreedomCommand
|
public class Command_playerverification extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
VPlayer target = plugin.pv.getVerificationPlayer(playerSender);
|
PlayerData target = plugin.pl.getData(playerSender);
|
||||||
|
|
||||||
List<String> ips = new ArrayList<>();
|
List<String> ips = new ArrayList<>();
|
||||||
ips.addAll(target.getIps());
|
ips.addAll(target.getIps());
|
||||||
@ -40,7 +40,20 @@ public class Command_playerverify extends FreedomCommand
|
|||||||
|
|
||||||
msg("Cleared all IP's except your current IP \"" + Ips.getIp(playerSender) + "\"");
|
msg("Cleared all IP's except your current IP \"" + Ips.getIp(playerSender) + "\"");
|
||||||
msg("Cleared " + cleared + " IP's.");
|
msg("Cleared " + cleared + " IP's.");
|
||||||
plugin.pv.saveVerificationData(target);
|
plugin.pl.save(target);
|
||||||
|
plugin.pl.syncIps(target);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("clearip"))
|
||||||
|
{
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
target.removeIp(args[1]);
|
||||||
|
msg("Removed" + args[1] + " from your list of IPs");
|
||||||
|
plugin.pl.save(target);
|
||||||
|
plugin.pl.syncIps(target);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,13 +63,7 @@ public class Command_playerverify extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdmin(sender))
|
PlayerData data = plugin.pl.getData(playerSender);
|
||||||
{
|
|
||||||
msg("This command is only for OP's.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
|
||||||
|
|
||||||
switch (args[0].toLowerCase())
|
switch (args[0].toLowerCase())
|
||||||
{
|
{
|
||||||
@ -66,37 +73,37 @@ public class Command_playerverify extends FreedomCommand
|
|||||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (data.getEnabled())
|
else if (data.hasVerification())
|
||||||
{
|
{
|
||||||
msg("Discord verification is already enabled for you.", ChatColor.RED);
|
msg("Discord verification is already enabled for you.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (data.getDiscordId() == null)
|
else if (data.getDiscordID() == null)
|
||||||
{
|
{
|
||||||
msg("Please link a discord account with /linkdiscord.", ChatColor.RED);
|
msg("Please link a discord account with /linkdiscord.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
data.setEnabled(true);
|
data.setVerification(true);
|
||||||
plugin.pv.saveVerificationData(data);
|
plugin.pl.save(data);
|
||||||
msg("Re-enabled Discord verification.", ChatColor.GREEN);
|
msg("Re-enabled Discord verification.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case "disable":
|
case "disable":
|
||||||
if (!data.getEnabled())
|
if (!data.hasVerification())
|
||||||
{
|
{
|
||||||
msg("Discord verification is already disabled for you.", ChatColor.RED);
|
msg("Discord verification is already disabled for you.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
data.setEnabled(false);
|
data.setVerification(false);
|
||||||
plugin.pv.saveVerificationData(data);
|
plugin.pl.save(data);
|
||||||
msg("Disabled Discord verification.", ChatColor.GREEN);
|
msg("Disabled Discord verification.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case "status":
|
case "status":
|
||||||
boolean enabled = target.getEnabled();
|
boolean enabled = target.hasVerification();
|
||||||
boolean specified = target.getDiscordId() != null;
|
boolean specified = target.getDiscordID() != null;
|
||||||
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
||||||
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordId() : ChatColor.RED + "not set"));
|
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordID() : ChatColor.RED + "not set"));
|
||||||
msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10");
|
msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -106,7 +113,7 @@ public class Command_playerverify extends FreedomCommand
|
|||||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (!data.getEnabled())
|
else if (!data.hasVerification())
|
||||||
{
|
{
|
||||||
msg("Discord verification is not enabled for you.", ChatColor.RED);
|
msg("Discord verification is not enabled for you.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
@ -1,64 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
|
||||||
@CommandParameters(description = "Sync your time with the real world time.", usage = "/<command> <on <utc_offset> | off>", aliases = "rt")
|
|
||||||
public class Command_realtime extends FreedomCommand
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
VPlayer player = plugin.pv.getVerificationPlayer(playerSender);
|
|
||||||
if (args.length == 0 || args.length > 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (args.length == 2)
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase("on"))
|
|
||||||
{
|
|
||||||
int tz;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
tz = Integer.parseInt(args[1]);
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ex)
|
|
||||||
{
|
|
||||||
msg("Invalid UTC offset.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (FUtil.timeZoneOutOfBounds(tz))
|
|
||||||
{
|
|
||||||
msg("Invalid UTC offset.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
player.setUtcOffset(tz);
|
|
||||||
player.setRealTime(true);
|
|
||||||
plugin.rt.enable(playerSender);
|
|
||||||
plugin.pv.saveVerificationData(player);
|
|
||||||
msg("Your in-game time is now synced with real time.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("off"))
|
|
||||||
{
|
|
||||||
if (!player.isRealTime())
|
|
||||||
{
|
|
||||||
msg("You aren't on real time.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
player.setRealTime(false);
|
|
||||||
msg("Your in-game time is no longer synced with real time.");
|
|
||||||
plugin.rt.disable(playerSender);
|
|
||||||
plugin.pv.saveVerificationData(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,8 +4,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -76,8 +77,9 @@ public class Command_ride extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
|
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
|
||||||
{
|
{
|
||||||
VPlayer vPlayerSender = plugin.pv.getVerificationPlayer(playerSender);
|
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
||||||
vPlayerSender.setRideMode(args[1].toLowerCase());
|
playerDataSender.setRideMode(args[1].toLowerCase());
|
||||||
|
plugin.pl.save(playerDataSender);
|
||||||
msg("Ride mode is now set to " + args[1].toLowerCase() + ".");
|
msg("Ride mode is now set to " + args[1].toLowerCase() + ".");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -90,7 +92,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
final PlayerData playerData = plugin.pl.getData(player);
|
||||||
|
|
||||||
if (player == playerSender)
|
if (player == playerSender)
|
||||||
{
|
{
|
||||||
@ -98,7 +100,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vPlayer.getRideMode().equals("off") && !isAdmin(sender))
|
if (playerData.getRideMode().equals("off") && !isAdmin(sender))
|
||||||
{
|
{
|
||||||
msg("That player cannot be ridden.", ChatColor.RED);
|
msg("That player cannot be ridden.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
@ -110,7 +112,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vPlayer.getRideMode().equals("ask") && !isAdmin(sender))
|
if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
|
||||||
{
|
{
|
||||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
msg("Sent a request to the player.", ChatColor.GREEN);
|
||||||
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you.");
|
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you.");
|
||||||
|
@ -15,7 +15,7 @@ public class Command_rideablepearl 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)
|
||||||
{
|
{
|
||||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getRideablePearl());
|
playerSender.getInventory().addItem(plugin.sh.getRideablePearl());
|
||||||
msg("You have been given a Rideable Ender Pearl", ChatColor.GREEN);
|
msg("You have been given a Rideable Ender Pearl", ChatColor.GREEN);
|
||||||
|
@ -7,9 +7,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
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.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
@ -109,7 +107,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
plugin.dc.syncRoles(admin);
|
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||||
@ -166,7 +164,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null && plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
msg("That player is already admin.");
|
msg("That player is already admin.");
|
||||||
return true;
|
return true;
|
||||||
@ -177,14 +175,14 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
Admin admin = null;
|
Admin admin = null;
|
||||||
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||||
{
|
{
|
||||||
if (loopAdmin.getName().equalsIgnoreCase(name))
|
if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(Ips.getIp(player)))
|
||||||
{
|
{
|
||||||
admin = loopAdmin;
|
admin = loopAdmin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.pv.isPlayerImpostor(player))
|
if (plugin.pl.isPlayerImpostor(player))
|
||||||
{
|
{
|
||||||
msg("This player was labeled as a Player impostor and is not an admin, therefore they cannot be added to the admin list.", ChatColor.RED);
|
msg("This player was labeled as a Player impostor and is not an admin, therefore they cannot be added to the admin list.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
@ -192,11 +190,6 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (admin == null) // New admin
|
if (admin == null) // New admin
|
||||||
{
|
{
|
||||||
if (plugin.mbl.isMasterBuilderImpostor(player))
|
|
||||||
{
|
|
||||||
msg("This player was labeled as a Master Builder impostor and is not an admin, therefore they cannot be added to the admin list.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
@ -206,81 +199,25 @@ 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);
|
||||||
admin = new Admin(player);
|
admin = new Admin(player);
|
||||||
|
|
||||||
// Attempt to find discord account
|
|
||||||
if (plugin.mbl.isMasterBuilder(player))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
|
||||||
admin.setDiscordID(plugin.mbl.getMasterBuilder(player).getDiscordID());
|
|
||||||
}
|
|
||||||
else if (plugin.pv.getVerificationPlayer(player.getName()) != null)
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player.getName());
|
|
||||||
if (vPlayer.getDiscordId() != null)
|
|
||||||
{
|
|
||||||
admin.setDiscordID(vPlayer.getDiscordId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.al.addAdmin(admin);
|
plugin.al.addAdmin(admin);
|
||||||
plugin.rm.updateDisplay(player);
|
plugin.rm.updateDisplay(player);
|
||||||
}
|
}
|
||||||
else // Existing admin
|
else // Existing admin
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Re-adding " + admin.getName() + " to the admin list", true);
|
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the admin list", true);
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
String oldName = admin.getName();
|
String oldName = admin.getName();
|
||||||
|
if (oldName != player.getName())
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||||
admin.addIp(Ips.getIp(player));
|
admin.addIp(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle master builders
|
|
||||||
if (!plugin.mbl.isMasterBuilder(player))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = null;
|
|
||||||
for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
|
|
||||||
{
|
|
||||||
if (loopMasterBuilder.getName().equalsIgnoreCase(name))
|
|
||||||
{
|
|
||||||
masterBuilder = loopMasterBuilder;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (masterBuilder != null)
|
|
||||||
{
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
masterBuilder.setName(player.getName());
|
|
||||||
masterBuilder.addIp(Ips.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
masterBuilder.setLastLogin(new Date());
|
|
||||||
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
admin.setActive(true);
|
admin.setActive(true);
|
||||||
admin.setLastLogin(new Date());
|
admin.setLastLogin(new Date());
|
||||||
|
|
||||||
// Attempt to find discord account
|
|
||||||
if (plugin.mbl.isMasterBuilder(player))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
|
||||||
admin.setDiscordID(plugin.mbl.getMasterBuilder(player).getDiscordID());
|
|
||||||
}
|
|
||||||
else if (plugin.pv.getVerificationPlayer(admin.getName()) != null)
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(admin.getName());
|
|
||||||
if (vPlayer.getDiscordId() != null)
|
|
||||||
{
|
|
||||||
admin.setDiscordID(vPlayer.getDiscordId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.al.isVerifiedAdmin(player))
|
if (plugin.al.isVerifiedAdmin(player))
|
||||||
{
|
{
|
||||||
plugin.al.verifiedNoAdmins.remove(player.getName());
|
plugin.al.verifiedNoAdmins.remove(player.getName());
|
||||||
@ -296,7 +233,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
plugin.dc.syncRoles(admin);
|
plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +251,6 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
player.sendMessage(YOU_ARE_OP);
|
player.sendMessage(YOU_ARE_OP);
|
||||||
}
|
}
|
||||||
plugin.pv.removeEntry(player.getName()); // admins can't have player verification entries
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -348,7 +284,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
plugin.dc.syncRoles(admin);
|
plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,7 +20,7 @@ public class Command_shop extends FreedomCommand
|
|||||||
msg("The shop is currently disabled!", ChatColor.RED);
|
msg("The shop is currently disabled!", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.sh.getData(playerSender)));
|
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.pl.getData(playerSender)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,27 +20,26 @@ public class Command_stop 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)
|
||||||
{
|
{
|
||||||
if (STOP_CONFIRM.containsKey(sender))
|
|
||||||
{
|
|
||||||
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + STOP_CONFIRM.get(sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
STOP_CONFIRM.remove(sender);
|
|
||||||
|
|
||||||
server.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
String reason = "Server is going offline, come back in about 20 seconds.";
|
String reason = "Server is going offline, come back in about 20 seconds.";
|
||||||
|
|
||||||
if (args.length > 0)
|
if (args.length != 0)
|
||||||
{
|
{
|
||||||
reason = StringUtils.join(args, " ");
|
reason = StringUtils.join(args, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
|
shutdown(reason);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (STOP_CONFIRM.containsKey(sender))
|
||||||
|
{
|
||||||
|
shutdown(STOP_CONFIRM.get(sender));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
msg("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
|
msg("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
|
||||||
|
|
||||||
STOP_CONFIRM.put(sender, reason);
|
STOP_CONFIRM.put(sender, reason);
|
||||||
@ -58,4 +57,18 @@ public class Command_stop extends FreedomCommand
|
|||||||
}.runTaskLater(plugin, 15 * 20);
|
}.runTaskLater(plugin, 15 * 20);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown(String reason)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
player.kickPlayer(ChatColor.LIGHT_PURPLE + reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
STOP_CONFIRM.remove(sender);
|
||||||
|
|
||||||
|
server.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
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 org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
@ -35,11 +33,6 @@ public class Command_tag extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("-s") || args[0].equals("-save"))
|
if (args[0].equals("-s") || args[0].equals("-save"))
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(playerSender) && !plugin.mbl.isMasterBuilder(playerSender) && !plugin.pv.getVerificationPlayer(playerSender).getEnabled())
|
|
||||||
{
|
|
||||||
msg("Only admins, Master Builders, and players with verification enabled can save their tags.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
save = true;
|
save = true;
|
||||||
args = ArrayUtils.remove(args, 0);
|
args = ArrayUtils.remove(args, 0);
|
||||||
}
|
}
|
||||||
@ -199,25 +192,8 @@ public class Command_tag extends FreedomCommand
|
|||||||
|
|
||||||
public void save(Player player, String tag)
|
public void save(Player player, String tag)
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
{
|
playerData.setTag(tag);
|
||||||
Admin admin = plugin.al.getAdmin(player);
|
plugin.pl.save(playerData);
|
||||||
admin.setTag(tag);
|
|
||||||
plugin.al.save(admin);
|
|
||||||
plugin.al.updateTables();
|
|
||||||
}
|
|
||||||
else if (plugin.mbl.isMasterBuilder(player))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
|
||||||
masterBuilder.setTag(tag);
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
}
|
|
||||||
else if (plugin.pv.getVerificationPlayer(player).getEnabled())
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
|
||||||
vPlayer.setTag(tag);
|
|
||||||
plugin.pv.saveVerificationData(vPlayer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
@ -10,11 +8,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -47,7 +41,7 @@ public class Command_tban extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = entry.getUsername();
|
username = entry.getName();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -47,7 +47,7 @@ public class Command_tempban extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = entry.getUsername();
|
username = entry.getName();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,22 +1,19 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
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.rank.Rank;
|
||||||
import org.bukkit.command.Command;
|
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.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command> [off]")
|
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command>")
|
||||||
public class Command_trail extends FreedomCommand
|
public class Command_trail 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)
|
||||||
{
|
{
|
||||||
if (args.length > 0 && "off".equals(args[0]))
|
if (plugin.tr.contains(playerSender))
|
||||||
{
|
{
|
||||||
plugin.tr.remove(playerSender);
|
plugin.tr.remove(playerSender);
|
||||||
msg("Trail disabled.");
|
msg("Trail disabled.");
|
||||||
@ -30,15 +27,4 @@ public class Command_trail extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
return Arrays.asList("off");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class Command_unban extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = entry.getUsername();
|
username = entry.getName();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Uncage a player", usage = "/<command> <name>")
|
||||||
|
public class Command_uncage extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer(args[0]);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("That player is not caged!", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
|
||||||
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 org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -21,12 +20,6 @@ public class Command_undisguiseall extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BlockedDisguises.disabled)
|
|
||||||
{
|
|
||||||
msg("Disguises are not enabled.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean admins = false;
|
boolean admins = false;
|
||||||
|
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("-a"))
|
if (args.length > 0 && args[0].equalsIgnoreCase("-a"))
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -9,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/<command>")
|
@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/<command> [player]")
|
||||||
public class Command_unlinkdiscord extends FreedomCommand
|
public class Command_unlinkdiscord extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -22,32 +21,30 @@ public class Command_unlinkdiscord extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdmin(playerSender))
|
if (args.length != 0 && plugin.al.isAdmin(playerSender))
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(playerSender);
|
PlayerData playerData = plugin.pl.getData(args[0]);
|
||||||
if (admin.getDiscordID() == null)
|
if (playerData == null)
|
||||||
{
|
{
|
||||||
msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
admin.setDiscordID(null);
|
|
||||||
plugin.al.save(admin);
|
playerData.setDiscordID(null);
|
||||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
msg("Unlinked " + args[0] + "'s discord account.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
PlayerData data = plugin.pl.getData(playerSender);
|
||||||
|
if (data.getDiscordID() == null)
|
||||||
{
|
{
|
||||||
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
|
||||||
if (data.getDiscordId() == null)
|
|
||||||
{
|
|
||||||
msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
data.setDiscordId(null);
|
|
||||||
data.setEnabled(false);
|
|
||||||
plugin.pv.saveVerificationData(data);
|
|
||||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
data.setDiscordID(null);
|
||||||
|
data.setVerification(false);
|
||||||
|
plugin.pl.save(data);
|
||||||
|
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -57,18 +53,11 @@ public class Command_unmute extends FreedomCommand
|
|||||||
playerdata.setMuted(false);
|
playerdata.setMuted(false);
|
||||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
msg(player, "You have been unmuted.", ChatColor.RED);
|
||||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||||
if (quiet)
|
if (!quiet)
|
||||||
{
|
{
|
||||||
playerdata.setMuted(false);
|
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
|
||||||
playerdata.setMuted(false);
|
|
||||||
msg("Unmuted " + player.getName());
|
|
||||||
|
|
||||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
|
||||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -77,23 +66,4 @@ public class Command_unmute extends FreedomCommand
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
||||||
{
|
|
||||||
if (!plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
List<String> arguments = new ArrayList<>();
|
|
||||||
arguments.addAll(FUtil.getPlayerList());
|
|
||||||
arguments.addAll(Arrays.asList("list", "purge", "all"));
|
|
||||||
return arguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
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.FLog;
|
||||||
@ -11,8 +11,6 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
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;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
@ -23,7 +21,6 @@ public class Command_vanish extends FreedomCommand
|
|||||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
Displayable display = plugin.rm.getDisplay(playerSender);
|
Displayable display = plugin.rm.getDisplay(playerSender);
|
||||||
String loginMsg = display.getColoredLoginMessage();
|
|
||||||
String displayName = display.getColor() + playerSender.getName();
|
String displayName = display.getColor() + playerSender.getName();
|
||||||
String tag = display.getColoredTag();
|
String tag = display.getColoredTag();
|
||||||
Admin admin = plugin.al.getAdmin(playerSender);
|
Admin admin = plugin.al.getAdmin(playerSender);
|
||||||
@ -38,21 +35,18 @@ public class Command_vanish extends FreedomCommand
|
|||||||
if (plugin.al.vanished.contains(playerSender))
|
if (plugin.al.vanished.contains(playerSender))
|
||||||
{
|
{
|
||||||
msg(ChatColor.GOLD + "You have been unvanished.");
|
msg(ChatColor.GOLD + "You have been unvanished.");
|
||||||
if (admin.hasLoginMessage())
|
|
||||||
{
|
|
||||||
loginMsg = FUtil.colorize(admin.getLoginMessage()).replace("%rank%", plugin.rm.getDisplay(admin).getName()).replace("%coloredrank%", plugin.rm.getDisplay(admin).getColoredName()).replace("%name%", admin.getName());
|
|
||||||
}
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
||||||
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
|
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
|
||||||
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**");
|
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**");
|
||||||
}
|
}
|
||||||
if (admin.getTag() != null)
|
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||||
|
if (playerData.getTag() != null)
|
||||||
{
|
{
|
||||||
tag = FUtil.colorize(admin.getTag());
|
tag = FUtil.colorize(playerData.getTag());
|
||||||
}
|
}
|
||||||
plugin.pl.getPlayer(playerSender).setTag(tag);
|
plugin.pl.getData(playerSender).setTag(tag);
|
||||||
FLog.info(playerSender.getName() + " is no longer vanished.");
|
FLog.info(playerSender.getName() + " is no longer vanished.");
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -79,9 +73,13 @@ public class Command_vanish extends FreedomCommand
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins." );
|
{
|
||||||
|
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins.");
|
||||||
|
}
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
player.hidePlayer(plugin, playerSender);
|
player.hidePlayer(plugin, playerSender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.esb.setVanished(playerSender.getName(), true);
|
plugin.esb.setVanished(playerSender.getName(), true);
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
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.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
@ -22,258 +18,76 @@ public class Command_verify extends FreedomCommand
|
|||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (args.length == 1 && plugin.al.isAdmin(playerSender))
|
if (!plugin.dc.enabled)
|
||||||
{
|
{
|
||||||
final Player player = getPlayer(args[0]);
|
msg("The Discord verification system is currently disabled", ChatColor.RED);
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!plugin.pv.isPlayerImpostor(player))
|
|
||||||
{
|
|
||||||
msg("That player is not an impostor.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
|
|
||||||
player.setOp(true);
|
|
||||||
player.sendMessage(YOU_ARE_OP);
|
|
||||||
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
|
|
||||||
{
|
|
||||||
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
|
|
||||||
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
|
|
||||||
}
|
|
||||||
plugin.pv.verifyPlayer(player, null);
|
|
||||||
plugin.rm.updateDisplay(player);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
if (!plugin.dc.enabled)
|
msg("/manuallyverify <playername>", ChatColor.WHITE);
|
||||||
{
|
return true;
|
||||||
msg("The Discord verification system is currently disabled", ChatColor.RED);
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (senderIsConsole || plugin.al.isAdmin(playerSender))
|
if (!plugin.pl.isImposter(playerSender))
|
||||||
{
|
{
|
||||||
msg("/verify <playername>", ChatColor.WHITE);
|
msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.pv.isPlayerImpostor(playerSender) && !plugin.al.isAdminImpostor(playerSender) && !plugin.mbl.isMasterBuilderImpostor(playerSender))
|
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||||
{
|
|
||||||
msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String discordId = "";
|
String discordId = playerData.getDiscordID();
|
||||||
|
|
||||||
if (plugin.pv.isPlayerImpostor(playerSender))
|
if (playerData.getDiscordID() == null)
|
||||||
|
{
|
||||||
|
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
String code = plugin.dc.generateCode(10);
|
||||||
|
plugin.dc.addVerificationCode(code, playerData);
|
||||||
|
plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + Ips.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
|
||||||
|
msg("A verification code has been sent to your account, please copy the code and run /verify <code>", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String code = args[0];
|
||||||
|
String backupCode = null;
|
||||||
|
|
||||||
|
if (plugin.pl.isImposter(playerSender))
|
||||||
|
{
|
||||||
|
PlayerData mapPlayer = plugin.dc.getVerificationCodes().get(code);
|
||||||
|
if (mapPlayer == null)
|
||||||
{
|
{
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
|
if (!playerData.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
||||||
if (vPlayer.getDiscordId() == null)
|
|
||||||
{
|
{
|
||||||
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
msg("You have entered an invalid verification code", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
discordId = vPlayer.getDiscordId();
|
else
|
||||||
}
|
|
||||||
else if (plugin.al.isAdminImpostor(playerSender))
|
|
||||||
{
|
|
||||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
|
||||||
if (admin.getDiscordID() == null)
|
|
||||||
{
|
{
|
||||||
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
backupCode = plugin.dc.getMD5(code);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
discordId = admin.getDiscordID();
|
|
||||||
}
|
|
||||||
else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
|
|
||||||
if (masterBuilder.getDiscordID() == null)
|
|
||||||
{
|
|
||||||
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
discordId = masterBuilder.getDiscordID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
String code = plugin.dc.generateCode(10);
|
|
||||||
if (plugin.pv.isPlayerImpostor(playerSender))
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
|
|
||||||
plugin.dc.addPlayerVerificationCode(code, vPlayer);
|
|
||||||
}
|
|
||||||
else if (plugin.al.isAdminImpostor(playerSender))
|
|
||||||
{
|
|
||||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
|
||||||
plugin.dc.addAdminVerificationCode(code, admin);
|
|
||||||
}
|
|
||||||
else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
|
|
||||||
plugin.dc.addMasterBuilderVerificationCode(code, masterBuilder);
|
|
||||||
}
|
|
||||||
plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + Ips.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
|
|
||||||
msg("A verification code has been sent to your account, please copy the code and run /verify <code>", ChatColor.GREEN);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String code = args[0];
|
plugin.dc.removeVerificationCode(code);
|
||||||
String backupCode = null;
|
|
||||||
|
|
||||||
if (plugin.pv.isPlayerImpostor(playerSender))
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
|
|
||||||
VPlayer mapPlayer = plugin.dc.getPlayerVerificationCodes().get(code);
|
|
||||||
if (mapPlayer == null)
|
|
||||||
{
|
|
||||||
if (!vPlayer.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
|
||||||
{
|
|
||||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backupCode = plugin.dc.getMD5(code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.dc.removePlayerVerificationCode(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
|
||||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
|
||||||
playerSender.setOp(true);
|
|
||||||
msg(YOU_ARE_OP);
|
|
||||||
if (fPlayer.getFreezeData().isFrozen())
|
|
||||||
{
|
|
||||||
fPlayer.getFreezeData().setFrozen(false);
|
|
||||||
msg("You have been unfrozen.");
|
|
||||||
}
|
|
||||||
plugin.pv.verifyPlayer(playerSender, backupCode);
|
|
||||||
plugin.rm.updateDisplay(playerSender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (plugin.al.isAdminImpostor(playerSender))
|
|
||||||
{
|
|
||||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
|
||||||
Admin mapAdmin = plugin.dc.getAdminVerificationCodes().get(code);
|
|
||||||
if (mapAdmin == null)
|
|
||||||
{
|
|
||||||
if (!admin.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
|
||||||
{
|
|
||||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backupCode = plugin.dc.getMD5(code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.dc.removeAdminVerificationCode(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
|
||||||
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Re-adding " + admin.getName() + " to the admin list", true);
|
|
||||||
|
|
||||||
admin.setName(playerSender.getName());
|
|
||||||
admin.addIp(Ips.getIp(playerSender));
|
|
||||||
|
|
||||||
if (backupCode != null)
|
|
||||||
{
|
|
||||||
admin.removeBackupCode(backupCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.mbl.isMasterBuilder(playerSender))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = null;
|
|
||||||
for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
|
|
||||||
{
|
|
||||||
if (loopMasterBuilder.getName().equalsIgnoreCase(playerSender.getName()))
|
|
||||||
{
|
|
||||||
masterBuilder = loopMasterBuilder;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (masterBuilder != null)
|
|
||||||
{
|
|
||||||
masterBuilder.setName(playerSender.getName());
|
|
||||||
masterBuilder.addIp(Ips.getIp(playerSender));
|
|
||||||
|
|
||||||
masterBuilder.setLastLogin(new Date());
|
|
||||||
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
admin.setActive(true);
|
|
||||||
admin.setLastLogin(new Date());
|
|
||||||
plugin.al.save(admin);
|
|
||||||
plugin.al.updateTables();
|
|
||||||
plugin.rm.updateDisplay(playerSender);
|
|
||||||
playerSender.setOp(true);
|
|
||||||
msg(YOU_ARE_OP);
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
|
||||||
if (fPlayer.getFreezeData().isFrozen())
|
|
||||||
{
|
|
||||||
fPlayer.getFreezeData().setFrozen(false);
|
|
||||||
msg("You have been unfrozen.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
|
|
||||||
MasterBuilder mapMasterBuilder = plugin.dc.getMasterBuilderVerificationCodes().get(code);
|
|
||||||
if (mapMasterBuilder == null)
|
|
||||||
{
|
|
||||||
if (!masterBuilder.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
|
||||||
{
|
|
||||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backupCode = plugin.dc.getMD5(code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.dc.removeMasterBuilderVerificationCode(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backupCode != null)
|
|
||||||
{
|
|
||||||
masterBuilder.removeBackupCode(backupCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
|
||||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
|
||||||
masterBuilder.setLastLogin(new Date());
|
|
||||||
masterBuilder.addIp(Ips.getIp(playerSender));
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
plugin.rm.updateDisplay(playerSender);
|
|
||||||
playerSender.setOp(true);
|
|
||||||
msg(YOU_ARE_OP);
|
|
||||||
if (fPlayer.getFreezeData().isFrozen())
|
|
||||||
{
|
|
||||||
fPlayer.getFreezeData().setFrozen(false);
|
|
||||||
msg("You have been unfrozen.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||||
|
if (fPlayer.getFreezeData().isFrozen())
|
||||||
|
{
|
||||||
|
fPlayer.getFreezeData().setFrozen(false);
|
||||||
|
msg("You have been unfrozen.");
|
||||||
|
}
|
||||||
|
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||||
|
playerSender.setOp(true);
|
||||||
|
plugin.pl.verify(playerSender, backupCode);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
@ -46,7 +46,7 @@ public class Command_warn extends FreedomCommand
|
|||||||
|
|
||||||
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
|
||||||
msg(player, ChatColor.RED + "[WARNING] You received a warning: " + warnReason);
|
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
|
||||||
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
|
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
|
||||||
msg(ChatColor.GREEN + "You have successfully warned " + player.getName());
|
msg(ChatColor.GREEN + "You have successfully warned " + player.getName());
|
||||||
final StringBuilder adminNotice = new StringBuilder()
|
final StringBuilder adminNotice = new StringBuilder()
|
||||||
|
@ -154,6 +154,20 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
|||||||
sender.sendMessage(color + message);
|
sender.sendMessage(color + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void msg(final CommandSender sender, final String message, final net.md_5.bungee.api.ChatColor color)
|
||||||
|
{
|
||||||
|
if (sender == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender.sendMessage(color + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void msg(final String message, final net.md_5.bungee.api.ChatColor color)
|
||||||
|
{
|
||||||
|
msg(sender, message, color);
|
||||||
|
}
|
||||||
|
|
||||||
protected void msg(final String message, final ChatColor color)
|
protected void msg(final String message, final ChatColor color)
|
||||||
{
|
{
|
||||||
msg(sender, message, color);
|
msg(sender, message, color);
|
||||||
|
@ -82,6 +82,11 @@ public enum ConfigEntry
|
|||||||
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
|
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
|
||||||
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
||||||
//
|
//
|
||||||
|
DONATION_PROBOARDS_URL(String.class, "donation.proboards_url"),
|
||||||
|
DONATION_GROUP_ID(String.class, "donation.donator_group_id"),
|
||||||
|
DONATION_SESSION_ID(String.class, "donation.session_id"),
|
||||||
|
DONATION_CSRF_TOKEN(String.class, "donation.csrf_token"),
|
||||||
|
//
|
||||||
SHOP_ENABLED(Boolean.class, "shop.enabled"),
|
SHOP_ENABLED(Boolean.class, "shop.enabled"),
|
||||||
SHOP_TITLE(String.class, "shop.title"),
|
SHOP_TITLE(String.class, "shop.title"),
|
||||||
SHOP_PREFIX(String.class, "shop.prefix"),
|
SHOP_PREFIX(String.class, "shop.prefix"),
|
||||||
|
@ -19,8 +19,7 @@ import me.totalfreedom.totalfreedommod.FreedomService;
|
|||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import net.dv8tion.jda.api.AccountType;
|
import net.dv8tion.jda.api.AccountType;
|
||||||
@ -51,12 +50,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
|
|
||||||
public class Discord extends FreedomService
|
public class Discord extends FreedomService
|
||||||
{
|
{
|
||||||
public static HashMap<String, VPlayer> PLAYER_LINK_CODES = new HashMap<>();
|
public static HashMap<String, PlayerData> LINK_CODES = new HashMap<>();
|
||||||
public static HashMap<String, VPlayer> PLAYER_VERIFICATION_CODES = new HashMap<>();
|
public static HashMap<String, PlayerData> VERIFICATION_CODES = new HashMap<>();
|
||||||
public static HashMap<String, Admin> ADMIN_LINK_CODES = new HashMap<>();
|
|
||||||
public static HashMap<String, Admin> ADMIN_VERIFICATION_CODES = new HashMap<>();
|
|
||||||
public static HashMap<String, MasterBuilder> MASTER_BUILDER_LINK_CODES = new HashMap<>();
|
|
||||||
public static HashMap<String, MasterBuilder> MASTER_BUILDER_VERIFICATION_CODES = new HashMap<>();
|
|
||||||
public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit"));
|
public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit"));
|
||||||
public List<CompletableFuture<Message>> sentMessages = new ArrayList<>();
|
public List<CompletableFuture<Message>> sentMessages = new ArrayList<>();
|
||||||
|
|
||||||
@ -153,58 +148,20 @@ public class Discord extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sendBackupCodes(VPlayer vPlayer)
|
public boolean sendBackupCodes(PlayerData playerData)
|
||||||
{
|
{
|
||||||
List<String> codes = generateBackupCodes();
|
List<String> codes = generateBackupCodes();
|
||||||
List<String> encryptedCodes = generateEncryptedBackupCodes(codes);
|
List<String> encryptedCodes = generateEncryptedBackupCodes(codes);
|
||||||
net.dv8tion.jda.api.entities.User user = bot.getUserById(vPlayer.getDiscordId());
|
net.dv8tion.jda.api.entities.User user = bot.getUserById(playerData.getDiscordID());
|
||||||
File file = generateBackupCodesFile(vPlayer.getName(), codes);
|
File file = generateBackupCodesFile(playerData.getName(), codes);
|
||||||
if (file == null)
|
if (file == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
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();
|
||||||
vPlayer.setBackupCodes(encryptedCodes);
|
playerData.setBackupCodes(encryptedCodes);
|
||||||
plugin.pv.saveVerificationData(vPlayer);
|
plugin.pl.save(playerData);
|
||||||
file.delete();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean sendBackupCodes(Admin admin)
|
|
||||||
{
|
|
||||||
List<String> codes = generateBackupCodes();
|
|
||||||
List<String> encryptedCodes = generateEncryptedBackupCodes(codes);
|
|
||||||
net.dv8tion.jda.api.entities.User user = bot.getUserById(admin.getDiscordID());
|
|
||||||
File file = generateBackupCodesFile(admin.getName(), codes);
|
|
||||||
if (file == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
admin.setBackupCodes(encryptedCodes);
|
|
||||||
plugin.al.save(admin);
|
|
||||||
plugin.al.updateTables();
|
|
||||||
file.delete();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean sendBackupCodes(MasterBuilder masterBuilder)
|
|
||||||
{
|
|
||||||
List<String> codes = generateBackupCodes();
|
|
||||||
List<String> encryptedCodes = generateEncryptedBackupCodes(codes);
|
|
||||||
net.dv8tion.jda.api.entities.User user = bot.getUserById(masterBuilder.getDiscordID());
|
|
||||||
File file = generateBackupCodesFile(masterBuilder.getName(), codes);
|
|
||||||
if (file == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
masterBuilder.setBackupCodes(encryptedCodes);
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
file.delete();
|
file.delete();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -283,49 +240,19 @@ public class Discord extends FreedomService
|
|||||||
return DigestUtils.md5Hex(string);
|
return DigestUtils.md5Hex(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerVerificationCode(String code, VPlayer vPlayer)
|
public void addVerificationCode(String code, PlayerData playerData)
|
||||||
{
|
{
|
||||||
PLAYER_VERIFICATION_CODES.put(code, vPlayer);
|
VERIFICATION_CODES.put(code, playerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayerVerificationCode(String code)
|
public void removeVerificationCode(String code)
|
||||||
{
|
{
|
||||||
PLAYER_VERIFICATION_CODES.remove(code);
|
VERIFICATION_CODES.remove(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, VPlayer> getPlayerVerificationCodes()
|
public HashMap<String, PlayerData> getVerificationCodes()
|
||||||
{
|
{
|
||||||
return PLAYER_VERIFICATION_CODES;
|
return VERIFICATION_CODES;
|
||||||
}
|
|
||||||
|
|
||||||
public void addAdminVerificationCode(String code, Admin admin)
|
|
||||||
{
|
|
||||||
ADMIN_VERIFICATION_CODES.put(code, admin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeAdminVerificationCode(String code)
|
|
||||||
{
|
|
||||||
ADMIN_VERIFICATION_CODES.remove(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, Admin> getAdminVerificationCodes()
|
|
||||||
{
|
|
||||||
return ADMIN_VERIFICATION_CODES;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMasterBuilderVerificationCode(String code, MasterBuilder masterBuilder)
|
|
||||||
{
|
|
||||||
MASTER_BUILDER_VERIFICATION_CODES.put(code, masterBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeMasterBuilderVerificationCode(String code)
|
|
||||||
{
|
|
||||||
MASTER_BUILDER_VERIFICATION_CODES.remove(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, MasterBuilder> getMasterBuilderVerificationCodes()
|
|
||||||
{
|
|
||||||
return MASTER_BUILDER_VERIFICATION_CODES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
@ -383,35 +310,11 @@ public class Discord extends FreedomService
|
|||||||
return user.getName() + "#" + user.getDiscriminator();
|
return user.getName() + "#" + user.getDiscriminator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCodeForAdmin(Admin admin)
|
public static String getCode(PlayerData playerData)
|
||||||
{
|
{
|
||||||
for (String code : ADMIN_LINK_CODES.keySet())
|
for (String code : LINK_CODES.keySet())
|
||||||
{
|
{
|
||||||
if (ADMIN_LINK_CODES.get(code).equals(admin))
|
if (LINK_CODES.get(code).equals(playerData))
|
||||||
{
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCodeForPlayer(VPlayer playerData)
|
|
||||||
{
|
|
||||||
for (String code : PLAYER_LINK_CODES.keySet())
|
|
||||||
{
|
|
||||||
if (PLAYER_LINK_CODES.get(code).equals(playerData))
|
|
||||||
{
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCodeForMasterBuilder(MasterBuilder masterBuilder)
|
|
||||||
{
|
|
||||||
for (String code : MASTER_BUILDER_LINK_CODES.keySet())
|
|
||||||
{
|
|
||||||
if (MASTER_BUILDER_LINK_CODES.get(code).equals(masterBuilder))
|
|
||||||
{
|
{
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
@ -477,9 +380,9 @@ public class Discord extends FreedomService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean syncRoles(Admin admin)
|
public static boolean syncRoles(Admin admin, String discordID)
|
||||||
{
|
{
|
||||||
if (admin.getDiscordID() == null)
|
if (discordID == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -491,7 +394,7 @@ public class Discord extends FreedomService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Member member = server.getMemberById(admin.getDiscordID());
|
Member member = server.getMemberById(discordID);
|
||||||
if (member == null)
|
if (member == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.discord;
|
package me.totalfreedom.totalfreedommod.discord;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
@ -18,34 +16,15 @@ public class PrivateMessageListener extends ListenerAdapter
|
|||||||
{
|
{
|
||||||
String code = event.getMessage().getContentRaw();
|
String code = event.getMessage().getContentRaw();
|
||||||
String name;
|
String name;
|
||||||
if (Discord.ADMIN_LINK_CODES.get(code) != null)
|
if (Discord.LINK_CODES.get(code) != null)
|
||||||
{
|
{
|
||||||
Admin admin = Discord.ADMIN_LINK_CODES.get(code);
|
PlayerData player = Discord.LINK_CODES.get(code);
|
||||||
name = admin.getName();
|
|
||||||
admin.setDiscordID(event.getMessage().getAuthor().getId());
|
|
||||||
TotalFreedomMod.plugin().al.save(admin);
|
|
||||||
TotalFreedomMod.plugin().al.updateTables();
|
|
||||||
Discord.ADMIN_LINK_CODES.remove(code);
|
|
||||||
Discord.syncRoles(admin);
|
|
||||||
}
|
|
||||||
else if (Discord.PLAYER_LINK_CODES.get(code) != null)
|
|
||||||
{
|
|
||||||
VPlayer player = Discord.PLAYER_LINK_CODES.get(code);
|
|
||||||
name = player.getName();
|
name = player.getName();
|
||||||
player.setDiscordId(event.getMessage().getAuthor().getId());
|
player.setDiscordID(event.getMessage().getAuthor().getId());
|
||||||
player.setEnabled(true);
|
player.setVerification(true);
|
||||||
|
|
||||||
TotalFreedomMod.plugin().pv.saveVerificationData(player);
|
TotalFreedomMod.plugin().pl.save(player);
|
||||||
Discord.PLAYER_LINK_CODES.remove(code);
|
Discord.LINK_CODES.remove(code);
|
||||||
}
|
|
||||||
else if (Discord.MASTER_BUILDER_LINK_CODES.get(code) != null)
|
|
||||||
{
|
|
||||||
MasterBuilder masterBuilder = Discord.MASTER_BUILDER_LINK_CODES.get(code);
|
|
||||||
name = masterBuilder.getName();
|
|
||||||
masterBuilder.setDiscordID(event.getMessage().getAuthor().getId());
|
|
||||||
TotalFreedomMod.plugin().mbl.save();
|
|
||||||
TotalFreedomMod.plugin().mbl.updateTables();
|
|
||||||
Discord.MASTER_BUILDER_LINK_CODES.remove(code);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ public class FreezeData
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (!plugin().al.isAdminImpostor(player) && plugin().pv.isPlayerImpostor(player))
|
if (!plugin().al.isAdminImpostor(player) && plugin().pl.isPlayerImpostor(player))
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
|
FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
|
||||||
setFrozen(false);
|
setFrozen(false);
|
||||||
|
@ -5,20 +5,15 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.security.auth.login.FailedLoginException;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
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.shop.ShopData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
@ -287,7 +282,7 @@ public class ItemFun extends FreedomService
|
|||||||
|
|
||||||
case BLAZE_ROD:
|
case BLAZE_ROD:
|
||||||
{
|
{
|
||||||
if (!plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory().getItemInMainHand(), plugin.sh.getLightningRod()))
|
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory().getItemInMainHand(), plugin.sh.getLightningRod()))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -311,7 +306,7 @@ public class ItemFun extends FreedomService
|
|||||||
|
|
||||||
case FIRE_CHARGE:
|
case FIRE_CHARGE:
|
||||||
{
|
{
|
||||||
if (!plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.FIRE_BALL, player.getInventory().getItemInMainHand(), plugin.sh.getFireBall()))
|
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.FIRE_BALL, player.getInventory().getItemInMainHand(), plugin.sh.getFireBall()))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -339,7 +334,7 @@ public class ItemFun extends FreedomService
|
|||||||
if (entity instanceof EnderPearl && entity.getShooter() instanceof Player)
|
if (entity instanceof EnderPearl && entity.getShooter() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player)entity.getShooter();
|
Player player = (Player)entity.getShooter();
|
||||||
if (plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory().getItemInMainHand(), plugin.sh.getRideablePearl()))
|
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory().getItemInMainHand(), plugin.sh.getRideablePearl()))
|
||||||
{
|
{
|
||||||
entity.addPassenger(player);
|
entity.addPassenger(player);
|
||||||
}
|
}
|
||||||
@ -397,10 +392,10 @@ public class ItemFun extends FreedomService
|
|||||||
public void onFish(PlayerFishEvent event)
|
public void onFish(PlayerFishEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ShopData sd = plugin.sh.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
PlayerInventory inv = event.getPlayer().getInventory();
|
PlayerInventory inv = event.getPlayer().getInventory();
|
||||||
ItemStack rod = inv.getItemInMainHand();
|
ItemStack rod = inv.getItemInMainHand();
|
||||||
if (plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.GRAPPLING_HOOK, player.getInventory().getItemInMainHand(), plugin.sh.getGrapplingHook()))
|
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.GRAPPLING_HOOK, player.getInventory().getItemInMainHand(), plugin.sh.getGrapplingHook()))
|
||||||
{
|
{
|
||||||
if (event.getState() == PlayerFishEvent.State.REEL_IN || event.getState() == PlayerFishEvent.State.IN_GROUND)
|
if (event.getState() == PlayerFishEvent.State.REEL_IN || event.getState() == PlayerFishEvent.State.IN_GROUND)
|
||||||
{
|
{
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.fun;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
public class RealTimer extends FreedomService
|
|
||||||
{
|
|
||||||
public RealTimer(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Player, BukkitTask> tasks = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
enable(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
disable(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enable(Player player)
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
|
||||||
if (vPlayer.isRealTime())
|
|
||||||
{
|
|
||||||
tasks.put(player, new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
player.setPlayerTime(FUtil.getTimeInTicks(vPlayer.getUtcOffset()), false);
|
|
||||||
}
|
|
||||||
}.runTaskTimer(plugin, 0L, 20));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disable(Player player)
|
|
||||||
{
|
|
||||||
if (!tasks.containsKey(player))
|
|
||||||
return;
|
|
||||||
tasks.get(player).cancel();
|
|
||||||
tasks.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
@ -91,4 +91,9 @@ public class Trailer extends FreedomService
|
|||||||
{
|
{
|
||||||
trailPlayers.add(player.getName());
|
trailPlayers.add(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean contains(Player player)
|
||||||
|
{
|
||||||
|
return trailPlayers.contains(player.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class Module_list extends HTTPDModule
|
|||||||
imposters.add(player.getName());
|
imposters.add(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.mbl.isMasterBuilder(player))
|
if (plugin.pl.getData(player).isMasterBuilder())
|
||||||
{
|
{
|
||||||
masterbuilders.add(player.getName());
|
masterbuilders.add(player.getName());
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ public class Module_list extends HTTPDModule
|
|||||||
|
|
||||||
public boolean isImposter(Player player)
|
public boolean isImposter(Player player)
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdminImpostor(player) || plugin.pv.isPlayerImpostor(player) || plugin.mbl.isMasterBuilderImpostor(player))
|
if (plugin.al.isAdminImpostor(player) || plugin.pl.isPlayerImpostor(player))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class Module_logs extends Module_file
|
|||||||
@Override
|
@Override
|
||||||
public NanoHTTPD.Response getResponse()
|
public NanoHTTPD.Response getResponse()
|
||||||
{
|
{
|
||||||
if (ConfigEntry.LOGS_SECRET.getString().equals(params.get("password")))
|
if (ConfigEntry.LOGS_SECRET.getString().equals(params.get("password")) && !ConfigEntry.LOGS_SECRET.getString().isEmpty())
|
||||||
{
|
{
|
||||||
FLog.info(session.getSocket().getInetAddress() + " is downloading latest.log.");
|
FLog.info(session.getSocket().getInetAddress() + " is downloading latest.log.");
|
||||||
return serveFile("latest.log", params, new File("./logs"));
|
return serveFile("latest.log", params, new File("./logs"));
|
||||||
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -66,11 +65,7 @@ public class Module_players extends HTTPDModule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Master Builders
|
masterbuilders.addAll(plugin.pl.getMasterBuilderNames());
|
||||||
for (MasterBuilder masterBuilder : plugin.mbl.getAllMasterBuilders().values())
|
|
||||||
{
|
|
||||||
masterbuilders.add(masterBuilder.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Developers
|
// Developers
|
||||||
developers.addAll(FUtil.DEVELOPERS);
|
developers.addAll(FUtil.DEVELOPERS);
|
||||||
|
@ -21,7 +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.player.PlayerData;
|
||||||
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;
|
||||||
@ -271,8 +271,8 @@ public class Module_schematic extends HTTPDModule
|
|||||||
private boolean isAuthorized(String remoteAddress)
|
private boolean isAuthorized(String remoteAddress)
|
||||||
{
|
{
|
||||||
Admin adminEntry = plugin.al.getEntryByIp(remoteAddress);
|
Admin adminEntry = plugin.al.getEntryByIp(remoteAddress);
|
||||||
MasterBuilder masterBuilderEntry = plugin.mbl.getEntryByIp(remoteAddress);
|
PlayerData data = plugin.pl.getDataByIp(remoteAddress);
|
||||||
return ((adminEntry != null && adminEntry.isActive()) || masterBuilderEntry != null);
|
return ((adminEntry != null && adminEntry.isActive()) || data != null && data.isMasterBuilder());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SchematicTransferException extends Exception
|
private static class SchematicTransferException extends Exception
|
||||||
|
@ -1,188 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.masterbuilder;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
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 org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class MasterBuilder implements ConfigLoadable, ConfigSavable, Validatable
|
|
||||||
{
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private String configKey;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String name;
|
|
||||||
@Getter
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
|
||||||
private final List<String> backupCodes = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Date lastLogin = new Date();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String discordID = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String tag = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private boolean clearChatOptOut = false;
|
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "masterbuilders.yml";
|
|
||||||
|
|
||||||
public MasterBuilder(Player player)
|
|
||||||
{
|
|
||||||
this.configKey = player.getName().toLowerCase();
|
|
||||||
this.name = player.getName();
|
|
||||||
this.ips.add(Ips.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public MasterBuilder(String configKey)
|
|
||||||
{
|
|
||||||
this.configKey = configKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
final StringBuilder output = new StringBuilder();
|
|
||||||
|
|
||||||
output.append("MasterBuilder: ").append(name).append("\n")
|
|
||||||
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
|
||||||
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
|
||||||
.append("- Discord ID: ").append(discordID).append("\n")
|
|
||||||
.append("- Tag: ").append(tag).append("\n")
|
|
||||||
.append("- Clear Chat Opt Out: ").append(clearChatOptOut)
|
|
||||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
|
|
||||||
|
|
||||||
return output.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadFrom(Player player)
|
|
||||||
{
|
|
||||||
configKey = player.getName().toLowerCase();
|
|
||||||
name = player.getName();
|
|
||||||
ips.clear();
|
|
||||||
ips.add(Ips.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
name = cs.getString("username", configKey);
|
|
||||||
ips.clear();
|
|
||||||
ips.addAll(cs.getStringList("ips"));
|
|
||||||
backupCodes.clear();
|
|
||||||
backupCodes.addAll(cs.getStringList("backupCodes"));
|
|
||||||
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
|
|
||||||
discordID = cs.getString("discord_id", null);
|
|
||||||
tag = cs.getString("tag", null);
|
|
||||||
clearChatOptOut = cs.getBoolean("clearChatOptOut", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
Validate.isTrue(isValid(), "Could not save master builder entry: " + name + ". Entry not valid!");
|
|
||||||
cs.set("username", name);
|
|
||||||
cs.set("ips", Lists.newArrayList(ips));
|
|
||||||
cs.set("backupCodes", Lists.newArrayList(backupCodes));
|
|
||||||
cs.set("last_login", FUtil.dateToString(lastLogin));
|
|
||||||
cs.set("discord_id", discordID);
|
|
||||||
cs.set("tag", tag);
|
|
||||||
cs.set("clearChatOptOut", clearChatOptOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addIp(String ip)
|
|
||||||
{
|
|
||||||
if (!ips.contains(ip))
|
|
||||||
{
|
|
||||||
ips.add(ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addIps(List<String> ips)
|
|
||||||
{
|
|
||||||
for (String ip : ips)
|
|
||||||
{
|
|
||||||
addIp(ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeIp(String ip)
|
|
||||||
{
|
|
||||||
ips.remove(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearIPs()
|
|
||||||
{
|
|
||||||
ips.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getBackupCodes()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(backupCodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackupCodes(List<String> codes)
|
|
||||||
{
|
|
||||||
backupCodes.clear();
|
|
||||||
backupCodes.addAll(codes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBackupCode(String code)
|
|
||||||
{
|
|
||||||
backupCodes.remove(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return configKey != null
|
|
||||||
&& name != null
|
|
||||||
&& !ips.isEmpty()
|
|
||||||
&& lastLogin != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConfigKey()
|
|
||||||
{
|
|
||||||
return this.configKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getIps()
|
|
||||||
{
|
|
||||||
return this.ips;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLastLogin()
|
|
||||||
{
|
|
||||||
return this.lastLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastLogin(final Date lastLogin)
|
|
||||||
{
|
|
||||||
this.lastLogin = lastLogin;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,295 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.masterbuilder;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
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.command.CommandSender;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.ServicePriority;
|
|
||||||
|
|
||||||
public class MasterBuilderList extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "masterbuilders.yml";
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Map<String, MasterBuilder> masterBuilders = Maps.newHashMap();
|
|
||||||
private final Map<String, MasterBuilder> nameTable = Maps.newHashMap();
|
|
||||||
private final Map<String, MasterBuilder> ipTable = Maps.newHashMap();
|
|
||||||
//
|
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
public MasterBuilderList(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
|
|
||||||
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
load();
|
|
||||||
|
|
||||||
server.getServicesManager().register(Function.class, new Function<Player, Boolean>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Boolean apply(Player player)
|
|
||||||
{
|
|
||||||
return isMasterBuilder(player);
|
|
||||||
}
|
|
||||||
}, plugin, ServicePriority.Normal);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load()
|
|
||||||
{
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
masterBuilders.clear();
|
|
||||||
for (String key : config.getKeys(false))
|
|
||||||
{
|
|
||||||
ConfigurationSection section = config.getConfigurationSection(key);
|
|
||||||
if (section == null)
|
|
||||||
{
|
|
||||||
logger.warning("Invalid master builder list format: " + key);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
MasterBuilder masterBuilder = new MasterBuilder(key);
|
|
||||||
masterBuilder.loadFrom(section);
|
|
||||||
|
|
||||||
if (!masterBuilder.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Could not load master builder: " + key + ". Missing details!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
masterBuilders.put(key, masterBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTables();
|
|
||||||
FLog.info("Loaded " + masterBuilders.size() + " master builders with " + ipTable.size() + " IPs");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
// Clear the config
|
|
||||||
for (String key : config.getKeys(false))
|
|
||||||
{
|
|
||||||
config.set(key, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MasterBuilder masterBuilder : masterBuilders.values())
|
|
||||||
{
|
|
||||||
masterBuilder.saveTo(config.createSection(masterBuilder.getConfigKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isMasterbuilderSync(CommandSender sender)
|
|
||||||
{
|
|
||||||
return isMasterBuilder(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMasterBuilder(CommandSender sender)
|
|
||||||
{
|
|
||||||
if (!(sender instanceof Player))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MasterBuilder masterBuilder = getMasterBuilder((Player)sender);
|
|
||||||
|
|
||||||
return masterBuilder != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, MasterBuilder> getAllMasterBuilders()
|
|
||||||
{
|
|
||||||
return this.masterBuilders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MasterBuilder getMasterBuilder(CommandSender sender)
|
|
||||||
{
|
|
||||||
if (sender instanceof Player)
|
|
||||||
{
|
|
||||||
return getMasterBuilder((Player)sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
return getEntryByName(sender.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MasterBuilder getMasterBuilder(Player player)
|
|
||||||
{
|
|
||||||
String ip = Ips.getIp(player);
|
|
||||||
MasterBuilder masterBuilder = getEntryByName(player.getName());
|
|
||||||
|
|
||||||
// By name
|
|
||||||
if (masterBuilder != null)
|
|
||||||
{
|
|
||||||
// Check if we're in online mode or if we have a matching IP
|
|
||||||
if (server.getOnlineMode() || masterBuilder.getIps().contains(ip))
|
|
||||||
{
|
|
||||||
if (!masterBuilder.getIps().contains(ip))
|
|
||||||
{
|
|
||||||
// Add the new IP if needed
|
|
||||||
masterBuilder.addIp(ip);
|
|
||||||
save();
|
|
||||||
updateTables();
|
|
||||||
}
|
|
||||||
return masterBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// By ip
|
|
||||||
masterBuilder = getEntryByIp(ip);
|
|
||||||
if (masterBuilder != null)
|
|
||||||
{
|
|
||||||
// Set the new username
|
|
||||||
masterBuilder.setName(player.getName());
|
|
||||||
save();
|
|
||||||
updateTables();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MasterBuilder getEntryByName(String name)
|
|
||||||
{
|
|
||||||
return nameTable.get(name.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MasterBuilder getEntryByIp(String ip)
|
|
||||||
{
|
|
||||||
return ipTable.get(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MasterBuilder getEntryByIpFuzzy(String needleIp)
|
|
||||||
{
|
|
||||||
final MasterBuilder directMasterBuilder = getEntryByIp(needleIp);
|
|
||||||
if (directMasterBuilder != null)
|
|
||||||
{
|
|
||||||
return directMasterBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String ip : ipTable.keySet())
|
|
||||||
{
|
|
||||||
if (FUtil.fuzzyIpMatch(needleIp, ip, 3))
|
|
||||||
{
|
|
||||||
return ipTable.get(ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateLastLogin(Player player)
|
|
||||||
{
|
|
||||||
final MasterBuilder masterBuilder = getMasterBuilder(player);
|
|
||||||
if (masterBuilder == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
masterBuilder.setLastLogin(new Date());
|
|
||||||
masterBuilder.setName(player.getName());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMasterBuilderImpostor(Player player)
|
|
||||||
{
|
|
||||||
return getEntryByName(player.getName()) != null && !isMasterBuilder(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIdentityMatched(Player player)
|
|
||||||
{
|
|
||||||
if (server.getOnlineMode())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MasterBuilder masterBuilder = getMasterBuilder(player);
|
|
||||||
return masterBuilder != null && masterBuilder.getName().equalsIgnoreCase(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean addMasterBuilder(MasterBuilder masterBuilder)
|
|
||||||
{
|
|
||||||
if (!masterBuilder.isValid())
|
|
||||||
{
|
|
||||||
logger.warning("Could not add master builder: " + masterBuilder.getConfigKey() + " master builder is missing details!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String key = masterBuilder.getConfigKey();
|
|
||||||
|
|
||||||
// Store master builder, update views
|
|
||||||
masterBuilders.put(key, masterBuilder);
|
|
||||||
updateTables();
|
|
||||||
|
|
||||||
// Save master builder
|
|
||||||
masterBuilder.saveTo(config.createSection(key));
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean removeMasterBuilder(MasterBuilder masterBuilder)
|
|
||||||
{
|
|
||||||
// Remove master builder, update views
|
|
||||||
if (masterBuilders.remove(masterBuilder.getConfigKey()) == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
updateTables();
|
|
||||||
|
|
||||||
// 'Unsave' master builder
|
|
||||||
config.set(masterBuilder.getConfigKey(), null);
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateTables()
|
|
||||||
{
|
|
||||||
nameTable.clear();
|
|
||||||
ipTable.clear();
|
|
||||||
|
|
||||||
for (MasterBuilder masterBuilder : masterBuilders.values())
|
|
||||||
{
|
|
||||||
nameTable.put(masterBuilder.getName().toLowerCase(), masterBuilder);
|
|
||||||
|
|
||||||
for (String ip : masterBuilder.getIps())
|
|
||||||
{
|
|
||||||
ipTable.put(ip, masterBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getMasterBuilderNames()
|
|
||||||
{
|
|
||||||
return nameTable.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getMasterBuilderIps()
|
|
||||||
{
|
|
||||||
return ipTable.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -106,7 +106,7 @@ public class PermissionManager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.mbl.isMasterBuilder(player) && !plugin.al.isAdmin(player))
|
if (plugin.pl.getData(player).isMasterBuilder() && !plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
if (nodes != null)
|
if (nodes != null)
|
||||||
{
|
{
|
||||||
|
@ -1,59 +1,116 @@
|
|||||||
package me.totalfreedom.totalfreedommod.player;
|
package me.totalfreedom.totalfreedommod.player;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
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 net.pravian.aero.base.ConfigLoadable;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||||
import net.pravian.aero.base.Validatable;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.lang.Validate;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PlayerData implements ConfigLoadable, ConfigSavable, Validatable
|
public class PlayerData
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String username;
|
private String name;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private long firstJoinUnix;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private long lastJoinUnix;
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
private final List<String> notes = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String tag = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String discordID = null;
|
||||||
|
private final List<String> backupCodes = Lists.newArrayList();
|
||||||
|
@Setter
|
||||||
|
private Boolean donator = false;
|
||||||
|
@Setter
|
||||||
|
private Boolean masterBuilder = false;
|
||||||
|
@Setter
|
||||||
|
private Boolean verification = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String rideMode = "ask";
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int coins;
|
||||||
|
private List<String> items = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int totalVotes;
|
||||||
|
|
||||||
|
public PlayerData(ResultSet resultSet)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
name = resultSet.getString("username");
|
||||||
|
ips.clear();
|
||||||
|
ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
||||||
|
notes.clear();
|
||||||
|
notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
|
||||||
|
tag = resultSet.getString("tag");
|
||||||
|
discordID = resultSet.getString("discord_id");
|
||||||
|
backupCodes.clear();
|
||||||
|
backupCodes.addAll(FUtil.stringToList(resultSet.getString("backup_codes")));
|
||||||
|
donator = resultSet.getBoolean("donator");
|
||||||
|
masterBuilder = resultSet.getBoolean("master_builder");
|
||||||
|
verification = resultSet.getBoolean("verification");
|
||||||
|
rideMode = resultSet.getString("ride_mode");
|
||||||
|
coins = resultSet.getInt("coins");
|
||||||
|
items.clear();
|
||||||
|
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
||||||
|
totalVotes = resultSet.getInt("total_votes");
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load player: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force verification for Master Builders
|
||||||
|
if (masterBuilder && !verification)
|
||||||
|
{
|
||||||
|
verification = true;
|
||||||
|
TotalFreedomMod.plugin().pl.save(this);
|
||||||
|
}
|
||||||
|
else if (!masterBuilder && discordID == null && verification)
|
||||||
|
{
|
||||||
|
this.verification = false;
|
||||||
|
TotalFreedomMod.plugin().pl.save(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
|
output.append("Player: ").append(name).append("\n")
|
||||||
|
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
||||||
|
.append("- Discord ID: ").append(discordID).append("\n")
|
||||||
|
.append("- Donator: ").append(donator).append("\n")
|
||||||
|
.append("- Master Builder: ").append(masterBuilder).append("\n")
|
||||||
|
.append("- Has Verification: ").append(verification).append("\n")
|
||||||
|
.append("- Coins: ").append(coins).append("\n")
|
||||||
|
.append("- Total Votes: ").append(totalVotes).append("\n")
|
||||||
|
.append("- Tag: ").append(tag).append("\n")
|
||||||
|
.append("- Ride Mode: ").append(rideMode)
|
||||||
|
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
|
||||||
|
|
||||||
|
return output.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerData(Player player)
|
public PlayerData(Player player)
|
||||||
{
|
{
|
||||||
this(player.getName());
|
this.name = player.getName();
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerData(String username)
|
|
||||||
{
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
this.username = cs.getString("username", username);
|
|
||||||
this.ips.clear();
|
|
||||||
this.ips.addAll(cs.getStringList("ips"));
|
|
||||||
this.firstJoinUnix = cs.getLong("first_join", 0);
|
|
||||||
this.lastJoinUnix = cs.getLong("last_join", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
Validate.isTrue(isValid(), "Could not save player entry: " + username + ". Entry not valid!");
|
|
||||||
cs.set("username", username);
|
|
||||||
cs.set("ips", ips);
|
|
||||||
cs.set("first_join", firstJoinUnix);
|
|
||||||
cs.set("last_join", lastJoinUnix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getIps()
|
public List<String> getIps()
|
||||||
@ -61,23 +118,127 @@ public class PlayerData implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return Collections.unmodifiableList(ips);
|
return Collections.unmodifiableList(ips);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP utils
|
|
||||||
public boolean addIp(String ip)
|
public boolean addIp(String ip)
|
||||||
{
|
{
|
||||||
return ips.contains(ip) ? false : ips.add(ip);
|
return !ips.contains(ip) && ips.add(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeIp(String ip)
|
public void removeIp(String ip)
|
||||||
{
|
{
|
||||||
return ips.remove(ip);
|
ips.remove(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void clearIps()
|
||||||
public boolean isValid()
|
|
||||||
{
|
{
|
||||||
return username != null
|
ips.clear();
|
||||||
&& firstJoinUnix != 0
|
}
|
||||||
&& lastJoinUnix != 0
|
|
||||||
&& !ips.isEmpty();
|
public void addIps(List<String> ips)
|
||||||
|
{
|
||||||
|
ips.addAll(ips);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getNotes()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableList(notes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearNotes()
|
||||||
|
{
|
||||||
|
notes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBackupCodes()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableList(backupCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackupCodes(List<String> codes)
|
||||||
|
{
|
||||||
|
backupCodes.clear();
|
||||||
|
backupCodes.addAll(codes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBackupCode(String code)
|
||||||
|
{
|
||||||
|
backupCodes.remove(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNote(String note)
|
||||||
|
{
|
||||||
|
notes.add(note);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeNote(int id) throws IndexOutOfBoundsException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
notes.remove(id);
|
||||||
|
}
|
||||||
|
catch (IndexOutOfBoundsException e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDonator()
|
||||||
|
{
|
||||||
|
return donator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveItem(ShopItem item)
|
||||||
|
{
|
||||||
|
items.add(item.getDataName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getItems()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableList(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasItem(ShopItem item)
|
||||||
|
{
|
||||||
|
if (items.contains(item.getDataName()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeItem(ShopItem item)
|
||||||
|
{
|
||||||
|
items.remove(item.getDataName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasVerification()
|
||||||
|
{
|
||||||
|
return verification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMasterBuilder()
|
||||||
|
{
|
||||||
|
return masterBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> toSQLStorable()
|
||||||
|
{
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>()
|
||||||
|
{{
|
||||||
|
put("username", name);
|
||||||
|
put("ips", FUtil.listToString(ips));
|
||||||
|
put("notes", FUtil.listToString(notes));
|
||||||
|
put("tag", tag);
|
||||||
|
put("discord_id", discordID);
|
||||||
|
put("backup_codes", FUtil.listToString(backupCodes));
|
||||||
|
put("donator", donator);
|
||||||
|
put("master_builder", masterBuilder);
|
||||||
|
put("verification", verification);
|
||||||
|
put("ride_mode", rideMode);
|
||||||
|
put("coins", coins);
|
||||||
|
put("items", FUtil.listToString(items));
|
||||||
|
put("total_votes", totalVotes);
|
||||||
|
}};
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,47 @@
|
|||||||
package me.totalfreedom.totalfreedommod.player;
|
package me.totalfreedom.totalfreedommod.player;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import java.io.File;
|
import java.sql.ResultSet;
|
||||||
import java.util.Collection;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
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 net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class PlayerList extends FreedomService
|
public class PlayerList extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final long AUTO_PURGE_TICKS = 20L * 60L * 5L;
|
|
||||||
//
|
|
||||||
@Getter
|
@Getter
|
||||||
public final Map<String, FPlayer> playerMap = Maps.newHashMap(); // ip,dataMap
|
public final Map<String, FPlayer> playerMap = Maps.newHashMap(); // ip,dataMap
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public final Map<String, PlayerData> dataMap = Maps.newHashMap(); // ip,dataMap
|
public final Map<String, PlayerData> dataMap = Maps.newHashMap(); // username, data
|
||||||
@Getter
|
|
||||||
private final File configFolder;
|
|
||||||
|
|
||||||
public PlayerList(TotalFreedomMod plugin)
|
public PlayerList(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
|
||||||
this.configFolder = new File(plugin.getDataFolder(), "players");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
playerMap.clear();
|
|
||||||
dataMap.clear();
|
dataMap.clear();
|
||||||
|
loadMasterBuilders();
|
||||||
// Preload online players
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
getPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
for (PlayerData data : dataMap.values())
|
|
||||||
{
|
|
||||||
YamlConfig config = getConfig(data);
|
|
||||||
data.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getPlayerSync(Player player)
|
public FPlayer getPlayerSync(Player player)
|
||||||
@ -74,6 +52,29 @@ public class PlayerList extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadMasterBuilders()
|
||||||
|
{
|
||||||
|
ResultSet resultSet = plugin.sql.getMasterBuilders();
|
||||||
|
|
||||||
|
if (resultSet == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
PlayerData playerData = load(resultSet);
|
||||||
|
dataMap.put(playerData.getName(), playerData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to parse master builders: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getIp(OfflinePlayer player)
|
public String getIp(OfflinePlayer player)
|
||||||
{
|
{
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
@ -86,6 +87,44 @@ public class PlayerList extends FreedomService
|
|||||||
return (entry == null ? null : entry.getIps().iterator().next());
|
return (entry == null ? null : entry.getIps().iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getMasterBuilderNames()
|
||||||
|
{
|
||||||
|
List<String> masterBuilders = new ArrayList<>();
|
||||||
|
for (PlayerData playerData : plugin.pl.dataMap.values())
|
||||||
|
{
|
||||||
|
if (playerData.isMasterBuilder())
|
||||||
|
{
|
||||||
|
masterBuilders.add(playerData.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return masterBuilders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canManageMasterBuilders(String name)
|
||||||
|
{
|
||||||
|
PlayerData data = getData(name);
|
||||||
|
|
||||||
|
if ((!ConfigEntry.HOST_SENDER_NAMES.getStringList().contains(name.toLowerCase()) && data != null && !ConfigEntry.SERVER_OWNERS.getStringList().contains(data.getName()))
|
||||||
|
&& !ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(data.getName())
|
||||||
|
&& !isTelnetMasterBuilder(data)
|
||||||
|
&& !ConfigEntry.HOST_SENDER_NAMES.getStringList().contains(name.toLowerCase()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTelnetMasterBuilder(PlayerData playerData)
|
||||||
|
{
|
||||||
|
Admin admin = plugin.al.getEntryByName(playerData.getName());
|
||||||
|
if (admin != null && admin.getRank().isAtLeast(Rank.TELNET_ADMIN) && playerData.isMasterBuilder())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// May not return null
|
// May not return null
|
||||||
public FPlayer getPlayer(Player player)
|
public FPlayer getPlayer(Player player)
|
||||||
{
|
{
|
||||||
@ -101,122 +140,191 @@ public class PlayerList extends FreedomService
|
|||||||
return tPlayer;
|
return tPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May not return null
|
public PlayerData loadByName(String name)
|
||||||
public PlayerData getData(Player player)
|
|
||||||
{
|
{
|
||||||
// Check already loaded
|
return load(plugin.sql.getPlayerByName(name));
|
||||||
PlayerData data = dataMap.get(Ips.getIp(player));
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load data
|
|
||||||
data = getData(player.getName());
|
|
||||||
|
|
||||||
// Create data if nonexistent
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
FLog.info("Creating new player data entry for " + player.getName());
|
|
||||||
|
|
||||||
// Create new player
|
|
||||||
final long unix = FUtil.getUnixTime();
|
|
||||||
data = new PlayerData(player);
|
|
||||||
data.setFirstJoinUnix(unix);
|
|
||||||
data.setLastJoinUnix(unix);
|
|
||||||
data.addIp(Ips.getIp(player));
|
|
||||||
|
|
||||||
// Store player
|
|
||||||
dataMap.put(player.getName().toLowerCase(), data);
|
|
||||||
|
|
||||||
// Save player
|
|
||||||
YamlConfig config = getConfig(data);
|
|
||||||
data.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// May return null
|
public PlayerData loadByIp(String ip)
|
||||||
public PlayerData getData(String username)
|
|
||||||
{
|
{
|
||||||
username = username.toLowerCase();
|
return load(plugin.sql.getPlayerByIp(ip));
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the player is a known player
|
public PlayerData load(ResultSet resultSet)
|
||||||
final File configFile = getConfigFile(username);
|
{
|
||||||
if (!configFile.exists())
|
if (resultSet == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return new PlayerData(resultSet);
|
||||||
|
}
|
||||||
|
|
||||||
// Create and load entry
|
public Boolean isPlayerImpostor(Player player)
|
||||||
final PlayerData data = new PlayerData(username);
|
{
|
||||||
data.loadFrom(getConfig(data));
|
PlayerData playerData = getData(player);
|
||||||
|
return !plugin.al.isAdmin(player)
|
||||||
|
&& (playerData.hasVerification())
|
||||||
|
&& !playerData.getIps().contains(Ips.getIp(player));
|
||||||
|
}
|
||||||
|
|
||||||
if (!data.isValid())
|
public boolean isImposter(Player player)
|
||||||
|
{
|
||||||
|
return isPlayerImpostor(player) || plugin.al.isAdminImpostor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void verify(Player player, String backupCode)
|
||||||
|
{
|
||||||
|
PlayerData playerData = getData(player);
|
||||||
|
if (backupCode != null)
|
||||||
{
|
{
|
||||||
FLog.warning("Could not load player data entry: " + username + ". Entry is not valid!");
|
playerData.removeBackupCode(backupCode);
|
||||||
configFile.delete();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
playerData.addIp(Ips.getIp(player));
|
||||||
|
save(playerData);
|
||||||
|
|
||||||
// Only store data if the player is online
|
if (plugin.al.isAdminImpostor(player))
|
||||||
for (String ip : data.getIps())
|
|
||||||
{
|
{
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers())
|
Admin admin = null;
|
||||||
|
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||||
{
|
{
|
||||||
if (Ips.getIp(onlinePlayer).equals(ip))
|
if (loopAdmin.getName().equalsIgnoreCase(player.getName()))
|
||||||
{
|
{
|
||||||
dataMap.put(ip, data);
|
admin = loopAdmin;
|
||||||
return data;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
admin.setLastLogin(new Date());
|
||||||
|
admin.addIp(Ips.getIp(player));
|
||||||
|
plugin.al.updateTables();
|
||||||
|
plugin.al.save(admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void syncIps(Admin admin)
|
||||||
|
{
|
||||||
|
PlayerData playerData = getData(admin.getName());
|
||||||
|
playerData.clearIps();
|
||||||
|
playerData.addIps(admin.getIps());
|
||||||
|
plugin.pl.save(playerData);
|
||||||
|
}
|
||||||
|
public void syncIps(PlayerData playerData)
|
||||||
|
{
|
||||||
|
Admin admin = plugin.al.getEntryByName(playerData.getName());
|
||||||
|
|
||||||
|
if (admin != null && admin.isActive())
|
||||||
|
{
|
||||||
|
admin.clearIPs();
|
||||||
|
admin.addIps(playerData.getIps());
|
||||||
|
plugin.al.updateTables();
|
||||||
|
plugin.al.save(admin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void save(PlayerData player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet currentSave = plugin.sql.getPlayerByName(player.getName());
|
||||||
|
for (Map.Entry<String, Object> entry : player.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.setPlayerValue(player, entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (SQLException e)
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final String ip = Ips.getIp(player);
|
|
||||||
playerMap.remove(ip);
|
|
||||||
dataMap.remove(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<FPlayer> getLoadedPlayers()
|
|
||||||
{
|
|
||||||
return playerMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<PlayerData> getLoadedData()
|
|
||||||
{
|
|
||||||
return dataMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int purgeAllData()
|
|
||||||
{
|
|
||||||
int deleted = 0;
|
|
||||||
for (File file : getConfigFolder().listFiles())
|
|
||||||
{
|
{
|
||||||
deleted += file.delete() ? 1 : 0;
|
FLog.severe("Failed to save player: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerData getData(Player player)
|
||||||
|
{
|
||||||
|
// Check for existing data
|
||||||
|
PlayerData playerData = dataMap.get(player.getName());
|
||||||
|
if (playerData != null)
|
||||||
|
{
|
||||||
|
return playerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataMap.clear();
|
// Load data
|
||||||
return deleted;
|
playerData = loadByName(player.getName());
|
||||||
|
|
||||||
|
if (playerData == null)
|
||||||
|
{
|
||||||
|
playerData = loadByIp(Ips.getIp(player));
|
||||||
|
if (playerData != null)
|
||||||
|
{
|
||||||
|
plugin.sql.updatePlayerName(playerData.getName(),player.getName());
|
||||||
|
playerData.setName(player.getName());
|
||||||
|
dataMap.put(player.getName(), playerData);
|
||||||
|
return playerData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dataMap.put(player.getName(), playerData);
|
||||||
|
return playerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new data if nonexistent
|
||||||
|
if (playerData == null)
|
||||||
|
{
|
||||||
|
FLog.info("Creating new player verification entry for " + player.getName());
|
||||||
|
|
||||||
|
// Create new player
|
||||||
|
playerData = new PlayerData(player);
|
||||||
|
playerData.addIp(Ips.getIp(player));
|
||||||
|
|
||||||
|
// Store player
|
||||||
|
dataMap.put(player.getName(), playerData);
|
||||||
|
|
||||||
|
// Save player
|
||||||
|
plugin.sql.addPlayer(playerData);
|
||||||
|
return playerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getConfigFile(String name)
|
public PlayerData getData(String username)
|
||||||
{
|
{
|
||||||
return new File(getConfigFolder(), name + ".yml");
|
// Check for existing data
|
||||||
|
PlayerData playerData = dataMap.get(username);
|
||||||
|
if (playerData != null)
|
||||||
|
{
|
||||||
|
return playerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerData = loadByName(username);
|
||||||
|
|
||||||
|
if (playerData != null)
|
||||||
|
{
|
||||||
|
dataMap.put(username, playerData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return playerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected YamlConfig getConfig(PlayerData data)
|
public PlayerData getDataByIp(String ip)
|
||||||
{
|
{
|
||||||
final YamlConfig config = new YamlConfig(plugin, getConfigFile(data.getUsername().toLowerCase()), false);
|
PlayerData player = loadByIp(ip);
|
||||||
config.load();
|
|
||||||
return config;
|
if (player != null)
|
||||||
|
{
|
||||||
|
dataMap.put(player.getName(), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,203 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.playerverification;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class PlayerVerification extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public final Map<String, VPlayer> dataMap = Maps.newHashMap(); // username, data
|
|
||||||
@Getter
|
|
||||||
private final File configFolder;
|
|
||||||
|
|
||||||
public PlayerVerification(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
|
|
||||||
this.configFolder = new File(plugin.getDataFolder(), "playerverification");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
dataMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean isPlayerImpostor(Player player)
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = getVerificationPlayer(player);
|
|
||||||
return !plugin.al.isAdmin(player)
|
|
||||||
&& (vPlayer.getEnabled())
|
|
||||||
&& !vPlayer.getIps().contains(Ips.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void verifyPlayer(Player player, String backupCode)
|
|
||||||
{
|
|
||||||
if (!isPlayerImpostor(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VPlayer vPlayer = getVerificationPlayer(player);
|
|
||||||
if (backupCode != null)
|
|
||||||
{
|
|
||||||
vPlayer.removeBackupCode(backupCode);
|
|
||||||
}
|
|
||||||
vPlayer.addIp(Ips.getIp(player));
|
|
||||||
dataMap.put(player.getName(), vPlayer);
|
|
||||||
YamlConfig config = getConfig(vPlayer);
|
|
||||||
vPlayer.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveVerificationData(VPlayer player)
|
|
||||||
{
|
|
||||||
YamlConfig config = getConfig(player);
|
|
||||||
player.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
dataMap.put(player.getName(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeEntry(String name)
|
|
||||||
{
|
|
||||||
name = name.toLowerCase(); // Configuration files are saved in lowercase
|
|
||||||
if (getVerificationPlayer(name) != null)
|
|
||||||
{
|
|
||||||
getConfigFile(name).delete();
|
|
||||||
dataMap.remove(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
for (VPlayer vPlayer : dataMap.values())
|
|
||||||
{
|
|
||||||
YamlConfig config = getConfig(vPlayer);
|
|
||||||
vPlayer.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// May not return null
|
|
||||||
public VPlayer getVerificationPlayer(Player player)
|
|
||||||
{
|
|
||||||
// Check for existing data
|
|
||||||
VPlayer vPlayer = dataMap.get(player.getName());
|
|
||||||
if (vPlayer != null)
|
|
||||||
{
|
|
||||||
return vPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load data
|
|
||||||
vPlayer = getVerificationPlayer(player.getName());
|
|
||||||
|
|
||||||
// Create new data if nonexistent
|
|
||||||
if (vPlayer == null)
|
|
||||||
{
|
|
||||||
FLog.info("Creating new player verification entry for " + player.getName());
|
|
||||||
|
|
||||||
// Create new player
|
|
||||||
vPlayer = new VPlayer(player);
|
|
||||||
vPlayer.addIp(Ips.getIp(player));
|
|
||||||
|
|
||||||
// Store player
|
|
||||||
dataMap.put(player.getName(), vPlayer);
|
|
||||||
|
|
||||||
// Save player
|
|
||||||
YamlConfig config = getConfig(vPlayer);
|
|
||||||
vPlayer.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return vPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// May return null
|
|
||||||
public VPlayer getVerificationPlayer(String username)
|
|
||||||
{
|
|
||||||
username = username.toLowerCase();
|
|
||||||
|
|
||||||
final File configFile = getConfigFile(username);
|
|
||||||
if (!configFile.exists())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final VPlayer vPlayer = new VPlayer(username);
|
|
||||||
vPlayer.loadFrom(getConfig(vPlayer));
|
|
||||||
|
|
||||||
if (!vPlayer.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Could not load player verification entry for " + username + ". Entry is not valid!");
|
|
||||||
configFile.delete();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only store data in map if the player is online
|
|
||||||
for (Player players : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (players.getName().equals(username))
|
|
||||||
{
|
|
||||||
dataMap.put(username, vPlayer);
|
|
||||||
return vPlayer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
dataMap.remove(event.getPlayer().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected File getConfigFile(String name)
|
|
||||||
{
|
|
||||||
return new File(getConfigFolder(), name + ".yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected YamlConfig getConfig(VPlayer player)
|
|
||||||
{
|
|
||||||
final YamlConfig config = new YamlConfig(plugin, getConfigFile(player.getName().toLowerCase()), false);
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
// Convert discordEnabled to enabled, and remove forumEnabled.
|
|
||||||
if (config.get("discordEnabled") != null)
|
|
||||||
{
|
|
||||||
config.set("enabled", config.getBoolean("discordEnabled"));
|
|
||||||
config.set("discordEnabled", null);
|
|
||||||
config.set("forumEnabled", null);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
config.save(getConfigFile(player.getName().toLowerCase()));
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
FLog.warning("Failed to convert player verification entry for " + player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,166 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.playerverification;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
|
|
||||||
{
|
|
||||||
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
|
||||||
private final List<Map<?, ?>> notes = Lists.newArrayList();
|
|
||||||
private final List<String> backupCodes = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String name;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String discordId = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String forumUsername = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean enabled = false;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String tag = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private boolean clearChatOptOut = false;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String rideMode = "ask";
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private int utcOffset = 0;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private boolean realTime = false;
|
|
||||||
|
|
||||||
public VPlayer(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VPlayer(Player player)
|
|
||||||
{
|
|
||||||
this(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
name = cs.getString("name", name);
|
|
||||||
ips.clear();
|
|
||||||
ips.addAll(cs.getStringList("ips"));
|
|
||||||
notes.clear();
|
|
||||||
notes.addAll(cs.getMapList("notes"));
|
|
||||||
backupCodes.clear();
|
|
||||||
backupCodes.addAll(cs.getStringList("backupCodes"));
|
|
||||||
discordId = cs.getString("discordId", null);
|
|
||||||
enabled = cs.getBoolean("enabled", false);
|
|
||||||
tag = cs.getString("tag", null);
|
|
||||||
clearChatOptOut = cs.getBoolean("clearChatOptOut", false);
|
|
||||||
rideMode = cs.getString("rideMode", rideMode);
|
|
||||||
utcOffset = cs.getInt("utcOffset", 0);
|
|
||||||
realTime = cs.getBoolean("realTime", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
Validate.isTrue(isValid(), "Could not save player verification entry: " + name + ". Entry not valid!");
|
|
||||||
cs.set("name", name);
|
|
||||||
cs.set("discordId", discordId);
|
|
||||||
cs.set("enabled", enabled);
|
|
||||||
cs.set("tag", tag);
|
|
||||||
cs.set("ips", Lists.newArrayList(ips));
|
|
||||||
cs.set("notes", Lists.newArrayList(notes));
|
|
||||||
cs.set("backupCodes", Lists.newArrayList(backupCodes));
|
|
||||||
cs.set("clearChatOptOut", clearChatOptOut);
|
|
||||||
cs.set("rideMode", rideMode);
|
|
||||||
cs.set("utcOffset", utcOffset);
|
|
||||||
cs.set("realTime", realTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getIps()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(ips);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean addIp(String ip)
|
|
||||||
{
|
|
||||||
return !ips.contains(ip) && ips.add(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeIp(String ip)
|
|
||||||
{
|
|
||||||
ips.remove(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map<?, ?>> getNotes()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(notes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearNotes()
|
|
||||||
{
|
|
||||||
notes.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getBackupCodes()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(backupCodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackupCodes(List<String> codes)
|
|
||||||
{
|
|
||||||
backupCodes.clear();
|
|
||||||
backupCodes.addAll(codes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBackupCode(String code)
|
|
||||||
{
|
|
||||||
FLog.info("fuck");
|
|
||||||
backupCodes.remove(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNote(String adder, String note)
|
|
||||||
{
|
|
||||||
|
|
||||||
Map<String, String> noteMap = new HashMap<>();
|
|
||||||
noteMap.put(adder, note);
|
|
||||||
notes.add(noteMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean removeNote(int id) throws IndexOutOfBoundsException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
notes.remove(id);
|
|
||||||
}
|
|
||||||
catch (IndexOutOfBoundsException e)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return name != null && !ips.isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.rank;
|
package me.totalfreedom.totalfreedommod.rank;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
public interface Displayable
|
public interface Displayable
|
||||||
{
|
{
|
||||||
@ -13,12 +13,15 @@ public interface Displayable
|
|||||||
|
|
||||||
public ChatColor getColor();
|
public ChatColor getColor();
|
||||||
|
|
||||||
|
public org.bukkit.ChatColor getTeamColor();
|
||||||
|
|
||||||
public String getColoredName();
|
public String getColoredName();
|
||||||
|
|
||||||
public String getColoredTag();
|
public String getColoredTag();
|
||||||
|
|
||||||
public String getColoredLoginMessage();
|
public String getColoredLoginMessage();
|
||||||
|
|
||||||
|
|
||||||
public boolean hasTeam();
|
public boolean hasTeam();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
package me.totalfreedom.totalfreedommod.rank;
|
package me.totalfreedom.totalfreedommod.rank;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
public enum Rank implements Displayable
|
public enum Rank implements Displayable
|
||||||
{
|
{
|
||||||
|
|
||||||
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW, false),
|
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW, null, false),
|
||||||
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE, false),
|
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE, null, false),
|
||||||
OP("an", "Operator", Type.PLAYER, "OP", ChatColor.GREEN, false),
|
OP("an", "Operator", Type.PLAYER, "OP", ChatColor.GREEN, null, false),
|
||||||
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA, true),
|
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA, org.bukkit.ChatColor.AQUA, true),
|
||||||
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN, true),
|
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN, org.bukkit.ChatColor.DARK_GREEN, true),
|
||||||
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD, true),
|
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD, org.bukkit.ChatColor.GOLD, true),
|
||||||
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false),
|
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, null, false),
|
||||||
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false);
|
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, null, false);
|
||||||
@Getter
|
@Getter
|
||||||
private final Type type;
|
private final Type type;
|
||||||
@Getter
|
@Getter
|
||||||
@ -28,9 +28,11 @@ public enum Rank implements Displayable
|
|||||||
@Getter
|
@Getter
|
||||||
private final ChatColor color;
|
private final ChatColor color;
|
||||||
@Getter
|
@Getter
|
||||||
|
private final org.bukkit.ChatColor teamColor;
|
||||||
|
@Getter
|
||||||
private final boolean hasTeam;
|
private final boolean hasTeam;
|
||||||
|
|
||||||
private Rank(String determiner, String name, Type type, String abbr, ChatColor color, Boolean hasTeam)
|
private Rank(String determiner, String name, Type type, String abbr, ChatColor color, org.bukkit.ChatColor teamColor, Boolean hasTeam)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -39,6 +41,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.teamColor = teamColor;
|
||||||
this.hasTeam = hasTeam;
|
this.hasTeam = hasTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,10 +5,8 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
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.player.PlayerData;
|
||||||
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 org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -81,11 +79,17 @@ public class RankManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Master builders show up if they are not admins
|
// Master builders show up if they are not admins
|
||||||
if (plugin.mbl.isMasterBuilder(player) && !plugin.al.isAdmin(player))
|
if (plugin.pl.getData(player).isMasterBuilder() && !plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
return Title.MASTER_BUILDER;
|
return Title.MASTER_BUILDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
|
if (!plugin.al.isAdmin(player) && playerData.isDonator())
|
||||||
|
{
|
||||||
|
return Title.DONATOR;
|
||||||
|
}
|
||||||
|
|
||||||
return getRank(player);
|
return getRank(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +149,7 @@ public class RankManager extends FreedomService
|
|||||||
|
|
||||||
public Rank getRank(Player player)
|
public Rank getRank(Player player)
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdminImpostor(player) || plugin.pv.isPlayerImpostor(player) || plugin.mbl.isMasterBuilderImpostor(player))
|
if (plugin.al.isAdminImpostor(player) || plugin.pl.isPlayerImpostor(player))
|
||||||
{
|
{
|
||||||
return Rank.IMPOSTOR;
|
return Rank.IMPOSTOR;
|
||||||
}
|
}
|
||||||
@ -159,6 +163,20 @@ public class RankManager extends FreedomService
|
|||||||
return player.isOp() ? Rank.OP : Rank.NON_OP;
|
return player.isOp() ? Rank.OP : Rank.NON_OP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTag(Player player, String defaultTag)
|
||||||
|
{
|
||||||
|
String tag = defaultTag;
|
||||||
|
|
||||||
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
|
String t = playerData.getTag();
|
||||||
|
if (t != null && !t.isEmpty())
|
||||||
|
{
|
||||||
|
tag = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateDisplay(Player player)
|
public void updateDisplay(Player player)
|
||||||
{
|
{
|
||||||
if (!player.isOnline())
|
if (!player.isOnline())
|
||||||
@ -166,18 +184,19 @@ public class RankManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
if (plugin.al.isAdmin(player))
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
Displayable display = getDisplay(player);
|
||||||
|
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || data.isDonator() || FUtil.isDeveloper(player.getName()))
|
||||||
{
|
{
|
||||||
Displayable display = getDisplay(player);
|
|
||||||
fPlayer.setTag(display.getColoredTag());
|
|
||||||
String displayName = display.getColor() + player.getName();
|
String displayName = display.getColor() + player.getName();
|
||||||
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
player.setPlayerListName(displayName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fPlayer.setTag(null);
|
fPlayer.setTag(null);
|
||||||
player.setPlayerListName(null);
|
player.setPlayerListName(null);
|
||||||
}
|
}
|
||||||
|
fPlayer.setTag(getTag(player, display.getColoredTag()));
|
||||||
updatePlayerTeam(player);
|
updatePlayerTeam(player);
|
||||||
plugin.pem.setPermissions(player);
|
plugin.pem.setPermissions(player);
|
||||||
}
|
}
|
||||||
@ -186,9 +205,8 @@ public class RankManager extends FreedomService
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
//plugin.pl.getData(player);
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
VPlayer target = plugin.pv.getVerificationPlayer(player);
|
PlayerData target = plugin.pl.getData(player);
|
||||||
|
|
||||||
// Unban admins
|
// Unban admins
|
||||||
boolean isAdmin = plugin.al.isAdmin(player);
|
boolean isAdmin = plugin.al.isAdmin(player);
|
||||||
@ -213,7 +231,7 @@ public class RankManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle impostors
|
// Handle impostors
|
||||||
boolean isImpostor = plugin.al.isAdminImpostor(player) || plugin.pv.isPlayerImpostor(player) || plugin.mbl.isMasterBuilderImpostor(player);
|
boolean isImpostor = plugin.al.isAdminImpostor(player) || plugin.pl.isPlayerImpostor(player);
|
||||||
if (isImpostor)
|
if (isImpostor)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + Rank.IMPOSTOR.getColoredLoginMessage());
|
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + Rank.IMPOSTOR.getColoredLoginMessage());
|
||||||
@ -221,11 +239,7 @@ public class RankManager extends FreedomService
|
|||||||
{
|
{
|
||||||
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an admin impostor and has been frozen!", ChatColor.RED);
|
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an admin impostor and has been frozen!", ChatColor.RED);
|
||||||
}
|
}
|
||||||
else if (plugin.mbl.isMasterBuilderImpostor(player))
|
else if (plugin.pl.isPlayerImpostor(player))
|
||||||
{
|
|
||||||
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as a Master Builder impostor and has been frozen!", ChatColor.RED);
|
|
||||||
}
|
|
||||||
else if (plugin.pv.isPlayerImpostor(player))
|
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as a player impostor and has been frozen!", ChatColor.RED);
|
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as a player impostor and has been frozen!", ChatColor.RED);
|
||||||
}
|
}
|
||||||
@ -240,7 +254,7 @@ public class RankManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set display
|
// Set display
|
||||||
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.mbl.isMasterBuilder(player))
|
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.pl.getData(player).isMasterBuilder() || plugin.pl.getData(player).isDonator())
|
||||||
{
|
{
|
||||||
final Displayable display = getDisplay(player);
|
final Displayable display = getDisplay(player);
|
||||||
|
|
||||||
@ -249,11 +263,11 @@ public class RankManager extends FreedomService
|
|||||||
updateDisplay(player);
|
updateDisplay(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.pv.isPlayerImpostor(player) && target.getEnabled())
|
if (!plugin.pl.isPlayerImpostor(player) && target.hasVerification())
|
||||||
{
|
{
|
||||||
if (target.getTag() != null)
|
if (target.getTag() != null)
|
||||||
{
|
{
|
||||||
plugin.pl.getPlayer(player).setTag(FUtil.colorize(target.getTag()));
|
plugin.pl.getData(player).setTag(FUtil.colorize(target.getTag()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,25 +296,27 @@ public class RankManager extends FreedomService
|
|||||||
|
|
||||||
public void updatePlayerTeam(Player player)
|
public void updatePlayerTeam(Player player)
|
||||||
{
|
{
|
||||||
FLog.info("Updating team data...");
|
|
||||||
Displayable display = getDisplay(player);
|
Displayable display = getDisplay(player);
|
||||||
Scoreboard scoreboard = server.getScoreboardManager().getMainScoreboard();
|
Scoreboard scoreboard = server.getScoreboardManager().getMainScoreboard();
|
||||||
Team team = scoreboard.getPlayerTeam(player);
|
Team team = scoreboard.getPlayerTeam(player);
|
||||||
if (team != null && !display.hasTeam())
|
if (!display.hasTeam())
|
||||||
{
|
{
|
||||||
FLog.info("Removing from team");
|
if (team != null)
|
||||||
team.removePlayer(player);
|
{
|
||||||
|
team.removePlayer(player);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
team = scoreboard.getTeam(display.toString());
|
String name = StringUtils.substring(display.toString(), 0, 16);
|
||||||
|
team = scoreboard.getTeam(name);
|
||||||
if (team == null)
|
if (team == null)
|
||||||
{
|
{
|
||||||
FLog.info("Creating team...");
|
team = scoreboard.registerNewTeam(name);
|
||||||
team = scoreboard.registerNewTeam(display.toString());
|
team.setColor(display.getTeamColor());
|
||||||
FLog.info("Created team " + team.getName());
|
}
|
||||||
team.setColor(display.getColor());
|
if (!team.hasPlayer(player))
|
||||||
|
{
|
||||||
|
team.addPlayer(player);
|
||||||
}
|
}
|
||||||
team.addPlayer(player);
|
|
||||||
FLog.info("Added player to team");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package me.totalfreedom.totalfreedommod.rank;
|
package me.totalfreedom.totalfreedommod.rank;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
public enum Title implements Displayable
|
public enum Title implements Displayable
|
||||||
{
|
{
|
||||||
|
|
||||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB", false),
|
DONATOR("a", "Very Important Person", ChatColor.of("#ff5600"), org.bukkit.ChatColor.LIGHT_PURPLE, "VIP", true), // turn to orange in 1.16
|
||||||
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, "VA", false),
|
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, org.bukkit.ChatColor.DARK_AQUA, "MB", true),
|
||||||
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, "Asst Exec", false),
|
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, org.bukkit.ChatColor.LIGHT_PURPLE, "VA", false),
|
||||||
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec", true),
|
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Asst Exec", true),
|
||||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev", true),
|
EXECUTIVE("an", "Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Exec", true),
|
||||||
OWNER("the", "Owner", ChatColor.DARK_RED, "Owner", true);
|
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, org.bukkit.ChatColor.DARK_PURPLE, "Dev", true),
|
||||||
|
OWNER("the", "Owner", ChatColor.of("#ff0000"), org.bukkit.ChatColor.DARK_RED, "Owner", true);
|
||||||
|
|
||||||
private final String determiner;
|
private final String determiner;
|
||||||
@Getter
|
@Getter
|
||||||
@ -25,9 +26,11 @@ public enum Title implements Displayable
|
|||||||
@Getter
|
@Getter
|
||||||
private final ChatColor color;
|
private final ChatColor color;
|
||||||
@Getter
|
@Getter
|
||||||
|
private final org.bukkit.ChatColor teamColor;
|
||||||
|
@Getter
|
||||||
private final boolean hasTeam;
|
private final boolean hasTeam;
|
||||||
|
|
||||||
private Title(String determiner, String name, ChatColor color, String tag, Boolean hasTeam)
|
private Title(String determiner, String name, ChatColor color, org.bukkit.ChatColor teamColor, String tag, Boolean hasTeam)
|
||||||
{
|
{
|
||||||
this.determiner = determiner;
|
this.determiner = determiner;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -35,6 +38,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.teamColor = teamColor;
|
||||||
this.hasTeam = hasTeam;
|
this.hasTeam = hasTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +1,24 @@
|
|||||||
package me.totalfreedom.totalfreedommod.shop;
|
package me.totalfreedom.totalfreedommod.shop;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.vexsoftware.votifier.model.Vote;
|
import com.vexsoftware.votifier.model.Vote;
|
||||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.rayzr522.jsonmessage.JSONMessage;
|
import me.rayzr522.jsonmessage.JSONMessage;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
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 org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
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.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -37,10 +27,6 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
public class Shop extends FreedomService
|
public class Shop extends FreedomService
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
public final Map<String, ShopData> dataMap = Maps.newHashMap();
|
|
||||||
@Getter
|
|
||||||
private final File configFolder;
|
|
||||||
private BukkitTask reactions;
|
private BukkitTask reactions;
|
||||||
public String reactionString = "";
|
public String reactionString = "";
|
||||||
public Date reactionStartTime;
|
public Date reactionStartTime;
|
||||||
@ -49,14 +35,11 @@ public class Shop extends FreedomService
|
|||||||
public Shop(TotalFreedomMod plugin)
|
public Shop(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
|
||||||
this.configFolder = new File(plugin.getDataFolder(), "shopdata");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
dataMap.clear();
|
|
||||||
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
long interval = ConfigEntry.SHOP_REACTIONS_INTERVAL.getInteger() * 20L;
|
long interval = ConfigEntry.SHOP_REACTIONS_INTERVAL.getInteger() * 20L;
|
||||||
@ -87,26 +70,12 @@ public class Shop extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
for (ShopData sd : dataMap.values())
|
|
||||||
{
|
|
||||||
save(sd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
reactions.cancel();
|
reactions.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(ShopData data)
|
|
||||||
{
|
|
||||||
YamlConfig config = getConfig(data);
|
|
||||||
data.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
dataMap.remove(data.getUsername());
|
|
||||||
dataMap.put(data.getUsername(), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShopPrefix()
|
public String getShopPrefix()
|
||||||
{
|
{
|
||||||
return FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString());
|
return FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString());
|
||||||
@ -117,82 +86,7 @@ public class Shop extends FreedomService
|
|||||||
return FUtil.colorize(ConfigEntry.SHOP_TITLE.getString());
|
return FUtil.colorize(ConfigEntry.SHOP_TITLE.getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// May not return null
|
public Inventory generateShopGUI(PlayerData playerData)
|
||||||
public ShopData getData(Player player)
|
|
||||||
{
|
|
||||||
// Check for existing data
|
|
||||||
ShopData data = dataMap.get(player.getName());
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load data
|
|
||||||
data = getData(player.getName());
|
|
||||||
|
|
||||||
String ip = Ips.getIp(player);
|
|
||||||
|
|
||||||
// Create new data if nonexistent
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
FLog.info("Creating new player verification entry for " + player.getName());
|
|
||||||
|
|
||||||
// Create new player
|
|
||||||
data = new ShopData(player);
|
|
||||||
data.addIp(Ips.getIp(player));
|
|
||||||
|
|
||||||
// Store player
|
|
||||||
dataMap.put(player.getName(), data);
|
|
||||||
|
|
||||||
// Save player
|
|
||||||
YamlConfig config = getConfig(data);
|
|
||||||
data.saveTo(config);
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!data.getsIps().contains(ip))
|
|
||||||
{
|
|
||||||
data.addIp(ip);
|
|
||||||
save(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopData getData(String username)
|
|
||||||
{
|
|
||||||
username = username.toLowerCase();
|
|
||||||
|
|
||||||
final File configFile = getConfigFile(username);
|
|
||||||
if (!configFile.exists())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ShopData shopData = new ShopData(username);
|
|
||||||
shopData.loadFrom(getConfig(shopData));
|
|
||||||
|
|
||||||
if (!shopData.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Could not load player verification entry for " + username + ". Entry is not valid!");
|
|
||||||
configFile.delete();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only store data in map if the player is online
|
|
||||||
for (Player players : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (players.getName().equals(username))
|
|
||||||
{
|
|
||||||
dataMap.put(username, shopData);
|
|
||||||
return shopData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return shopData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Inventory generateShopGUI(ShopData shopData)
|
|
||||||
{
|
{
|
||||||
Inventory gui = server.createInventory(null, 36, getShopTitle());
|
Inventory gui = server.createInventory(null, 36, getShopTitle());
|
||||||
for (int slot = 0; slot < 36; slot++)
|
for (int slot = 0; slot < 36; slot++)
|
||||||
@ -205,19 +99,19 @@ public class Shop extends FreedomService
|
|||||||
}
|
}
|
||||||
for (ShopItem shopItem : ShopItem.values())
|
for (ShopItem shopItem : ShopItem.values())
|
||||||
{
|
{
|
||||||
ItemStack item = shopGUIItem(shopItem, shopData);
|
ItemStack item = shopGUIItem(shopItem, playerData);
|
||||||
gui.setItem(shopItem.getSlot(), item);
|
gui.setItem(shopItem.getSlot(), item);
|
||||||
}
|
}
|
||||||
// Coins
|
// Coins
|
||||||
ItemStack coins = new ItemStack(Material.GOLD_NUGGET);
|
ItemStack coins = new ItemStack(Material.GOLD_NUGGET);
|
||||||
ItemMeta meta = coins.getItemMeta();
|
ItemMeta meta = coins.getItemMeta();
|
||||||
meta.setDisplayName(FUtil.colorize("&c&lYou have &e&l" + shopData.getCoins() + "&c&l coins"));
|
meta.setDisplayName(FUtil.colorize("&c&lYou have &e&l" + playerData.getCoins() + "&c&l coins"));
|
||||||
coins.setItemMeta(meta);
|
coins.setItemMeta(meta);
|
||||||
gui.setItem(35, coins);
|
gui.setItem(35, coins);
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRealItem(ShopData data, ShopItem shopItem, ItemStack givenItem, ItemStack realItem)
|
public boolean isRealItem(PlayerData data, ShopItem shopItem, ItemStack givenItem, ItemStack realItem)
|
||||||
{
|
{
|
||||||
if (!data.hasItem(shopItem) || !givenItem.getType().equals(realItem.getType()))
|
if (!data.hasItem(shopItem) || !givenItem.getType().equals(realItem.getType()))
|
||||||
{
|
{
|
||||||
@ -292,7 +186,7 @@ public class Shop extends FreedomService
|
|||||||
return price - coins;
|
return price - coins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack shopGUIItem(ShopItem item, ShopData data)
|
public ItemStack shopGUIItem(ShopItem item, PlayerData data)
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(item.getIcon());
|
ItemStack itemStack = new ItemStack(item.getIcon());
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
@ -341,18 +235,18 @@ public class Shop extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
ShopData shopData = getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
int price = shopItem.getCost();
|
int price = shopItem.getCost();
|
||||||
int coins = shopData.getCoins();
|
int coins = playerData.getCoins();
|
||||||
|
|
||||||
if (shopData.hasItem(shopItem) || !plugin.sh.canAfford(price, coins))
|
if (playerData.hasItem(shopItem) || !plugin.sh.canAfford(price, coins))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shopData.giveItem(shopItem);
|
playerData.giveItem(shopItem);
|
||||||
shopData.setCoins(coins - price);
|
playerData.setCoins(coins - price);
|
||||||
save(shopData);
|
plugin.pl.save(playerData);
|
||||||
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|
||||||
@ -389,13 +283,6 @@ public class Shop extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
final String ip = Ips.getIp(event.getPlayer());
|
|
||||||
dataMap.remove(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerVote(VotifierEvent event)
|
public void onPlayerVote(VotifierEvent event)
|
||||||
{
|
{
|
||||||
@ -403,21 +290,21 @@ public class Shop extends FreedomService
|
|||||||
String name = vote.getUsername();
|
String name = vote.getUsername();
|
||||||
int coinsPerVote = ConfigEntry.SHOP_COINS_PER_VOTE.getInteger();
|
int coinsPerVote = ConfigEntry.SHOP_COINS_PER_VOTE.getInteger();
|
||||||
Player player = server.getPlayer(name);
|
Player player = server.getPlayer(name);
|
||||||
ShopData data = null;
|
PlayerData data = null;
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
data = plugin.sh.getData(player);
|
data = plugin.pl.getData(player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = plugin.sh.getData(name);
|
data = plugin.pl.getData(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
data.setCoins(data.getCoins() + coinsPerVote);
|
data.setCoins(data.getCoins() + coinsPerVote);
|
||||||
data.setTotalVotes(data.getTotalVotes() + 1);
|
data.setTotalVotes(data.getTotalVotes() + 1);
|
||||||
save(data);
|
plugin.pl.save(data);
|
||||||
FUtil.bcastMsg(ChatColor.GREEN + name + ChatColor.AQUA + " has voted for us on " + ChatColor.GREEN + vote.getServiceName() + ChatColor.AQUA + "!");
|
FUtil.bcastMsg(ChatColor.GREEN + name + ChatColor.AQUA + " has voted for us on " + ChatColor.GREEN + vote.getServiceName() + ChatColor.AQUA + "!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,21 +313,4 @@ public class Shop extends FreedomService
|
|||||||
player.sendMessage(ChatColor.GREEN + "Thank you for voting for us! Here are " + coinsPerVote + " coins!");
|
player.sendMessage(ChatColor.GREEN + "Thank you for voting for us! Here are " + coinsPerVote + " coins!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ShopData> getLoadedData()
|
|
||||||
{
|
|
||||||
return dataMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected File getConfigFile(String name)
|
|
||||||
{
|
|
||||||
return new File(getConfigFolder(), name.toLowerCase() + ".yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected YamlConfig getConfig(ShopData data)
|
|
||||||
{
|
|
||||||
final YamlConfig config = new YamlConfig(plugin, getConfigFile(data.getUsername()), false);
|
|
||||||
config.load();
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,107 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.shop;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
|
|
||||||
{
|
|
||||||
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String username;
|
|
||||||
private String uuid;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private int coins;
|
|
||||||
private List<String> items = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private int totalVotes;
|
|
||||||
|
|
||||||
public ShopData(Player player)
|
|
||||||
{
|
|
||||||
this(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopData(String name)
|
|
||||||
{
|
|
||||||
this.username = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
this.username = cs.getString("username", username);
|
|
||||||
this.ips.addAll(cs.getStringList("ips"));
|
|
||||||
this.coins = cs.getInt("coins", coins);
|
|
||||||
this.items.addAll(cs.getStringList("items"));
|
|
||||||
this.totalVotes = cs.getInt("totalVotes");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
Validate.isTrue(isValid(), "Could not save shop entry: " + username + ". Entry not valid!");
|
|
||||||
cs.set("username", username);
|
|
||||||
cs.set("ips", ips);
|
|
||||||
cs.set("coins", coins);
|
|
||||||
cs.set("items", items);
|
|
||||||
cs.set("totalVotes", totalVotes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getItems()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void giveItem(ShopItem item)
|
|
||||||
{
|
|
||||||
items.add(item.getDataName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasItem(ShopItem item)
|
|
||||||
{
|
|
||||||
if (items.contains(item.getDataName()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean addIp(String ip)
|
|
||||||
{
|
|
||||||
return !ips.contains(ip) && ips.add(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeIp(String ip)
|
|
||||||
{
|
|
||||||
ips.remove(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getsIps()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(ips);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeItem(ShopItem item)
|
|
||||||
{
|
|
||||||
items.remove(item.getDataName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return username != null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,6 +11,7 @@ import me.totalfreedom.totalfreedommod.FreedomService;
|
|||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
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 );");
|
connection.createStatement().execute("CREATE TABLE `bans` ( `name` VARCHAR, `ips` VARCHAR, `by` VARCHAR NOT NULL, `at` LONG NOT NULL, `expires` LONG, `reason` VARCHAR );");
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -89,13 +90,24 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
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);");
|
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, `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)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
FLog.severe("Failed to create the admins table: " + e.getMessage());
|
FLog.severe("Failed to create the admins table: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!tableExists(meta, "players"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().execute("CREATE TABLE `players` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `notes` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `backup_codes` VARCHAR, `donator` BOOLEAN NOT NULL, `master_builder` BOOLEAN NOT NULL,`verification` BOOLEAN NOT NULL, `ride_mode` VARCHAR NOT NULL, `coins` INT NOT NULL, `items` VARCHAR, `total_votes` INT NOT NULL);");
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to create the players table: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -107,7 +119,7 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection.createStatement().execute("TRUNCATE TABLE " + table);
|
connection.createStatement().execute("DELETE FROM " + table);
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -120,7 +132,6 @@ public class SQLite extends FreedomService
|
|||||||
return connection.createStatement().executeQuery("SELECT * FROM bans");
|
return connection.createStatement().executeQuery("SELECT * FROM bans");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ResultSet getAdminList() throws SQLException
|
public ResultSet getAdminList() throws SQLException
|
||||||
{
|
{
|
||||||
return connection.createStatement().executeQuery("SELECT * FROM admins");
|
return connection.createStatement().executeQuery("SELECT * FROM admins");
|
||||||
@ -138,7 +149,24 @@ public class SQLite extends FreedomService
|
|||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
FLog.severe("Failed to update value: " + e.getMessage());
|
FLog.severe("Failed to update admin value: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerValue(PlayerData player, String key, Object value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Object[] data = {key, player.getName()};
|
||||||
|
PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE players SET {0}=? WHERE username=''{1}''", data));
|
||||||
|
FLog.info(statement.toString());
|
||||||
|
statement = setUnknownType(statement, 1, value);
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to update player value: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +181,22 @@ public class SQLite extends FreedomService
|
|||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
FLog.severe("Failed to update value: " + e.getMessage());
|
FLog.severe("Failed to update admin name: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePlayerName(String oldName, String newName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE players SET username=? WHERE username=''{0}''", oldName));
|
||||||
|
statement = setUnknownType(statement, 1, newName);
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to update player name: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,21 +251,18 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO admins VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO admins VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
statement.setString(1, admin.getName());
|
statement.setString(1, admin.getName());
|
||||||
statement.setString(2, FUtil.listToString(admin.getIps()));
|
statement.setString(2, FUtil.listToString(admin.getIps()));
|
||||||
statement.setString(3, admin.getRank().toString());
|
statement.setString(3, admin.getRank().toString());
|
||||||
statement.setBoolean(4, admin.isActive());
|
statement.setBoolean(4, admin.isActive());
|
||||||
statement.setLong(5, admin.getLastLogin().getTime());
|
statement.setLong(5, admin.getLastLogin().getTime());
|
||||||
statement.setString(6, admin.getLoginMessage());
|
statement.setString(6, admin.getLoginMessage());
|
||||||
statement.setString(7, admin.getTag());
|
statement.setBoolean(7, admin.getCommandSpy());
|
||||||
statement.setString(8, admin.getDiscordID());
|
statement.setBoolean(8, admin.getPotionSpy());
|
||||||
statement.setString(9, FUtil.listToString(admin.getBackupCodes()));
|
statement.setString(9, admin.getAcFormat());
|
||||||
statement.setBoolean(10, admin.getCommandSpy());
|
statement.setBoolean(10, admin.getOldTags());
|
||||||
statement.setBoolean(11, admin.getPotionSpy());
|
statement.setBoolean(11, admin.getLogStick());
|
||||||
statement.setString(12, admin.getAcFormat());
|
|
||||||
statement.setBoolean(13, admin.getOldTags());
|
|
||||||
statement.setBoolean(14, admin.getLogStick());
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@ -231,6 +271,32 @@ public class SQLite extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPlayer(PlayerData player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO players VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
statement.setString(1, player.getName());
|
||||||
|
statement.setString(2, FUtil.listToString(player.getIps()));
|
||||||
|
statement.setString(3, FUtil.listToString(player.getNotes()));
|
||||||
|
statement.setString(4, player.getTag());
|
||||||
|
statement.setString(5, player.getDiscordID());
|
||||||
|
statement.setString(6, FUtil.listToString(player.getBackupCodes()));
|
||||||
|
statement.setBoolean(7, player.isDonator());
|
||||||
|
statement.setBoolean(8, player.isMasterBuilder());
|
||||||
|
statement.setBoolean(9, player.hasVerification());
|
||||||
|
statement.setString(10, player.getRideMode());
|
||||||
|
statement.setInt(11, player.getCoins());
|
||||||
|
statement.setString(12, FUtil.listToString(player.getItems()));
|
||||||
|
statement.setInt(13, player.getTotalVotes());
|
||||||
|
statement.executeUpdate();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to add player: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ResultSet getAdminByName(String name)
|
public ResultSet getAdminByName(String name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -249,12 +315,65 @@ public class SQLite extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAdmin(Admin admin)
|
public ResultSet getPlayerByName(String name)
|
||||||
{
|
{
|
||||||
Object[] data = {admin.getName(), FUtil.listToString(admin.getBackupCodes())};
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans where name=''{0}'' and ips=''{1}''", data));
|
ResultSet resultSet = connection.createStatement().executeQuery(MessageFormat.format("SELECT * FROM players WHERE username=''{0}''", name));
|
||||||
|
if (resultSet.next())
|
||||||
|
{
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get player by name: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultSet getMasterBuilders()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet resultSet = connection.createStatement().executeQuery("SELECT * FROM players WHERE master_builder=true");
|
||||||
|
if (resultSet.next())
|
||||||
|
{
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get Master Builders: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultSet getPlayerByIp(String ip)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet resultSet = connection.createStatement().executeQuery(MessageFormat.format("SELECT * FROM players WHERE ips LIKE ''%{0}%''", ip));
|
||||||
|
if (resultSet.next())
|
||||||
|
{
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get player by ip: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAdmin(Admin admin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM admins where name=''{0}''", admin.getName()));
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -283,10 +402,13 @@ public class SQLite extends FreedomService
|
|||||||
|
|
||||||
public void removeBan(Ban ban)
|
public void removeBan(Ban ban)
|
||||||
{
|
{
|
||||||
Object[] data = {ban.getUsername(), String.join(", ", ban.getIps())};
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans where name=''{0}'' and ips=''{1}''", data));
|
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans WHERE name=''{0}''", ban.getUsername()));
|
||||||
|
for (String ip : ban.getIps())
|
||||||
|
{
|
||||||
|
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans WHERE ips LIKE ''%{0}%''", ip));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@ import java.util.regex.Pattern;
|
|||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
@ -52,7 +53,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");
|
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "supernt");
|
||||||
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(
|
||||||
@ -124,11 +125,6 @@ public class FUtil
|
|||||||
return FUtil.DEVELOPERS.contains(name);
|
return FUtil.DEVELOPERS.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canManageMasterBuilders(String name)
|
|
||||||
{
|
|
||||||
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_MASTER_BUILDER_MANAGEMENT.getStringList().contains(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatName(String name)
|
public static String formatName(String name)
|
||||||
{
|
{
|
||||||
return WordUtils.capitalizeFully(name.replace("_", " "));
|
return WordUtils.capitalizeFully(name.replace("_", " "));
|
||||||
@ -191,7 +187,10 @@ public class FUtil
|
|||||||
{
|
{
|
||||||
JSONArray json = new JSONArray();
|
JSONArray json = new JSONArray();
|
||||||
json.add(name);
|
json.add(name);
|
||||||
String response = postRequestToEndpoint("https://api.mojang.com/profiles/minecraft", json.toString());
|
List<String> headers = new ArrayList<>();
|
||||||
|
headers.add("Accept:application/json");
|
||||||
|
headers.add("Content-Type:application/json");
|
||||||
|
String response = postRequestToEndpoint("https://api.mojang.com/profiles/minecraft", "POST", headers, json.toString());
|
||||||
// Don't care how stupid this looks, couldn't find anything to parse a json string to something readable in java with something not horrendously huge, maybe im just retarded
|
// Don't care how stupid this looks, couldn't find anything to parse a json string to something readable in java with something not horrendously huge, maybe im just retarded
|
||||||
Pattern pattern = Pattern.compile("(?<=\"id\":\")[a-f0-9].{31}");
|
Pattern pattern = Pattern.compile("(?<=\"id\":\")[a-f0-9].{31}");
|
||||||
Matcher matcher = pattern.matcher(response);
|
Matcher matcher = pattern.matcher(response);
|
||||||
@ -208,13 +207,16 @@ public class FUtil
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String postRequestToEndpoint(String endpoint, String body) throws IOException
|
public static String postRequestToEndpoint(String endpoint, String method, List<String>headers, String body) throws IOException
|
||||||
{
|
{
|
||||||
URL url = new URL(endpoint);
|
URL url = new URL(endpoint);
|
||||||
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
|
||||||
connection.setRequestMethod("POST");
|
connection.setRequestMethod(method);
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
for (String header : headers)
|
||||||
connection.setRequestProperty("Content-Type", "application/json");
|
{
|
||||||
|
String[] kv = header.split(":");
|
||||||
|
connection.setRequestProperty(kv[0], kv[1]);
|
||||||
|
}
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||||
outputStream.writeBytes(body);
|
outputStream.writeBytes(body);
|
||||||
@ -556,7 +558,15 @@ public class FUtil
|
|||||||
|
|
||||||
public static String colorize(String string)
|
public static String colorize(String string)
|
||||||
{
|
{
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
Matcher matcher = Pattern.compile("&#[a-f0-9]{6}").matcher(string);
|
||||||
|
while (matcher.find())
|
||||||
|
{
|
||||||
|
String code = matcher.group().replace("&", "");
|
||||||
|
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
string = ChatColor.translateAlternateColorCodes('&', string);
|
||||||
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getUnixDate(long unix)
|
public static Date getUnixDate(long unix)
|
||||||
|
@ -54,51 +54,57 @@ public class Groups
|
|||||||
EntityType.COW,
|
EntityType.COW,
|
||||||
EntityType.CREEPER,
|
EntityType.CREEPER,
|
||||||
EntityType.DOLPHIN,
|
EntityType.DOLPHIN,
|
||||||
|
EntityType.DONKEY,
|
||||||
EntityType.DROWNED,
|
EntityType.DROWNED,
|
||||||
EntityType.ENDER_DRAGON,
|
EntityType.ELDER_GUARDIAN,
|
||||||
EntityType.ENDERMAN,
|
EntityType.ENDERMAN,
|
||||||
|
EntityType.ENDERMITE,
|
||||||
EntityType.EVOKER,
|
EntityType.EVOKER,
|
||||||
EntityType.FOX,
|
EntityType.FOX,
|
||||||
EntityType.GHAST,
|
EntityType.GHAST,
|
||||||
EntityType.GIANT,
|
EntityType.GUARDIAN,
|
||||||
EntityType.HUSK,
|
EntityType.HOGLIN,
|
||||||
EntityType.ILLUSIONER,
|
|
||||||
EntityType.IRON_GOLEM,
|
|
||||||
EntityType.HORSE,
|
EntityType.HORSE,
|
||||||
|
EntityType.HUSK,
|
||||||
EntityType.LLAMA,
|
EntityType.LLAMA,
|
||||||
EntityType.MAGMA_CUBE,
|
EntityType.MAGMA_CUBE,
|
||||||
EntityType.MUSHROOM_COW,
|
EntityType.MUSHROOM_COW,
|
||||||
|
EntityType.MULE,
|
||||||
EntityType.OCELOT,
|
EntityType.OCELOT,
|
||||||
EntityType.PANDA,
|
EntityType.PANDA,
|
||||||
EntityType.PARROT,
|
EntityType.PARROT,
|
||||||
EntityType.PILLAGER,
|
|
||||||
EntityType.PHANTOM,
|
EntityType.PHANTOM,
|
||||||
EntityType.PIG,
|
EntityType.PIG,
|
||||||
EntityType.PIG_ZOMBIE,
|
EntityType.PILLAGER,
|
||||||
EntityType.POLAR_BEAR,
|
EntityType.POLAR_BEAR,
|
||||||
EntityType.PUFFERFISH,
|
EntityType.PUFFERFISH,
|
||||||
|
EntityType.RABBIT,
|
||||||
EntityType.RAVAGER,
|
EntityType.RAVAGER,
|
||||||
|
EntityType.SALMON,
|
||||||
EntityType.SHEEP,
|
EntityType.SHEEP,
|
||||||
EntityType.SHULKER,
|
EntityType.SHULKER,
|
||||||
EntityType.SILVERFISH,
|
EntityType.SILVERFISH,
|
||||||
EntityType.SKELETON,
|
EntityType.SKELETON,
|
||||||
|
EntityType.SKELETON_HORSE,
|
||||||
EntityType.SLIME,
|
EntityType.SLIME,
|
||||||
EntityType.SNOWMAN,
|
|
||||||
EntityType.SPIDER,
|
EntityType.SPIDER,
|
||||||
EntityType.SQUID,
|
EntityType.SQUID,
|
||||||
EntityType.STRAY,
|
EntityType.STRAY,
|
||||||
EntityType.TROPICAL_FISH,
|
EntityType.STRIDER,
|
||||||
EntityType.TRADER_LLAMA,
|
EntityType.TRADER_LLAMA,
|
||||||
|
EntityType.TROPICAL_FISH,
|
||||||
EntityType.TURTLE,
|
EntityType.TURTLE,
|
||||||
EntityType.VEX,
|
EntityType.VEX,
|
||||||
EntityType.VILLAGER,
|
EntityType.VILLAGER,
|
||||||
EntityType.WITCH,
|
|
||||||
EntityType.WITHER,
|
|
||||||
EntityType.WITHER_SKELETON,
|
|
||||||
EntityType.VINDICATOR,
|
EntityType.VINDICATOR,
|
||||||
EntityType.WANDERING_TRADER,
|
EntityType.WANDERING_TRADER,
|
||||||
|
EntityType.WITCH,
|
||||||
|
EntityType.WITHER_SKELETON,
|
||||||
EntityType.WOLF,
|
EntityType.WOLF,
|
||||||
EntityType.ZOMBIE);
|
EntityType.ZOMBIE,
|
||||||
|
EntityType.ZOMBIE_HORSE,
|
||||||
|
EntityType.ZOMBIFIED_PIGLIN,
|
||||||
|
EntityType.ZOMBIE_VILLAGER);
|
||||||
|
|
||||||
public static final List<Material> SPAWN_EGGS = Arrays.asList(
|
public static final List<Material> SPAWN_EGGS = Arrays.asList(
|
||||||
Material.BAT_SPAWN_EGG,
|
Material.BAT_SPAWN_EGG,
|
||||||
@ -120,6 +126,7 @@ public class Groups
|
|||||||
Material.FOX_SPAWN_EGG,
|
Material.FOX_SPAWN_EGG,
|
||||||
Material.GHAST_SPAWN_EGG,
|
Material.GHAST_SPAWN_EGG,
|
||||||
Material.GUARDIAN_SPAWN_EGG,
|
Material.GUARDIAN_SPAWN_EGG,
|
||||||
|
Material.HOGLIN_SPAWN_EGG,
|
||||||
Material.HORSE_SPAWN_EGG,
|
Material.HORSE_SPAWN_EGG,
|
||||||
Material.HUSK_SPAWN_EGG,
|
Material.HUSK_SPAWN_EGG,
|
||||||
Material.LLAMA_SPAWN_EGG,
|
Material.LLAMA_SPAWN_EGG,
|
||||||
@ -146,6 +153,7 @@ public class Groups
|
|||||||
Material.SPIDER_SPAWN_EGG,
|
Material.SPIDER_SPAWN_EGG,
|
||||||
Material.SQUID_SPAWN_EGG,
|
Material.SQUID_SPAWN_EGG,
|
||||||
Material.STRAY_SPAWN_EGG,
|
Material.STRAY_SPAWN_EGG,
|
||||||
|
Material.STRIDER_SPAWN_EGG,
|
||||||
Material.TRADER_LLAMA_SPAWN_EGG,
|
Material.TRADER_LLAMA_SPAWN_EGG,
|
||||||
Material.TROPICAL_FISH_SPAWN_EGG,
|
Material.TROPICAL_FISH_SPAWN_EGG,
|
||||||
Material.TURTLE_SPAWN_EGG,
|
Material.TURTLE_SPAWN_EGG,
|
||||||
@ -158,7 +166,7 @@ public class Groups
|
|||||||
Material.WOLF_SPAWN_EGG,
|
Material.WOLF_SPAWN_EGG,
|
||||||
Material.ZOMBIE_SPAWN_EGG,
|
Material.ZOMBIE_SPAWN_EGG,
|
||||||
Material.ZOMBIE_HORSE_SPAWN_EGG,
|
Material.ZOMBIE_HORSE_SPAWN_EGG,
|
||||||
Material.ZOMBIE_PIGMAN_SPAWN_EGG,
|
Material.ZOMBIFIED_PIGLIN_SPAWN_EGG,
|
||||||
Material.ZOMBIE_VILLAGER_SPAWN_EGG);
|
Material.ZOMBIE_VILLAGER_SPAWN_EGG);
|
||||||
|
|
||||||
public static final List<Material> BANNERS = Arrays.asList(
|
public static final List<Material> BANNERS = Arrays.asList(
|
||||||
|
@ -29,7 +29,7 @@ public class WorldRestrictions extends FreedomService
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final List<String> BLOCKED_WORLDEDIT_COMMANDS = Arrays.asList(
|
private final List<String> BLOCKED_WORLDEDIT_COMMANDS = Arrays.asList(
|
||||||
"green", "fixlava", "fixwater", "br", "brush", "tool", "mat", "range", "cs", "up", "fill", "setblock", "tree", "replacenear");
|
"green", "fixlava", "fixwater", "br", "brush", "tool", "mat", "range", "cs", "up", "fill", "setblock", "tree", "replacenear", "bigtree");
|
||||||
|
|
||||||
private final Map<Flag<?>, Object> flags = new HashMap<Flag<?>, Object>()
|
private final Map<Flag<?>, Object> flags = new HashMap<Flag<?>, Object>()
|
||||||
{{
|
{{
|
||||||
@ -60,7 +60,7 @@ public class WorldRestrictions extends FreedomService
|
|||||||
|
|
||||||
public boolean doRestrict(Player player)
|
public boolean doRestrict(Player player)
|
||||||
{
|
{
|
||||||
if (!plugin.mbl.isMasterBuilder(player) && !FUtil.canManageMasterBuilders(player.getName()))
|
if (!plugin.pl.getData(player).isMasterBuilder() && !plugin.pl.canManageMasterBuilders(player.getName()))
|
||||||
{
|
{
|
||||||
if (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()) || player.getWorld().equals(plugin.wm.hubworld.getWorld()))
|
if (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()) || player.getWorld().equals(plugin.wm.hubworld.getWorld()))
|
||||||
{
|
{
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#
|
|
||||||
# TotalFreedomMod 5.5 Admin List
|
|
||||||
#
|
|
||||||
|
|
||||||
prozza:
|
|
||||||
username: Prozza
|
|
||||||
active: true
|
|
||||||
rank: SENIOR_ADMIN
|
|
||||||
ips:
|
|
||||||
- 127.0.0.1
|
|
||||||
last_login: Wed, 2 Apr 2016 16:08:39 +0200
|
|
||||||
login_message: 'the &5Lead Developer&b!'
|
|
||||||
|
|
||||||
madgeek1450:
|
|
||||||
username: Madgeek1450
|
|
||||||
active: true
|
|
||||||
rank: SENIOR_ADMIN
|
|
||||||
ips:
|
|
||||||
- 1.2.3.4
|
|
||||||
- 8.8.8.8
|
|
||||||
last_login: Wed, 2 Apr 2016 16:08:39 +0200
|
|
||||||
login_message: 'the &4Co-Founder&b and &6Master-ass-kicker&b.'
|
|
||||||
|
|
||||||
markbyron:
|
|
||||||
username: markbyron
|
|
||||||
active: true
|
|
||||||
rank: SENIOR_ADMIN
|
|
||||||
ips:
|
|
||||||
- 8.8.4.4
|
|
||||||
last_login: Wed, 2 Apr 2016 16:08:39 +0200
|
|
||||||
login_message: 'the &dOwner&b.'
|
|
@ -1,3 +0,0 @@
|
|||||||
#
|
|
||||||
# TotalFreedomMod 5.5 Player Bans
|
|
||||||
#
|
|
@ -155,6 +155,12 @@ social_links:
|
|||||||
Website: 'https://totalfreedom.me/'
|
Website: 'https://totalfreedom.me/'
|
||||||
Discord: 'https://discordapp.com/invite/XXjmAmV/'
|
Discord: 'https://discordapp.com/invite/XXjmAmV/'
|
||||||
|
|
||||||
|
donation:
|
||||||
|
proboards_url: ''
|
||||||
|
donator_group_id: ''
|
||||||
|
session_id: ''
|
||||||
|
csrf_token: ''
|
||||||
|
|
||||||
# Blocking certain events
|
# Blocking certain events
|
||||||
allow:
|
allow:
|
||||||
fire_place: false
|
fire_place: false
|
||||||
@ -343,7 +349,7 @@ protectarea:
|
|||||||
# Make sure these are all lower-case.
|
# Make sure these are all lower-case.
|
||||||
host_sender_names:
|
host_sender_names:
|
||||||
- rcon
|
- rcon
|
||||||
- remotebukkit
|
- console
|
||||||
|
|
||||||
# Announcer
|
# Announcer
|
||||||
announcer:
|
announcer:
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#
|
|
||||||
# TotalFreedomMod 5.5 Master Builder List
|
|
||||||
#
|
|
Loading…
Reference in New Issue
Block a user