mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge branch 'development' of https://github.com/TFPatches/TotalFreedomMod into development
Conflicts: src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
This commit is contained in:
commit
1e36b484ac
7
.idea/misc.xml
generated
7
.idea/misc.xml
generated
@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<list size="1">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||||
|
</list>
|
||||||
|
</component>
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
<list>
|
<list>
|
||||||
@ -7,5 +12,5 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||||
</project>
|
</project>
|
37
pom.xml
37
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>me.totalfreedom</groupId>
|
<groupId>me.totalfreedom</groupId>
|
||||||
<artifactId>TotalFreedomMod</artifactId>
|
<artifactId>TotalFreedomMod</artifactId>
|
||||||
<version>5.6</version>
|
<version>2020.9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -104,6 +104,11 @@
|
|||||||
<id>rayzr-repo</id>
|
<id>rayzr-repo</id>
|
||||||
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>ess-repo</id>
|
||||||
|
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -117,14 +122,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.6</version>
|
<version>2.7</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.9</version>
|
<version>3.11</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -153,6 +158,7 @@
|
|||||||
<groupId>com.github.TFPatches</groupId>
|
<groupId>com.github.TFPatches</groupId>
|
||||||
<artifactId>TF-LibsDisguises</artifactId>
|
<artifactId>TF-LibsDisguises</artifactId>
|
||||||
<version>0cfa32159a</version>
|
<version>0cfa32159a</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -165,28 +171,28 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.ess3</groupId>
|
<groupId>net.ess3</groupId>
|
||||||
<artifactId>EssentialsX</artifactId>
|
<artifactId>EssentialsX</artifactId>
|
||||||
<version>2.16.1</version>
|
<version>2.18.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dv8tion</groupId>
|
<groupId>net.dv8tion</groupId>
|
||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>4.0.0_39</version>
|
<version>4.2.0_168</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.coreprotect</groupId>
|
<groupId>net.coreprotect</groupId>
|
||||||
<artifactId>coreprotect</artifactId>
|
<artifactId>coreprotect</artifactId>
|
||||||
<version>2.16.3</version>
|
<version>2.18.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-bukkit</artifactId>
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
<version>7.0.2</version>
|
<version>7.0.3</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -201,6 +207,7 @@
|
|||||||
<groupId>me.rayzr522</groupId>
|
<groupId>me.rayzr522</groupId>
|
||||||
<artifactId>jsonmessage</artifactId>
|
<artifactId>jsonmessage</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -237,9 +244,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.speedxx</groupId>
|
<groupId>com.github.TFPatches</groupId>
|
||||||
<artifactId>TFGuilds</artifactId>
|
<artifactId>TFGuilds</artifactId>
|
||||||
<version>master</version>
|
<version>ad93b9ed00</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -247,6 +255,13 @@
|
|||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.dean.jraw</groupId>
|
||||||
|
<artifactId>JRAW</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -331,7 +346,8 @@
|
|||||||
<entry key="buildCodeName" value="${tfm.build.codename}"/>
|
<entry key="buildCodeName" value="${tfm.build.codename}"/>
|
||||||
<entry key="buildVersion" value="${project.version}"/>
|
<entry key="buildVersion" value="${project.version}"/>
|
||||||
<entry key="buildDate" value="${timestamp}"/>
|
<entry key="buildDate" value="${timestamp}"/>
|
||||||
<!--<entry key="buildHead" value="${git.commit.id.abbrev}"/>-->
|
<!--suppress UnresolvedMavenProperty -->
|
||||||
|
<entry key="buildHead" value="${git.commit.id.abbrev}"/>
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -407,6 +423,7 @@
|
|||||||
<include>commons-codec:commons-codec</include>
|
<include>commons-codec:commons-codec</include>
|
||||||
<include>org.reflections:reflections</include>
|
<include>org.reflections:reflections</include>
|
||||||
<include>javassist:javassist</include>
|
<include>javassist:javassist</include>
|
||||||
|
<include>me.rayzr522:jsonmessage</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
187
src/main/java/me/totalfreedom/totalfreedommod/AMP.java
Normal file
187
src/main/java/me/totalfreedom/totalfreedommod/AMP.java
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import joptsimple.internal.Strings;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
public class AMP extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public String URL = ConfigEntry.AMP_URL.getString();
|
||||||
|
private String API_URL = URL + "/API/Core";
|
||||||
|
private String USERNAME = ConfigEntry.AMP_USERNAME.getString();
|
||||||
|
private String PASSWORD = ConfigEntry.AMP_PASSWORD.getString();
|
||||||
|
private String SESSION_ID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||||
|
|
||||||
|
private final List<String> headers = Arrays.asList("Accept:application/json");
|
||||||
|
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
login();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void login()
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("username", USERNAME);
|
||||||
|
json.put("password", PASSWORD);
|
||||||
|
json.put("token", "");
|
||||||
|
json.put("rememberMe", false);
|
||||||
|
|
||||||
|
String response;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = FUtil.sendRequest(API_URL + "/Login", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject jsonResponse;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jsonResponse = (JSONObject)new JSONParser().parse(response);
|
||||||
|
}
|
||||||
|
catch (ParseException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object sessionID = jsonResponse.get("sessionID");
|
||||||
|
if (sessionID == null)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid AMP credentials have been specified in the config");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SESSION_ID = sessionID.toString();
|
||||||
|
FLog.info("Logged into AMP");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logout()
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/Logout", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Logged out of AMP");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAccountStatus(StaffMember staffMember)
|
||||||
|
{
|
||||||
|
String username = staffMember.getAmpUsername();
|
||||||
|
|
||||||
|
if (username == null || !enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!staffMember.isActive() || staffMember.getRank() != Rank.ADMIN)
|
||||||
|
{
|
||||||
|
FLog.debug("Disabling amp acc");
|
||||||
|
setAccountEnabled(username, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.debug("Enabling amp acc");
|
||||||
|
setAccountEnabled(username, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createAccount(String username, String password)
|
||||||
|
{
|
||||||
|
makeAccount(username);
|
||||||
|
setPassword(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountEnabled(String username, boolean enable)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("Username", username);
|
||||||
|
json.put("Disabled", !enable);
|
||||||
|
json.put("PasswordExpires", false);
|
||||||
|
json.put("CannotChangePassword", false);
|
||||||
|
json.put("MustChangePassword", false);
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/UpdateUserInfo", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeAccount(String username)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("Username", username);
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/CreateUser", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String username, String password)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("Username", username);
|
||||||
|
json.put("NewPassword", password);
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/ResetUserPassword", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -62,7 +62,7 @@ public class AntiSpam extends FreedomService
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ public class AntiSpam extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitConfiguration;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
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.bukkit.util.FileUtil;
|
import org.bukkit.util.FileUtil;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
|
||||||
|
|
||||||
public class BackupManager extends FreedomService
|
public class BackupManager extends FreedomService
|
||||||
{
|
{
|
||||||
@ -31,7 +29,7 @@ public class BackupManager extends FreedomService
|
|||||||
public void createAllBackups()
|
public void createAllBackups()
|
||||||
{
|
{
|
||||||
createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||||
createBackups(PermbanList.CONFIG_FILENAME);
|
createBackups(IndefiniteBanList.CONFIG_FILENAME);
|
||||||
createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
||||||
createBackups(PunishmentList.CONFIG_FILENAME);
|
createBackups(PunishmentList.CONFIG_FILENAME);
|
||||||
createBackups("database.db");
|
createBackups("database.db");
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
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.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
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;
|
||||||
@ -65,7 +65,7 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
|
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
|
||||||
@ -87,10 +87,10 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for adminchat
|
// Check for staffchat
|
||||||
if (fPlayer.inAdminChat())
|
if (fPlayer.inStaffChat())
|
||||||
{
|
{
|
||||||
FSync.adminChatMessage(player, message);
|
FSync.staffChatMessage(player, message);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for mentions
|
// Check for mentions
|
||||||
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.sl.isStaff(player);
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
||||||
@ -136,76 +136,44 @@ public class ChatManager extends FreedomService
|
|||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
|
|
||||||
// Send to discord
|
// Send to discord
|
||||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
if (!ConfigEntry.STAFF_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
||||||
{
|
{
|
||||||
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor(Admin admin, Displayable display)
|
public ChatColor getColor(Displayable display)
|
||||||
{
|
{
|
||||||
ChatColor color = display.getColor();
|
ChatColor color = display.getColor();
|
||||||
if (admin.getOldTags())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (color.equals(ChatColor.AQUA))
|
|
||||||
{
|
|
||||||
color = ChatColor.GOLD;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.GOLD))
|
|
||||||
{
|
|
||||||
color = ChatColor.LIGHT_PURPLE;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.DARK_RED))
|
|
||||||
{
|
|
||||||
color = ChatColor.BLUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColoredTag(Admin admin, Displayable display)
|
public String getColoredTag(Displayable display)
|
||||||
{
|
{
|
||||||
ChatColor color = display.getColor();
|
ChatColor color = display.getColor();
|
||||||
if (admin.getOldTags())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (color.equals(ChatColor.AQUA))
|
|
||||||
{
|
|
||||||
color = ChatColor.GOLD;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.GOLD))
|
|
||||||
{
|
|
||||||
color = ChatColor.LIGHT_PURPLE;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.DARK_RED))
|
|
||||||
{
|
|
||||||
color = ChatColor.BLUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return color + display.getAbbr();
|
return color + display.getAbbr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adminChat(CommandSender sender, String message)
|
public void staffChat(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
Displayable display = plugin.rm.getDisplay(sender);
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
FLog.info("[STAFF] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(player);
|
StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||||
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
if (!Strings.isNullOrEmpty(staffMember.getAcFormat()))
|
||||||
{
|
{
|
||||||
String format = admin.getAcFormat();
|
String format = staffMember.getAcFormat();
|
||||||
ChatColor color = getColor(admin, display);
|
ChatColor color = getColor(display);
|
||||||
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
||||||
player.sendMessage(FUtil.colorize(msg));
|
player.sendMessage(FUtil.colorize(msg));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(admin, display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
player.sendMessage("[" + ChatColor.AQUA + "STAFF" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,7 +183,7 @@ public class ChatManager extends FreedomService
|
|||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
|
@ -23,9 +23,9 @@ public class CommandSpy extends FreedomService
|
|||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
if (plugin.sl.isStaff(player) && plugin.sl.getAdmin(player).getCommandSpy())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
|
if (plugin.sl.isStaff(event.getPlayer()) && !plugin.sl.isAdmin(player))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,34 @@ public class FreedomServiceHandler
|
|||||||
{
|
{
|
||||||
return services.size();
|
return services.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startServices()
|
||||||
|
{
|
||||||
|
for (FreedomService service : getServices())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
service.onStart();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopServices()
|
||||||
|
{
|
||||||
|
for (FreedomService service : getServices())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
service.onStop();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -24,7 +24,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class LoginProcess extends FreedomService
|
public class LoginProcess extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final int DEFAULT_PORT = 25565;
|
public static final int DEFAULT_PORT = 25565;
|
||||||
public static final int MIN_USERNAME_LENGTH = 2;
|
public static final int MIN_USERNAME_LENGTH = 2;
|
||||||
public static final int MAX_USERNAME_LENGTH = 20;
|
public static final int MAX_USERNAME_LENGTH = 20;
|
||||||
@ -53,7 +52,7 @@ public class LoginProcess extends FreedomService
|
|||||||
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
||||||
{
|
{
|
||||||
final String ip = event.getAddress().getHostAddress().trim();
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
// Check if the player is already online
|
// Check if the player is already online
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
@ -63,10 +62,10 @@ public class LoginProcess extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin)
|
if (isStaff)
|
||||||
{
|
{
|
||||||
event.allow();
|
event.allow();
|
||||||
FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
|
FSync.playerKick(onlinePlayer, "A staff member just logged in with the username you are using.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,11 +112,11 @@ public class LoginProcess extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player is admin
|
// Check if player is staff
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
// Validation below this point
|
// Validation below this point
|
||||||
if (isAdmin) // Player is admin
|
if (isStaff) // Player is staff
|
||||||
{
|
{
|
||||||
// Force-allow log in
|
// Force-allow log in
|
||||||
event.allow();
|
event.allow();
|
||||||
@ -127,9 +126,9 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(onlinePlayer))
|
if (!plugin.sl.isStaff(onlinePlayer))
|
||||||
{
|
{
|
||||||
onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
|
onlinePlayer.kickPlayer("You have been kicked to free up room for a staff member.");
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +148,7 @@ public class LoginProcess extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player is not an admin
|
// Player is not a staff member
|
||||||
// Server full check
|
// Server full check
|
||||||
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
|
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
|
||||||
{
|
{
|
||||||
@ -157,10 +156,10 @@ public class LoginProcess extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Admin-only mode
|
// Staff-only mode
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to staff only.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +225,7 @@ public class LoginProcess extends FreedomService
|
|||||||
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
String tag = playerData.getTag();
|
String tag = playerData.getTag();
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
@ -244,7 +243,7 @@ public class LoginProcess extends FreedomService
|
|||||||
FLog.info(noteMessage);
|
FLog.info(noteMessage);
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdminImpostor(p))
|
if (plugin.sl.isStaffImpostor(p))
|
||||||
{
|
{
|
||||||
notice.send(p);
|
notice.send(p);
|
||||||
}
|
}
|
||||||
@ -257,9 +256,9 @@ public class LoginProcess extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
|
player.sendMessage(ChatColor.RED + "Server is currently closed to non-staff.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockdownEnabled)
|
if (lockdownEnabled)
|
||||||
|
@ -45,7 +45,7 @@ public class Muter extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(player))
|
if (plugin.sl.isStaffSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
MUTED_PLAYERS.remove(player.getName());
|
MUTED_PLAYERS.remove(player.getName());
|
||||||
@ -70,7 +70,7 @@ public class Muter extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
return;
|
return;
|
||||||
|
@ -1,392 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class ProtectArea extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String DATA_FILENAME = "protectedareas.dat";
|
|
||||||
public static final double MAX_RADIUS = 50.0;
|
|
||||||
//
|
|
||||||
private final Map<String, SerializableProtectedRegion> areas = Maps.newHashMap();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart()
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
File input = new File(plugin.getDataFolder(), DATA_FILENAME);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (input.exists())
|
|
||||||
{
|
|
||||||
FileInputStream fis = new FileInputStream(input);
|
|
||||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
|
||||||
areas.clear();
|
|
||||||
areas.putAll((HashMap<String, SerializableProtectedRegion>)ois.readObject());
|
|
||||||
ois.close();
|
|
||||||
fis.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
input.delete();
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanProtectedAreas();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop()
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), DATA_FILENAME));
|
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
|
||||||
oos.writeObject(areas);
|
|
||||||
oos.close();
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location location = event.getBlock().getLocation();
|
|
||||||
|
|
||||||
if (isInProtectedArea(location))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location location = event.getBlock().getLocation();
|
|
||||||
|
|
||||||
if (isInProtectedArea(location))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInProtectedArea(final Location modifyLocation)
|
|
||||||
{
|
|
||||||
boolean doSave = false;
|
|
||||||
boolean inProtectedArea = false;
|
|
||||||
|
|
||||||
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
final SerializableProtectedRegion region = it.next().getValue();
|
|
||||||
|
|
||||||
Location regionCenter = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
regionCenter = region.getLocation();
|
|
||||||
}
|
|
||||||
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
doSave = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regionCenter != null)
|
|
||||||
{
|
|
||||||
if (modifyLocation.getWorld() == regionCenter.getWorld())
|
|
||||||
{
|
|
||||||
final double regionRadius = region.getRadius();
|
|
||||||
if (modifyLocation.distanceSquared(regionCenter) <= (regionRadius * regionRadius))
|
|
||||||
{
|
|
||||||
inProtectedArea = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doSave)
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return inProtectedArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInProtectedArea(final Vector min, final Vector max, final String worldName)
|
|
||||||
{
|
|
||||||
boolean doSave = false;
|
|
||||||
boolean inProtectedArea = false;
|
|
||||||
|
|
||||||
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
final SerializableProtectedRegion region = it.next().getValue();
|
|
||||||
|
|
||||||
Location regionCenter = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
regionCenter = region.getLocation();
|
|
||||||
}
|
|
||||||
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
doSave = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regionCenter != null)
|
|
||||||
{
|
|
||||||
if (worldName.equals(regionCenter.getWorld().getName()))
|
|
||||||
{
|
|
||||||
if (cubeIntersectsSphere(min, max, regionCenter.toVector(), region.getRadius()))
|
|
||||||
{
|
|
||||||
inProtectedArea = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doSave)
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return inProtectedArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean cubeIntersectsSphere(Vector min, Vector max, Vector sphere, double radius)
|
|
||||||
{
|
|
||||||
double d = square(radius);
|
|
||||||
|
|
||||||
if (sphere.getX() < min.getX())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getX() - min.getX());
|
|
||||||
}
|
|
||||||
else if (sphere.getX() > max.getX())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getX() - max.getX());
|
|
||||||
}
|
|
||||||
if (sphere.getY() < min.getY())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getY() - min.getY());
|
|
||||||
}
|
|
||||||
else if (sphere.getY() > max.getY())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getY() - max.getY());
|
|
||||||
}
|
|
||||||
if (sphere.getZ() < min.getZ())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getZ() - min.getZ());
|
|
||||||
}
|
|
||||||
else if (sphere.getZ() > max.getZ())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getZ() - max.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return d > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double square(double v)
|
|
||||||
{
|
|
||||||
return v * v;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addProtectedArea(String label, Location location, double radius)
|
|
||||||
{
|
|
||||||
areas.put(label.toLowerCase(), new SerializableProtectedRegion(location, radius));
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeProtectedArea(String label)
|
|
||||||
{
|
|
||||||
areas.remove(label.toLowerCase());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearProtectedAreas()
|
|
||||||
{
|
|
||||||
clearProtectedAreas(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearProtectedAreas(boolean createSpawnpointProtectedAreas)
|
|
||||||
{
|
|
||||||
areas.clear();
|
|
||||||
|
|
||||||
if (createSpawnpointProtectedAreas)
|
|
||||||
{
|
|
||||||
autoAddSpawnpoints();
|
|
||||||
}
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanProtectedAreas()
|
|
||||||
{
|
|
||||||
boolean doSave = false;
|
|
||||||
|
|
||||||
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
it.next().getValue().getLocation();
|
|
||||||
}
|
|
||||||
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
doSave = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doSave)
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getProtectedAreaLabels()
|
|
||||||
{
|
|
||||||
return areas.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void autoAddSpawnpoints()
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ConfigEntry.PROTECTAREA_SPAWNPOINTS.getBoolean())
|
|
||||||
{
|
|
||||||
for (World world : Bukkit.getWorlds())
|
|
||||||
{
|
|
||||||
addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), ConfigEntry.PROTECTAREA_RADIUS.getDouble());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class SerializableProtectedRegion implements Serializable
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 213123517828282L;
|
|
||||||
private final double x, y, z;
|
|
||||||
private final double radius;
|
|
||||||
private final String worldName;
|
|
||||||
private final UUID worldUUID;
|
|
||||||
private transient Location location = null;
|
|
||||||
|
|
||||||
public SerializableProtectedRegion(final Location location, final double radius)
|
|
||||||
{
|
|
||||||
this.x = location.getX();
|
|
||||||
this.y = location.getY();
|
|
||||||
this.z = location.getZ();
|
|
||||||
this.radius = radius;
|
|
||||||
this.worldName = location.getWorld().getName();
|
|
||||||
this.worldUUID = location.getWorld().getUID();
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getLocation() throws CantFindWorldException
|
|
||||||
{
|
|
||||||
if (this.location == null)
|
|
||||||
{
|
|
||||||
World world = Bukkit.getWorld(this.worldUUID);
|
|
||||||
|
|
||||||
if (world == null)
|
|
||||||
{
|
|
||||||
world = Bukkit.getWorld(this.worldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world == null)
|
|
||||||
{
|
|
||||||
throw new CantFindWorldException("Can't find world " + this.worldName + ", UUID: " + this.worldUUID.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
location = new Location(world, x, y, z);
|
|
||||||
}
|
|
||||||
return this.location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRadius()
|
|
||||||
{
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CantFindWorldException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public CantFindWorldException(String string)
|
|
||||||
{
|
|
||||||
super(string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
223
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
223
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.dean.jraw.ApiException;
|
||||||
|
import net.dean.jraw.RedditClient;
|
||||||
|
import net.dean.jraw.http.OkHttpNetworkAdapter;
|
||||||
|
import net.dean.jraw.http.UserAgent;
|
||||||
|
import net.dean.jraw.models.CurrentFlair;
|
||||||
|
import net.dean.jraw.models.Flair;
|
||||||
|
import net.dean.jraw.oauth.Credentials;
|
||||||
|
import net.dean.jraw.oauth.OAuthHelper;
|
||||||
|
import net.dean.jraw.references.SubredditReference;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Reddit extends FreedomService
|
||||||
|
{
|
||||||
|
private final String SUBREDDIT_NAME = ConfigEntry.REDDIT_SUBREDDIT_NAME.getString();
|
||||||
|
private final String USERNAME = ConfigEntry.REDDIT_USERNAME.getString();
|
||||||
|
private final String PASSWORD = ConfigEntry.REDDIT_PASSWORD.getString();
|
||||||
|
private final String CLIENT_ID = ConfigEntry.REDDIT_CLIENT_ID.getString();
|
||||||
|
private final String CLIENT_SECRET = ConfigEntry.REDDIT_CLIENT_SECRET.getString();
|
||||||
|
|
||||||
|
private final UserAgent userAgent = new UserAgent("bot", "me.totalfreedom.reddit", plugin.build.version, USERNAME);
|
||||||
|
private final Credentials credentials = Credentials.script(USERNAME, PASSWORD, CLIENT_ID, CLIENT_SECRET);
|
||||||
|
|
||||||
|
private RedditClient reddit = null;
|
||||||
|
private SubredditReference subreddit = null;
|
||||||
|
|
||||||
|
private HashMap<String, PlayerData> linkCodes = new HashMap<>();
|
||||||
|
private HashMap<PlayerData, String> pending = new HashMap<>();
|
||||||
|
|
||||||
|
private Map<Displayable, String> flairList = new HashMap<>();
|
||||||
|
|
||||||
|
private Map<Displayable, String> flairNameList = new HashMap<>();
|
||||||
|
|
||||||
|
private List<Displayable> noFlairDisplays = Arrays.asList(Title.VERIFIED_STAFF, Rank.IMPOSTOR, Rank.NON_OP, Rank.OP);
|
||||||
|
|
||||||
|
public boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
enabled = ConfigEntry.REDDIT_CLIENT_ID.getString() == null;
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reddit == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reddit = OAuthHelper.automatic(new OkHttpNetworkAdapter(userAgent), credentials);
|
||||||
|
reddit.setLogHttp(FUtil.inDeveloperMode());
|
||||||
|
}
|
||||||
|
catch (NoClassDefFoundError e)
|
||||||
|
{
|
||||||
|
FLog.warning("The JRAW plugin is not installed, therefore the Reddit service cannot start.");
|
||||||
|
FLog.warning("To resolve this error, please download the latest JRAW from: https://github.com/TFPatches/Minecraft-JRAW/releases");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (NullPointerException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid Reddit credentials specified, please double check everything in the config.");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subreddit == null)
|
||||||
|
{
|
||||||
|
subreddit = reddit.subreddit(SUBREDDIT_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadFlairList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlair(String username, String flairID)
|
||||||
|
{
|
||||||
|
List<Flair> flairs = subreddit.userFlairOptions();
|
||||||
|
Flair flair = null;
|
||||||
|
for (Flair f : flairs)
|
||||||
|
{
|
||||||
|
if (f.getId().equals(flairID))
|
||||||
|
{
|
||||||
|
flair = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flair == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
subreddit.otherUserFlair(username).updateToTemplate(flair.getId(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFlair(String username)
|
||||||
|
{
|
||||||
|
subreddit.otherUserFlair(username).updateToTemplate("", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendModMessage(String username, String subject, String body) throws ApiException
|
||||||
|
{
|
||||||
|
reddit.me().inbox().compose("/r/" + SUBREDDIT_NAME, username, subject, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String addLinkCode(PlayerData data, String username)
|
||||||
|
{
|
||||||
|
String code = FUtil.randomAlphanumericString(10);
|
||||||
|
linkCodes.put(code, data);
|
||||||
|
pending.put(data, username);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String checkLinkCode(String code)
|
||||||
|
{
|
||||||
|
PlayerData data = linkCodes.get(code);
|
||||||
|
String username = pending.get(data);
|
||||||
|
if (data == null || username == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
linkCodes.remove(code);
|
||||||
|
pending.remove(data);
|
||||||
|
|
||||||
|
data.setRedditUsername(username);
|
||||||
|
plugin.pl.save(data);
|
||||||
|
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateFlair(Player player)
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
String username = data.getRedditUsername();
|
||||||
|
Displayable display = plugin.rm.getDisplay(player);
|
||||||
|
if (username == null)
|
||||||
|
{
|
||||||
|
FLog.debug("No Reddit account");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentFlair currentFlair = subreddit.otherUserFlair(username).current();
|
||||||
|
String currentFlairName = currentFlair.getText();
|
||||||
|
String currentFlairID = currentFlair.getId();
|
||||||
|
String neededFlairID = flairList.get(display);
|
||||||
|
String neededFlairName = flairNameList.get(display);
|
||||||
|
|
||||||
|
FLog.debug("Current ID: " + currentFlairID);
|
||||||
|
FLog.debug("Needed ID: " + neededFlairID);
|
||||||
|
|
||||||
|
FLog.debug("Current Name: " + currentFlairName);
|
||||||
|
FLog.debug("Needed Name: " + neededFlairName);
|
||||||
|
|
||||||
|
|
||||||
|
// Work around
|
||||||
|
//if (currentFlairID == null && neededFlairID != null || currentFlairID != null && neededFlairID != null && !currentFlairID.equals(neededFlairID))
|
||||||
|
if (Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null || !Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null && !currentFlairName.equals(neededFlairName))
|
||||||
|
{
|
||||||
|
FLog.debug("Setting flair");
|
||||||
|
setFlair(username, neededFlairID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noFlairDisplays.contains(display) && !Strings.isNullOrEmpty(currentFlairName))
|
||||||
|
{
|
||||||
|
FLog.debug("Removing flair");
|
||||||
|
removeFlair(username);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFlairList()
|
||||||
|
{
|
||||||
|
flairList.put(Title.OWNER, ConfigEntry.REDDIT_SERVER_OWNER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.EXECUTIVE, ConfigEntry.REDDIT_EXECUTIVE_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.ASSISTANT_EXECUTIVE, ConfigEntry.REDDIT_ASSISTANT_EXECUTIVE_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.DEVELOPER, ConfigEntry.REDDIT_DEVELOPER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.ADMIN, ConfigEntry.REDDIT_ADMIN_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.MOD, ConfigEntry.REDDIT_MOD_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.TRIAL_MOD, ConfigEntry.REDDIT_TRIAL_MOD_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.MASTER_BUILDER, ConfigEntry.REDDIT_MASTER_BUILDER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.DONATOR, ConfigEntry.REDDIT_DONATOR_FLAIR_ID.getString());
|
||||||
|
|
||||||
|
// Work around because the current flair id keeps returning null, either a JRAW bug or a reddit bug
|
||||||
|
flairNameList.put(Title.OWNER, "Server Owner");
|
||||||
|
flairNameList.put(Title.EXECUTIVE, "Executive");
|
||||||
|
flairNameList.put(Title.ASSISTANT_EXECUTIVE, "Assistant Executive");
|
||||||
|
flairNameList.put(Title.DEVELOPER, "Developer");
|
||||||
|
flairNameList.put(Rank.ADMIN, "Admin");
|
||||||
|
flairNameList.put(Rank.MOD, "Mod");
|
||||||
|
flairNameList.put(Rank.TRIAL_MOD, "Trial Mod");
|
||||||
|
flairNameList.put(Title.MASTER_BUILDER, "Master Builder");
|
||||||
|
flairNameList.put(Title.DONATOR, "Premium");
|
||||||
|
}
|
||||||
|
}
|
@ -30,9 +30,9 @@ public class ServerPing extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_STAFFMODE_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,8 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||||
@ -27,7 +24,6 @@ import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
|||||||
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
||||||
import me.totalfreedom.totalfreedommod.caging.Cager;
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||||
@ -46,6 +42,8 @@ import me.totalfreedom.totalfreedommod.rank.RankManager;
|
|||||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||||
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||||
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.ActivityLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffList;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
@ -57,17 +55,17 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.reflections.Reflections;
|
|
||||||
import org.spigotmc.SpigotConfig;
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
public class TotalFreedomMod extends JavaPlugin
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
{
|
{
|
||||||
private static TotalFreedomMod plugin;
|
private static TotalFreedomMod plugin;
|
||||||
|
|
||||||
public static TotalFreedomMod getPlugin()
|
public static TotalFreedomMod getPlugin()
|
||||||
{
|
{
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "config.yml";
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
//
|
//
|
||||||
public static final BuildProperties build = new BuildProperties();
|
public static final BuildProperties build = new BuildProperties();
|
||||||
@ -87,7 +85,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public SavedFlags sf;
|
public SavedFlags sf;
|
||||||
public WorldManager wm;
|
public WorldManager wm;
|
||||||
public LogViewer lv;
|
public LogViewer lv;
|
||||||
public AdminList al;
|
public StaffList sl;
|
||||||
public ActivityLog acl;
|
public ActivityLog acl;
|
||||||
public RankManager rm;
|
public RankManager rm;
|
||||||
public CommandBlocker cb;
|
public CommandBlocker cb;
|
||||||
@ -108,9 +106,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public Discord dc;
|
public Discord dc;
|
||||||
public PunishmentList pul;
|
public PunishmentList pul;
|
||||||
public BanManager bm;
|
public BanManager bm;
|
||||||
public PermbanList pm;
|
public IndefiniteBanList im;
|
||||||
public PermissionManager pem;
|
public PermissionManager pem;
|
||||||
public ProtectArea pa;
|
public Reddit rd;
|
||||||
public GameRuleHandler gr;
|
public GameRuleHandler gr;
|
||||||
public CommandSpy cs;
|
public CommandSpy cs;
|
||||||
public Cager ca;
|
public Cager ca;
|
||||||
@ -137,6 +135,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public EntityWiper ew;
|
public EntityWiper ew;
|
||||||
public Sitter st;
|
public Sitter st;
|
||||||
public VanishHandler vh;
|
public VanishHandler vh;
|
||||||
|
public AMP amp;
|
||||||
|
|
||||||
//public HubWorldRestrictions hwr;
|
//public HubWorldRestrictions hwr;
|
||||||
//
|
//
|
||||||
@ -185,17 +184,17 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
config = new MainConfig();
|
config = new MainConfig();
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
|
if (FUtil.inDeveloperMode())
|
||||||
|
{
|
||||||
|
FLog.debug("Developer mode enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
cl = new CommandLoader();
|
cl = new CommandLoader();
|
||||||
cl.loadCommands();
|
cl.loadCommands();
|
||||||
|
|
||||||
BackupManager backups = new BackupManager();
|
BackupManager backups = new BackupManager();
|
||||||
backups.createAllBackups();
|
backups.createAllBackups();
|
||||||
|
|
||||||
if (FUtil.inDeveloperMode())
|
|
||||||
{
|
|
||||||
FLog.debug("Developer mode enabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
permissions = new PermissionConfig(this);
|
permissions = new PermissionConfig(this);
|
||||||
permissions.load();
|
permissions.load();
|
||||||
|
|
||||||
@ -205,7 +204,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
wm = new WorldManager();
|
wm = new WorldManager();
|
||||||
lv = new LogViewer();
|
lv = new LogViewer();
|
||||||
sql = new SQLite();
|
sql = new SQLite();
|
||||||
al = new AdminList();
|
sl = new StaffList();
|
||||||
acl = new ActivityLog();
|
acl = new ActivityLog();
|
||||||
rm = new RankManager();
|
rm = new RankManager();
|
||||||
cb = new CommandBlocker();
|
cb = new CommandBlocker();
|
||||||
@ -226,14 +225,15 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
dc = new Discord();
|
dc = new Discord();
|
||||||
pul = new PunishmentList();
|
pul = new PunishmentList();
|
||||||
bm = new BanManager();
|
bm = new BanManager();
|
||||||
pm = new PermbanList();
|
im = new IndefiniteBanList();
|
||||||
pem = new PermissionManager();
|
pem = new PermissionManager();
|
||||||
pa = new ProtectArea();
|
rd = new Reddit();
|
||||||
gr = new GameRuleHandler();
|
gr = new GameRuleHandler();
|
||||||
snp = new SignBlocker();
|
snp = new SignBlocker();
|
||||||
ew = new EntityWiper();
|
ew = new EntityWiper();
|
||||||
st = new Sitter();
|
st = new Sitter();
|
||||||
vh = new VanishHandler();
|
vh = new VanishHandler();
|
||||||
|
amp = new AMP();
|
||||||
|
|
||||||
// Single admin utils
|
// Single admin utils
|
||||||
cs = new CommandSpy();
|
cs = new CommandSpy();
|
||||||
@ -271,28 +271,16 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
fab = new FAWEBridge();
|
fab = new FAWEBridge();
|
||||||
wgb = new WorldGuardBridge();
|
wgb = new WorldGuardBridge();
|
||||||
|
|
||||||
for (FreedomService service : fsh.getServices())
|
fsh.startServices();
|
||||||
{
|
|
||||||
service.onStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
FLog.info("Started " + fsh.getServiceAmount() + " services.");
|
FLog.info("Started " + fsh.getServiceAmount() + " services.");
|
||||||
|
|
||||||
timer.update();
|
timer.update();
|
||||||
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod
|
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
||||||
new Metrics(this);
|
new Metrics(this, 2966);
|
||||||
|
|
||||||
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
plugin.pa.autoAddSpawnpoints();
|
|
||||||
}
|
|
||||||
}.runTaskLater(plugin, 60L);
|
|
||||||
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
||||||
SpigotConfig.config.set("settings.restart-on-crash", false);
|
SpigotConfig.config.set("settings.restart-on-crash", false);
|
||||||
}
|
}
|
||||||
@ -301,10 +289,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public void onDisable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
// Stop services and bridges
|
// Stop services and bridges
|
||||||
for (FreedomService service : fsh.getServices())
|
fsh.stopServices();
|
||||||
{
|
|
||||||
service.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(plugin);
|
getServer().getScheduler().cancelTasks(plugin);
|
||||||
|
|
||||||
@ -313,7 +298,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
public static class BuildProperties
|
public static class BuildProperties
|
||||||
{
|
{
|
||||||
|
|
||||||
public String author;
|
public String author;
|
||||||
public String codename;
|
public String codename;
|
||||||
public String version;
|
public String version;
|
||||||
|
@ -31,7 +31,7 @@ public class VanishHandler extends FreedomService
|
|||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
|
if (!plugin.sl.isAdmin(player) && plugin.sl.isVanished(p.getName()))
|
||||||
{
|
{
|
||||||
player.hidePlayer(plugin, p);
|
player.hidePlayer(plugin, p);
|
||||||
}
|
}
|
||||||
@ -39,17 +39,17 @@ public class VanishHandler extends FreedomService
|
|||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
|
if (!plugin.sl.isAdmin(p) && plugin.sl.isVanished(player.getName()))
|
||||||
{
|
{
|
||||||
p.hidePlayer(plugin, player);
|
p.hidePlayer(plugin, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isVanished(player.getName()))
|
if (plugin.sl.isVanished(player.getName()))
|
||||||
{
|
{
|
||||||
plugin.esb.setVanished(player.getName(), true);
|
plugin.esb.setVanished(player.getName(), true);
|
||||||
FLog.info(player.getName() + " joined while still vanished.");
|
FLog.info(player.getName() + " joined while still vanished.");
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
@ -57,7 +57,7 @@ public class VanishHandler extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (!plugin.al.isVanished(player.getName()))
|
if (!plugin.sl.isVanished(player.getName()))
|
||||||
{
|
{
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
@ -73,11 +73,11 @@ public class VanishHandler extends FreedomService
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (plugin.al.isVanished(player.getName()))
|
if (plugin.sl.isVanished(player.getName()))
|
||||||
{
|
{
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
FLog.info(player.getName() + " left while still vanished.");
|
FLog.info(player.getName() + " left while still vanished.");
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
|
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,370 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.admin;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class AdminList extends FreedomService
|
|
||||||
{
|
|
||||||
@Getter
|
|
||||||
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
|
||||||
// Only active admins below
|
|
||||||
@Getter
|
|
||||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
|
||||||
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
|
||||||
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
|
||||||
public final List<String> verifiedNoAdmins = new ArrayList<>();
|
|
||||||
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
|
||||||
public static List<String> vanished = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart()
|
|
||||||
{
|
|
||||||
load();
|
|
||||||
deactivateOldEntries(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load()
|
|
||||||
{
|
|
||||||
allAdmins.clear();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet adminSet = plugin.sql.getAdminList();
|
|
||||||
{
|
|
||||||
while (adminSet.next())
|
|
||||||
{
|
|
||||||
Admin admin = new Admin(adminSet);
|
|
||||||
allAdmins.add(admin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
FLog.severe("Failed to load adminlist: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTables();
|
|
||||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void messageAllAdmins(String message)
|
|
||||||
{
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (isAdmin(player))
|
|
||||||
{
|
|
||||||
player.sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isAdminSync(CommandSender sender)
|
|
||||||
{
|
|
||||||
return isAdmin(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getActiveAdminNames()
|
|
||||||
{
|
|
||||||
List<String> names = new ArrayList();
|
|
||||||
for (Admin admin : activeAdmins)
|
|
||||||
{
|
|
||||||
names.add(admin.getName());
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAdmin(CommandSender sender)
|
|
||||||
{
|
|
||||||
if (!(sender instanceof Player))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Admin admin = getAdmin((Player)sender);
|
|
||||||
|
|
||||||
return admin != null && admin.isActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTelnetAdmin(CommandSender sender)
|
|
||||||
{
|
|
||||||
Admin admin = getAdmin(sender);
|
|
||||||
if (admin == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return admin.getRank().ordinal() >= Rank.TELNET_ADMIN.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSeniorAdmin(CommandSender sender)
|
|
||||||
{
|
|
||||||
Admin admin = getAdmin(sender);
|
|
||||||
if (admin == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return admin.getRank().ordinal() >= Rank.SENIOR_ADMIN.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Admin getAdmin(CommandSender sender)
|
|
||||||
{
|
|
||||||
if (sender instanceof Player)
|
|
||||||
{
|
|
||||||
return getAdmin((Player)sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
return getEntryByName(sender.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Admin getAdmin(Player player)
|
|
||||||
{
|
|
||||||
// Find admin
|
|
||||||
String ip = FUtil.getIp(player);
|
|
||||||
Admin admin = getEntryByName(player.getName());
|
|
||||||
|
|
||||||
// Admin by name
|
|
||||||
if (admin != null)
|
|
||||||
{
|
|
||||||
// Check if we're in online mode,
|
|
||||||
// Or the players IP is in the admin entry
|
|
||||||
if (Bukkit.getOnlineMode() || admin.getIps().contains(ip))
|
|
||||||
{
|
|
||||||
if (!admin.getIps().contains(ip))
|
|
||||||
{
|
|
||||||
// Add the new IP if we have to
|
|
||||||
admin.addIp(ip);
|
|
||||||
save(admin);
|
|
||||||
updateTables();
|
|
||||||
}
|
|
||||||
return admin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Admin by ip
|
|
||||||
admin = getEntryByIp(ip);
|
|
||||||
if (admin != null)
|
|
||||||
{
|
|
||||||
// Set the new username
|
|
||||||
String oldName = admin.getName();
|
|
||||||
admin.setName(player.getName());
|
|
||||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
|
||||||
updateTables();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Admin getEntryByName(String name)
|
|
||||||
{
|
|
||||||
return nameTable.get(name.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Admin getEntryByIp(String ip)
|
|
||||||
{
|
|
||||||
return ipTable.get(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Admin getEntryByIpFuzzy(String needleIp)
|
|
||||||
{
|
|
||||||
final Admin directAdmin = getEntryByIp(needleIp);
|
|
||||||
if (directAdmin != null)
|
|
||||||
{
|
|
||||||
return directAdmin;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String ip : ipTable.keySet())
|
|
||||||
{
|
|
||||||
if (FUtil.fuzzyIpMatch(needleIp, ip, 3))
|
|
||||||
{
|
|
||||||
return ipTable.get(ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateLastLogin(Player player)
|
|
||||||
{
|
|
||||||
final Admin admin = getAdmin(player);
|
|
||||||
if (admin == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
admin.setLastLogin(new Date());
|
|
||||||
admin.setName(player.getName());
|
|
||||||
save(admin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAdminImpostor(Player player)
|
|
||||||
{
|
|
||||||
return getEntryByName(player.getName()) != null && !isAdmin(player) && !isVerifiedAdmin(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVerifiedAdmin(Player player)
|
|
||||||
{
|
|
||||||
return verifiedNoAdmins.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(FUtil.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIdentityMatched(Player player)
|
|
||||||
{
|
|
||||||
if (Bukkit.getOnlineMode())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Admin admin = getAdmin(player);
|
|
||||||
return admin == null ? false : admin.getName().equalsIgnoreCase(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean addAdmin(Admin admin)
|
|
||||||
{
|
|
||||||
if (!admin.isValid())
|
|
||||||
{
|
|
||||||
logger.warning("Could not add admin: " + admin.getName() + " Admin is missing details!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store admin, update views
|
|
||||||
allAdmins.add(admin);
|
|
||||||
updateTables();
|
|
||||||
|
|
||||||
// Save admin
|
|
||||||
plugin.sql.addAdmin(admin);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean removeAdmin(Admin admin)
|
|
||||||
{
|
|
||||||
if (admin.getRank().isAtLeast(Rank.TELNET_ADMIN))
|
|
||||||
{
|
|
||||||
if (plugin.btb != null)
|
|
||||||
{
|
|
||||||
plugin.btb.killTelnetSessions(admin.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove admin, update views
|
|
||||||
if (!allAdmins.remove(admin))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
updateTables();
|
|
||||||
|
|
||||||
// Unsave admin
|
|
||||||
plugin.sql.removeAdmin(admin);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateTables()
|
|
||||||
{
|
|
||||||
activeAdmins.clear();
|
|
||||||
nameTable.clear();
|
|
||||||
ipTable.clear();
|
|
||||||
|
|
||||||
for (Admin admin : allAdmins)
|
|
||||||
{
|
|
||||||
if (!admin.isActive())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
activeAdmins.add(admin);
|
|
||||||
nameTable.put(admin.getName().toLowerCase(), admin);
|
|
||||||
|
|
||||||
for (String ip : admin.getIps())
|
|
||||||
{
|
|
||||||
ipTable.put(ip, admin);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getAdminNames()
|
|
||||||
{
|
|
||||||
return nameTable.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getAdminIps()
|
|
||||||
{
|
|
||||||
return ipTable.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save(Admin admin)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
|
|
||||||
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
|
||||||
{
|
|
||||||
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
|
||||||
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
|
|
||||||
{
|
|
||||||
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
FLog.severe("Failed to save admin: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deactivateOldEntries(boolean verbose)
|
|
||||||
{
|
|
||||||
for (Admin admin : allAdmins)
|
|
||||||
{
|
|
||||||
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Date lastLogin = admin.getLastLogin();
|
|
||||||
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
|
||||||
|
|
||||||
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
admin.setActive(false);
|
|
||||||
save(admin);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTables();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVanished(String player)
|
|
||||||
{
|
|
||||||
return vanished.contains(player);
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,17 +10,16 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.config.IConfig;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Ban implements IConfig
|
public class Ban
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
@ -29,6 +28,9 @@ public class Ban implements IConfig
|
|||||||
@Setter
|
@Setter
|
||||||
private String username = null;
|
private String username = null;
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private UUID uuid = null;
|
||||||
|
@Getter
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -47,9 +49,10 @@ public class Ban implements IConfig
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
|
public Ban(String username, UUID uuid, String ip, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this(username,
|
this(username,
|
||||||
|
uuid,
|
||||||
Arrays.asList(ip),
|
Arrays.asList(ip),
|
||||||
by,
|
by,
|
||||||
at,
|
at,
|
||||||
@ -57,9 +60,10 @@ public class Ban implements IConfig
|
|||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, List<String> ips, String by, Date at, Date expire, String reason)
|
public Ban(String username, UUID uuid, List<String> ips, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
this.uuid = uuid;
|
||||||
if (ips != null)
|
if (ips != null)
|
||||||
{
|
{
|
||||||
this.ips.addAll(ips);
|
this.ips.addAll(ips);
|
||||||
@ -80,12 +84,12 @@ public class Ban implements IConfig
|
|||||||
|
|
||||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
return new Ban(null, null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
return new Ban(null, null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -98,7 +102,8 @@ public class Ban implements IConfig
|
|||||||
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player,
|
return new Ban(player,
|
||||||
new ArrayList<String>(),
|
null,
|
||||||
|
new ArrayList<>(),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
@ -115,6 +120,7 @@ public class Ban implements IConfig
|
|||||||
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
|
player.getUniqueId(),
|
||||||
FUtil.getIp(player),
|
FUtil.getIp(player),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
@ -125,6 +131,7 @@ public class Ban implements IConfig
|
|||||||
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
|
player.getUniqueId(),
|
||||||
FUtil.getFuzzyIp(FUtil.getIp(player)),
|
FUtil.getFuzzyIp(FUtil.getIp(player)),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
@ -137,6 +144,11 @@ public class Ban implements IConfig
|
|||||||
return username != null && !username.isEmpty();
|
return username != null && !username.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasUUID()
|
||||||
|
{
|
||||||
|
return uuid != null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addIp(String ip)
|
public boolean addIp(String ip)
|
||||||
{
|
{
|
||||||
return ips.add(ip);
|
return ips.add(ip);
|
||||||
@ -238,31 +250,6 @@ public class Ban implements IConfig
|
|||||||
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
|
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int hash = 7;
|
|
||||||
hash = 79 * hash + (this.username != null ? this.username.toLowerCase().hashCode() : 0);
|
|
||||||
hash = 79 * hash + (this.ips != null ? this.ips.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return username != null || !ips.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dedupeIps()
|
private void dedupeIps()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
@ -27,8 +28,9 @@ public class BanManager extends FreedomService
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final Set<Ban> bans = Sets.newHashSet();
|
private final Set<Ban> bans = Sets.newHashSet();
|
||||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
|
||||||
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||||
|
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
||||||
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -44,12 +46,18 @@ public class BanManager extends FreedomService
|
|||||||
while (banSet.next())
|
while (banSet.next())
|
||||||
{
|
{
|
||||||
String name = banSet.getString("name");
|
String name = banSet.getString("name");
|
||||||
|
UUID uuid = null;
|
||||||
|
String strUUID = banSet.getString("uuid");
|
||||||
|
if (strUUID != null)
|
||||||
|
{
|
||||||
|
uuid = UUID.fromString(strUUID);
|
||||||
|
}
|
||||||
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
|
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
|
||||||
String by = banSet.getString("by");
|
String by = banSet.getString("by");
|
||||||
Date at = new Date(banSet.getLong("at"));
|
Date at = new Date(banSet.getLong("at"));
|
||||||
Date expires = new Date(banSet.getLong("expires"));
|
Date expires = new Date(banSet.getLong("expires"));
|
||||||
String reason = banSet.getString("reason");
|
String reason = banSet.getString("reason");
|
||||||
Ban ban = new Ban(name, ips, by, at, expires, reason);
|
Ban ban = new Ban(name, uuid, ips, by, at, expires, reason);
|
||||||
bans.add(ban);
|
bans.add(ban);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,6 +144,18 @@ public class BanManager extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Ban getByUUID(UUID uuid)
|
||||||
|
{
|
||||||
|
final Ban directBan = uuidBans.get(uuid);
|
||||||
|
|
||||||
|
if (directBan != null && !directBan.isExpired())
|
||||||
|
{
|
||||||
|
return directBan;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Ban unbanIp(String ip)
|
public Ban unbanIp(String ip)
|
||||||
{
|
{
|
||||||
final Ban ban = getByIp(ip);
|
final Ban ban = getByIp(ip);
|
||||||
@ -224,14 +244,20 @@ public class BanManager extends FreedomService
|
|||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
final String username = event.getPlayer().getName();
|
final String username = event.getPlayer().getName();
|
||||||
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
final String ip = FUtil.getIp(event);
|
final String ip = FUtil.getIp(event);
|
||||||
|
|
||||||
// Regular ban
|
// Regular ban
|
||||||
Ban ban = getByUsername(username);
|
Ban ban = getByUsername(username);
|
||||||
|
if (ban == null)
|
||||||
|
{
|
||||||
|
ban = getByUUID(uuid);
|
||||||
|
|
||||||
if (ban == null)
|
if (ban == null)
|
||||||
{
|
{
|
||||||
ban = getByIp(ip);
|
ban = getByIp(ip);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ban != null && !ban.isExpired())
|
if (ban != null && !ban.isExpired())
|
||||||
{
|
{
|
||||||
@ -245,7 +271,7 @@ public class BanManager extends FreedomService
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final PlayerData data = plugin.pl.getData(player);
|
final PlayerData data = plugin.pl.getData(player);
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -279,6 +305,7 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
nameBans.clear();
|
nameBans.clear();
|
||||||
|
uuidBans.clear();
|
||||||
ipBans.clear();
|
ipBans.clear();
|
||||||
for (Ban ban : bans)
|
for (Ban ban : bans)
|
||||||
{
|
{
|
||||||
@ -287,6 +314,11 @@ public class BanManager extends FreedomService
|
|||||||
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ban.hasUUID())
|
||||||
|
{
|
||||||
|
uuidBans.put(ban.getUuid(), ban);
|
||||||
|
}
|
||||||
|
|
||||||
if (ban.hasIps())
|
if (ban.hasIps())
|
||||||
{
|
{
|
||||||
for (String ip : ban.getIps())
|
for (String ip : ban.getIps())
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public class IndefiniteBan implements IConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String username = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private UUID uuid = null;
|
||||||
|
@Getter
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String reason = null;
|
||||||
|
|
||||||
|
public IndefiniteBan()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFrom(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
this.username = cs.getName();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String strUUID = cs.getString("uuid", null);
|
||||||
|
if (strUUID != null)
|
||||||
|
{
|
||||||
|
UUID uuid = UUID.fromString(strUUID);
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to load indefinite banned UUID for " + this.username + ". Make sure the UUID is in the correct format with dashes.");
|
||||||
|
}
|
||||||
|
this.ips.clear();
|
||||||
|
this.ips.addAll(cs.getStringList("ips"));
|
||||||
|
this.reason = cs.getString("reason", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return username != null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
|
||||||
|
public class IndefiniteBanList extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "indefinitebans.yml";
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int nameBanCount = 0;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int uuidBanCount = 0;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int ipBanCount = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
indefBans.clear();
|
||||||
|
|
||||||
|
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
for (String name : config.getKeys(false))
|
||||||
|
{
|
||||||
|
if (!config.isConfigurationSection(name))
|
||||||
|
{
|
||||||
|
FLog.warning("Could not load indefinite ban for " + name + ": Invalid format!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IndefiniteBan indefBan = new IndefiniteBan();
|
||||||
|
ConfigurationSection cs = config.getConfigurationSection(name);
|
||||||
|
indefBan.loadFrom(cs);
|
||||||
|
|
||||||
|
if (!indefBan.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Not adding indefinite ban for " + name + ": Missing information.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
indefBans.add(indefBan);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCount();
|
||||||
|
|
||||||
|
FLog.info("Loaded " + nameBanCount + " indefinite name bans, " + uuidBanCount + " UUID bans, and " + ipBanCount + " ip bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final String username = event.getPlayer().getName();
|
||||||
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
final String ip = FUtil.getIp(event);
|
||||||
|
|
||||||
|
String bannedBy = "";
|
||||||
|
IndefiniteBan ban = null;
|
||||||
|
|
||||||
|
for (IndefiniteBan indefBan : indefBans)
|
||||||
|
{
|
||||||
|
if (username.toLowerCase().equals(indefBan.getUsername().toLowerCase()))
|
||||||
|
{
|
||||||
|
bannedBy = "username";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid))
|
||||||
|
{
|
||||||
|
bannedBy = "UUID";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (indefBan.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
bannedBy = "IP address";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
String kickMessage = ChatColor.RED + "Your " + bannedBy + " is indefinitely banned from this server.";
|
||||||
|
String reason = ban.getReason();
|
||||||
|
if (!Strings.isNullOrEmpty(reason))
|
||||||
|
{
|
||||||
|
kickMessage += "\nReason: " + ChatColor.GOLD + reason;
|
||||||
|
}
|
||||||
|
String appealURL = ConfigEntry.SERVER_INDEFBAN_URL.getString();
|
||||||
|
if (!Strings.isNullOrEmpty(appealURL))
|
||||||
|
{
|
||||||
|
kickMessage += ChatColor.RED + "\n\nRelease procedures are available at\n" + ChatColor.GOLD + ConfigEntry.SERVER_INDEFBAN_URL.getString();
|
||||||
|
}
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCount()
|
||||||
|
{
|
||||||
|
nameBanCount = 0;
|
||||||
|
uuidBanCount = 0;
|
||||||
|
ipBanCount = 0;
|
||||||
|
|
||||||
|
for (IndefiniteBan indefBan : indefBans)
|
||||||
|
{
|
||||||
|
nameBanCount += 1;
|
||||||
|
if (indefBan.getUuid() != null)
|
||||||
|
{
|
||||||
|
uuidBanCount += 1;
|
||||||
|
}
|
||||||
|
ipBanCount += indefBan.getIps().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,92 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.banning;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import java.util.Set;
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
|
|
||||||
public class PermbanList extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "permbans.yml";
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Set<String> permbannedNames = Sets.newHashSet();
|
|
||||||
@Getter
|
|
||||||
private final Set<String> permbannedIps = Sets.newHashSet();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart()
|
|
||||||
{
|
|
||||||
permbannedNames.clear();
|
|
||||||
permbannedIps.clear();
|
|
||||||
|
|
||||||
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
for (String name : config.getKeys(false))
|
|
||||||
{
|
|
||||||
permbannedNames.add(name.toLowerCase().trim());
|
|
||||||
permbannedIps.addAll(config.getStringList(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
FLog.info("Loaded " + permbannedIps.size() + " perm IP bans and " + permbannedNames.size() + " perm username bans.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
|
||||||
{
|
|
||||||
final String username = event.getPlayer().getName();
|
|
||||||
final String ip = FUtil.getIp(event);
|
|
||||||
|
|
||||||
// Permbanned IPs
|
|
||||||
for (String testIp : getPermbannedIps())
|
|
||||||
{
|
|
||||||
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
|
|
||||||
{
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
|
||||||
ChatColor.RED + "Your IP address is permanently banned from this server.\n"
|
|
||||||
+ "Release procedures are available at\n"
|
|
||||||
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Permbanned usernames
|
|
||||||
for (String testPlayer : getPermbannedNames())
|
|
||||||
{
|
|
||||||
if (testPlayer.equalsIgnoreCase(username))
|
|
||||||
{
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
|
||||||
ChatColor.RED + "Your username is permanently banned from this server.\n"
|
|
||||||
+ "Release procedures are available at\n"
|
|
||||||
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getPermbannedNames()
|
|
||||||
{
|
|
||||||
return this.permbannedNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getPermbannedIps()
|
|
||||||
{
|
|
||||||
return this.permbannedIps;
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,7 +30,7 @@ public class EditBlocker extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.sl.isStaffSync(event.getPlayer()))
|
||||||
{
|
{
|
||||||
fPlayer.setEditBlocked(false);
|
fPlayer.setEditBlocked(false);
|
||||||
return;
|
return;
|
||||||
@ -49,7 +49,7 @@ public class EditBlocker extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.sl.isStaffSync(event.getPlayer()))
|
||||||
{
|
{
|
||||||
fPlayer.setEditBlocked(false);
|
fPlayer.setEditBlocked(false);
|
||||||
return;
|
return;
|
||||||
|
@ -11,13 +11,21 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeModifier;
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
import org.bukkit.block.data.AnaloguePowerable;
|
import org.bukkit.block.data.AnaloguePowerable;
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.block.data.Powerable;
|
import org.bukkit.block.data.Powerable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
@ -27,7 +35,6 @@ import org.bukkit.event.entity.FireworkExplodeEvent;
|
|||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.material.Redstone;
|
|
||||||
|
|
||||||
public class EventBlocker extends FreedomService
|
public class EventBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
@ -141,7 +148,7 @@ public class EventBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(event.getPlayer()))
|
if (!plugin.sl.isStaff(event.getPlayer()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
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;
|
||||||
@ -91,7 +90,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
case WATER_BUCKET:
|
case WATER_BUCKET:
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -104,7 +103,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
|
|
||||||
case LAVA_BUCKET:
|
case LAVA_BUCKET:
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class PVPBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null & !plugin.al.isAdmin(player))
|
if (player != null & !plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
if (player.getGameMode() == GameMode.CREATIVE)
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
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.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -19,7 +20,6 @@ import org.bukkit.command.SimpleCommandMap;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.SimplePluginManager;
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
|
|
||||||
public class CommandBlocker extends FreedomService
|
public class CommandBlocker extends FreedomService
|
||||||
@ -171,7 +171,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
|
|
||||||
for (String part : commandParts)
|
for (String part : commandParts)
|
||||||
{
|
{
|
||||||
if (command.startsWith("/") && !plugin.al.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
if (command.startsWith("/") && !plugin.sl.isStaff(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ public enum CommandBlockerRank
|
|||||||
return TELNET;
|
return TELNET;
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
|
StaffMember staffMember = TotalFreedomMod.plugin().sl.getAdmin(sender);
|
||||||
if (admin != null)
|
if (staffMember != null)
|
||||||
{
|
{
|
||||||
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
if (staffMember.getRank() == Rank.ADMIN)
|
||||||
{
|
{
|
||||||
return SENIOR;
|
return SENIOR;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
|||||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -43,15 +43,15 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
final StaffMember staffMember = plugin.sl.getEntryByIpFuzzy(ip);
|
||||||
|
|
||||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
if (staffMember == null || !staffMember.isActive() || !staffMember.getRank().hasConsoleVariant())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setBypassPassword(true);
|
event.setBypassPassword(true);
|
||||||
event.setName(admin.getName());
|
event.setName(staffMember.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
@ -77,14 +77,14 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
boolean isTelnetAdmin = false;
|
boolean isTelnetAdmin = false;
|
||||||
boolean isSeniorAdmin = false;
|
boolean isSeniorAdmin = false;
|
||||||
|
|
||||||
final Admin admin = plugin.al.getAdmin(player);
|
final StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||||
if (admin != null)
|
if (staffMember != null)
|
||||||
{
|
{
|
||||||
boolean active = admin.isActive();
|
boolean active = staffMember.isActive();
|
||||||
|
|
||||||
isAdmin = active;
|
isAdmin = active;
|
||||||
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
isSeniorAdmin = active && staffMember.getRank() == Rank.ADMIN;
|
||||||
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.TELNET_ADMIN);
|
isTelnetAdmin = active && (isSeniorAdmin || staffMember.getRank() == Rank.MOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||||
@ -121,22 +121,22 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
return bukkitTelnetPlugin;
|
return bukkitTelnetPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Admin> getConnectedAdmins()
|
public List<StaffMember> getConnectedAdmins()
|
||||||
{
|
{
|
||||||
List<Admin> admins = new ArrayList<>();
|
List<StaffMember> staffMembers = new ArrayList<>();
|
||||||
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
if (telnet != null)
|
if (telnet != null)
|
||||||
{
|
{
|
||||||
for (ClientSession session : telnet.appender.getSessions())
|
for (ClientSession session : telnet.appender.getSessions())
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
|
StaffMember staffMember = plugin.sl.getEntryByName(session.getUserName().toLowerCase());
|
||||||
if (admin != null && !admins.contains(admin))
|
if (staffMember != null && !staffMembers.contains(staffMember))
|
||||||
{
|
{
|
||||||
admins.add(admin);
|
staffMembers.add(staffMember);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return admins;
|
return staffMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void killTelnetSessions(final String name)
|
public void killTelnetSessions(final String name)
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.BlockedDisguises;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.libraryaddict.disguise.BlockedDisguises;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class LibsDisguisesBridge extends FreedomService
|
public class LibsDisguisesBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
private LibsDisguises libsDisguisesPlugin = null;
|
private LibsDisguises libsDisguisesPlugin = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,7 +63,7 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undisguiseAll(boolean admins)
|
public void undisguiseAll(boolean staff)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -79,7 +78,7 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
if (DisguiseAPI.isDisguised(player))
|
if (DisguiseAPI.isDisguised(player))
|
||||||
{
|
{
|
||||||
if (!admins && plugin.al.isAdmin(player))
|
if (!staff && plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class Cager extends FreedomService
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player == null
|
if (player == null
|
||||||
|| plugin.al.isAdmin(player))
|
|| plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@ public class CommandLoader extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FLog.debug("Loading command class " + commandClass.getSimpleName());
|
|
||||||
add(commandClass.newInstance());
|
add(commandClass.newInstance());
|
||||||
}
|
}
|
||||||
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
||||||
@ -73,10 +72,7 @@ public class CommandLoader extends FreedomService
|
|||||||
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
|
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getCommandAmount()
|
FLog.info("Loaded " + commands.size() + " commands");
|
||||||
{
|
|
||||||
return commands.size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
|||||||
public @interface CommandPermissions
|
public @interface CommandPermissions
|
||||||
{
|
{
|
||||||
|
|
||||||
Rank level() default Rank.IMPOSTOR;
|
Rank level() default Rank.NON_OP;
|
||||||
|
|
||||||
SourceType source() default SourceType.BOTH;
|
SourceType source() default SourceType.BOTH;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class Command_adventure extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRank(Rank.SUPER_ADMIN);
|
checkRank(Rank.TRIAL_MOD);
|
||||||
|
|
||||||
if (args[0].equals("-a"))
|
if (args[0].equals("-a"))
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ public class Command_adventure extends FreedomCommand
|
|||||||
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
FUtil.staffAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
||||||
msg("Your gamemode has been set to adventure.");
|
msg("Your gamemode has been set to adventure.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.entity.AreaEffectCloud;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
||||||
public class Command_aeclear extends FreedomCommand
|
public class Command_aeclear extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -17,7 +17,7 @@ public class Command_aeclear 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)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Removing all area effect clouds.", true);
|
FUtil.staffAction(sender.getName(), "Removing all area effect clouds.", true);
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
for (World world : server.getWorlds())
|
for (World world : server.getWorlds())
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
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.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Manage your AMP account", usage = "/<command> <create | resetpassword>")
|
||||||
|
public class Command_amp extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!plugin.amp.isEnabled())
|
||||||
|
{
|
||||||
|
msg("AMP integration is currently disabled.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData playerData = getData(playerSender);
|
||||||
|
|
||||||
|
if (playerData.getDiscordID() == null)
|
||||||
|
{
|
||||||
|
msg("You must have a linked discord account.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("create"))
|
||||||
|
{
|
||||||
|
msg("Creating your AMP account...", ChatColor.GREEN);
|
||||||
|
StaffMember staffMember = getAdmin(playerSender);
|
||||||
|
|
||||||
|
if (staffMember.getAmpUsername() != null)
|
||||||
|
{
|
||||||
|
msg("You already have an AMP account.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String username = sender.getName();
|
||||||
|
String password = FUtil.randomString(30);
|
||||||
|
|
||||||
|
staffMember.setAmpUsername(username);
|
||||||
|
plugin.sl.save(staffMember);
|
||||||
|
plugin.sl.updateTables();
|
||||||
|
|
||||||
|
plugin.amp.createAccount(username, password);
|
||||||
|
plugin.dc.sendAMPInfo(playerData, username, password);
|
||||||
|
msg("Successfully created your AMP account. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (args[0].equals("resetpassword"))
|
||||||
|
{
|
||||||
|
StaffMember staffMember = getAdmin(playerSender);
|
||||||
|
|
||||||
|
if (staffMember.getAmpUsername() == null)
|
||||||
|
{
|
||||||
|
msg("You do not have an AMP account.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Resetting your password...", ChatColor.GREEN);
|
||||||
|
|
||||||
|
String username = staffMember.getAmpUsername();
|
||||||
|
String password = FUtil.randomString(30);
|
||||||
|
plugin.amp.setPassword(username,password);
|
||||||
|
plugin.dc.sendAMPInfo(playerData, username, password);
|
||||||
|
|
||||||
|
msg("Successfully reset your AMP account password. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1 && plugin.sl.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return Arrays.asList("create", "resetpassword");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
||||||
public class Command_announce extends FreedomCommand
|
public class Command_announce extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
||||||
public class Command_autoclear extends FreedomCommand
|
public class Command_autoclear extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
||||||
public class Command_autotp extends FreedomCommand
|
public class Command_autotp extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -18,11 +18,10 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
||||||
public class Command_ban extends FreedomCommand
|
public class Command_ban 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)
|
||||||
{
|
{
|
||||||
@ -105,7 +104,10 @@ public class Command_ban extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Banned " + player.getName() + " quietly.");
|
||||||
|
}
|
||||||
// Kill player
|
// Kill player
|
||||||
player.setHealth(0.0);
|
player.setHealth(0.0);
|
||||||
}
|
}
|
||||||
@ -122,7 +124,17 @@ public class Command_ban extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ban player
|
// Ban player
|
||||||
Ban ban = Ban.forPlayerName(username, sender, null, reason);
|
Ban ban;
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
ban = Ban.forPlayer(player, sender, null, reason);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ban = Ban.forPlayerName(username, sender, null, reason);
|
||||||
|
}
|
||||||
|
|
||||||
for (String ip : ips)
|
for (String ip : ips)
|
||||||
{
|
{
|
||||||
ban.addIp(ip);
|
ban.addIp(ip);
|
||||||
@ -142,7 +154,7 @@ public class Command_ban extends FreedomCommand
|
|||||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||||
}
|
}
|
||||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||||
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
|
FUtil.staffAction(sender.getName(), String.format(bcast.toString()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kick player and handle others on IP
|
// Kick player and handle others on IP
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]")
|
@CommandParameters(description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]")
|
||||||
public class Command_banip extends FreedomCommand
|
public class Command_banip extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ public class Command_banip extends FreedomCommand
|
|||||||
{
|
{
|
||||||
// Broadcast
|
// Broadcast
|
||||||
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
||||||
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
|
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.sl.isStaff(player) ? "the IP " + ip : "an IP");
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ 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 all banned player names. Senior Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
@CommandParameters(description = "Shows all banned player names. Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||||
public class Command_banlist extends FreedomCommand
|
public class Command_banlist extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -18,23 +18,19 @@ public class Command_banlist extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("purge"))
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
checkRank(Rank.ADMIN);
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
FUtil.staffAction(sender.getName(), "Purging the ban list", true);
|
||||||
int amount = plugin.bm.purge();
|
int amount = plugin.bm.purge();
|
||||||
msg("Purged " + amount + " player bans.");
|
msg("Purged " + amount + " player bans.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(plugin.bm.getAllBans().size() + " player bans ("
|
msg(plugin.bm.getAllBans().size() + " player bans ("
|
||||||
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
||||||
+ plugin.bm.getIpBans().size() + " IPs)");
|
+ plugin.bm.getIpBans().size() + " IPs)");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]")
|
@CommandParameters(description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]")
|
||||||
public class Command_banname extends FreedomCommand
|
public class Command_banname extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ public class Command_banname extends FreedomCommand
|
|||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Banned the name " + name, true);
|
FUtil.staffAction(sender.getName(), "Banned the name " + name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = getPlayer(name);
|
Player player = getPlayer(name);
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
||||||
public class Command_blockcmd extends FreedomCommand
|
public class Command_blockcmd extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -23,7 +23,7 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
FUtil.staffAction(sender.getName(), "Unblocking commands for all players", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -40,18 +40,18 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("-a"))
|
if (args[0].equals("-a"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
|
FUtil.staffAction(sender.getName(), "Blocking commands for all non-staff", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (isAdmin(player))
|
if (isStaff(player))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
counter += 1;
|
counter += 1;
|
||||||
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||||
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
msg(player, "Your commands have been blocked by a staff member.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Blocked commands for " + counter + " players.");
|
msg("Blocked commands for " + counter + " players.");
|
||||||
@ -66,9 +66,9 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin(player))
|
if (isStaff(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
msg(player.getName() + " is a staff member, and cannot have their commands blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
if (!playerdata.allCommandsBlocked())
|
if (!playerdata.allCommandsBlocked())
|
||||||
{
|
{
|
||||||
playerdata.setCommandsBlocked(true);
|
playerdata.setCommandsBlocked(true);
|
||||||
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||||
msg("Blocked commands for " + player.getName() + ".");
|
msg("Blocked commands for " + player.getName() + ".");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Restricts/unrestricts block modification abilities for everyone on the server or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]")
|
@CommandParameters(description = "Restricts/unrestricts block modification abilities for everyone on the server or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]")
|
||||||
public class Command_blockedit extends FreedomCommand
|
public class Command_blockedit extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
|
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -63,11 +63,11 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("all"))
|
if (args[0].equals("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins.", true);
|
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for all non-staff.", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
playerdata.setEditBlocked(true);
|
playerdata.setEditBlocked(true);
|
||||||
@ -105,20 +105,20 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
final FPlayer pd = plugin.pl.getPlayer(player2);
|
final FPlayer pd = plugin.pl.getPlayer(player2);
|
||||||
if (pd.isEditBlocked())
|
if (pd.isEditBlocked())
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
||||||
pd.setEditBlocked(false);
|
pd.setEditBlocked(false);
|
||||||
msg("Unblocking block modification abilities for " + player2.getName());
|
msg("Unblocking block modification abilities for " + player2.getName());
|
||||||
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player2))
|
if (plugin.sl.isStaff(player2))
|
||||||
{
|
{
|
||||||
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
|
msg(player2.getName() + " is a staff member, and cannot have their block edits blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
||||||
pd.setEditBlocked(true);
|
pd.setEditBlocked(true);
|
||||||
|
|
||||||
if (smite)
|
if (smite)
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode")
|
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode")
|
||||||
public class Command_blockpvp extends FreedomCommand
|
public class Command_blockpvp extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
|
FUtil.staffAction(sender.getName(), "Enabling PVP for all players.", true);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -64,11 +64,11 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("all"))
|
if (args[0].equals("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
|
FUtil.staffAction(sender.getName(), "Disabling PVP for all non-staff", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
playerdata.setPvpBlocked(true);
|
playerdata.setPvpBlocked(true);
|
||||||
@ -106,20 +106,20 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
final FPlayer pd = plugin.pl.getPlayer(p);
|
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||||
if (pd.isPvpBlocked())
|
if (pd.isPvpBlocked())
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
FUtil.staffAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
||||||
pd.setPvpBlocked(false);
|
pd.setPvpBlocked(false);
|
||||||
msg("Enabling PVP for " + p.getName());
|
msg("Enabling PVP for " + p.getName());
|
||||||
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(p))
|
if (plugin.sl.isStaff(p))
|
||||||
{
|
{
|
||||||
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
|
msg(p.getName() + " is a staff member, and cannot have their PVP disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
FUtil.staffAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
||||||
pd.setPvpBlocked(true);
|
pd.setPvpBlocked(true);
|
||||||
if (smite)
|
if (smite)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
||||||
public class Command_blockredstone extends FreedomCommand
|
public class Command_blockredstone extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -18,14 +18,14 @@ public class Command_blockredstone extends FreedomCommand
|
|||||||
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
{
|
{
|
||||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
|
||||||
FUtil.adminAction(sender.getName(), "Blocking all redstone", true);
|
FUtil.staffAction(sender.getName(), "Blocking all redstone", true);
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedom", "Unblocking all redstone", false);
|
FUtil.staffAction("TotalFreedom", "Unblocking all redstone", false);
|
||||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ public class Command_blockredstone extends FreedomCommand
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);
|
FUtil.staffAction(sender.getName(), "Unblocking all redstone", true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||||
public class Command_cage extends FreedomCommand
|
public class Command_cage extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
String skullName = null;
|
String skullName = null;
|
||||||
if ("purge".equals(args[0]))
|
if ("purge".equals(args[0]))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
FUtil.staffAction(sender.getName(), "Uncaging all players", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
@ -101,11 +101,11 @@ public class Command_cage extends FreedomCommand
|
|||||||
|
|
||||||
if (outerMaterial == Material.PLAYER_HEAD)
|
if (outerMaterial == Material.PLAYER_HEAD)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
FUtil.staffAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Caging " + player.getName(), true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "For the people that are still alive - gives a cake to everyone on the server.", usage = "/<command>")
|
@CommandParameters(description = "For the people that are still alive - gives a cake to everyone on the server.", usage = "/<command>")
|
||||||
public class Command_cake extends FreedomCommand
|
public class Command_cake extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ public class Command_cake extends FreedomCommand
|
|||||||
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final int firstEmpty = player.getInventory().firstEmpty();
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
if (firstEmpty >= 0)
|
if (firstEmpty >= 0)
|
||||||
|
@ -16,7 +16,7 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Player targetPlayer = playerSender;
|
Player targetPlayer = playerSender;
|
||||||
|
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
if (args.length == 1 && plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
|
|
||||||
targetPlayer = getPlayer(args[0]);
|
targetPlayer = getPlayer(args[0]);
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
||||||
public class Command_clearchat extends FreedomCommand
|
public class Command_clearchat extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -16,7 +16,7 @@ public class Command_clearchat extends FreedomCommand
|
|||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
@ -24,7 +24,7 @@ public class Command_clearchat extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
FUtil.staffAction(sender.getName(), "Cleared chat", true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
|
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
|
||||||
public class Command_cleardiscordqueue extends FreedomCommand
|
public class Command_cleardiscordqueue extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -29,11 +29,11 @@ public class Command_clearinventory extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(sender))
|
if (plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
if (args[0].equals("-a"))
|
if (args[0].equals("-a"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
|
FUtil.staffAction(sender.getName(), "Clearing everyone's inventory", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
@ -67,7 +67,7 @@ public class Command_clearinventory extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
if (args.length == 1 && plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
List<String> players = FUtil.getPlayerList();
|
List<String> players = FUtil.getPlayerList();
|
||||||
players.add("-a");
|
players.add("-a");
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
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.TRIAL_MOD, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Spy on commands", usage = "/<command>", aliases = "commandspy")
|
@CommandParameters(description = "Spy on commands", usage = "/<command>", aliases = "commandspy")
|
||||||
public class Command_cmdspy extends FreedomCommand
|
public class Command_cmdspy extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -14,11 +14,11 @@ public class Command_cmdspy 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)
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(playerSender);
|
StaffMember staffMember = plugin.sl.getAdmin(playerSender);
|
||||||
admin.setCommandSpy(!admin.getCommandSpy());
|
staffMember.setCommandSpy(!staffMember.getCommandSpy());
|
||||||
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
msg("CommandSpy " + (staffMember.getCommandSpy() ? "enabled." : "disabled."));
|
||||||
plugin.al.save(admin);
|
plugin.sl.save(staffMember);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.MOD, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Telnet/Console command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message>", aliases = "csay")
|
@CommandParameters(description = "Telnet/Console command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message>", aliases = "csay")
|
||||||
public class Command_consolesay extends FreedomCommand
|
public class Command_consolesay extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "For those who have no friends - gives a cookie to everyone on the server.", usage = "/<command>")
|
@CommandParameters(description = "For those who have no friends - gives a cookie to everyone on the server.", usage = "/<command>")
|
||||||
public class Command_cookie extends FreedomCommand
|
public class Command_cookie extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ public class Command_creative extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRank(Rank.SUPER_ADMIN);
|
checkRank(Rank.TRIAL_MOD);
|
||||||
|
|
||||||
if (args[0].equals("-a"))
|
if (args[0].equals("-a"))
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ public class Command_creative extends FreedomCommand
|
|||||||
targetPlayer.setGameMode(GameMode.CREATIVE);
|
targetPlayer.setGameMode(GameMode.CREATIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
|
FUtil.staffAction(sender.getName(), "Changing everyone's gamemode to creative", false);
|
||||||
msg("Your gamemode has been set to creative.");
|
msg("Your gamemode has been set to creative.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Curse someone - sends a cursed texture pack to the specified player.", usage = "/<command> <player>")
|
@CommandParameters(description = "Curse someone - sends a cursed texture pack to the specified player.", usage = "/<command> <player>")
|
||||||
public class Command_curse extends FreedomCommand
|
public class Command_curse extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ public class Command_curse extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender) && FUtil.isExecutive(sender.getName()))
|
if (args.length == 1 && plugin.sl.isStaff(sender) && FUtil.isExecutive(sender.getName()))
|
||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Essentials Interface Command - Remove the nickname of all players on the server.", usage = "/<command>")
|
@CommandParameters(description = "Essentials Interface Command - Remove the nickname of all players on the server.", usage = "/<command>")
|
||||||
public class Command_denick extends FreedomCommand
|
public class Command_denick extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ public class Command_denick extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
|
FUtil.staffAction(sender.getName(), "Removing all nicknames", false);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
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;
|
||||||
@ -10,7 +9,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Deop a player", usage = "/<command> <partialname>")
|
@CommandParameters(description = "Deop a player", usage = "/<command> <partialname>")
|
||||||
public class Command_deop extends FreedomCommand
|
public class Command_deop extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -31,12 +30,12 @@ public class Command_deop extends FreedomCommand
|
|||||||
final String targetName = args[0].toLowerCase();
|
final String targetName = args[0].toLowerCase();
|
||||||
|
|
||||||
final List<String> matchedPlayerNames = new ArrayList<>();
|
final List<String> matchedPlayerNames = new ArrayList<>();
|
||||||
for (final Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||||
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
|
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
|
||||||
{
|
{
|
||||||
if (player.isOp() && !AdminList.vanished.contains(player.getName()))
|
if (player.isOp() && !plugin.sl.isVanished(player.getName()))
|
||||||
{
|
{
|
||||||
matchedPlayerNames.add(player.getName());
|
matchedPlayerNames.add(player.getName());
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
@ -49,7 +48,7 @@ public class Command_deop extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
|
FUtil.staffAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Deop everyone on the server.", usage = "/<command>")
|
@CommandParameters(description = "Deop everyone on the server.", usage = "/<command>")
|
||||||
public class Command_deopall extends FreedomCommand
|
public class Command_deopall extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -14,7 +14,7 @@ public class Command_deopall 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)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "De-opping all players on the server", true);
|
FUtil.staffAction(sender.getName(), "De-opping all players on the server", true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle LibsDisguises for everyone online.", usage = "/<command>", aliases = "dtoggle")
|
@CommandParameters(description = "Toggle LibsDisguises for everyone online.", usage = "/<command>", aliases = "dtoggle")
|
||||||
public class Command_disguisetoggle extends FreedomCommand
|
public class Command_disguisetoggle extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ public class Command_disguisetoggle extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
|
FUtil.staffAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
|
||||||
|
|
||||||
if (plugin.ldb.isDisguisesEnabled())
|
if (plugin.ldb.isDisguisesEnabled())
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Adds or removes donators", usage = "/<command> <mode> <name> <ip> <package> [forum_user]")
|
@CommandParameters(description = "Adds or removes donators", usage = "/<command> <mode> <name> <ip> <package> [forum_user]")
|
||||||
public class Command_donator extends FreedomCommand
|
public class Command_donator extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ public class Command_donator extends FreedomCommand
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FUtil.postRequestToEndpoint(url, "POST", headers, payload);
|
FUtil.sendRequest(url, "POST", headers, payload);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
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.staff.StaffMember;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Sends the specified player to their doom.", usage = "/<command> <playername> [reason]")
|
@CommandParameters(description = "Sends the specified player to their doom.", usage = "/<command> <playername> [reason]")
|
||||||
public class Command_doom extends FreedomCommand
|
public class Command_doom extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -38,22 +38,23 @@ public class Command_doom extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
||||||
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||||
|
|
||||||
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
// Remove from admin
|
// Remove from admin
|
||||||
Admin admin = getAdmin(player);
|
StaffMember staffMember = getAdmin(player);
|
||||||
if (admin != null)
|
if (staffMember != null)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the admin list", true);
|
FUtil.staffAction(sender.getName(), "Removing " + player.getName() + " from the staff list", true);
|
||||||
admin.setActive(false);
|
staffMember.setActive(false);
|
||||||
plugin.al.save(admin);
|
plugin.sl.save(staffMember);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
|
plugin.amp.updateAccountStatus(staffMember);
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
plugin.dc.syncRoles(staffMember, plugin.pl.getData(staffMember.getName()).getDiscordID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ public class Command_doom extends FreedomCommand
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
// message
|
// message
|
||||||
FUtil.adminAction(sender.getName(), "Banning " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Banning " + player.getName(), true);
|
||||||
msg(sender, player.getName() + " has been banned and IP is: " + ip);
|
msg(sender, player.getName() + " has been banned and IP is: " + ip);
|
||||||
|
|
||||||
// generate explosion
|
// generate explosion
|
||||||
|
@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name | -a]", aliases = "ew,rd")
|
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name | -a]", aliases = "ew,rd")
|
||||||
public class Command_entitywipe extends FreedomCommand
|
public class Command_entitywipe extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ public class Command_entitywipe extends FreedomCommand
|
|||||||
entityName = FUtil.formatName(type.name());
|
entityName = FUtil.formatName(type.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging all " + (type != null ? entityName + "s" : "entities"), true);
|
FUtil.staffAction(sender.getName(), "Purging all " + (type != null ? entityName + "s" : "entities"), true);
|
||||||
int count;
|
int count;
|
||||||
if (type != null)
|
if (type != null)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Push people away from you.", usage = "/<command> [radius] [strength]")
|
@CommandParameters(description = "Push people away from you.", usage = "/<command> [radius] [strength]")
|
||||||
public class Command_expel extends FreedomCommand
|
public class Command_expel extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Surprise someone.", usage = "/<command> <player>")
|
@CommandParameters(description = "Surprise someone.", usage = "/<command> <player>")
|
||||||
public class Command_explode extends FreedomCommand
|
public class Command_explode extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ public class Command_explode extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
if (args.length == 1 && plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.MOD, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Make arrows explode", usage = "/<command>", aliases = "ea")
|
@CommandParameters(description = "Make arrows explode", usage = "/<command>", aliases = "ea")
|
||||||
public class Command_explosivearrows extends FreedomCommand
|
public class Command_explosivearrows extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>", aliases = "showip,listip")
|
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>", aliases = "showip,listip")
|
||||||
public class Command_findip extends FreedomCommand
|
public class Command_findip extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ public class Command_forcekill 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.al.isAdmin(sender) && !senderIsConsole)
|
if (!plugin.sl.isMod(sender) && !senderIsConsole)
|
||||||
{
|
{
|
||||||
playerSender.setHealth(0);
|
playerSender.setHealth(0);
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,8 +8,8 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Freeze/Unfreeze a specified player, or all non-admins on the server.", usage = "/<command> [target | purge]", aliases = "fr")
|
@CommandParameters(description = "Freeze/Unfreeze a specified player, or all non-staff on the server.", usage = "/<command> [target | purge]", aliases = "fr")
|
||||||
public class Command_freeze extends FreedomCommand
|
public class Command_freeze extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -23,31 +23,30 @@ public class Command_freeze extends FreedomCommand
|
|||||||
|
|
||||||
if (!gFreeze)
|
if (!gFreeze)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Disabling global player freeze", false);
|
FUtil.staffAction(sender.getName(), "Disabling global player freeze", false);
|
||||||
msg("Players are now free to move.");
|
msg("Players are now free to move.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
|
FUtil.staffAction(sender.getName(), "Enabling global player freeze", false);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!isAdmin(player))
|
if (!isStaff(player))
|
||||||
{
|
{
|
||||||
player.sendTitle(ChatColor.RED + "You've been globally frozen.", ChatColor.YELLOW + "Please be patient and you will be unfrozen shortly.", 20, 100, 60);
|
player.sendTitle(ChatColor.RED + "You've been globally frozen.", ChatColor.YELLOW + "Please be patient and you will be unfrozen shortly.", 20, 100, 60);
|
||||||
msg(player, "You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.", ChatColor.RED);
|
msg(player, "You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg("Players are now frozen.");
|
msg("Players are now frozen.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
|
FUtil.staffAction(sender.getName(), "Unfreezing all players", false);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!isAdmin(player))
|
if (!isStaff(player))
|
||||||
{
|
{
|
||||||
player.sendTitle(ChatColor.GREEN + "You've been unfrozen.", ChatColor.YELLOW + "You may now move again.", 20, 100, 60);
|
player.sendTitle(ChatColor.GREEN + "You've been unfrozen.", ChatColor.YELLOW + "You may now move again.", 20, 100, 60);
|
||||||
}
|
}
|
||||||
@ -69,7 +68,6 @@ public class Command_freeze extends FreedomCommand
|
|||||||
|
|
||||||
msg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
msg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
msg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
msg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "You'll never even see it coming - repeatedly push players away from you until command is untoggled.", usage = "/<command> <on [radius (default=25)] | off>")
|
@CommandParameters(description = "You'll never even see it coming - repeatedly push players away from you until command is untoggled.", usage = "/<command> <on [radius (default=25)] | off>")
|
||||||
public class Command_fuckoff extends FreedomCommand
|
public class Command_fuckoff extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "View server health, such as ticks-per-second, memory, etc.", usage = "/<command>")
|
@CommandParameters(description = "View server health, such as ticks-per-second, memory, etc.", usage = "/<command>")
|
||||||
public class Command_health extends FreedomCommand
|
public class Command_health extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -152,7 +152,7 @@ public class Command_hubworld extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ public class Command_hubworld extends FreedomCommand
|
|||||||
// TODO: Redo this properly
|
// TODO: Redo this properly
|
||||||
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||||
{
|
{
|
||||||
if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
|
if (!(sender instanceof Player) || playerSender == null || !plugin.sl.isAdmin(playerSender))
|
||||||
{
|
{
|
||||||
throw new PermissionDeniedException();
|
throw new PermissionDeniedException();
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
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.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Reload the permban list.", usage = "/<command> reload", aliases = "pb")
|
@CommandParameters(description = "Reload the indefinite ban list.", usage = "/<command> reload", aliases = "ib")
|
||||||
public class Command_permban extends FreedomCommand
|
public class Command_indefban extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -24,12 +23,10 @@ public class Command_permban extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Reloading permban list...", ChatColor.RED);
|
msg("Reloading the indefinite ban list...");
|
||||||
plugin.pm.onStop();
|
plugin.im.onStop();
|
||||||
plugin.pm.onStart();
|
plugin.im.onStart();
|
||||||
msg("Reloaded permban list.");
|
msg("Reloaded the indefinite ban list.");
|
||||||
msg(plugin.pm.getPermbannedIps().size() + " IPs and "
|
|
||||||
+ plugin.pm.getPermbannedNames().size() + " usernames loaded.");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -26,11 +26,11 @@ public class Command_invis extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("clear"))
|
if (args[0].equalsIgnoreCase("clear"))
|
||||||
{
|
{
|
||||||
if(!plugin.al.isAdmin(sender))
|
if(!plugin.sl.isStaff(sender))
|
||||||
return noPerms();
|
return noPerms();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Clearing all invisibility potion effects from all players", true);
|
FUtil.staffAction(sender.getName(), "Clearing all invisibility potion effects from all players", true);
|
||||||
clear = true;
|
clear = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,10 +43,10 @@ public class Command_invis extends FreedomCommand
|
|||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.al.isVanished(player.getName()))
|
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.sl.isVanished(player.getName()))
|
||||||
{
|
{
|
||||||
players.add(player.getName());
|
players.add(player.getName());
|
||||||
if (clear && !plugin.al.isAdmin(player))
|
if (clear && !plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
player.removePotionEffect((PotionEffectType.INVISIBILITY));
|
player.removePotionEffect((PotionEffectType.INVISIBILITY));
|
||||||
clears++;
|
clears++;
|
||||||
@ -71,7 +71,7 @@ public class Command_invis extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
if (args.length == 1 && plugin.sl.isStaff(sender))
|
||||||
return Arrays.asList("clear");
|
return Arrays.asList("clear");
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -12,10 +12,10 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
@CommandParameters(description = "Look into another player's inventory, or optionally take items out.", usage = "/<command> <player> [offhand | armor]", aliases = "inv,insee")
|
@CommandParameters(description = "Look into another player's inventory, or optionally take items out.", usage = "/<command> <player> [offhand | armor]", aliases = "inv,insee")
|
||||||
public class Command_invsee extends FreedomCommand
|
public class Command_invsee 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)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -35,16 +35,15 @@ public class Command_invsee extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player) && !plugin.al.isAdmin(playerSender))
|
if (plugin.sl.isStaff(player) && !plugin.sl.isStaff(playerSender))
|
||||||
{
|
{
|
||||||
msg("You cannot spy on administrators.");
|
msg("You cannot spy on staff members.");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inv;
|
Inventory inv;
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
@ -75,7 +74,7 @@ public class Command_invsee extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
@ -110,4 +109,3 @@ public class Command_invsee extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class Command_jumppads extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Kick the specified player.", usage = "/<command> <player> [reason] [-q]")
|
@CommandParameters(description = "Kick the specified player.", usage = "/<command> <player> [reason] [-q]")
|
||||||
public class Command_kick extends FreedomCommand
|
public class Command_kick extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -65,11 +65,15 @@ public class Command_kick extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (reason != null)
|
if (reason != null)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
|
FUtil.staffAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Kicking " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Kicking " + player.getName(), true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Kicked " + player.getName() + " quietly.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,21 +7,21 @@ 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.TELNET_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Kick all non-admins on server.", usage = "/<command>", aliases = "kickall")
|
@CommandParameters(description = "Kick all non-staff on server.", usage = "/<command>", aliases = "kickall")
|
||||||
public class Command_kicknoob extends FreedomCommand
|
public class Command_kicknoob 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)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Disconnecting all non-admins.", true);
|
FUtil.staffAction(sender.getName(), "Disconnecting all non-staff.", true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
player.kickPlayer(ChatColor.RED + "All non-admins were kicked by " + sender.getName() + ".");
|
player.kickPlayer(ChatColor.RED + "All non-staff were kicked by " + sender.getName() + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Show the last command the specified player used.", usage = "/<command> <player>")
|
@CommandParameters(description = "Show the last command the specified player used.", usage = "/<command> <player>")
|
||||||
public class Command_lastcmd extends FreedomCommand
|
public class Command_lastcmd extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ public class Command_linkdiscord extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length > 1 && plugin.al.isAdmin(playerSender))
|
if (args.length > 1 && plugin.sl.isStaff(playerSender))
|
||||||
{
|
{
|
||||||
PlayerData playerData = plugin.pl.getData(args[0]);
|
PlayerData playerData = plugin.pl.getData(args[0]);
|
||||||
if (playerData == null)
|
if (playerData == null)
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.dean.jraw.ApiException;
|
||||||
|
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 = "Link your reddit account", usage = "/<command> <username | code <code>>")
|
||||||
|
public class Command_linkreddit extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (!plugin.rd.enabled)
|
||||||
|
{
|
||||||
|
msg("The Reddit system is currently disabled.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getData(playerSender).getRedditUsername() != null)
|
||||||
|
{
|
||||||
|
msg("Your Reddit account is already linked.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1 && !args[0].equals("code"))
|
||||||
|
{
|
||||||
|
String username = args[0];
|
||||||
|
String code = plugin.rd.addLinkCode(getData(playerSender), username);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
plugin.rd.sendModMessage(username, "Link Code", "Please run the following in-game to link your Reddit account: /linkreddit code " + code);
|
||||||
|
}
|
||||||
|
catch (ApiException e)
|
||||||
|
{
|
||||||
|
msg("Could not find a Reddit account by the name of " + args[0], ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("A linking code has been sent to " + username + ". Please check your mod mail at " + ChatColor.AQUA + "https://www.reddit.com/message/moderator", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String code = args[1];
|
||||||
|
String username = plugin.rd.checkLinkCode(code);
|
||||||
|
|
||||||
|
if (username == null)
|
||||||
|
{
|
||||||
|
msg(code + " is not a valid code", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Successfully linked the Reddit account " + username + " to your Minecraft account.", ChatColor.GREEN);
|
||||||
|
if (plugin.rd.updateFlair(playerSender))
|
||||||
|
{
|
||||||
|
msg("Your flair has been updated.", ChatColor.GREEN);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,11 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffList;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -15,10 +15,9 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i | -f | -v]", aliases = "who,lsit")
|
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-s | -i | -f | -v]", aliases = "who,lsit")
|
||||||
public class Command_list extends FreedomCommand
|
public class Command_list 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)
|
||||||
{
|
{
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
@ -41,20 +40,20 @@ public class Command_list extends FreedomCommand
|
|||||||
String s = args[0];
|
String s = args[0];
|
||||||
switch (s)
|
switch (s)
|
||||||
{
|
{
|
||||||
case "-a":
|
case "-s":
|
||||||
{
|
{
|
||||||
listFilter = ListFilter.ADMINS;
|
listFilter = ListFilter.STAFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "-v":
|
case "-v":
|
||||||
{
|
{
|
||||||
checkRank(Rank.SUPER_ADMIN);
|
checkRank(Rank.TRIAL_MOD);
|
||||||
listFilter = ListFilter.VANISHED_ADMINS;
|
listFilter = ListFilter.VANISHED_STAFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "-t":
|
case "-t":
|
||||||
{
|
{
|
||||||
checkRank(Rank.TELNET_ADMIN);
|
checkRank(Rank.MOD);
|
||||||
listFilter = ListFilter.TELNET_SESSIONS;
|
listFilter = ListFilter.TELNET_SESSIONS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -83,20 +82,20 @@ public class Command_list extends FreedomCommand
|
|||||||
|
|
||||||
List<String> n = new ArrayList<>();
|
List<String> n = new ArrayList<>();
|
||||||
|
|
||||||
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender) && plugin.al.getAdmin(sender).getRank().isAtLeast(Rank.TELNET_ADMIN))
|
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.sl.isStaff(sender) && plugin.sl.getAdmin(sender).getRank().isAtLeast(Rank.MOD))
|
||||||
{
|
{
|
||||||
List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
|
List<StaffMember> connectedStaffMembers = plugin.btb.getConnectedAdmins();
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
|
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedStaffMembers.size())
|
||||||
.append(ChatColor.BLUE)
|
.append(ChatColor.BLUE)
|
||||||
.append(" admins connected to telnet.");
|
.append(" staff connected to telnet.");
|
||||||
for (Admin admin : connectedAdmins)
|
for (StaffMember staffMember : connectedStaffMembers)
|
||||||
{
|
{
|
||||||
n.add(plugin.rm.getDisplay(admin).getColoredTag() + admin.getName());
|
n.add(plugin.rm.getDisplay(staffMember).getColoredTag() + staffMember.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size())
|
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - StaffList.vanished.size())
|
||||||
.append(ChatColor.BLUE)
|
.append(ChatColor.BLUE)
|
||||||
.append(" out of a maximum ")
|
.append(" out of a maximum ")
|
||||||
.append(ChatColor.RED)
|
.append(ChatColor.RED)
|
||||||
@ -105,19 +104,19 @@ public class Command_list extends FreedomCommand
|
|||||||
.append(" players online.");
|
.append(" players online.");
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
|
if (listFilter == ListFilter.STAFF && !plugin.sl.isStaff(p))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (listFilter == ListFilter.ADMINS && AdminList.vanished.contains(p.getName()))
|
if (listFilter == ListFilter.STAFF && plugin.sl.isVanished(p.getName()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (listFilter == ListFilter.VANISHED_ADMINS && !AdminList.vanished.contains(p.getName()))
|
if (listFilter == ListFilter.VANISHED_STAFF && !plugin.sl.isVanished(p.getName()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (listFilter == ListFilter.IMPOSTORS && !plugin.al.isAdminImpostor(p))
|
if (listFilter == ListFilter.IMPOSTORS && !plugin.sl.isStaffImpostor(p))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -125,22 +124,15 @@ public class Command_list extends FreedomCommand
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (listFilter == ListFilter.PLAYERS && AdminList.vanished.contains(p.getName()))
|
if (listFilter == ListFilter.PLAYERS && plugin.sl.isVanished(p.getName()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Displayable display = plugin.rm.getDisplay(p);
|
final Displayable display = plugin.rm.getDisplay(p);
|
||||||
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldTags())
|
|
||||||
{
|
|
||||||
n.add(getOldPrefix(display) + p.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
n.add(display.getColoredTag() + p.getName());
|
n.add(display.getColoredTag() + p.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
||||||
onlineUsers.append("Connected ")
|
onlineUsers.append("Connected ")
|
||||||
.append(playerType)
|
.append(playerType)
|
||||||
@ -162,29 +154,11 @@ public class Command_list extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOldPrefix(Displayable display)
|
|
||||||
{
|
|
||||||
ChatColor color = display.getColor();
|
|
||||||
|
|
||||||
if (color.equals(ChatColor.AQUA))
|
|
||||||
{
|
|
||||||
color = ChatColor.GOLD;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.GOLD))
|
|
||||||
{
|
|
||||||
color = ChatColor.LIGHT_PURPLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
String prefix = "[" + display.getAbbr() + "]";
|
|
||||||
|
|
||||||
return color + prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum ListFilter
|
private enum ListFilter
|
||||||
{
|
{
|
||||||
PLAYERS,
|
PLAYERS,
|
||||||
ADMINS,
|
STAFF,
|
||||||
VANISHED_ADMINS,
|
VANISHED_STAFF,
|
||||||
TELNET_SESSIONS,
|
TELNET_SESSIONS,
|
||||||
FAMOUS_PLAYERS,
|
FAMOUS_PLAYERS,
|
||||||
IMPOSTORS
|
IMPOSTORS
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "This is evil, and I never should have wrote it - blocks specified player's input.", usage = "/<command> <all | purge | <<partialname> on | off> [-q]>")
|
@CommandParameters(description = "This is evil, and I never should have wrote it - blocks specified player's input.", usage = "/<command> <all | purge | <<partialname> on | off> [-q]>")
|
||||||
public class Command_lockup extends FreedomCommand
|
public class Command_lockup extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("all"))
|
if (args[0].equalsIgnoreCase("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Locking up all players", true);
|
FUtil.staffAction(sender.getName(), "Locking up all players", true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("purge"))
|
else if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unlocking all players", true);
|
FUtil.staffAction(sender.getName(), "Unlocking all players", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
cancelLockup(player);
|
cancelLockup(player);
|
||||||
@ -59,7 +59,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Locking up " + player.getName(), true);
|
||||||
}
|
}
|
||||||
startLockup(player);
|
startLockup(player);
|
||||||
msg("Locked up " + player.getName() + ".");
|
msg("Locked up " + player.getName() + ".");
|
||||||
@ -76,7 +76,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Unlocking " + player.getName(), true);
|
||||||
}
|
}
|
||||||
cancelLockup(player);
|
cancelLockup(player);
|
||||||
msg("Unlocked " + player.getName() + ".");
|
msg("Unlocked " + player.getName() + ".");
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
|
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
|
||||||
public class Command_logs extends FreedomCommand
|
public class Command_logs extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
|
||||||
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 = "Obtain a magical saddle.", usage = "/<command>")
|
|
||||||
public class Command_magicalsaddle extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.MAGICAL_SADDLE))
|
|
||||||
{
|
|
||||||
playerSender.getInventory().addItem(plugin.sh.getMagicalSaddle());
|
|
||||||
msg("You have been given a Magical Saddle", ChatColor.GREEN);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("You do not own a Magical Saddle! Purchase one from the shop.", ChatColor.RED);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,7 +19,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Make a WorldGuard region for an OP.", usage = "/<command> <playername> <name>", aliases = "mor")
|
@CommandParameters(description = "Make a WorldGuard region for an OP.", usage = "/<command> <playername> <name>", aliases = "mor")
|
||||||
public class Command_makeopregion extends FreedomCommand
|
public class Command_makeopregion extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | take> <item> <player>", aliases = "ms")
|
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | take> <item> <player>", aliases = "ms")
|
||||||
public class Command_manageshop extends FreedomCommand
|
public class Command_manageshop extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Manually verify someone", usage = "/<command> <playername>", aliases="mv")
|
@CommandParameters(description = "Manually verify someone", usage = "/<command> <playername>", aliases="mv")
|
||||||
public class Command_manuallyverify extends FreedomCommand
|
public class Command_manuallyverify extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -39,7 +39,7 @@ public class Command_manuallyverify extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
|
FUtil.staffAction(sender.getName(), "Manually verifying player " + player.getName(), false);
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
player.sendMessage(YOU_ARE_OP);
|
player.sendMessage(YOU_ARE_OP);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "seth's personal command", usage = "/<command> <players>", aliases = "genocide")
|
@CommandParameters(description = "seth's personal command", usage = "/<command> <players>", aliases = "genocide")
|
||||||
public class Command_massmurder extends FreedomCommand
|
public class Command_massmurder extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -152,7 +152,7 @@ public class Command_masterbuilderworld extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ public class Command_masterbuilderworld extends FreedomCommand
|
|||||||
// TODO: Redo this properly
|
// TODO: Redo this properly
|
||||||
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||||
{
|
{
|
||||||
if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
|
if (!(sender instanceof Player) || playerSender == null || !plugin.sl.isAdmin(playerSender))
|
||||||
{
|
{
|
||||||
throw new PermissionDeniedException();
|
throw new PermissionDeniedException();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player))
|
if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the Master Builder list", true);
|
FUtil.staffAction(sender.getName(), "Re-adding " + player.getName() + " to the Master Builder list", true);
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
player.sendMessage(YOU_ARE_OP);
|
player.sendMessage(YOU_ARE_OP);
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (!data.isMasterBuilder())
|
else if (!data.isMasterBuilder())
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
|
FUtil.staffAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
|
||||||
data.setMasterBuilder(true);
|
data.setMasterBuilder(true);
|
||||||
data.setVerification(true);
|
data.setVerification(true);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
@ -113,7 +113,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
|
FUtil.staffAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
|
||||||
data.setMasterBuilder(false);
|
data.setMasterBuilder(false);
|
||||||
if (data.getDiscordID() == null)
|
if (data.getDiscordID() == null)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Control mob limiting parameters.", usage = "/<command> <on|off|setmax <count>|dragon|giant|ghast|slime>")
|
@CommandParameters(description = "Control mob limiting parameters.", usage = "/<command> <on|off|setmax <count>|dragon|giant|ghast|slime>")
|
||||||
public class Command_moblimiter extends FreedomCommand
|
public class Command_moblimiter extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command> [name]", aliases = "mp")
|
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command> [name]", aliases = "mp")
|
||||||
public class Command_mobpurge extends FreedomCommand
|
public class Command_mobpurge extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ public class Command_mobpurge extends FreedomCommand
|
|||||||
mobName = FUtil.formatName(type.name());
|
mobName = FUtil.formatName(type.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging all " + (type != null ? mobName + "s" : "mobs"), true);
|
FUtil.staffAction(sender.getName(), "Purging all " + (type != null ? mobName + "s" : "mobs"), true);
|
||||||
int count = plugin.ew.purgeMobs(type);
|
int count = plugin.ew.purgeMobs(type);
|
||||||
msg(count + " " + (type != null ? mobName : "mob") + FUtil.showS(count) + " removed.");
|
msg(count + " " + (type != null ? mobName : "mob") + FUtil.showS(count) + " removed.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
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_16_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
@ -10,6 +11,7 @@ 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_16_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;
|
||||||
@ -141,13 +143,13 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
item.setItemMeta(potionMeta);
|
item.setItemMeta(potionMeta);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// TODO: Fix code here bc 1.15 made some things private for some reason
|
|
||||||
/*case "attribute":
|
case "attribute":
|
||||||
if (args.length < 3)
|
if (args.length < 3)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||||
NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
|
NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
|
||||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||||
NBTTagCompound cmpnd = new NBTTagCompound();
|
NBTTagCompound cmpnd = new NBTTagCompound();
|
||||||
@ -157,28 +159,39 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
msg("Invalid attribute. Please run /attributelist for a list of valid attributes.");
|
msg("Invalid attribute. Please run /attributelist for a list of valid attributes.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cmpnd.set("AttributeName", new NBTTagString(attribute.getAttribute()));
|
cmpnd.setString("AttributeName", attribute.getAttribute());
|
||||||
cmpnd.set("Name", new NBTTagString(attribute.getAttribute()));
|
cmpnd.setString("Name", attribute.getAttribute());
|
||||||
int amount;
|
double amount;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
amount = Integer.parseInt(args[2]);
|
amount = Double.parseDouble(args[2]);
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("The amount specified is not a valid integer.");
|
msg("The amount specified is not a valid integer.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cmpnd.set("Amount", new NBTTagInt(amount));
|
if (Double.isNaN(amount))
|
||||||
cmpnd.set("Operation", new NBTTagInt(0));
|
{
|
||||||
cmpnd.set("UUIDLeast", new NBTTagInt(894654));
|
msg("The amount specified is illegal.");
|
||||||
cmpnd.set("UUIDMost", new NBTTagInt(2872));
|
return true;
|
||||||
cmpnd.set("Slot", new NBTTagString("mainhand"));
|
}
|
||||||
|
cmpnd.setDouble("Amount", amount);
|
||||||
|
cmpnd.setInt("Operation", 0);
|
||||||
|
Random random = new Random();
|
||||||
|
cmpnd.setIntArray("UUID", new int[]
|
||||||
|
{
|
||||||
|
random.nextInt(),
|
||||||
|
random.nextInt(),
|
||||||
|
random.nextInt(),
|
||||||
|
random.nextInt()
|
||||||
|
});
|
||||||
|
cmpnd.setString("Slot", "mainhand");
|
||||||
modifiers.add(cmpnd);
|
modifiers.add(cmpnd);
|
||||||
compound.set("AttributeModifiers", modifiers);
|
compound.set("AttributeModifiers", modifiers);
|
||||||
nmsStack.setTag(compound);
|
nmsStack.setTag(compound);
|
||||||
item = CraftItemStack.asBukkitCopy(nmsStack);
|
item = CraftItemStack.asBukkitCopy(nmsStack);
|
||||||
break;*/
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -200,21 +213,20 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
return stack.getTag().getList("AttributeModifiers", 10);
|
return stack.getTag().getList("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private enum Attribute
|
private enum Attribute
|
||||||
{
|
{
|
||||||
GENERIC_MAX_HEALTH("GENERIC_MAX_HEALTH", "generic.maxHealth"),
|
GENERIC_MAX_HEALTH("GENERIC_MAX_HEALTH", "generic.max_health"),
|
||||||
GENERIC_FOLLOW_RANGE("GENERIC_FOLLOW_RANGE", "generic.followRange"),
|
GENERIC_FOLLOW_RANGE("GENERIC_FOLLOW_RANGE", "generic.follow_range"),
|
||||||
GENERIC_KNOCKBACK_RESISTANCE("GENERIC_KNOCKBACK_RESISTANCE", "generic.knockbackResistance"),
|
GENERIC_KNOCKBACK_RESISTANCE("GENERIC_KNOCKBACK_RESISTANCE", "generic.knockback_resistance"),
|
||||||
GENERIC_MOVEMENT_SPEED("GENERIC_MOVEMENT_SPEED", "generic.movementSpeed"),
|
GENERIC_MOVEMENT_SPEED("GENERIC_MOVEMENT_SPEED", "generic.movement_speed"),
|
||||||
GENERIC_FLYING_SPEED("GENERIC_FLYING_SPEED", "generic.flyingSpeed"),
|
GENERIC_FLYING_SPEED("GENERIC_FLYING_SPEED", "generic.flying_speed"),
|
||||||
GENERIC_ATTACK_DAMAGE("GENERIC_ATTACK_DAMAGE", "generic.attackDamage"),
|
GENERIC_ATTACK_DAMAGE("GENERIC_ATTACK_DAMAGE", "generic.attack_damage"),
|
||||||
GENERIC_ATTACK_SPEED("GENERIC_ATTACK_SPEED", "generic.attackSpeed"),
|
GENERIC_ATTACK_SPEED("GENERIC_ATTACK_SPEED", "generic.attack_speed"),
|
||||||
GENERIC_ARMOR("GENERIC_ARMOR", "generic.armor"),
|
GENERIC_ARMOR("GENERIC_ARMOR", "generic.armor"),
|
||||||
GENERIC_ARMOR_TOUGHNESS("GENERIC_ARMOR_TOUGHNESS", "generic.armorToughmess"),
|
GENERIC_ARMOR_TOUGHNESS("GENERIC_ARMOR_TOUGHNESS", "generic.armor_toughmess"),
|
||||||
GENERIC_LUCK("GENERIC_LUCK", "generic.luck"),
|
GENERIC_LUCK("GENERIC_LUCK", "generic.luck"),
|
||||||
HORSE_JUMP_STRENGTH("GENERIC_MAX_HEALTH", "horse.JumpStrength"),
|
HORSE_JUMP_STRENGTH("GENERIC_MAX_HEALTH", "horse.jump_strength"),
|
||||||
ZOMBIE_SPAWN_REINFORCEMENTS("ZOMBIE_SPAWN_REINFORCEMENTS", "zombie.SpawnReinforcements");
|
ZOMBIE_SPAWN_REINFORCEMENTS("ZOMBIE_SPAWN_REINFORCEMENTS", "zombie.spawn_reinforcements");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String attribute;
|
private final String attribute;
|
||||||
|
@ -16,7 +16,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
||||||
public class Command_mute extends FreedomCommand
|
public class Command_mute extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -53,7 +53,7 @@ public class Command_mute extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
|
FUtil.staffAction(sender.getName(), "Unmuting all players.", true);
|
||||||
FPlayer info;
|
FPlayer info;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Player mp : server.getOnlinePlayers())
|
for (Player mp : server.getOnlinePlayers())
|
||||||
@ -73,13 +73,13 @@ public class Command_mute extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("all"))
|
if (args[0].equals("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Muting all non-admins", true);
|
FUtil.staffAction(sender.getName(), "Muting all non-staff", true);
|
||||||
|
|
||||||
FPlayer playerdata;
|
FPlayer playerdata;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
player.sendTitle(ChatColor.RED + "You've been muted globally.", ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
|
player.sendTitle(ChatColor.RED + "You've been muted globally.", ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
|
||||||
playerdata = plugin.pl.getPlayer(player);
|
playerdata = plugin.pl.getPlayer(player);
|
||||||
@ -120,9 +120,9 @@ public class Command_mute extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is an admin, and can't be muted.");
|
msg(player.getName() + " is a staff member, and can't be muted.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public class Command_mute extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Muting " + player.getName(), true);
|
||||||
|
|
||||||
if (smite)
|
if (smite)
|
||||||
{
|
{
|
||||||
@ -163,7 +163,7 @@ public class Command_mute extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ 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.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -15,9 +15,9 @@ 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.TRIAL_MOD, 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>")
|
@CommandParameters(description = "Manage your staff entry.", usage = "/<command> [-o <staff member>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setscformat <format> | clearscformat> | oldtags | logstick | syncroles>")
|
||||||
public class Command_myadmin extends FreedomCommand
|
public class Command_mystaff extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,13 +29,13 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player init = null;
|
Player init = null;
|
||||||
Admin target = getAdmin(playerSender);
|
StaffMember target = getAdmin(playerSender);
|
||||||
Player targetPlayer = playerSender;
|
Player targetPlayer = playerSender;
|
||||||
|
|
||||||
// -o switch
|
// -o switch
|
||||||
if (args[0].equals("-o"))
|
if (args[0].equals("-o"))
|
||||||
{
|
{
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
checkRank(Rank.ADMIN);
|
||||||
init = playerSender;
|
init = playerSender;
|
||||||
targetPlayer = getPlayer(args[1]);
|
targetPlayer = getPlayer(args[1]);
|
||||||
if (targetPlayer == null)
|
if (targetPlayer == null)
|
||||||
@ -47,7 +47,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
target = getAdmin(targetPlayer);
|
target = getAdmin(targetPlayer);
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
msg("That player is not an admin", ChatColor.RED);
|
msg("That player is not a staff member", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,19 +72,19 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
|
|
||||||
if (init == null)
|
if (init == null)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Clearing my supered IPs", true);
|
FUtil.staffAction(sender.getName(), "Clearing my IPs", true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "' supered IPs", true);
|
FUtil.staffAction(sender.getName(), "Clearing " + target.getName() + "' IPs", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int counter = target.getIps().size() - 1;
|
int counter = target.getIps().size() - 1;
|
||||||
target.clearIPs();
|
target.clearIPs();
|
||||||
target.addIp(targetIp);
|
target.addIp(targetIp);
|
||||||
|
|
||||||
plugin.al.save(target);
|
plugin.sl.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
|
|
||||||
plugin.pl.syncIps(target);
|
plugin.pl.syncIps(target);
|
||||||
|
|
||||||
@ -121,16 +121,16 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("You cannot remove that admin's current IP.");
|
msg("You cannot remove that staff members's current IP.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing a supered IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
FUtil.staffAction(sender.getName(), "Removing an IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
||||||
|
|
||||||
target.removeIp(args[1]);
|
target.removeIp(args[1]);
|
||||||
plugin.al.save(target);
|
plugin.sl.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
|
|
||||||
plugin.pl.syncIps(target);
|
plugin.pl.syncIps(target);
|
||||||
|
|
||||||
@ -141,6 +141,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
|
|
||||||
case "setlogin":
|
case "setlogin":
|
||||||
{
|
{
|
||||||
|
checkRank(Rank.MOD);
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -158,58 +159,44 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
msg("Your login message cannot be more than 100 characters (excluding your rank and your name)", ChatColor.RED);
|
msg("Your login message cannot be more than 100 characters (excluding your rank and your name)", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
FUtil.adminAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
FUtil.staffAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||||
target.setLoginMessage(message);
|
target.setLoginMessage(message);
|
||||||
String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
|
String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
|
||||||
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
|
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
|
||||||
msg("> " + previewMessage);
|
msg("> " + previewMessage);
|
||||||
plugin.al.save(target);
|
plugin.sl.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "clearlogin":
|
case "clearlogin":
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Clearing personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
checkRank(Rank.MOD);
|
||||||
|
FUtil.staffAction(sender.getName(), "Clearing personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||||
target.setLoginMessage(null);
|
target.setLoginMessage(null);
|
||||||
plugin.al.save(target);
|
plugin.sl.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "setacformat":
|
case "setscformat":
|
||||||
{
|
{
|
||||||
String format = StringUtils.join(args, " ", 1, args.length);
|
String format = StringUtils.join(args, " ", 1, args.length);
|
||||||
target.setAcFormat(format);
|
target.setAcFormat(format);
|
||||||
plugin.al.save(target);
|
plugin.sl.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY);
|
msg("Set staff chat format to \"" + format + "\".", ChatColor.GRAY);
|
||||||
String example = format.replace("%name%", "ExampleAdmin").replace("%rank%", Rank.TELNET_ADMIN.getAbbr()).replace("%rankcolor%", Rank.TELNET_ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog.");
|
String example = format.replace("%name%", "ExampleStaff").replace("%rank%", Rank.MOD.getAbbr()).replace("%rankcolor%", Rank.MOD.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog.");
|
||||||
msg(ChatColor.GRAY + "Example: " + FUtil.colorize(example));
|
msg(ChatColor.GRAY + "Example: " + FUtil.colorize(example));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "clearacformat":
|
|
||||||
|
case "clearscformat":
|
||||||
{
|
{
|
||||||
target.setAcFormat(null);
|
target.setAcFormat(null);
|
||||||
plugin.al.save(target);
|
plugin.sl.save(target);
|
||||||
plugin.al.updateTables();
|
plugin.sl.updateTables();
|
||||||
msg("Cleared admin chat format.", ChatColor.GRAY);
|
msg("Cleared staff chat format.", ChatColor.GRAY);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "oldtags":
|
|
||||||
{
|
|
||||||
target.setOldTags(!target.getOldTags());
|
|
||||||
plugin.al.save(target);
|
|
||||||
plugin.al.updateTables();
|
|
||||||
msg((target.getOldTags() ? "Enabled" : "Disabled") + " old tags.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "logstick":
|
|
||||||
{
|
|
||||||
target.setLogStick(!target.getLogStick());
|
|
||||||
plugin.al.save(target);
|
|
||||||
plugin.al.updateTables();
|
|
||||||
msg((target.getLogStick() ? "Enabled" : "Disabled") + " log-stick lookup.");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,13 +243,13 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> singleArguments = Arrays.asList("clearips", "setlogin", "setacformat");
|
List<String> singleArguments = Arrays.asList("clearips", "setlogin", "setscformat");
|
||||||
List<String> doubleArguments = Arrays.asList("clearip", "clearlogin", "clearacformat", "oldtags", "logstick", "syncroles");
|
List<String> doubleArguments = Arrays.asList("clearip", "clearlogin", "clearscformat", "oldtags", "syncroles");
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
@ -283,7 +270,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[0].equals("clearip"))
|
if (args[0].equals("clearip"))
|
||||||
{
|
{
|
||||||
List<String> ips = plugin.al.getAdmin(sender).getIps();
|
List<String> ips = plugin.sl.getAdmin(sender).getIps();
|
||||||
ips.remove(FUtil.getIp((Player)sender));
|
ips.remove(FUtil.getIp((Player)sender));
|
||||||
return ips;
|
return ips;
|
||||||
}
|
}
|
||||||
@ -304,10 +291,10 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[0].equals("-o") && args[2].equals("clearip"))
|
if (args[0].equals("-o") && args[2].equals("clearip"))
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getEntryByName(args[1]);
|
StaffMember staffMember = plugin.sl.getEntryByName(args[1]);
|
||||||
if (admin != null)
|
if (staffMember != null)
|
||||||
{
|
{
|
||||||
return admin.getIps();
|
return staffMember.getIps();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/<command> [player]", 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
|
||||||
{
|
{
|
||||||
@ -53,12 +53,12 @@ public class Command_nickclean extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning " + player.getName() + "'s nickname", false);
|
FUtil.staffAction(sender.getName(), "Cleaning " + player.getName() + "'s nickname", false);
|
||||||
cleanNickname(player);
|
cleanNickname(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
|
FUtil.staffAction(sender.getName(), "Cleaning all nicknames", false);
|
||||||
for (final Player player : server.getOnlinePlayers())
|
for (final Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
cleanNickname(player);
|
cleanNickname(player);
|
||||||
|
@ -41,11 +41,11 @@ public class Command_nickfilter extends FreedomCommand
|
|||||||
|
|
||||||
player = getPlayerByDisplayName(displayName);
|
player = getPlayerByDisplayName(displayName);
|
||||||
|
|
||||||
if (player == null || plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
if (player == null || plugin.sl.isVanished(player.getName()) && !plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
player = getPlayerByDisplayNameAlt(displayName);
|
player = getPlayerByDisplayNameAlt(displayName);
|
||||||
|
|
||||||
if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
if (player == null || !plugin.sl.isVanished(player.getName()) && !plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
|
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
|
||||||
return true;
|
return true;
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Manage notes for a player", usage = "/<command> <name> <list | add <note> | remove <id> | clear>")
|
@CommandParameters(description = "Manage notes for a player", usage = "/<command> <name> <list | add <note> | remove <id> | clear>")
|
||||||
public class Command_notes extends FreedomCommand
|
public class Command_notes extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user