mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 20:46:41 +00:00
Compare commits
17 Commits
2020.9
...
2020.9-bet
Author | SHA1 | Date | |
---|---|---|---|
eb6514332e | |||
098d3e4cf1 | |||
81eb333b6a | |||
3057421d6d | |||
9cb96e81ac | |||
d67189e170 | |||
451ef8f009 | |||
7af53448be | |||
2072c89f77 | |||
43b266f17d | |||
c61f7e78fd | |||
14ab1e95b5 | |||
44fe8f6f94 | |||
1c487a6a60 | |||
6f4cc8d4b5 | |||
f98f6990ea | |||
4c81c94702 |
18
.idea/codeStyles/Project.xml
generated
18
.idea/codeStyles/Project.xml
generated
@ -9,6 +9,24 @@
|
||||
</value>
|
||||
</option>
|
||||
</JavaCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="BRACE_STYLE" value="2" />
|
||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||
|
41
pom.xml
41
pom.xml
@ -46,7 +46,12 @@
|
||||
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.org/repository/nms/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
@ -136,14 +141,14 @@
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.9</version>
|
||||
<version>1.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -171,7 +176,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.18.0</version>
|
||||
<version>2.18.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -185,7 +190,7 @@
|
||||
<dependency>
|
||||
<groupId>net.coreprotect</groupId>
|
||||
<artifactId>coreprotect</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<version>19.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -197,10 +202,10 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -217,13 +222,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.goldtreeservers</groupId>
|
||||
<artifactId>worldguardextraflags</artifactId>
|
||||
@ -291,7 +289,7 @@
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<version>4.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>get-the-git-infos</id>
|
||||
@ -416,6 +414,12 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib</shadedPattern> <!-- Replace this -->
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>commons-io:commons-io</include>
|
||||
@ -424,6 +428,7 @@
|
||||
<include>org.reflections:reflections</include>
|
||||
<include>javassist:javassist</include>
|
||||
<include>me.rayzr522:jsonmessage</include>
|
||||
<include>io.papermc:paperlib</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
@ -439,8 +444,8 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.1.1</version>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
|
@ -1,187 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
@ -197,7 +198,7 @@ public class LoginProcess extends FreedomService
|
||||
int z = FUtil.randomInteger(-10000, 10000);
|
||||
int y = player.getWorld().getHighestBlockYAt(x, z);
|
||||
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||
player.teleport(location);
|
||||
PaperLib.teleportAsync(player, location);
|
||||
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
||||
return;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class Monitors extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
plugin.sl.messageAllStaff(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
|
||||
plugin.sl.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
|
||||
player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(),
|
||||
latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : "")));
|
||||
}
|
||||
|
@ -3,14 +3,15 @@ package me.totalfreedom.totalfreedommod;
|
||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||
import ca.momothereal.mojangson.value.MojangsonCompound;
|
||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -61,7 +62,7 @@ public class MovementValidator extends FreedomService
|
||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation());
|
||||
}
|
||||
|
||||
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
||||
@ -110,7 +111,7 @@ public class MovementValidator extends FreedomService
|
||||
// Validate position
|
||||
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
||||
{
|
||||
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +132,7 @@ public class MovementValidator extends FreedomService
|
||||
|
||||
private Boolean exploitItem(ItemStack item)
|
||||
{
|
||||
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||
MojangsonCompound compound = new MojangsonCompound();
|
||||
boolean foundNegative = false;
|
||||
@ -168,7 +169,7 @@ public class MovementValidator extends FreedomService
|
||||
}
|
||||
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R2.ItemStack stack)
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
{
|
||||
|
178
src/main/java/me/totalfreedom/totalfreedommod/Pterodactyl.java
Normal file
178
src/main/java/me/totalfreedom/totalfreedommod/Pterodactyl.java
Normal file
@ -0,0 +1,178 @@
|
||||
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 me.totalfreedom.totalfreedommod.util.Response;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
public class Pterodactyl extends FreedomService
|
||||
{
|
||||
|
||||
public final String URL = ConfigEntry.PTERO_URL.getString();
|
||||
private final String SERVER_KEY = ConfigEntry.PTERO_SERVER_KEY.getString();
|
||||
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
|
||||
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
|
||||
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
|
||||
|
||||
@Getter
|
||||
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void updateAccountStatus(StaffMember staffMember)
|
||||
{
|
||||
String id = staffMember.getPteroID();
|
||||
|
||||
if (Strings.isNullOrEmpty(id) || !enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!staffMember.isActive() || staffMember.getRank() != Rank.ADMIN)
|
||||
{
|
||||
FLog.debug("Disabling ptero acc");
|
||||
removeAccountFromServer(id);
|
||||
return;
|
||||
}
|
||||
|
||||
FLog.debug("Enabling aptero acc");
|
||||
addAccountToServer(id);
|
||||
}
|
||||
|
||||
public String createAccount(String username, String password)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("username", username);
|
||||
json.put("password", password);
|
||||
json.put("email", username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString());
|
||||
json.put("first_name", username);
|
||||
json.put("last_name", "\u200E"); // required, so I made it appear empty
|
||||
|
||||
Response response;
|
||||
JSONObject jsonResponse;
|
||||
try
|
||||
{
|
||||
response = FUtil.sendRequest(URL + "/api/application/users", "POST", ADMIN_HEADERS, json.toJSONString());
|
||||
jsonResponse = response.getJSONMessage();
|
||||
}
|
||||
catch (IOException | ParseException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return ((JSONObject)jsonResponse.get("attributes")).get("id").toString();
|
||||
|
||||
}
|
||||
|
||||
public boolean deleteAccount(String id)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
try
|
||||
{
|
||||
return FUtil.sendRequest(URL + "/api/application/users/" + id, "DELETE", ADMIN_HEADERS, json.toJSONString()).getCode() == 204;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAccountToServer(String id)
|
||||
{
|
||||
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
|
||||
|
||||
JSONObject userData = getUserData(id);
|
||||
if (userData == null)
|
||||
{
|
||||
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("email", userData.get("email").toString());
|
||||
json.put("permissions", Arrays.asList("control.console", "control.start", "control.restart", "control.stop", "control.kill"));
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(url, "POST", SERVER_HEADERS, json.toJSONString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAccountFromServer(String id)
|
||||
{
|
||||
JSONObject userData = getUserData(id);
|
||||
if (userData == null)
|
||||
{
|
||||
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users/" + userData.get("uuid");
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(url, "DELETE", SERVER_HEADERS, null);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject getUserData(String id)
|
||||
{
|
||||
Response response;
|
||||
JSONObject jsonResponse;
|
||||
try
|
||||
{
|
||||
response = FUtil.sendRequest(URL + "/api/application/users/" + id, "GET", ADMIN_HEADERS, null);
|
||||
jsonResponse = response.getJSONMessage();
|
||||
|
||||
}
|
||||
catch (IOException | ParseException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return (JSONObject)jsonResponse.get("attributes");
|
||||
|
||||
}
|
||||
|
||||
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
|
||||
public void setPassword(String id, String password)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("password", password);
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(URL + "/api/application/users/" + id, "PATCH", ADMIN_HEADERS, json.toJSONString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -201,23 +201,19 @@ public class Reddit extends FreedomService
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -4,14 +4,14 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_16_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftServer;
|
||||
|
||||
public class ServerInterface extends FreedomService
|
||||
{
|
||||
public static final String COMPILE_NMS_VERSION = "v1_16_R1";
|
||||
public static final String COMPILE_NMS_VERSION = "v1_16_R2";
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -135,7 +135,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public EntityWiper ew;
|
||||
public Sitter st;
|
||||
public VanishHandler vh;
|
||||
public AMP amp;
|
||||
public Pterodactyl ptero;
|
||||
|
||||
//public HubWorldRestrictions hwr;
|
||||
//
|
||||
@ -233,7 +233,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
ew = new EntityWiper();
|
||||
st = new Sitter();
|
||||
vh = new VanishHandler();
|
||||
amp = new AMP();
|
||||
ptero = new Pterodactyl();
|
||||
|
||||
// Single admin utils
|
||||
cs = new CommandSpy();
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -43,6 +44,14 @@ public class PVPBlocker extends FreedomService
|
||||
player = (Player)arrow.getShooter();
|
||||
}
|
||||
}
|
||||
else if (event.getDamager() instanceof SpectralArrow)
|
||||
{
|
||||
SpectralArrow spectralArrow = (SpectralArrow)event.getDamager();
|
||||
if (spectralArrow.getShooter() instanceof Player)
|
||||
{
|
||||
player = (Player)spectralArrow.getShooter();
|
||||
}
|
||||
}
|
||||
else if (event.getDamager() instanceof Trident)
|
||||
{
|
||||
Trident trident = (Trident)event.getDamager();
|
||||
@ -84,7 +93,5 @@ public class PVPBlocker extends FreedomService
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -35,7 +35,7 @@ public class SignBlocker extends FreedomService
|
||||
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||
{
|
||||
ItemStack sign = event.getItemInHand();
|
||||
net.minecraft.server.v1_16_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||
String line1 = bet.getString("Text1");
|
||||
|
@ -12,11 +12,14 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class FAWEBridge extends FreedomService
|
||||
@ -29,7 +32,7 @@ public class FAWEBridge extends FreedomService
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
api = plugin.cpb.getCoreProtectAPI();
|
||||
api = ((CoreProtect)Bukkit.getPluginManager().getPlugin("CoreProtect")).getAPI();
|
||||
|
||||
/*
|
||||
* Iterates over blocks placed by GenerationCommands (in the EditSession) and adds them to the CoreProtect logs.
|
||||
@ -127,7 +130,12 @@ public class FAWEBridge extends FreedomService
|
||||
if (!pattern.apply(blockVector3).getBlockType().getMaterial().isAir())
|
||||
{
|
||||
blocksPlaced.putIfAbsent(playerAndSessionEntry, new AbstractMap.SimpleEntry<>(pattern, new ArrayList<>()));
|
||||
blocksPlaced.get(playerAndSessionEntry).getValue().add(new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass()));
|
||||
BlockVector3 vectorClone = new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass());
|
||||
|
||||
if (!blocksPlaced.get(playerAndSessionEntry).getValue().contains(vectorClone))
|
||||
{
|
||||
blocksPlaced.get(playerAndSessionEntry).getValue().add(vectorClone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,23 +146,23 @@ public class FAWEBridge extends FreedomService
|
||||
{
|
||||
world = server.getWorld(editSession.getWorld().getName());
|
||||
}
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
List<BlockState> blocks = new ArrayList<>();
|
||||
|
||||
for (BlockVector3 blockVector3 : region)
|
||||
{
|
||||
blocks.add(world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()));
|
||||
blocks.add(world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()).getState());
|
||||
}
|
||||
|
||||
logBlockEdit(playerName, editSession, pattern, blocks);
|
||||
}
|
||||
|
||||
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, List<Block> blocks)
|
||||
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, List<BlockState> blocks)
|
||||
{
|
||||
Map.Entry<String, EditSession> playerAndSessionEntry = new AbstractMap.SimpleEntry(playerName, editSession);
|
||||
|
||||
server.getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
server.getScheduler().scheduleAsyncDelayedTask(plugin, () ->
|
||||
{
|
||||
for (Block block : blocks)
|
||||
for (BlockState block : blocks)
|
||||
{
|
||||
BlockVector3 blockVector3 = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
|
||||
|
@ -46,23 +46,6 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
return libsDisguisesPlugin;
|
||||
}
|
||||
|
||||
public Boolean isDisguised(Player player)
|
||||
{
|
||||
try
|
||||
{
|
||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||
if (libsDisguises != null)
|
||||
{
|
||||
return DisguiseAPI.isDisguised(player);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void undisguiseAll(boolean staff)
|
||||
{
|
||||
try
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.caging;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -71,7 +72,7 @@ public class Cager extends FreedomService
|
||||
|
||||
if (outOfCage)
|
||||
{
|
||||
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
|
||||
PaperLib.teleportAsync(player.getPlayer(), cageLoc.subtract(0, 0.1, 0));
|
||||
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
||||
cage.regenerate();
|
||||
}
|
||||
|
@ -1,101 +0,0 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Adds or removes donators", usage = "/<command> <mode> <name> <ip> <package> [forum_user]")
|
||||
public class Command_donator extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!FUtil.isFromHostConsole(sender.getName()) && !ConfigEntry.SERVER_OWNERS.getStringList().contains(sender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
Boolean mode = args[0].equals("add");
|
||||
String name = args[1];
|
||||
String ip = args[2];
|
||||
String pkg = args[3];
|
||||
String forum_id = null;
|
||||
|
||||
if (args.length > 4)
|
||||
{
|
||||
forum_id = args[4];
|
||||
}
|
||||
|
||||
PlayerData data = plugin.pl.getData(name);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = plugin.pl.getDataByIp(ip);
|
||||
}
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
data.setDonator(mode);
|
||||
plugin.pl.save(data);
|
||||
}
|
||||
|
||||
if (mode)
|
||||
{
|
||||
FUtil.bcastMsg(ChatColor.AQUA + name + ChatColor.GREEN + " has donated to the server!");
|
||||
}
|
||||
Player player = getPlayer(name);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
|
||||
if (forum_id != null && !forum_id.equals("0"))
|
||||
{
|
||||
String baseurl = ConfigEntry.DONATION_PROBOARDS_URL.getString();
|
||||
String group_id = ConfigEntry.DONATION_GROUP_ID.getString();
|
||||
String session_id = ConfigEntry.DONATION_SESSION_ID.getString();
|
||||
String csrf_token = ConfigEntry.DONATION_CSRF_TOKEN.getString();
|
||||
if (baseurl == null || group_id == null || session_id == null || csrf_token == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
String url = baseurl + "/user/group_members/" + (mode ? "adding" : "remove");
|
||||
List<String> headers = Arrays.asList("Cookie:session_id=" + session_id, "X-Requested-With:XMLHttpRequest");
|
||||
String payload = "group_id=" + group_id + "&user_ids[]=" + forum_id + "&csrf_token=" + csrf_token;
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(url, "POST", headers, payload);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -44,14 +44,14 @@ public class Command_doom extends FreedomCommand
|
||||
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
||||
|
||||
// Remove from admin
|
||||
StaffMember staffMember = getAdmin(player);
|
||||
StaffMember staffMember = getStaffMember(player);
|
||||
if (staffMember != null)
|
||||
{
|
||||
FUtil.staffAction(sender.getName(), "Removing " + player.getName() + " from the staff list", true);
|
||||
staffMember.setActive(false);
|
||||
plugin.sl.save(staffMember);
|
||||
plugin.sl.updateTables();
|
||||
plugin.amp.updateAccountStatus(staffMember);
|
||||
plugin.ptero.updateAccountStatus(staffMember);
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(staffMember, plugin.pl.getData(staffMember.getName()).getDiscordID());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -72,7 +73,7 @@ public class Command_hubworld extends FreedomCommand
|
||||
if (hubWorld == null || playerSender.getWorld() == hubWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -82,15 +82,15 @@ public class Command_list extends FreedomCommand
|
||||
|
||||
List<String> n = new ArrayList<>();
|
||||
|
||||
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.sl.isStaff(sender) && plugin.sl.getAdmin(sender).getRank().isAtLeast(Rank.MOD))
|
||||
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.sl.isStaff(sender) && plugin.sl.getAdmin(playerSender).getRank().isAtLeast(Rank.MOD))
|
||||
{
|
||||
List<StaffMember> connectedStaffMembers = plugin.btb.getConnectedAdmins();
|
||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedStaffMembers.size())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" staff connected to telnet.");
|
||||
.append(" staff members connected to telnet.");
|
||||
for (StaffMember staffMember : connectedStaffMembers)
|
||||
{
|
||||
n.add(plugin.rm.getDisplay(staffMember).getColoredTag() + staffMember.getName());
|
||||
n.add(staffMember.getName());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -139,13 +139,11 @@ public class Command_list extends FreedomCommand
|
||||
.append(": ")
|
||||
.append(StringUtils.join(n, ChatColor.WHITE + ", "));
|
||||
if (senderIsConsole)
|
||||
|
||||
{
|
||||
sender.sendMessage(ChatColor.stripColor(onlineStats.toString()));
|
||||
sender.sendMessage(ChatColor.stripColor(onlineUsers.toString()));
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
sender.sendMessage(onlineStats.toString());
|
||||
sender.sendMessage(onlineUsers.toString());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -12,7 +13,7 @@ public class Command_localspawn extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
playerSender.teleport(playerSender.getWorld().getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, playerSender.getWorld().getSpawnLocation());
|
||||
msg("Teleported to spawnpoint for world \"" + playerSender.getWorld().getName() + "\".");
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -72,7 +73,7 @@ public class Command_masterbuilderworld extends FreedomCommand
|
||||
if (masterBuilderWorld == null || playerSender.getWorld() == masterBuilderWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5,13 +5,13 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagList;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -149,7 +149,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
{
|
||||
return false;
|
||||
}
|
||||
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
|
||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||
NBTTagCompound cmpnd = new NBTTagCompound();
|
||||
@ -199,7 +199,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R2.ItemStack stack)
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ public class Command_mystaff extends FreedomCommand
|
||||
}
|
||||
|
||||
Player init = null;
|
||||
StaffMember target = getAdmin(playerSender);
|
||||
StaffMember target = getStaffMember(playerSender);
|
||||
Player targetPlayer = playerSender;
|
||||
|
||||
// -o switch
|
||||
@ -44,7 +44,7 @@ public class Command_mystaff extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
target = getAdmin(targetPlayer);
|
||||
target = getStaffMember(targetPlayer);
|
||||
if (target == null)
|
||||
{
|
||||
msg("That player is not a staff member", ChatColor.RED);
|
||||
|
@ -0,0 +1,136 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
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 Pterodactyl panel account", usage = "/<command> <create | delete>")
|
||||
public class Command_panel extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (!plugin.ptero.isEnabled())
|
||||
{
|
||||
msg("Pterodactyl 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 Pterodactyl account...", ChatColor.GREEN);
|
||||
StaffMember staffMember = getStaffMember(playerSender);
|
||||
|
||||
if (staffMember.getPteroID() != null)
|
||||
{
|
||||
msg("You already have a Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
String username = sender.getName();
|
||||
String password = FUtil.randomString(30);
|
||||
|
||||
String id = plugin.ptero.createAccount(username, password);
|
||||
if (Strings.isNullOrEmpty(id))
|
||||
{
|
||||
msg("Failed to create your Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.ptero.addAccountToServer(id);
|
||||
|
||||
staffMember.setPteroID(id);
|
||||
plugin.sl.save(staffMember);
|
||||
plugin.sl.updateTables();
|
||||
|
||||
plugin.dc.sendPteroInfo(playerData, username, password);
|
||||
msg("Successfully created your Pterodactyl account. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equals("delete"))
|
||||
{
|
||||
msg("Deleting your Pterodactyl account...", ChatColor.GREEN);
|
||||
StaffMember staffMember = getStaffMember(playerSender);
|
||||
|
||||
if (staffMember.getPteroID() == null)
|
||||
{
|
||||
msg("You do not have a Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean deleted = plugin.ptero.deleteAccount(staffMember.getPteroID());
|
||||
|
||||
if (!deleted)
|
||||
{
|
||||
msg("Failed to delete your Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
staffMember.setPteroID(null);
|
||||
plugin.sl.save(staffMember);
|
||||
plugin.sl.updateTables();
|
||||
|
||||
msg("Successfully deleted your Pterodactyl account.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
/*else if (args[0].equals("resetpassword"))
|
||||
{
|
||||
StaffMember staffMember = getAdmin(playerSender);
|
||||
|
||||
if (staffMember.getAmpUsername() == null)
|
||||
{
|
||||
msg("You do not have a Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Resetting your password...", ChatColor.GREEN);
|
||||
|
||||
String id = staffMember.getPteroID();
|
||||
String password = FUtil.randomString(30);
|
||||
plugin.ptero.setPassword(id, password);
|
||||
plugin.dc.sendPteroInfo(playerData, null, 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", "delete");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@ -10,14 +11,13 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Go to the PlotWorld.", usage = "/<command>", aliases = "pw")
|
||||
public class Command_plotworld extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
World plotworld = server.getWorld("plotworld");
|
||||
if (plotworld != null)
|
||||
{
|
||||
playerSender.teleport(plotworld.getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, plotworld.getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Manipulate your potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
||||
usage = "/<command> <list | clear [target name] | add <type> <duration> <amplifier> [target name]>",
|
||||
usage = "/<command> <list | clearall | clear [target name] | add <type> <duration> <amplifier> [target name]>",
|
||||
aliases="effect")
|
||||
public class Command_potion extends FreedomCommand
|
||||
{
|
||||
@ -25,8 +25,9 @@ public class Command_potion extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 1 || args.length == 2)
|
||||
switch (args.length)
|
||||
{
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
List<String> potionEffectTypeNames = new ArrayList<>();
|
||||
@ -46,6 +47,7 @@ public class Command_potion extends FreedomCommand
|
||||
noPerms();
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.staffAction(sender.getName(), "Cleared all potion effects from all players", true);
|
||||
for (Player target : server.getOnlinePlayers())
|
||||
{
|
||||
@ -55,30 +57,32 @@ public class Command_potion extends FreedomCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("clear"))
|
||||
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
Player target = playerSender;
|
||||
|
||||
if (args.length == 2)
|
||||
if(args.length == 2)
|
||||
{
|
||||
target = getPlayer(args[1], true);
|
||||
|
||||
if (target == null)
|
||||
if (!plugin.sl.isStaff(sender) && !target.equals(getPlayer(sender.getName())))
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
||||
msg(ChatColor.RED + "Only staff can clear potion effects from other players.");
|
||||
return true;
|
||||
}
|
||||
target = getPlayer(args[1], true);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("You must specify a target player when using this command from the console.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.sl.isStaff(sender))
|
||||
if (target == null)
|
||||
{
|
||||
msg(ChatColor.RED + "Only staff can clear potion effects from other players.");
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -89,19 +93,22 @@ public class Command_potion extends FreedomCommand
|
||||
|
||||
msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player " + target.getName() + "." : "from yourself."), ChatColor.AQUA);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (args.length == 4 || args.length == 5)
|
||||
{
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
Player target = playerSender;
|
||||
|
||||
if (args.length == 5)
|
||||
{
|
||||
if (!plugin.sl.isStaff(sender) && !getPlayer(args[4]).equals(getPlayer(sender.getName())))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Only staff can apply potion effects to other players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
target = getPlayer(args[4]);
|
||||
|
||||
if (target == null || plugin.sl.isVanished(target.getName()) && !plugin.sl.isStaff(sender))
|
||||
@ -110,17 +117,13 @@ public class Command_potion extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
sender.sendMessage("You must specify a target player when using this command from the console.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.sl.isStaff(sender))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Only staff can apply potion effects to other players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]);
|
||||
@ -161,16 +164,9 @@ public class Command_potion extends FreedomCommand
|
||||
+ ", Duration: " + new_effect.getDuration()
|
||||
+ ", Amplifier: " + new_effect.getAmplifier()
|
||||
+ (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -179,8 +175,9 @@ public class Command_potion extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
switch (args.length)
|
||||
{
|
||||
case 1:
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.addAll(Arrays.asList("list", "clear", "add"));
|
||||
if (plugin.sl.isStaff(sender))
|
||||
@ -188,9 +185,8 @@ public class Command_potion extends FreedomCommand
|
||||
arguments.add("clearall");
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
|
||||
case 2:
|
||||
if (args[0].equals("clear"))
|
||||
{
|
||||
if (plugin.sl.isStaff(sender))
|
||||
@ -202,28 +198,32 @@ public class Command_potion extends FreedomCommand
|
||||
{
|
||||
return getAllPotionTypes();
|
||||
}
|
||||
}
|
||||
else if (args.length == 3)
|
||||
{
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
return Arrays.asList("<duration>");
|
||||
}
|
||||
}
|
||||
else if (args.length == 4)
|
||||
{
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
return Arrays.asList("<amplifier>");
|
||||
}
|
||||
}
|
||||
else if (args.length == 5 && plugin.sl.isStaff(sender))
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (plugin.sl.isStaff(sender))
|
||||
{
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TimerTask;
|
||||
@ -55,7 +56,7 @@ public class Command_ride extends FreedomCommand
|
||||
|
||||
if (requester.getWorld() != playerSender.getWorld())
|
||||
{
|
||||
requester.teleport(playerSender);
|
||||
PaperLib.teleportAsync(requester, playerSender.getLocation());
|
||||
}
|
||||
|
||||
playerSender.addPassenger(requester);
|
||||
@ -145,7 +146,7 @@ public class Command_ride extends FreedomCommand
|
||||
|
||||
if (player.getWorld() != playerSender.getWorld())
|
||||
{
|
||||
playerSender.teleport(player);
|
||||
PaperLib.teleportAsync(playerSender, player.getLocation());
|
||||
}
|
||||
|
||||
player.addPassenger(playerSender);
|
||||
|
@ -19,7 +19,7 @@ public class Command_setlimit extends FreedomCommand
|
||||
{
|
||||
try
|
||||
{
|
||||
amount = Math.max(1, Math.min(plugin.web.getMaxLimit(), Integer.parseInt(args[0])));
|
||||
amount = Math.max(-1, Math.min(plugin.web.getMaxLimit(), Integer.parseInt(args[0])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
|
@ -0,0 +1,66 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets a specific player's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> <player> [limit]", aliases = "setpl,spl")
|
||||
public class Command_setplayerlimit extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
int amount;
|
||||
if (args.length > 0)
|
||||
{
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
amount = Math.max(-1, Math.min(plugin.web.getMaxLimit(), Integer.parseInt(args[1])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[1], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
amount = plugin.web.getDefaultLimit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
boolean success = false;
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
try
|
||||
{
|
||||
plugin.web.setLimit(player, amount);
|
||||
success = true;
|
||||
}
|
||||
catch (NoClassDefFoundError | NullPointerException ex)
|
||||
{
|
||||
msg("WorldEdit is not enabled on this server.");
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
FUtil.staffAction(sender.getName(), "Setting " + player.getName() + "'s WorldEdit block modification limit to " + amount + ".", true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||
@ -111,7 +112,7 @@ public class Command_slconfig extends FreedomCommand
|
||||
plugin.dc.syncRoles(staffMember, plugin.pl.getData(staffMember.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
plugin.amp.updateAccountStatus(staffMember);
|
||||
plugin.ptero.updateAccountStatus(staffMember);
|
||||
|
||||
msg("Set " + staffMember.getName() + "'s rank to " + rank.getName());
|
||||
return true;
|
||||
@ -205,7 +206,7 @@ public class Command_slconfig extends FreedomCommand
|
||||
|
||||
plugin.sl.addAdmin(staffMember);
|
||||
plugin.rm.updateDisplay(player);
|
||||
plugin.amp.updateAccountStatus(staffMember);
|
||||
plugin.ptero.updateAccountStatus(staffMember);
|
||||
}
|
||||
else // Existing staff member
|
||||
{
|
||||
@ -242,7 +243,7 @@ public class Command_slconfig extends FreedomCommand
|
||||
{
|
||||
plugin.dc.syncRoles(staffMember, plugin.pl.getData(player).getDiscordID());
|
||||
}
|
||||
plugin.amp.updateAccountStatus(staffMember);
|
||||
plugin.ptero.updateAccountStatus(staffMember);
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
@ -285,24 +286,20 @@ public class Command_slconfig extends FreedomCommand
|
||||
FUtil.staffAction(sender.getName(), "Removing " + staffMember.getName() + " from the staff list", true);
|
||||
staffMember.setActive(false);
|
||||
|
||||
if (plugin.pl.getPlayer(player).inStaffChat())
|
||||
{
|
||||
plugin.pl.getPlayer(player).setStaffChat(false);
|
||||
}
|
||||
|
||||
plugin.sl.save(staffMember);
|
||||
plugin.sl.updateTables();
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
plugin.pl.getPlayer(player).setStaffChat(false);
|
||||
}
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(staffMember, plugin.pl.getData(staffMember.getName()).getDiscordID());
|
||||
Discord.syncRoles(staffMember, plugin.pl.getData(staffMember.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
plugin.amp.updateAccountStatus(staffMember);
|
||||
plugin.ptero.updateAccountStatus(staffMember);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@ -40,7 +41,7 @@ public class Command_spectate extends FreedomCommand
|
||||
|
||||
if (playerSender.getWorld() != player.getWorld())
|
||||
{
|
||||
playerSender.teleport(player);
|
||||
PaperLib.teleportAsync(playerSender, player.getLocation());
|
||||
}
|
||||
|
||||
playerSender.setSpectatorTarget(player);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -72,7 +73,7 @@ public class Command_staffworld extends FreedomCommand
|
||||
if (staffWorld == null || playerSender.getWorld() == staffWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Throw a mob in the direction you are facing when you left click with a stick.",
|
||||
@CommandParameters(description = "Throw a mob in the direction you are facing when you right click with a bone.",
|
||||
usage = "/<command> <mobtype [speed] | off | list>")
|
||||
public class Command_tossmob extends FreedomCommand
|
||||
{
|
||||
@ -100,7 +100,7 @@ public class Command_tossmob extends FreedomCommand
|
||||
|
||||
playerData.enableMobThrower(type, speed);
|
||||
msg("MobThrower is enabled. Mob: " + type + " - Speed: " + speed + ".", ChatColor.GREEN);
|
||||
msg("Left click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
|
||||
msg("Right click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
|
||||
msg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
|
||||
|
||||
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.BONE, 1));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -19,7 +20,7 @@ public class Command_tprandom extends FreedomCommand
|
||||
int z = FUtil.randomInteger(-50000, 50000);
|
||||
int y = playerSender.getWorld().getHighestBlockYAt(x, z);
|
||||
Location location = new Location(playerSender.getLocation().getWorld(), x, y, z);
|
||||
playerSender.teleport(location);
|
||||
PaperLib.teleportAsync(playerSender, location);
|
||||
msg("Poof!", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Undisguise all online players on the server", usage = "/<command> [-a]", aliases = "uall")
|
||||
public class Command_undisguiseall extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ public class Command_verify extends FreedomCommand
|
||||
{
|
||||
String code = plugin.dc.generateCode(10);
|
||||
plugin.dc.addVerificationCode(code, playerData);
|
||||
plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + FUtil.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
|
||||
plugin.dc.getUser(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + FUtil.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
|
||||
msg("A verification code has been sent to your account, please copy the code and run /verify <code>", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
@ -324,12 +324,12 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
return player;
|
||||
}
|
||||
|
||||
protected StaffMember getAdmin(CommandSender sender)
|
||||
protected StaffMember getStaffMember(CommandSender sender)
|
||||
{
|
||||
return plugin.sl.getAdmin(sender);
|
||||
}
|
||||
|
||||
protected StaffMember getAdmin(Player player)
|
||||
protected StaffMember getStaffMember(Player player)
|
||||
{
|
||||
return plugin.sl.getAdmin(player);
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ public enum ConfigEntry
|
||||
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
|
||||
SERVER_OWNERS(List.class, "server.owners"),
|
||||
SERVER_EXECUTIVES(List.class, "server.executives"),
|
||||
SERVER_ASSISTANT_EXECUTIVES(List.class, "server.assistant_executives"),
|
||||
SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"),
|
||||
SERVER_BAN_URL(String.class, "server.ban_url"),
|
||||
SERVER_INDEFBAN_URL(String.class, "server.indefban_url"),
|
||||
@ -80,7 +79,6 @@ public enum ConfigEntry
|
||||
DISCORD_MOD_ROLE_ID(String.class, "discord.mod_role_id"),
|
||||
DISCORD_ADMIN_ROLE_ID(String.class, "discord.admin_role_id"),
|
||||
DISCORD_DEVELOPER_ROLE_ID(String.class, "discord.developer_role_id"),
|
||||
DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID(String.class, "discord.assistant_executive_role_id"),
|
||||
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
|
||||
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
||||
//
|
||||
@ -89,19 +87,19 @@ public enum ConfigEntry
|
||||
REDDIT_PASSWORD(String.class, "reddit.password"),
|
||||
REDDIT_CLIENT_ID(String.class, "reddit.client_id"),
|
||||
REDDIT_CLIENT_SECRET(String.class, "reddit.client_secret"),
|
||||
REDDIT_DONATOR_FLAIR_ID(String.class, "reddit.donator_flair_id"),
|
||||
REDDIT_MASTER_BUILDER_FLAIR_ID(String.class, "reddit.master_builder_flair_id"),
|
||||
REDDIT_TRIAL_MOD_FLAIR_ID(String.class, "reddit.trial_mod_flair_id"),
|
||||
REDDIT_MOD_FLAIR_ID(String.class, "reddit.mod_flair_id"),
|
||||
REDDIT_ADMIN_FLAIR_ID(String.class, "reddit.admin_flair_id"),
|
||||
REDDIT_DEVELOPER_FLAIR_ID(String.class, "reddit.developer_flair_id"),
|
||||
REDDIT_ASSISTANT_EXECUTIVE_FLAIR_ID(String.class, "reddit.assistant_executive_flair_id"),
|
||||
REDDIT_EXECUTIVE_FLAIR_ID(String.class, "reddit.executive_flair_id"),
|
||||
REDDIT_SERVER_OWNER_FLAIR_ID(String.class, "reddit.server_owner_flair_id"),
|
||||
//
|
||||
AMP_URL(String.class, "amp.url"),
|
||||
AMP_USERNAME(String.class, "amp.username"),
|
||||
AMP_PASSWORD(String.class, "amp.password"),
|
||||
PTERO_URL(String.class, "ptero.url"),
|
||||
PTERO_DEFAULT_EMAIL_DOMAIN(String.class, "ptero.default_email_domain"),
|
||||
PTERO_SERVER_UUID(String.class, "ptero.server_uuid"),
|
||||
PTERO_ADMIN_KEY(String.class, "ptero.admin_key"),
|
||||
PTERO_SERVER_KEY(String.class, "ptero.server_key"),
|
||||
//
|
||||
DONATION_PROBOARDS_URL(String.class, "donation.proboards_url"),
|
||||
DONATION_GROUP_ID(String.class, "donation.donator_group_id"),
|
||||
|
@ -34,6 +34,9 @@ import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.ReadyEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
import net.dv8tion.jda.api.utils.ChunkingFilter;
|
||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||
import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -90,6 +93,9 @@ public class Discord extends FreedomService
|
||||
})
|
||||
.setAutoReconnect(true)
|
||||
.setRateLimitPool(RATELIMIT_EXECUTOR)
|
||||
.setChunkingFilter(ChunkingFilter.ALL)
|
||||
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
||||
.build();
|
||||
FLog.info("Discord verification bot has successfully enabled!");
|
||||
}
|
||||
@ -143,19 +149,39 @@ public class Discord extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
public void sendAMPInfo(PlayerData playerData, String username, String password)
|
||||
public void sendPteroInfo(PlayerData playerData, String username, String password)
|
||||
{
|
||||
User user = bot.getUserById(playerData.getDiscordID());
|
||||
String message = "The following is your AMP details:\n\nUsername: " + username + "\nPassword: " + password + "\n\nYou can connect to AMP at " + plugin.amp.URL;
|
||||
User user = getUser(playerData.getDiscordID());
|
||||
String message = "The following are your Pterodactyl details:\n\nUsername: " + username + "\nPassword: " + password + "\n\nYou can connect to the panel at " + plugin.ptero.URL;
|
||||
PrivateChannel privateChannel = user.openPrivateChannel().complete();
|
||||
privateChannel.sendMessage(message).complete();
|
||||
}
|
||||
|
||||
public User getUser(String id)
|
||||
{
|
||||
Guild guild = bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString());
|
||||
|
||||
if (guild == null)
|
||||
{
|
||||
FLog.severe("Either the bot is not in the discord server or it doesn't exist. Check the server ID.");
|
||||
return null;
|
||||
}
|
||||
|
||||
Member member = guild.getMemberById(id);
|
||||
|
||||
if (member == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return member.getUser();
|
||||
}
|
||||
|
||||
public boolean sendBackupCodes(PlayerData playerData)
|
||||
{
|
||||
List<String> codes = generateBackupCodes();
|
||||
List<String> encryptedCodes = generateEncryptedBackupCodes(codes);
|
||||
User user = bot.getUserById(playerData.getDiscordID());
|
||||
User user = getUser(playerData.getDiscordID());
|
||||
File file = generateBackupCodesFile(playerData.getName(), codes);
|
||||
if (file == null)
|
||||
{
|
||||
|
@ -60,11 +60,6 @@ public class DiscordToMinecraftListener extends ListenerAdapter
|
||||
{
|
||||
return Title.EXECUTIVE.getColoredTag();
|
||||
}
|
||||
// Assistant Executives
|
||||
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString())))
|
||||
{
|
||||
return Title.ASSISTANT_EXECUTIVE.getColoredTag();
|
||||
}
|
||||
// Admins
|
||||
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_ADMIN_ROLE_ID.getString())))
|
||||
{
|
||||
|
@ -33,7 +33,6 @@ public class Module_list extends HTTPDModule
|
||||
final JSONArray mods = new JSONArray();
|
||||
final JSONArray admins = new JSONArray();
|
||||
final JSONArray developers = new JSONArray();
|
||||
final JSONArray assistant_executives = new JSONArray();
|
||||
final JSONArray executives = new JSONArray();
|
||||
final JSONArray owners = new JSONArray();
|
||||
|
||||
@ -60,11 +59,6 @@ public class Module_list extends HTTPDModule
|
||||
developers.add(player.getName());
|
||||
}
|
||||
|
||||
if (ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getList().contains(player.getName()) && !FUtil.DEVELOPERS.contains(player.getName()))
|
||||
{
|
||||
assistant_executives.add(player.getName());
|
||||
}
|
||||
|
||||
if (ConfigEntry.SERVER_EXECUTIVES.getList().contains(player.getName()) && !FUtil.DEVELOPERS.contains(player.getName()))
|
||||
{
|
||||
executives.add(player.getName());
|
||||
@ -105,7 +99,6 @@ public class Module_list extends HTTPDModule
|
||||
responseObject.put("mods", mods);
|
||||
responseObject.put("admins", admins);
|
||||
responseObject.put("developers", developers);
|
||||
responseObject.put("assistant_executives", assistant_executives);
|
||||
responseObject.put("executives", executives);
|
||||
responseObject.put("owners", owners);
|
||||
responseObject.put("online", server.getOnlinePlayers().size());
|
||||
@ -154,7 +147,7 @@ public class Module_list extends HTTPDModule
|
||||
|
||||
public boolean hasSpecialTitle(Player player)
|
||||
{
|
||||
if (FUtil.DEVELOPERS.contains(player.getName()) || ConfigEntry.SERVER_EXECUTIVES.getList().contains(player.getName()) || ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getList().contains(player.getName()) || ConfigEntry.SERVER_OWNERS.getList().contains(player.getName()))
|
||||
if (FUtil.DEVELOPERS.contains(player.getName()) || ConfigEntry.SERVER_EXECUTIVES.getList().contains(player.getName()) || ConfigEntry.SERVER_OWNERS.getList().contains(player.getName()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.rank;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
@ -62,11 +63,6 @@ public class RankManager extends FreedomService
|
||||
return Title.EXECUTIVE;
|
||||
}
|
||||
|
||||
if (ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getList().contains(player.getName()) && plugin.sl.isStaff(player))
|
||||
{
|
||||
return Title.ASSISTANT_EXECUTIVE;
|
||||
}
|
||||
|
||||
if (plugin.sl.isVerifiedStaff(player))
|
||||
{
|
||||
return Title.VERIFIED_STAFF;
|
||||
@ -78,12 +74,6 @@ public class RankManager extends FreedomService
|
||||
return Title.MASTER_BUILDER;
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
if (!plugin.sl.isStaff(player) && playerData.isDonator())
|
||||
{
|
||||
return Title.DONATOR;
|
||||
}
|
||||
|
||||
return getRank(player);
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,8 @@ import net.md_5.bungee.api.ChatColor;
|
||||
public enum Title implements Displayable
|
||||
{
|
||||
|
||||
DONATOR("a", "Premium Member", ChatColor.of("#ff5600"), org.bukkit.ChatColor.LIGHT_PURPLE, "Premium", true),
|
||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, org.bukkit.ChatColor.DARK_AQUA, "MB", true),
|
||||
VERIFIED_STAFF("a", "Verified Staff", ChatColor.LIGHT_PURPLE, org.bukkit.ChatColor.LIGHT_PURPLE, "VS", false),
|
||||
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Asst Exec", true),
|
||||
EXECUTIVE("an", "Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Exec", true),
|
||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, org.bukkit.ChatColor.DARK_PURPLE, "Dev", true),
|
||||
OWNER("the", "Owner", ChatColor.of("#ff0000"), org.bukkit.ChatColor.DARK_RED, "Owner", true);
|
||||
|
@ -82,7 +82,7 @@ public class SQLite extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.createStatement().execute("CREATE TABLE `staff` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `rank` VARCHAR NOT NULL, `active` BOOLEAN NOT NULL, `last_login` LONG NOT NULL, `login_message` VARCHAR, `command_spy` BOOLEAN NOT NULL, `potion_spy` BOOLEAN NOT NULL, `ac_format` VARCHAR, `amp_username` VARCHAR);");
|
||||
connection.createStatement().execute("CREATE TABLE `staff` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `rank` VARCHAR NOT NULL, `active` BOOLEAN NOT NULL, `last_login` LONG NOT NULL, `login_message` VARCHAR, `command_spy` BOOLEAN NOT NULL, `potion_spy` BOOLEAN NOT NULL, `ac_format` VARCHAR, `ptero_id` VARCHAR);");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -233,7 +233,7 @@ public class SQLite extends FreedomService
|
||||
}
|
||||
else if (value instanceof Boolean)
|
||||
{
|
||||
result = resultSet.getBoolean(key);
|
||||
result = resultSet.getObject(key);
|
||||
}
|
||||
else if (value instanceof Long)
|
||||
{
|
||||
@ -256,12 +256,12 @@ public class SQLite extends FreedomService
|
||||
statement.setBoolean(7, staffMember.getCommandSpy());
|
||||
statement.setBoolean(8, staffMember.getPotionSpy());
|
||||
statement.setString(9, staffMember.getAcFormat());
|
||||
statement.setString(10, staffMember.getAmpUsername());
|
||||
statement.setString(10, staffMember.getPteroID());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to add staff member: " + e.getMessage());
|
||||
FLog.severe("Failed to add staff member: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ public class SQLite extends FreedomService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to add player: " + e.getMessage());
|
||||
FLog.severe("Failed to add player: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ public class SQLite extends FreedomService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to get staff member by name: " + e.getMessage());
|
||||
FLog.severe("Failed to get staff member by name: " + e);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -323,7 +323,7 @@ public class SQLite extends FreedomService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to get player by name: " + e.getMessage());
|
||||
FLog.severe("Failed to get player by name: " + e);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -337,7 +337,7 @@ public class SQLite extends FreedomService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to get Master Builders: " + e.getMessage());
|
||||
FLog.severe("Failed to get Master Builders: " + e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -79,6 +79,18 @@ public class StaffList extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
public void potionSpyMessage(String message)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
StaffMember staffMember = getAdmin(player.getPlayer());
|
||||
if (isStaff(player) && staffMember.getPotionSpy())
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean isStaffSync(CommandSender sender)
|
||||
{
|
||||
return isStaff(sender);
|
||||
|
@ -47,7 +47,7 @@ public class StaffMember
|
||||
private String acFormat = null;
|
||||
@Getter
|
||||
@Setter
|
||||
private String ampUsername = null;
|
||||
private String pteroID = null;
|
||||
|
||||
public StaffMember(Player player)
|
||||
{
|
||||
@ -69,7 +69,7 @@ public class StaffMember
|
||||
this.commandSpy = resultSet.getBoolean("command_spy");
|
||||
this.potionSpy = resultSet.getBoolean("potion_spy");
|
||||
this.acFormat = resultSet.getString("ac_format");
|
||||
this.ampUsername = resultSet.getString("amp_username");
|
||||
this.pteroID = resultSet.getString("ptero_id");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -90,7 +90,7 @@ public class StaffMember
|
||||
.append("- Is Active: ").append(active).append("\n")
|
||||
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
||||
.append("- AMP Username: ").append(ampUsername).append("\n");
|
||||
.append("- Pterodactyl ID: ").append(pteroID).append("\n");
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class StaffMember
|
||||
put("command_spy", commandSpy);
|
||||
put("potion_spy", potionSpy);
|
||||
put("ac_format", acFormat);
|
||||
put("amp_username", ampUsername);
|
||||
put("ptero_id", pteroID);
|
||||
}};
|
||||
return map;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -26,7 +27,6 @@ import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@ -132,7 +132,7 @@ public class FUtil
|
||||
|
||||
public static boolean isExecutive(String name)
|
||||
{
|
||||
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getStringList().contains(name);
|
||||
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name);
|
||||
}
|
||||
|
||||
public static boolean isDeveloper(Player player)
|
||||
@ -237,10 +237,10 @@ public class FUtil
|
||||
List<String> headers = new ArrayList<>();
|
||||
headers.add("Accept:application/json");
|
||||
headers.add("Content-Type:application/json");
|
||||
String response = sendRequest("https://api.mojang.com/profiles/minecraft", "POST", headers, json.toString());
|
||||
Response response = sendRequest("https://api.mojang.com/profiles/minecraft", "POST", headers, json.toString());
|
||||
// Don't care how stupid this looks, couldn't find anything to parse a json string to something readable in java with something not horrendously huge, maybe im just retarded
|
||||
Pattern pattern = Pattern.compile("(?<=\"id\":\")[a-f0-9].{31}");
|
||||
Matcher matcher = pattern.matcher(response);
|
||||
Matcher matcher = pattern.matcher(response.getMessage());
|
||||
if (matcher.find())
|
||||
{
|
||||
String rawUUID = matcher.group(0).replaceFirst("([a-f0-9]{8})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]+)", "$1-$2-$3-$4-$5");
|
||||
@ -254,21 +254,34 @@ public class FUtil
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String sendRequest(String endpoint, String method, List<String>headers, String body) throws IOException
|
||||
public static Response sendRequest(String endpoint, String method, List<String>headers, String body) throws IOException
|
||||
{
|
||||
URL url = new URL(endpoint);
|
||||
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
|
||||
connection.setRequestMethod(method);
|
||||
|
||||
if (headers != null)
|
||||
{
|
||||
|
||||
for (String header : headers)
|
||||
{
|
||||
String[] kv = header.split(":");
|
||||
connection.setRequestProperty(kv[0], kv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
FLog.info(connection.getRequestMethod());
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.writeBytes(body);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
@ -279,7 +292,8 @@ public class FUtil
|
||||
}
|
||||
|
||||
in.close();
|
||||
return response.toString();
|
||||
|
||||
return new Response(connection.getResponseCode(), response.toString());
|
||||
}
|
||||
|
||||
public static void bcastMsg(String message, ChatColor color)
|
||||
@ -854,10 +868,4 @@ public class FUtil
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.getPlugin(), delay);
|
||||
}
|
||||
|
||||
private static class MojangResponse
|
||||
{
|
||||
String id;
|
||||
String name;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
public class Groups
|
||||
{
|
||||
|
||||
public static final List<Material> WOOL_COLORS = Arrays.asList(
|
||||
Material.WHITE_WOOL,
|
||||
Material.RED_WOOL,
|
||||
@ -81,6 +80,7 @@ public class Groups
|
||||
EntityType.PHANTOM,
|
||||
EntityType.PIG,
|
||||
EntityType.PIGLIN,
|
||||
EntityType.PIGLIN_BRUTE,
|
||||
EntityType.PILLAGER,
|
||||
EntityType.POLAR_BEAR,
|
||||
EntityType.PUFFERFISH,
|
||||
@ -147,6 +147,7 @@ public class Groups
|
||||
Material.PHANTOM_SPAWN_EGG,
|
||||
Material.PIG_SPAWN_EGG,
|
||||
Material.PIGLIN_SPAWN_EGG,
|
||||
Material.PIGLIN_BRUTE_SPAWN_EGG,
|
||||
Material.PILLAGER_SPAWN_EGG,
|
||||
Material.POLAR_BEAR_SPAWN_EGG,
|
||||
Material.PUFFERFISH_SPAWN_EGG,
|
||||
|
@ -0,0 +1,25 @@
|
||||
package me.totalfreedom.totalfreedommod.util;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
public class Response
|
||||
{
|
||||
@Getter
|
||||
private int code;
|
||||
@Getter
|
||||
private String message;
|
||||
|
||||
public Response(int code, String message)
|
||||
{
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public JSONObject getJSONMessage() throws ParseException
|
||||
{
|
||||
return (JSONObject) new JSONParser().parse(message);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.world;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
@ -49,7 +50,7 @@ public abstract class CustomWorld extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
player.teleport(getWorld().getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, getWorld().getSpawnLocation());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.world;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -127,7 +128,7 @@ public class WorldManager extends FreedomService
|
||||
if (player.getWorld().getName().equalsIgnoreCase(targetWorld))
|
||||
{
|
||||
playerMsg(player, "Going to main world.", ChatColor.GRAY);
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -136,12 +137,11 @@ public class WorldManager extends FreedomService
|
||||
if (world.getName().equalsIgnoreCase(targetWorld))
|
||||
{
|
||||
playerMsg(player, "Going to world: " + targetWorld, ChatColor.GRAY);
|
||||
player.teleport(world.getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, world.getSpawnLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg(player, "World " + targetWorld + " not found.", ChatColor.GRAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,9 +36,6 @@ server:
|
||||
# All players who show up as executive
|
||||
executives: []
|
||||
|
||||
# All players who show up as assistant executive
|
||||
assistant_executives: []
|
||||
|
||||
# All those who can manage the master builder list
|
||||
master_builder_management: []
|
||||
|
||||
@ -76,8 +73,6 @@ discord:
|
||||
admin_role_id: ''
|
||||
# Developer role ID
|
||||
developer_role_id: ''
|
||||
# Assistant Executive Admin role ID
|
||||
assistant_executive_role_id: ''
|
||||
# Executive Admin role ID
|
||||
executive_role_id: ''
|
||||
# Owner role ID
|
||||
@ -95,8 +90,6 @@ reddit:
|
||||
client_id: ''
|
||||
# Developer app secret
|
||||
client_secret: ''
|
||||
# Donator flair ID
|
||||
donator_flair_id: ''
|
||||
# Master Builder flair ID
|
||||
master_builder_flair_id: ''
|
||||
# Trial Mod flair ID
|
||||
@ -107,21 +100,23 @@ reddit:
|
||||
admin_flair_id: ''
|
||||
# Developer flair ID
|
||||
developer_flair_id: ''
|
||||
# Assistant Executive Admin flair ID
|
||||
assistant_executive_flair_id: ''
|
||||
# Executive Admin flair ID
|
||||
executive_flair_id: ''
|
||||
# Owner flair ID
|
||||
server_owner_flair_id: ''
|
||||
|
||||
# AMP
|
||||
amp:
|
||||
# Pterodactyl
|
||||
ptero:
|
||||
# URL - do not leave a trailing forward slash
|
||||
url: ''
|
||||
# Username
|
||||
username: ''
|
||||
# Password
|
||||
password: ''
|
||||
# The default email domain used to set email addresses for new users - do not include the @
|
||||
default_email_domain: 'example.com'
|
||||
# Server UUID
|
||||
server_uuid: ''
|
||||
# Admin panel API key
|
||||
admin_key: ''
|
||||
# Server API key
|
||||
server_key: ''
|
||||
|
||||
# The shop
|
||||
shop:
|
||||
@ -147,7 +142,7 @@ shop:
|
||||
interval: 300
|
||||
|
||||
# How much time do players have to react
|
||||
time: 30
|
||||
time: 30.0
|
||||
|
||||
# How many coins do winners get?
|
||||
coins_per_win: 5
|
||||
|
@ -2,6 +2,17 @@ name: TotalFreedomMod
|
||||
main: me.totalfreedom.totalfreedommod.TotalFreedomMod
|
||||
version: ${project.version}
|
||||
description: Plugin for the Total Freedom server.
|
||||
loadbefore: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit, WorldGuard, WorldGuardExtraFlags, TFGuilds, SuperVanish, PremiumVanish]
|
||||
softdepend:
|
||||
- BukkitTelnet
|
||||
- Essentials
|
||||
- CoreProtect
|
||||
- LibsDisguises
|
||||
- WorldEdit
|
||||
- WorldGuard
|
||||
- WorldGuardExtraFlags
|
||||
- TFGuilds
|
||||
- JDA
|
||||
- JRAW
|
||||
- Votifier
|
||||
authors: [Madgeek1450, Prozza]
|
||||
api-version: 1.16
|
||||
api-version: "1.16"
|
Reference in New Issue
Block a user