Compare commits

..

4 Commits

Author SHA1 Message Date
a33a39af19 Retired support for 2021.02 fully. (#72) 2021-06-07 16:16:10 +01:00
e1e8f1b3b5 Merge branch 'main' into RELEASE-2021.05 2021-06-06 11:37:44 +01:00
86a8e21d06 TotalFreedomMod May Update 2021-06-06 14:06:01 +10:00
da37ca52fa Bump version 2021-05-27 11:35:11 +10:00
34 changed files with 270 additions and 483 deletions

53
pom.xml
View File

@ -39,11 +39,6 @@
</scm>
<repositories>
<repository>
<id>apache-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
@ -111,13 +106,13 @@
</repository>
<repository>
<id>ess-repo</id>
<url>https://ci.ender.zone/plugin/repository/everything/</url>
<id>rayzr-repo</id>
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
</repository>
<repository>
<id>mattmalec-repo</id>
<url>https://repo.mattmalec.com/repository/releases</url>
<id>ess-repo</id>
<url>https://ci.ender.zone/plugin/repository/everything/</url>
</repository>
</repositories>
@ -154,7 +149,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<version>1.8</version>
<scope>compile</scope>
</dependency>
@ -196,21 +191,21 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.3.0_277</version>
<version>4.2.1_255</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId>
<version>19.5</version>
<version>19.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.5</version>
<version>7.0.4</version>
<scope>provided</scope>
</dependency>
@ -221,6 +216,13 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.rayzr522</groupId>
<artifactId>jsonmessage</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.vexsoftware</groupId>
<artifactId>votifier</artifactId>
@ -269,26 +271,12 @@
<version>3.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.mattmalec</groupId>
<artifactId>Pterodactyl4J</artifactId>
<version>2.BETA_47</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
@ -323,7 +311,7 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.5</version>
<version>4.0.2</version>
<executions>
<execution>
<id>get-the-git-infos</id>
@ -436,12 +424,10 @@
</plugin>
<!-- Shade -->
<!-- NOTE: This should only be temporary. This will need to be updated when a stable build comes out
that supports Java 16 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
@ -453,7 +439,8 @@
<relocations>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib</shadedPattern>
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib
</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>org.bstats</pattern>
@ -467,11 +454,11 @@
<include>commons-codec:commons-codec</include>
<include>org.reflections:reflections</include>
<include>org.javassist:javassist</include>
<include>me.rayzr522:jsonmessage</include>
<include>io.papermc:paperlib</include>
<include>com.github.speedxx:Mojangson</include>
<include>org.bstats:bstats-bukkit</include>
<include>org.jetbrains:annotations</include>
<include>com.mattmalec:Pterodactyl4J</include>
</includes>
</artifactSet>
</configuration>

View File

@ -85,10 +85,6 @@ public class AutoEject extends FreedomService
player.kickPlayer(kickMessage);
break;
}
default:
{
FLog.warning("Unrecognized EjectMethod " + method.name() + " found, defaulting to STRIKE_THREE");
}
case STRIKE_THREE:
{
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));

View File

@ -25,6 +25,11 @@ public class CommandSpy extends FreedomService
{
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
{
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
{
continue;
}
if (player != event.getPlayer())
{
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());

View File

@ -2,8 +2,6 @@ package me.totalfreedom.totalfreedommod;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Bukkit;
import org.bukkit.World;
@ -34,12 +32,9 @@ public class EntityWiper extends FreedomService
{
@Override
public void run()
{
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
wipeEntities(false);
}
}
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
}

View File

@ -4,6 +4,7 @@ import io.papermc.lib.PaperLib;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import me.rayzr522.jsonmessage.JSONMessage;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData;

View File

@ -1,30 +1,26 @@
package me.totalfreedom.totalfreedommod;
import com.mattmalec.pterodactyl4j.Permission;
import com.mattmalec.pterodactyl4j.PowerAction;
import com.mattmalec.pterodactyl4j.PteroAction;
import com.mattmalec.pterodactyl4j.PteroBuilder;
import com.mattmalec.pterodactyl4j.application.entities.ApplicationUser;
import com.mattmalec.pterodactyl4j.application.entities.PteroApplication;
import com.mattmalec.pterodactyl4j.application.managers.UserAction;
import com.mattmalec.pterodactyl4j.client.entities.ClientServer;
import com.mattmalec.pterodactyl4j.client.entities.ClientSubuser;
import com.mattmalec.pterodactyl4j.client.entities.PteroClient;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import joptsimple.internal.Strings;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.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 String CLIENT_KEY = ConfigEntry.PTERO_CLIENT_KEY.getString();
private final String IDENTIFIER = ConfigEntry.PTERO_SERVER_UUID.getString();
private final PteroApplication adminAPI = PteroBuilder.createApplication(URL, ADMIN_KEY);
private final PteroClient clientAPI = PteroBuilder.createClient(URL, CLIENT_KEY);
private final ClientServer server = clientAPI.retrieveServerByIdentifier(IDENTIFIER).execute();
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);
private boolean enabled = !Strings.isNullOrEmpty(URL);
@ -47,60 +43,163 @@ public class Pterodactyl extends FreedomService
if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
{
FLog.debug("Disabling Pterodactyl account");
FLog.debug("Disabling ptero acc");
removeAccountFromServer(id);
return;
}
FLog.debug("Enabling Pterodactyl account");
FLog.debug("Enabling ptero acc");
addAccountToServer(id);
}
@SuppressWarnings("unchecked")
public String createAccount(String username, String password)
{
UserAction action = adminAPI.getUserManager().createUser()
.setUserName(username)
.setEmail(username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString())
.setFirstName(username)
.setLastName("\u200E") // Required - make it appear empty
.setPassword(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
return action.execute().getId();
}
public void deleteAccount(String id)
Response response;
JSONObject jsonResponse;
try
{
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
PteroAction<Void> action = adminAPI.getUserManager().deleteUser(username);
action.execute();
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;
}
}
@SuppressWarnings("unchecked")
public void addAccountToServer(String id)
{
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
String email = username.getEmail();
PteroAction<ClientServer> server = clientAPI.retrieveServerByIdentifier(IDENTIFIER);
server.execute().getSubuserManager().createUser()
.setEmail(email)
.setPermissions(Permission.CONTROL_PERMISSIONS).execute();
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)
{
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
PteroAction<ClientServer> server = clientAPI.retrieveServerByIdentifier(IDENTIFIER);
ClientSubuser clientSubuser = server.execute().getSubuser(username.getUUID()).retrieve().execute();
server.execute().getSubuserManager().deleteUser(clientSubuser).execute();
JSONObject userData = getUserData(id);
if (userData == null)
{
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
return;
}
public void stopServer()
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users/" + userData.get("uuid");
try
{
clientAPI.setPower(server, PowerAction.STOP).execute();
FUtil.sendRequest(url, "DELETE", SERVER_HEADERS, null);
}
catch (IOException e)
{
FLog.severe(e);
}
}
public void restartServer()
public JSONObject getUserData(String id)
{
clientAPI.setPower(server, PowerAction.RESTART).execute();
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
@SuppressWarnings("unchecked")
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);
}
}
public String getURL()
{
return URL;
}
public String getServerKey()
{
return SERVER_KEY;
}
public String getAdminKey()
{
return ADMIN_KEY;
}
public List<String> getServerHeaders()
{
return SERVER_HEADERS;
}
public List<String> getAdminHeaders()
{
return ADMIN_HEADERS;
}
public boolean isEnabled()

View File

@ -43,7 +43,6 @@ public class IndefiniteBan implements IConfig
@Override
public void saveTo(ConfigurationSection cs)
{
// The indefinite ban list is only intended to be modified manually. It is not intended to save.
}
@Override

View File

@ -171,11 +171,6 @@ public class BlockBlocker extends FreedomService
}
break;
}
default:
{
// Do nothing
break;
}
}
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))

View File

@ -36,9 +36,10 @@ public class InteractBlocker extends FreedomService
break;
}
default:
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
{
// Do nothing
//
break;
}
}
@ -157,11 +158,6 @@ public class InteractBlocker extends FreedomService
event.setCancelled(true);
break;
}
default:
{
// Do nothing
break;
}
}
}
}

View File

@ -1,8 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
@ -77,11 +75,9 @@ public class Command_blockcmd extends FreedomCommand
FPlayer playerdata = plugin.pl.getPlayer(player);
if (!playerdata.allCommandsBlocked())
{
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
playerdata.setCommandsBlocked(true);
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
msg("Blocked commands for " + player.getName() + ".");
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
}
else
{

View File

@ -1,8 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils;
@ -130,8 +128,6 @@ public class Command_blockedit extends FreedomCommand
msg(player2, "Your block modification abilities have been blocked.", ChatColor.RED);
msg("Blocked all block modification abilities for " + player2.getName());
plugin.pul.logPunishment(new Punishment(player2.getName(), FUtil.getIp(player2), sender.getName(), PunishmentType.BLOCKEDIT, null));
}
return true;
}

View File

@ -1,8 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.ArrayUtils;
@ -127,7 +125,6 @@ public class Command_blockpvp extends FreedomCommand
{
Command_smite.smite(sender, p, reason);
}
plugin.pul.logPunishment(new Punishment(p.getName(), FUtil.getIp(p), sender.getName(), PunishmentType.BLOCKPVP, null));
msg(p, "Your PVP has been disabled.", ChatColor.RED);
msg("Disabled PVP for " + p.getName());

View File

@ -5,8 +5,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
@ -85,21 +83,8 @@ public class Command_cage extends FreedomCommand
msg("Invalid block!", ChatColor.RED);
break;
}
default:
{
return false;
}
}
}
if (outerMaterial == Material.PLAYER_HEAD)
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
}
else
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
}
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
@ -111,9 +96,17 @@ public class Command_cage extends FreedomCommand
{
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
}
player.setGameMode(GameMode.SURVIVAL);
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.CAGE, null));
if (outerMaterial == Material.PLAYER_HEAD)
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
}
else
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
}
return true;
}

View File

@ -64,12 +64,6 @@ public class Command_entitywipe extends FreedomCommand
return true;
}
if (type == EntityType.PLAYER)
{
msg("Player entities cannot be purged.", ChatColor.RED);
return true;
}
if (!getAllEntities().contains(type))
{
msg(FUtil.formatName(type.name()) + " is an entity, however: it is a mob.", ChatColor.RED);

View File

@ -23,12 +23,12 @@ public class Command_freeze extends FreedomCommand
if (!gFreeze)
{
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
FUtil.adminAction(sender.getName(), "Disabling global player freeze", false);
msg("Players are now free to move.");
return true;
}
FUtil.adminAction(sender.getName(), "Freezing all players", false);
FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
for (Player player : server.getOnlinePlayers())
{
if (!isAdmin(player))

View File

@ -35,8 +35,8 @@ public class Command_manageshop extends FreedomCommand
}
switch (args[1])
{
case "add":
{
try
{
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
@ -75,9 +75,7 @@ public class Command_manageshop extends FreedomCommand
msg("Invalid number: " + args[2], ChatColor.RED);
return true;
}
}
case "remove":
{
try
{
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
@ -124,9 +122,7 @@ public class Command_manageshop extends FreedomCommand
msg("Invalid number: " + args[2], ChatColor.RED);
return true;
}
}
case "set":
{
try
{
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
@ -152,11 +148,6 @@ public class Command_manageshop extends FreedomCommand
return true;
}
}
default:
{
return false;
}
}
}
else if (args[0].equals("items"))
{

View File

@ -116,13 +116,9 @@ public class Command_notes extends FreedomCommand
msg("Cleared " + count + " notes.", ChatColor.GREEN);
return true;
}
default:
{
}
return false;
}
}
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)

View File

@ -1,8 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
@ -58,13 +56,11 @@ public class Command_orbit extends FreedomCommand
}
}
FUtil.adminAction(sender.getName(), "Orbiting " + player.getName(), false);
player.setGameMode(GameMode.SURVIVAL);
playerdata.startOrbiting(strength);
player.setVelocity(new Vector(0, strength, 0));
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.ORBIT, null));
player.setVelocity(new Vector(0, strength, 0));
FUtil.adminAction(sender.getName(), "Orbiting " + player.getName(), false);
return true;
}
}

View File

@ -17,9 +17,11 @@ import org.bukkit.entity.Player;
@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);
@ -30,7 +32,7 @@ public class Command_panel extends FreedomCommand
if (playerData.getDiscordID() == null)
{
msg("You must have a linked Discord account.", ChatColor.RED);
msg("You must have a linked discord account.", ChatColor.RED);
return true;
}
@ -61,11 +63,13 @@ public class Command_panel extends FreedomCommand
}
plugin.ptero.addAccountToServer(id);
admin.setPteroID(id);
plugin.al.save(admin);
plugin.al.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);
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].equalsIgnoreCase("delete"))
@ -79,10 +83,18 @@ public class Command_panel extends FreedomCommand
return true;
}
plugin.ptero.deleteAccount(admin.getPteroID());
boolean deleted = plugin.ptero.deleteAccount(admin.getPteroID());
if (!deleted)
{
msg("Failed to delete your Pterodactyl account.", ChatColor.RED);
return true;
}
admin.setPteroID(null);
plugin.al.save(admin);
plugin.al.updateTables();
msg("Successfully deleted your Pterodactyl account.", ChatColor.GREEN);
return true;
}

View File

@ -29,7 +29,6 @@ public class Command_potion extends FreedomCommand
switch (args.length)
{
case 1:
{
if (args[0].equalsIgnoreCase("list"))
{
List<String> potionEffectTypeNames = new ArrayList<>();
@ -59,10 +58,8 @@ public class Command_potion extends FreedomCommand
}
}
}
}
case 2:
{
if (args[0].equalsIgnoreCase("clear"))
{
Player target = playerSender;
@ -98,11 +95,9 @@ public class Command_potion extends FreedomCommand
msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player " + target.getName() + "." : "from yourself."), ChatColor.AQUA);
}
break;
}
case 4:
case 5:
{
if (args[0].equalsIgnoreCase("add"))
{
Player target = playerSender;
@ -172,12 +167,9 @@ public class Command_potion extends FreedomCommand
+ (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
}
break;
}
default:
{
return false;
}
}
return true;
}
@ -187,17 +179,14 @@ public class Command_potion extends FreedomCommand
switch (args.length)
{
case 1:
{
List<String> arguments = new ArrayList<>(Arrays.asList("list", "clear", "add"));
if (plugin.al.isAdmin(sender))
{
arguments.add("clearall");
}
return arguments;
}
case 2:
{
if (args[0].equals("clear"))
{
if (plugin.al.isAdmin(sender))
@ -210,28 +199,22 @@ public class Command_potion extends FreedomCommand
return getAllPotionTypes();
}
break;
}
case 3:
{
if (args[0].equals("add"))
{
return Collections.singletonList("<duration>");
}
break;
}
case 4:
{
if (args[0].equals("add"))
{
return Collections.singletonList("<amplifier>");
}
break;
}
case 5:
{
if (plugin.al.isAdmin(sender))
{
if (args[0].equals("add"))
@ -242,12 +225,6 @@ public class Command_potion extends FreedomCommand
break;
}
default:
{
break;
}
}
return Collections.emptyList();
}

View File

@ -1,77 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.HashMap;
import java.util.Map;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Restart the server", usage = "/<command> [reason]")
public class Command_restart extends FreedomCommand
{
private static final Map<CommandSender, String> RESTART_CONFIRM = new HashMap<>();
@Override
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
if (!plugin.ptero.isEnabled())
{
msg("Pterodactyl integration is currently disabled.", ChatColor.RED);
return true;
}
String reason = "Server is restarting!";
if (args.length != 0)
{
reason = StringUtils.join(args, " ");
}
if (sender.getName().equals("CONSOLE"))
{
restart(reason);
return true;
}
else if (RESTART_CONFIRM.containsKey(sender))
{
restart(RESTART_CONFIRM.get(sender));
return true;
}
msg("Warning: You're about to restart the server. Type /restart again to confirm you want to do this.");
RESTART_CONFIRM.put(sender, reason);
new BukkitRunnable()
{
@Override
public void run()
{
if (RESTART_CONFIRM.containsKey(sender))
{
RESTART_CONFIRM.remove(sender);
msg("Restart request expired.");
}
}
}.runTaskLater(plugin, 15 * 20);
return true;
}
public void restart(String reason)
{
FUtil.bcastMsg("Server is restarting!", ChatColor.LIGHT_PURPLE);
for (Player player : server.getOnlinePlayers())
{
player.kickPlayer(ChatColor.LIGHT_PURPLE + reason);
}
RESTART_CONFIRM.remove(sender);
plugin.ptero.restartServer();
}
}

View File

@ -20,6 +20,7 @@ public class Command_stop extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
String reason = "Server is going offline, come back in about 20 seconds.";
if (args.length != 0)
@ -38,6 +39,7 @@ public class Command_stop extends FreedomCommand
return true;
}
msg("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
STOP_CONFIRM.put(sender, reason);
@ -67,13 +69,6 @@ public class Command_stop extends FreedomCommand
STOP_CONFIRM.remove(sender);
if (plugin.ptero.isEnabled())
{
plugin.ptero.stopServer();
}
else
{
server.shutdown();
}
}
}

View File

@ -105,11 +105,6 @@ public class Command_tag extends FreedomCommand
}
return true;
}
default:
{
return false;
}
}
}
else if (args.length >= 2)
@ -284,11 +279,6 @@ public class Command_tag extends FreedomCommand
msg("Tag set to '" + outputTag + ChatColor.GRAY + "'." + (save ? " (Saved)" : "") + from + to);
return true;
}
default:
{
return false;
}
}
}
return false;

View File

@ -16,12 +16,6 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]")
public class Command_toggle extends FreedomCommand
{
private final List<String> toggles = Arrays.asList(
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "structureblocks", "jigsaws", "grindstones",
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
"landmines", "tossmob", "gravity");
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
@ -29,10 +23,38 @@ public class Command_toggle extends FreedomCommand
if (args.length == 0)
{
msg("Available toggles: ");
for (String toggle : toggles)
{
msg("- " + toggle);
}
msg("- waterplace");
msg("- fireplace");
msg("- lavaplace");
msg("- fluidspread");
msg("- lavadmg");
msg("- firespread");
msg("- frostwalk");
msg("- firework");
msg("- prelog");
msg("- lockdown");
msg("- petprotect");
msg("- entitywipe");
msg("- nonuke [range] [count]");
msg("- explosives [radius]");
msg("- unsafeenchs");
msg("- bells");
msg("- armorstands");
msg("- structureblocks");
msg("- jigsaws");
msg("- grindstones");
msg("- jukeboxes");
msg("- spawners");
msg("- 4chan");
msg("- beehives");
msg("- respawnanchors");
msg("- autotp");
msg("- autoclear");
msg("- minecarts");
msg("- landmines");
msg("- mp44");
msg("- tossmob");
msg("- gravity");
return false;
}
@ -282,16 +304,6 @@ public class Command_toggle extends FreedomCommand
toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
break;
}
default:
{
msg("Available toggles: ");
for (String toggle : toggles)
{
msg("- " + toggle);
}
return false;
}
}
return true;
}

View File

@ -1,9 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
@ -56,16 +53,15 @@ public class Command_warn extends FreedomCommand
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
plugin.pl.getPlayer(player).incrementWarnings(quiet);
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.WARN, warnReason));
msg(ChatColor.GREEN + "You have successfully warned " + player.getName());
if (quiet)
{
msg("You have successfully warned " + player.getName() + " quietly.");
msg("Warned " + player.getName() + " quietly");
return true;
}
else
{
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
String adminNotice = ChatColor.RED +
sender.getName() +
" - " +
@ -75,9 +71,7 @@ public class Command_warn extends FreedomCommand
ChatColor.YELLOW +
warnReason;
plugin.al.messageAllAdmins(adminNotice);
msg("You have successfully warned " + player.getName() + ".");
}
plugin.pl.getPlayer(player).incrementWarnings();
return true;
}
}

View File

@ -91,7 +91,7 @@ public enum ConfigEntry
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_CLIENT_KEY(String.class, "ptero.client_key"),
PTERO_SERVER_KEY(String.class, "ptero.server_key"),
//
SHOP_ENABLED(Boolean.class, "shop.enabled"),
SHOP_TITLE(String.class, "shop.title"),

View File

@ -128,7 +128,7 @@ public class ItemFun extends FreedomService
LivingEntity livingEntity = (LivingEntity)event.getRightClicked();
EntityType entityType = livingEntity.getType();
if (entityType != fPlayer.mobThrowerCreature())
if (!(entityType == fPlayer.mobThrowerCreature()))
{
return;
}
@ -304,11 +304,6 @@ public class ItemFun extends FreedomService
}
break;
}
default:
{
// Do nothing
break;
}
}
}

View File

@ -73,7 +73,7 @@ public class Landminer extends FreedomService
continue;
}
if (player.getLocation().distanceSquared(location) > (landmine.radius * landmine.radius))
if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius)))
{
break;
}

View File

@ -79,21 +79,12 @@ public class Module_list extends HTTPDModule
switch (admin.getRank())
{
case ADMIN:
{
admins.add(player.getName());
break;
}
case SENIOR_ADMIN:
{
senioradmins.add(player.getName());
break;
}
default:
{
// Do nothing
break;
}
}
}
}

View File

@ -51,21 +51,12 @@ public class Module_players extends HTTPDModule
switch (admin.getRank())
{
case ADMIN:
{
admins.add(username);
break;
}
case SENIOR_ADMIN:
{
senioradmins.add(username);
break;
}
default:
{
// Do nothing
break;
}
}
}
masterbuilders.addAll(plugin.pl.getMasterBuilderNames());

View File

@ -429,19 +429,14 @@ public class FPlayer
this.warningCount = warningCount;
}
public void incrementWarnings(boolean quiet)
public void incrementWarnings()
{
this.warningCount++;
if (this.warningCount % 2 == 0)
{
Player p = getPlayer();
if (!quiet)
{
p.getWorld().strikeLightning(p.getLocation());
}
FUtil.playerMsg(p, ChatColor.RED + "You have been warned at least twice now, make sure to read the rules at " + ConfigEntry.SERVER_BAN_URL.getString());
}
}

View File

@ -7,11 +7,5 @@ public enum PunishmentType
KICK,
TEMPBAN,
BAN,
DOOM,
WARN,
CAGE,
BLOCKEDIT,
BLOCKPVP,
BLOCKCMD,
ORBIT
DOOM
}

View File

@ -85,23 +85,18 @@ discord:
# Owner role ID
server_owner_role_id: ''
# Pterodactyl (requires Discord verification to be enabled)
# Pterodactyl
ptero:
# URL - do not leave a trailing forward slash
url: ''
# The default email domain used to set email addresses for new users - do not include the @
default_email_domain: 'example.com'
# Long Server UUID (for example: abf9a712-6c5a-4504-b4bc-37f1061b8801)
# Do NOT give the short Server UUID
# Server UUID
server_uuid: ''
# Admin panel API key
# Create this key by going to Settings > Application API > Create New
# Make sure you give it Users and Servers permissions
admin_key: ''
# Client API key
# Create a new user and add them as a subuser to the server with all control privileges.
# Then, login to the new user account and go to User Settings. Click on API Credentials and create a new one.
client_key: ''
# Server API key
server_key: ''
# The shop
shop:

View File

@ -1,50 +1,16 @@
#
# TotalFreedomMod 5.5 Permissions
# TotalFreedomMod Permissions
# by ZeroEpoch1969
#
# Note that every group inherits the previous groups' permissions
# Meaning Telnet Admins have the permissions of Operators and Super Admins, and etc
# Meaning Senior Admins have the permissions of Operators and Admins, and etc
# This is used to remove all permission begging with the root node
# This is useful when a plugin gives all permissions to a player because they are opped
remove:
- "voxelsniper"
- "bending.admin"
- "bending.ability.Cleanse"
- "worldedit.brush.apply"
- "essentials.near.exclude"
- "plots.admin"
- "plots.debugroadregen"
- "plots.debugclaimtest"
- "plots.debugpaste"
- "plots.debugallowunsafe"
- "plots.debugloadtest"
- "plots.debugsavetest"
- "plots.cluster"
#Crackshot
- "crackshot.bypass.all"
#NetworkManager
- "networkmanager.*"
- "networkmanager.notify.joinbanned"
- "networkmanager.notify.*"
- "networkmanager.announce.global"
- "networkmanager.announce"
- "networkmanager.chatlock"
- "networkmanager.clearchat.bypass"
- "networkmanager.clearchat.*"
- "networkmanager.notify.ticket.new"
- "networkmanager.lookup"
- "networkmanager.maintenance.*"
- "networkmanager.permissions"
- "networkmanager.reports"
- "networkmanager.tickets"
- "networkmanager.chatlock.bypass"
- "networkmanager.anticaps.bypass"
- "networkmanager.antispam.bypass"
- "networkmanager.commandblocker.bypass"
- "networkmanager.tags.*"
- "bending"
# Operator permission nodes
operators:
@ -70,10 +36,7 @@ operators:
- "worldedit.removebelow"
- "worldedit.removenear"
- "worldedit.replacenear"
- "worldedit.brush.*"
- "worldedit.global-mask"
- "worldedit.fill"
- "worldedit.fill.recursive"
# LibsDisguises
- "libsdisguises.noactionbar"
@ -83,66 +46,6 @@ operators:
- "worldguard.region.removemember.own.*"
- "worldguard.region.info.*"
# Bending
- "bending.command.add"
- "bending.command.bind"
- "bending.command.check"
- "bending.command.choose"
- "bending.command.rechoose"
- "bending.command.clear"
- "bending.command.copy"
- "bending.command.display"
- "bending.command.help"
- "bending.command.invincible"
- "bending.command.preset"
- "bending.command.preset.list"
- "bending.command.preset.create"
- "bending.command.preset.delete"
- "bending.command.preset.bind"
- "bending.command.preset.bind.assign"
- "bending.command.preset.bind.external"
- "bending.command.toggle"
- "bending.command.version"
- "bending.command.who"
- "bending.earth"
- "bending.air"
- "bending.fire"
- "bending.water"
- "bending.water.bloodbending.anytime"
- "bending.ability.AvatarState"
- "bending.command.add.chi"
- "bending.command.choose.chi"
- "bending.ability.Paralyze"
- "bending.ability.RapidPunch"
- "bending.ability.Smokescreen"
- "bending.ability.WarriorStance"
- "bending.ability.AcrobatStance"
- "bending.ability.QuickStrike"
- "bending.ability.SwiftKick"
- "bending.ability.ChiCombo"
- "bending.chi.passive"
- "bending.ability.MetalClips.throw"
- "bending.ability.AirCombo"
- "bending.ability.Flight"
- "bending.ability.WaterCombo"
- "bending.ability.EarthCombo"
- "bending.ability.FireCombo"
- "bending.ability.ChiCombo"
- "bending.air.passive"
- "bending.chi.passive"
- "bending.earth.passive"
- "bending.fire.passive"
- "bending.water.passive"
# NetworkManager
- "networkmanager.chatlog"
- "networkmanager.find"
- "networkmanager.gtps"
- "networkmanager.lookup"
- "networkmanager.slashserver.*"
- "networkmanager.notification.join"
- "networkmanager.party.nolimit"
- "networkmanager.tabcompletechat"
# Master Builder permission nodes
master_builders:
- "worldedit.tool.*"
@ -159,22 +62,10 @@ master_builders:
# Admin permission nodes
admins:
- "coreprotect.*"
- "worldedit.*"
- "worldguard.*"
- "bending.admin.remove"
- "bending.command.toggle.all"
- "bending.admin.toggle"
- "bending.command.reload"
- "plots.cluster"
- "networkmanager.adminchat"
- "networkmanager.announce.server"
- "networkmanager.socialspy"
- "networkmanager.fullproxy.bypass"
- "networkmanager.lookup.ip"
#Crackshot
- "crackshot.bypass.all"
- "bending.*"
# Senior Admin permission nodes
senior_admins:
- "bending.admin.permaremove"
- "bending.ability.Cleanse"
senior_admins: []