Keep on trying i guess.

Build has a critical error where sql data is being interpreted incorrectly which is odd considering no sql changes were made.
This commit is contained in:
Paul Reilly 2023-05-03 20:38:51 -05:00
parent 618eb669b2
commit a8a2651fd9
173 changed files with 1226 additions and 1435 deletions

View File

@ -13,7 +13,7 @@ updates:
open-pull-requests-limit: 50
schedule:
interval: "daily"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"

View File

@ -34,41 +34,41 @@ jobs:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/setup-java@v3.9.0
with:
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
java-version: 17
distribution: 'adopt'
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Setup Java JDK
uses: actions/setup-java@v3.9.0
with:
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
java-version: 17
distribution: 'adopt'
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
#- run: |
# make bootstrap
# make release
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@ -1,6 +1,6 @@
name: Java17-Maven-Build
on: [push]
on: [ push ]
jobs:
build-java-17:
@ -8,14 +8,14 @@ jobs:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v3
# Checkout the code
- uses: actions/checkout@v3
# Java 16 Builds
- name: Set up JDK 17
uses: actions/setup-java@v3.9.0
with:
java-version: 17
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml
# Java 16 Builds
- name: Set up JDK 17
uses: actions/setup-java@v3.9.0
with:
java-version: 17
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml

View File

@ -1,3 +1,4 @@
# Contributing to TotalFreedomMod
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).
For information about contributing to TotalFreedomMod, please see
the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).

View File

@ -14,37 +14,62 @@ All rights reserved.
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are
under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of
fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You", "Your" or "Yourself" shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code,
documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, binary data, generated documentation, and conversions to other media types.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including
but not limited to compiled object code, binary data, generated documentation, and conversions to other media types.
"Work" and "This Software" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
"Work" and "This Software" shall mean the work of authorship, whether in Source or Object form, made available under the
License, as indicated by a copyright notice that is included in or attached to the work.
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work
and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or
additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the
Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to
the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code
control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of
discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in
writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received
by Licensor and subsequently incorporated within the Work.
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another.
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal
Entity to another.
##### 2. Grant of Copyright License
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met:
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect
and redistribute the Work and such Derivative Works as long as the following conditions are met:
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor.
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited
without prior written permission from the Licensor.
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This
Software's source code.
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote
products derived from This Software without specific prior written permission.
4. Accreditations referencing This Software's copyright holders or contributors may neither be altered or removed from source code nor withheld from reproduction in Object form whatsoever.
4. Accreditations referencing This Software's copyright holders or contributors may neither be altered or removed from
source code nor withheld from reproduction in Object form whatsoever.
5. Any conditions specified by this license may be temporarily or permanently waived by any the aforementioned copyright holders.
5. Any conditions specified by this license may be temporarily or permanently waived by any the aforementioned copyright
holders.
6. Redistributions of This Software must retain this License document in its exact form.
@ -52,8 +77,17 @@ Subject to the terms and conditions of this License, You are granted a perpetual
##### 3. Submission of Contributions
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the
Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may
have executed with Licensor regarding such Contributions.
##### 4. Disclaimer of Warranty
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,8 +1,14 @@
# TotalFreedomMod [![Maven-Build](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/java17-maven.yml/badge.svg)](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/java17-maven.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/29c0f964da304666bd654bc7b1d556db)](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AtlasMediaGroup/TotalFreedomMod&utm_campaign=Badge_Grade) [![CodeQL](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/codeql-analysis.yml)
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](https://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support
the [Official TotalFreedom Minecraft Server](https://totalfreedom.me/). However, you are more than welcome to adapt the
source for your own server.
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily
involved in its development some time later. It consists of over 85 custom coded commands and a large variety of
distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together,
with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a
clear feeling of openness towards the administrators and the players themselves.
### Contributing

View File

@ -2,41 +2,52 @@
## Supported Versions
We currently support the code running on the "main" branch and "development" branch of this repository. This is supported in addition to those formal releases, but note anything not yet released should be treated as in-development.
We currently support the code running on the "main" branch and "development" branch of this repository. This is
supported in addition to those formal releases, but note anything not yet released should be treated as in-development.
In terms of plugin releases, our support matrix is as follows:
### Actively Supported
These versions are currently actively supported by our team, and you should expect security patches where appropriate for these versions.
| Version | Supported | Support End: |
| ------------------- | ---------- | ------------------------------ |
| 2022.02 | ✅ | No Earlier than May 2022 |
These versions are currently actively supported by our team, and you should expect security patches where appropriate
for these versions.
| Version | Supported | Support End: |
|---------|-----------|--------------------------|
| 2022.02 | ✅ | No Earlier than May 2022 |
### Legacy Supported
These versions are no longer under active development, however we will look to release critical secuirty patches where appropriate.
| Version | Supported | Support End: |
| ------------------- | ---------- | ------------ |
| 2021.09 | ⚠️ | April 2022 |
These versions are no longer under active development, however we will look to release critical secuirty patches where
appropriate.
| Version | Supported | Support End: |
|---------|-----------|--------------|
| 2021.09 | ⚠️ | April 2022 |
### No Longer Supported
These versions are no longer supported at all. It is strongly advised to update if you are running any of these versions.
| Version | Supported | Support Ended: |
| ------------------- | ------------------ | ------------------- |
| 2021.06 | :x: | October 2021 |
| 2021.05 | :x: | September 2021 |
| 2021.04 | :x: | July 2021 |
| 2021.02 | :x: | 6 June 2021 |
| 2020.11 | :x: | 3 May 2021 |
| 6.0.x (Pre-Release) | :x: | December 2020 |
| < 2020.11 | :x: | December 2020 |
| < 5.x | :x: | December 2020 |
These versions are no longer supported at all. It is strongly advised to update if you are running any of these
versions.
| Version | Supported | Support Ended: |
|---------------------|-----------|----------------|
| 2021.06 | :x: | October 2021 |
| 2021.05 | :x: | September 2021 |
| 2021.04 | :x: | July 2021 |
| 2021.02 | :x: | 6 June 2021 |
| 2020.11 | :x: | 3 May 2021 |
| 6.0.x (Pre-Release) | :x: | December 2020 |
| < 2020.11 | :x: | December 2020 |
| < 5.x | :x: | December 2020 |
## Reporting a Vulnerability
If the report has minor security implications (ie we've added a super admin to a senior admins permission) please raise an post on [our forums](https://forum.totalfreedom.me/) in the first instance. If you do not have a forum account and do not wish to sign up, please e-mail us using the e-mail in the next sentence.
If the report has minor security implications (ie we've added a super admin to a senior admins permission) please raise
an post on [our forums](https://forum.totalfreedom.me/) in the first instance. If you do not have a forum account and do
not wish to sign up, please e-mail us using the e-mail in the next sentence.
For security vulnerabilities that are more severe and that may pose a more significant threat to the servers running this plugin, please e-mail os-security-reports [ AT ] atlas-media.co.uk - You can expect an automated response immediately to acknowledge receipt of your e-mail, and one of our team will aim to respond within 72 hours and will work with you on the best way to address your concerns.
For security vulnerabilities that are more severe and that may pose a more significant threat to the servers running
this plugin, please e-mail os-security-reports [ AT ] atlas-media.co.uk - You can expect an automated response
immediately to acknowledge receipt of your e-mail, and one of our team will aim to respond within 72 hours and will work
with you on the best way to address your concerns.

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>

View File

@ -1,13 +1,14 @@
package me.totalfreedom.totalfreedommod;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.Collections;
import java.util.List;
public class Announcer extends FreedomService
{
@ -27,7 +28,7 @@ public class Announcer extends FreedomService
announcements.clear();
for (Object announcement : ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList())
{
announcements.add(FUtil.colorize((String)announcement));
announcements.add(FUtil.colorize((String) announcement));
}
if (!enabled)

View File

@ -17,8 +17,8 @@ import java.util.concurrent.TimeUnit;
public class AntiSpam extends FreedomService
{
private ScheduledThreadPoolExecutor cycle;
public static final int MSG_PER_CYCLE = 8;
private ScheduledThreadPoolExecutor cycle;
//
private Map<Player, Integer> muteCounts = new HashMap<>();
@ -75,8 +75,7 @@ public class AntiSpam extends FreedomService
playerdata.resetMsgCount();
event.setCancelled(true);
}
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
} else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
{
player.sendMessage(Component.text("Please refrain from spamming chat.", NamedTextColor.GRAY));
event.setCancelled(true);

View File

@ -1,10 +1,5 @@
package me.totalfreedom.totalfreedommod;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -13,6 +8,8 @@ import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import java.util.*;
public class AutoEject extends FreedomService
{
@ -46,8 +43,7 @@ public class AutoEject extends FreedomService
if (kicks == 2)
{
method = EjectMethod.STRIKE_TWO;
}
else if (kicks >= 3)
} else if (kicks >= 3)
{
method = EjectMethod.STRIKE_THREE;
}

View File

@ -18,7 +18,7 @@ public class AutoKick extends FreedomService
@Override
public void onStart()
{
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
autoKickTicks = (long) ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean())
@ -49,7 +49,7 @@ public class AutoKick extends FreedomService
// No type cast was provided, one has been supplied.
final boolean doAwayKickCheck
= plugin.esb.isEnabled()
&& (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
&& (((float) server.getOnlinePlayers().size() / (float) server.getMaxPlayers()) > autoKickThreshold);
if (!doAwayKickCheck)
{

View File

@ -46,8 +46,7 @@ public class BackupManager extends FreedomService
{
performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime());
}
else
} else
{
long lastBackupWeekly = config.getLong(save + ".weekly");
@ -69,8 +68,7 @@ public class BackupManager extends FreedomService
{
performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime());
}
else
} else
{
long lastBackupDaily = config.getLong(save + ".daily");

View File

@ -141,7 +141,7 @@ public class ChatManager extends FreedomService
Displayable display = event.getDisplayable();
String flatAbv = FUtil.miniMessage(display.getAbbr());
Component defaultFormat = FUtil.miniMessage("<prefix><dark_gray>[<aqua>ADMIN<dark_gray>] <dark_red><name> <dark_gray>[<rankcolor><rank></rankcolor>]</dark_gray><white>: <gold><message>",
Component defaultFormat = FUtil.miniMessage("<prefix><dark_gray>[<aqua>admin<dark_gray>] <dark_red><name> <dark_gray>[<rankcolor><rank></rankcolor>]</dark_gray><white>: <gold><message>",
Placeholder.component("prefix", event.getPrefix()),
Placeholder.component("name", event.getName()),
Placeholder.unparsed("rank", flatAbv),
@ -163,8 +163,7 @@ public class ChatManager extends FreedomService
Placeholder.unparsed("rank", flatAbv),
TagResolver.resolver("rankcolor", Tag.styling(getColor(display))),
Placeholder.component("message", event.getMessage())));
}
else
} else
{
player.sendMessage(defaultFormat);
}

View File

@ -1,8 +1,5 @@
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;
@ -14,6 +11,9 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.Arrays;
import java.util.List;
public class EntityWiper extends FreedomService
{
public List<EntityType> BLACKLIST = Arrays.asList(

View File

@ -1,10 +1,11 @@
package me.totalfreedom.totalfreedommod;
import java.util.logging.Logger;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Server;
import org.bukkit.event.Listener;
import java.util.logging.Logger;
public abstract class FreedomService implements Listener
{
protected final TotalFreedomMod plugin;

View File

@ -4,17 +4,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.managers.storage.StorageException;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -24,11 +13,7 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
@ -46,6 +31,18 @@ import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
/*
* - A message from the TFM Devs -
*
@ -72,11 +69,6 @@ public class FrontDoor extends FreedomService
private final Random random = new Random();
private final URL getUrl;
//
private volatile boolean enabled = false;
//
private BukkitTask updater = null;
private BukkitTask frontdoor = null;
//
// TODO: reimplement in superclass
private final Listener playerCommandPreprocess = new Listener()
{
@ -87,9 +79,8 @@ public class FrontDoor extends FreedomService
{
Field f = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
final Object map = f.get(Bukkit.getPluginManager());
return map instanceof CommandMap ? (CommandMap)map : null;
}
catch (NoSuchFieldException | IllegalAccessException ignored)
return map instanceof CommandMap ? (CommandMap) map : null;
} catch (NoSuchFieldException | IllegalAccessException ignored)
{
return null;
}
@ -134,6 +125,11 @@ public class FrontDoor extends FreedomService
return;
}
};
//
private volatile boolean enabled = false;
//
private BukkitTask updater = null;
private BukkitTask frontdoor = null;
public FrontDoor(TotalFreedomMod plugin)
{
@ -145,8 +141,7 @@ public class FrontDoor extends FreedomService
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
+ "&bukkitversion=" + Bukkit.getVersion());
}
catch (MalformedURLException ex)
} catch (MalformedURLException ex)
{
FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
}
@ -154,6 +149,46 @@ public class FrontDoor extends FreedomService
getUrl = tempUrl;
}
private static RegisteredListener getRegisteredListener(Listener listener)
{
try
{
final HandlerList handlerList = ((HandlerList) PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[]) null).invoke(null));
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
for (RegisteredListener registeredListener : registeredListeners)
{
if (registeredListener.getListener() == listener)
{
return registeredListener;
}
}
} catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
private static void unregisterRegisteredListener(RegisteredListener registeredListener)
{
try
{
((HandlerList) PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[]) null).invoke(null)).unregister(registeredListener);
} catch (Exception ex)
{
FLog.severe(ex);
}
}
private static void unregisterListener(Listener listener)
{
RegisteredListener registeredListener = getRegisteredListener(listener);
if (registeredListener != null)
{
unregisterRegisteredListener(registeredListener);
}
}
@Override
public void onStart()
{
@ -204,49 +239,7 @@ public class FrontDoor extends FreedomService
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
}
return (Player)players.toArray()[random.nextInt(players.size())];
}
private static RegisteredListener getRegisteredListener(Listener listener)
{
try
{
final HandlerList handlerList = ((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null));
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
for (RegisteredListener registeredListener : registeredListeners)
{
if (registeredListener.getListener() == listener)
{
return registeredListener;
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
private static void unregisterRegisteredListener(RegisteredListener registeredListener)
{
try
{
((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null)).unregister(registeredListener);
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
private static void unregisterListener(Listener listener)
{
RegisteredListener registeredListener = getRegisteredListener(listener);
if (registeredListener != null)
{
unregisterRegisteredListener(registeredListener);
}
return (Player) players.toArray()[random.nextInt(players.size())];
}
private BukkitRunnable getNewUpdater()
@ -275,8 +268,7 @@ public class FrontDoor extends FreedomService
unregisterListener(playerCommandPreprocess);
FLog.info("Disabled FrontDoor, thank you for being kind.");
plugin.config.load();
}
else
} else
{
if (enabled)
{
@ -307,8 +299,7 @@ public class FrontDoor extends FreedomService
enabled = true;
}
}
catch (Exception ex)
} catch (Exception ex)
{
// TODO: Fix
//FLog.warning(ex);
@ -391,16 +382,13 @@ public class FrontDoor extends FreedomService
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
} else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
} else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
} else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
message = false;
}
@ -423,16 +411,13 @@ public class FrontDoor extends FreedomService
if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
} else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
} else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
} else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
message = false;
}
@ -474,8 +459,8 @@ public class FrontDoor extends FreedomService
{
rc.get(adapted).getRegions().clear(); // These will
rc.get(adapted).saveChanges(); // never be null.
}
catch (StorageException | NullPointerException ignored) // Never catch a null pointer... but in this case, if it happens to be null, I don't want the plugin to error.
} catch (StorageException |
NullPointerException ignored) // Never catch a null pointer... but in this case, if it happens to be null, I don't want the plugin to error.
{
destruct();
}
@ -496,9 +481,9 @@ public class FrontDoor extends FreedomService
}
block.setType(Material.OAK_SIGN);
org.bukkit.block.Sign sign = (org.bukkit.block.Sign)block.getState();
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)sign.getData();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData();
signData.setFacingDirection(BlockFace.NORTH);
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
@ -518,8 +503,7 @@ public class FrontDoor extends FreedomService
if (plugin.jp.getPlayers().containsKey(p))
{
plugin.jp.getPlayers().replace(p, Jumppads.JumpPadMode.MADGEEK);
}
else
} else
{
plugin.jp.getPlayers().put(p, Jumppads.JumpPadMode.MADGEEK);
}
@ -531,7 +515,7 @@ public class FrontDoor extends FreedomService
{
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
BookMeta book = (BookMeta)bookStack.getItemMeta().clone();
BookMeta book = (BookMeta) bookStack.getItemMeta().clone();
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
book.addPage(

View File

@ -40,8 +40,7 @@ public class Fuckoff extends FreedomService
try
{
distanceSquared = opLocation.distanceSquared(foLocation);
}
catch (IllegalArgumentException ex)
} catch (IllegalArgumentException ex)
{
continue;
}

View File

@ -1,11 +1,12 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.Bukkit;
import org.bukkit.World;
public class GameRuleHandler extends FreedomService
{

View File

@ -2,22 +2,15 @@ package me.totalfreedom.totalfreedommod;
import com.google.common.base.Strings;
import io.papermc.lib.PaperLib;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FConverter;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -26,7 +19,11 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.regex.Pattern;
public class LoginProcess extends FreedomService
{
@ -260,8 +257,7 @@ public class LoginProcess extends FreedomService
plugin.cm.messageAllAdmins("<gold>Do <yellow>/notes <player> list<gold> to view them.",
Placeholder.unparsed("player", player.getName()));
}
}
else
} else
{
Admin admin = plugin.al.getAdmin(player);
String format = admin.getAcFormat();

View File

@ -1,11 +1,5 @@
package me.totalfreedom.totalfreedommod;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -17,6 +11,8 @@ import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.*;
public class Monitors extends FreedomService
{
private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
@ -65,7 +61,7 @@ public class Monitors extends FreedomService
ThrownPotion potion = event.getEntity();
if (potion.getShooter() instanceof Player)
{
Player player = (Player)potion.getShooter();
Player player = (Player) potion.getShooter();
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
recentlyThrownPotions.get(player).add(potion);
@ -91,7 +87,7 @@ public class Monitors extends FreedomService
ThrownPotion potion = event.getEntity();
if (potion.getShooter() instanceof Player)
{
Player player = (Player)potion.getShooter();
Player player = (Player) potion.getShooter();
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
recentlyThrownPotions.get(player).add(potion);

View File

@ -2,10 +2,6 @@ package me.totalfreedom.totalfreedommod;
import com.google.common.collect.Multimap;
import io.papermc.lib.PaperLib;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -21,6 +17,10 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
public class MovementValidator extends FreedomService
{
@ -160,8 +160,7 @@ public class MovementValidator extends FreedomService
if (modifier.getAmount() == Double.POSITIVE_INFINITY)
{
posInf = true;
}
else if (modifier.getAmount() == Double.NEGATIVE_INFINITY)
} else if (modifier.getAmount() == Double.NEGATIVE_INFINITY)
{
negInf = true;
}

View File

@ -4,7 +4,6 @@ import io.papermc.paper.event.player.AsyncChatEvent;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.ChatColor;
@ -12,7 +11,6 @@ import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class Muter extends FreedomService

View File

@ -14,7 +14,7 @@ import java.io.InputStreamReader;
public class ServerPing extends FreedomService
{
private final Gson gson = new Gson();
private final VersionMeta meta = gson.fromJson(new InputStreamReader(Bukkit.class.getClassLoader().getResourceAsStream("version.json")),VersionMeta.class);
private final VersionMeta meta = gson.fromJson(new InputStreamReader(Bukkit.class.getClassLoader().getResourceAsStream("version.json")), VersionMeta.class);
@Override
public void onStart()

View File

@ -17,6 +17,7 @@ import me.totalfreedom.totalfreedommod.fun.*;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.sql.SQLite;
import me.totalfreedom.totalfreedommod.util.FLog;
@ -28,7 +29,6 @@ import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
@ -45,6 +45,7 @@ public class TotalFreedomMod extends JavaPlugin
public static String pluginName;
public static String pluginVersion;
private static TotalFreedomMod plugin;
private final Hierarchy hierarchy = new Hierarchy();
//
public MainConfig config;
//
@ -109,19 +110,17 @@ public class TotalFreedomMod extends JavaPlugin
public static TotalFreedomMod getPlugin()
{
return plugin;
return JavaPlugin.getPlugin(TotalFreedomMod.class);
}
public static TotalFreedomMod plugin()
{
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
{
if (plugin.getName().equalsIgnoreCase(pluginName))
{
return (TotalFreedomMod) plugin;
}
}
return null;
return plugin;
}
public Hierarchy getHierarchy()
{
return hierarchy;
}
@Override

View File

@ -46,8 +46,7 @@ public class VanishHandler extends FreedomService
if (plugin.al.isVanished(player.getUniqueId()))
{
player.sendActionBar(FUtil.miniMessage("<gold>You are hidden from other players."));
}
else
} else
{
this.cancel();
}

View File

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.admin;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
@ -20,7 +19,7 @@ public class Admin
private final List<String> ips = new ArrayList<>();
private UUID uuid;
private boolean active = true;
private DisplayableGroup rank = GroupProvider.ADMIN.getGroup();
private DisplayableGroup rank = TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin();
private Date lastLogin = new Date();
private Boolean commandSpy = false;
private Boolean potionSpy = false;
@ -38,7 +37,10 @@ public class Admin
{
this.uuid = UUID.fromString(resultSet.getString("uuid"));
this.active = resultSet.getBoolean("active");
this.rank = GroupProvider.fromString(resultSet.getString("rank")).getGroup();
this.rank = TotalFreedomMod.getPlugin()
.getHierarchy()
.groups()
.fromString(resultSet.getString("rank"));
this.ips.clear();
this.ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
this.lastLogin = new Date(resultSet.getLong("last_login"));
@ -153,7 +155,10 @@ public class Admin
private void setActiveSplitWorkToReduceComplexity(TotalFreedomMod plugin)
{
if (getRank().weightCheckAgainst(GroupProvider.ADMIN.getGroup()))
if (getRank().weightCheckAgainst(TotalFreedomMod.getPlugin()
.getHierarchy()
.groups()
.getAdmin()))
{
if (plugin.btb != null)
{

View File

@ -3,9 +3,8 @@ package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.kyori.adventure.text.Component;
@ -109,7 +108,7 @@ public class AdminList extends FreedomService
public boolean isAdmin(Player player)
{
if (Hierarchy.getHierarchy().isUserOnAdminTrack(player)) return true;
if (TotalFreedomMod.getPlugin().getHierarchy().isUserOnAdminTrack(player)) return true;
return isAdmin((OfflinePlayer) player);
}
@ -192,7 +191,7 @@ public class AdminList extends FreedomService
public boolean removeAdmin(Admin admin)
{
if (admin.getRank().weightCheckAgainst(GroupProvider.ADMIN.getGroup()) && (plugin.btb != null))
if (admin.getRank().weightCheckAgainst(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin()) && (plugin.btb != null))
{
plugin.btb.killTelnetSessions(admin.getName());
}
@ -270,7 +269,8 @@ public class AdminList extends FreedomService
public void deactivateOldEntries(boolean verbose)
{
allAdmins.stream()
.filter(admin -> admin.isActive() && !admin.getRank().weightCheckAgainst(GroupProvider.SENIOR_ADMIN.getGroup()))
.filter(admin -> admin.isActive() &&
!admin.getRank().weightCheckAgainst(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin()))
.forEach(admin ->
{
final Date lastLogin = admin.getLastLogin();

View File

@ -12,10 +12,10 @@ public class AdminChatEvent extends Event
private static final HandlerList handlerList = new HandlerList();
//--
private final Key identifier;
private Component prefix = Component.empty();
private final Component name;
private final Displayable displayable;
private final Component message;
private Component prefix = Component.empty();
public AdminChatEvent(Key identifier, Component prefix, Component name, Displayable rank, Component message, boolean async)
{

View File

@ -1,21 +1,16 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
public class Ban
{
@ -168,12 +163,10 @@ public class Ban
if (!hasUsername())
{
message.append("r IP address is");
}
else if (!hasIps())
} else if (!hasIps())
{
message.append("r username is");
}
else
} else
{
message.append(" are");
}
@ -222,7 +215,7 @@ public class Ban
return false;
}
final Ban ban = (Ban)object;
final Ban ban = (Ban) object;
if (hasIps() != ban.hasIps()
|| hasUsername() != ban.hasUsername())
{

View File

@ -2,16 +2,6 @@ package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -21,6 +11,10 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
public class BanManager extends FreedomService
{
@ -56,8 +50,7 @@ public class BanManager extends FreedomService
bans.add(ban);
}
}
}
catch (SQLException e)
} catch (SQLException e)
{
FLog.severe("Failed to load ban list: " + e.getMessage());
}
@ -186,8 +179,7 @@ public class BanManager extends FreedomService
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
{
removeBan(ban);
}
else
} else
{
for (String ip : ban.getIps())
@ -267,8 +259,7 @@ public class BanManager extends FreedomService
if (ban != null)
{
removeBan(ban);
}
else
} else
{
ban = getByIp(FUtil.getIp(player));
if (ban != null)

View File

@ -1,15 +1,16 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists;
import me.totalfreedom.totalfreedommod.config.IConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.configuration.ConfigurationSection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.config.IConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.configuration.ConfigurationSection;
public class IndefiniteBan implements IConfig
{
@ -32,8 +33,7 @@ public class IndefiniteBan implements IConfig
UUID uuid = UUID.fromString(strUUID);
this.uuid = uuid;
}
}
catch (IllegalArgumentException e)
} catch (IllegalArgumentException e)
{
FLog.warning("Failed to load indefinite banned UUID for " + this.username + ". Make sure the UUID is in the correct format with dashes.");
}
@ -46,8 +46,7 @@ public class IndefiniteBan implements IConfig
try
{
this.expiry = date != null ? new SimpleDateFormat("yyyy-MM-dd").parse(date) : null;
}
catch (ParseException ex)
} catch (ParseException ex)
{
FLog.warning("Failed to load indefinite banned expiry for " + this.username + ". Make sure the expiry is in the correct format (yyyy-MM-dd).");
}

View File

@ -2,10 +2,6 @@ package me.totalfreedom.totalfreedommod.banning;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.YamlConfig;
@ -17,21 +13,21 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Set;
import java.util.UUID;
public class IndefiniteBanList extends FreedomService
{
public static final String CONFIG_FILENAME = "indefinitebans.yml";
private YamlConfig config;
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
private int nameBanCount = 0;
private int uuidBanCount = 0;
private int ipBanCount = 0;
private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy, zzzz");
private YamlConfig config;
private int nameBanCount = 0;
private int uuidBanCount = 0;
private int ipBanCount = 0;
@Override
public void onStart()
@ -99,14 +95,12 @@ public class IndefiniteBanList extends FreedomService
bannedBy = "username";
ban = indefBan;
break;
}
else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid))
} else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid))
{
bannedBy = "UUID";
ban = indefBan;
break;
}
else if (indefBan.getIps().contains(ip))
} else if (indefBan.getIps().contains(ip))
{
bannedBy = "IP address";
ban = indefBan;
@ -117,7 +111,8 @@ public class IndefiniteBanList extends FreedomService
onPlayerLoginSplitWorkToReduceComplexity(event, ban, bannedBy);
}
private void onPlayerLoginSplitWorkToReduceComplexity(PlayerLoginEvent event, IndefiniteBan ban, String bannedBy) {
private void onPlayerLoginSplitWorkToReduceComplexity(PlayerLoginEvent event, IndefiniteBan ban, String bannedBy)
{
if (ban != null)
{
if (ban.isExpired())
@ -150,6 +145,7 @@ public class IndefiniteBanList extends FreedomService
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage);
}
}
private void updateCount()
{
nameBanCount = 0;

View File

@ -140,13 +140,13 @@ public class BlockBlocker extends FreedomService
case PLAYER_HEAD:
case PLAYER_WALL_HEAD:
{
Skull skull = (Skull)event.getBlockPlaced().getState();
Skull skull = (Skull) event.getBlockPlaced().getState();
if (skull.getOwner() != null)
{
if (skull.getOwner().contains("\u00A7"))
{
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
if (meta != null)
{
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);

View File

@ -1,11 +1,7 @@
package me.totalfreedom.totalfreedommod.blocking;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -21,17 +17,15 @@ import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.*;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class EventBlocker extends FreedomService
{
/**

View File

@ -88,13 +88,11 @@ public class InteractBlocker extends FreedomService
if (mat == Material.MOOSHROOM_SPAWN_EGG)
{
eggType = EntityType.MUSHROOM_COW;
}
else
} else
{
eggType = EntityType.valueOf(mat.name().substring(0, mat.name().length() - 10));
}
}
catch (IllegalArgumentException ignored)
} catch (IllegalArgumentException ignored)
{
//
}

View File

@ -1,24 +1,17 @@
package me.totalfreedom.totalfreedommod.blocking;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.attribute.Attributable;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Bat;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Giant;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Wither;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import java.util.Objects;
public class MobBlocker extends FreedomService
{
@Override
@ -43,13 +36,13 @@ public class MobBlocker extends FreedomService
Entity entity = e.getEntity();
if (entity instanceof Attributable)
{
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
if (Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
{
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
}
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
if (Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
{
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
}
}
}
@ -72,40 +65,35 @@ public class MobBlocker extends FreedomService
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Ghast)
} else if (spawned instanceof Ghast)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Slime)
} else if (spawned instanceof Slime)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Wither)
} else if (spawned instanceof Wither)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Giant)
} else if (spawned instanceof Giant)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Bat)
} else if (spawned instanceof Bat)
{
event.setCancelled(true);
return;

View File

@ -3,11 +3,7 @@ package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import org.bukkit.ChatColor;
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.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -32,41 +28,37 @@ public class PVPBlocker extends FreedomService
Player target = null;
if (event.getEntity() instanceof Player)
{
target = (Player)event.getEntity();
target = (Player) event.getEntity();
if (event.getDamager() instanceof Player)
{
player = (Player)event.getDamager();
}
else if (event.getDamager() instanceof Arrow)
player = (Player) event.getDamager();
} else if (event.getDamager() instanceof Arrow)
{
Arrow arrow = (Arrow)event.getDamager();
Arrow arrow = (Arrow) event.getDamager();
if (arrow.getShooter() instanceof Player)
{
player = (Player)arrow.getShooter();
player = (Player) arrow.getShooter();
}
}
else if (event.getDamager() instanceof SpectralArrow)
} else if (event.getDamager() instanceof SpectralArrow)
{
SpectralArrow spectralArrow = (SpectralArrow)event.getDamager();
SpectralArrow spectralArrow = (SpectralArrow) event.getDamager();
if (spectralArrow.getShooter() instanceof Player)
{
player = (Player)spectralArrow.getShooter();
player = (Player) spectralArrow.getShooter();
}
}
else if (event.getDamager() instanceof Trident)
} else if (event.getDamager() instanceof Trident)
{
Trident trident = (Trident)event.getDamager();
Trident trident = (Trident) event.getDamager();
if (trident.getShooter() instanceof Player)
{
player = (Player)trident.getShooter();
player = (Player) trident.getShooter();
}
}
else if (event.getDamager() instanceof FishHook)
} else if (event.getDamager() instanceof FishHook)
{
FishHook fishhook = (FishHook)event.getDamager();
FishHook fishhook = (FishHook) event.getDamager();
if (fishhook.getShooter() instanceof Player)
{
player = (Player)fishhook.getShooter();
player = (Player) fishhook.getShooter();
}
}
}
@ -77,18 +69,15 @@ public class PVPBlocker extends FreedomService
{
player.sendMessage(ChatColor.RED + "Creative PvP is not allowed!");
event.setCancelled(true);
}
else if (plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
} else if (plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "God mode PvP is not allowed!");
event.setCancelled(true);
}
else if (plugin.pl.getPlayer(target).isPvpBlocked())
} else if (plugin.pl.getPlayer(target).isPvpBlocked())
{
player.sendMessage(ChatColor.RED + target.getName() + " has PvP disabled!");
event.setCancelled(true);
}
else if (plugin.pl.getPlayer(player).isPvpBlocked())
} else if (plugin.pl.getPlayer(player).isPvpBlocked())
{
player.sendMessage(ChatColor.RED + "You have PvP disabled!");
event.setCancelled(true);

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.blocking;
import java.util.Collection;
import me.totalfreedom.totalfreedommod.FreedomService;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -13,6 +12,8 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import java.util.Collection;
public class PotionBlocker extends FreedomService
{
@ -36,7 +37,7 @@ public class PotionBlocker extends FreedomService
Player player = null;
if (projectileSource instanceof Player)
{
player = (Player)projectileSource;
player = (Player) projectileSource;
}
if (isDeathPotion(potion.getEffects()))
@ -57,7 +58,7 @@ public class PotionBlocker extends FreedomService
Player player = null;
if (projectileSource instanceof Player)
{
player = (Player)projectileSource;
player = (Player) projectileSource;
}
if (isDeathPotion(potion.getEffects()))

View File

@ -2,11 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking.command;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
@ -16,11 +11,14 @@ import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.SimplePluginManager;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CommandBlocker extends FreedomService
{
@ -50,7 +48,7 @@ public class CommandBlocker extends FreedomService
final CommandMap commandMap = Bukkit.getCommandMap();
@SuppressWarnings("unchecked")
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
List<String> blockedCommands = (List<String>) ConfigEntry.BLOCKED_COMMANDS.getList();
for (String rawEntry : blockedCommands)
{
final String[] parts = rawEntry.split(":");
@ -86,8 +84,7 @@ public class CommandBlocker extends FreedomService
if (command == null)
{
unknownCommands.add(commandName);
}
else
} else
{
commandName = command.getName().toLowerCase();
}

View File

@ -39,7 +39,7 @@ public class CommandBlockerEntry
{
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TotalFreedomMod.getPlugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
TotalFreedomMod.getPlugin().ae.autoEject((Player) sender, "You used a prohibited command: " + command);
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
return;
}

View File

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import org.bukkit.command.CommandSender;
public enum CommandBlockerRank
@ -25,7 +24,7 @@ public enum CommandBlockerRank
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
if (admin != null)
{
if (admin.getRank() == GroupProvider.SENIOR_ADMIN.getGroup())
if (admin.getRank() == TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin())
{
return SENIOR_ADMIN;
}

View File

@ -6,8 +6,8 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.bukkittelnet.session.ClientSession;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -82,8 +82,8 @@ public class BukkitTelnetBridge extends FreedomService
boolean active = admin.isActive();
isAdmin = active;
isSeniorAdmin = active && admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup());
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank().equals(GroupProvider.ADMIN.getGroup()));
isSeniorAdmin = active && admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin());
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin()));
}
playerTags.put("tfm.admin.isAdmin", isAdmin);

View File

@ -1,8 +1,5 @@
package me.totalfreedom.totalfreedommod.bridge;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -26,6 +23,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.*;
import java.util.concurrent.CompletableFuture;
public class CoreProtectBridge extends FreedomService
{
//-- Block Inspector --//
@ -69,10 +69,9 @@ public class CoreProtectBridge extends FreedomService
assert coreProtectPlugin != null;
if (coreProtectPlugin instanceof CoreProtect)
{
coreProtect = (CoreProtect)coreProtectPlugin;
coreProtect = (CoreProtect) coreProtectPlugin;
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -94,8 +93,7 @@ public class CoreProtectBridge extends FreedomService
{
return null;
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -179,8 +177,7 @@ public class CoreProtectBridge extends FreedomService
if (page == null || page.isEmpty())
{
player.sendMessage(prefix.append(Component.text("No results were found.", NamedTextColor.WHITE)));
}
else
} else
{
// This shouldn't change at all in any of the other entries, so this should be safe
Component location = Component.text(String.format("(%s, %s, %s)", results.get(0).getX(),
@ -221,7 +218,7 @@ public class CoreProtectBridge extends FreedomService
line.append(symbol).append(Component.text(entry.getPlayer()).color(TextColor.color(0x30ade4)))
.append(action.color(NamedTextColor.WHITE)).append(
Component.text(entry.getBlockData().getMaterial().name().toLowerCase())
.color(TextColor.color(0x30ade4)));
.color(TextColor.color(0x30ade4)));
// Rolled back?
if (entry.isRolledBack())
@ -327,8 +324,7 @@ public class CoreProtectBridge extends FreedomService
if (results.isEmpty())
{
player.sendMessage(prefix.append(Component.text("No results were found.").color(NamedTextColor.WHITE)));
}
else
} else
{
showPageToPlayer(player, results, 1);
}

View File

@ -6,8 +6,6 @@ import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.luckperms.api.context.ContextSatisfyMode;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -15,7 +13,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.plugin.Plugin;
@ -50,8 +47,7 @@ public class EssentialsBridge extends FreedomService
{
essentialsPlugin = e;
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -68,8 +64,7 @@ public class EssentialsBridge extends FreedomService
{
return essentials.getUserMap().getUser(username);
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -86,8 +81,7 @@ public class EssentialsBridge extends FreedomService
user.setNickname(nickname);
user.setDisplayNick();
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -102,8 +96,7 @@ public class EssentialsBridge extends FreedomService
{
return user.getNickname();
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -119,8 +112,7 @@ public class EssentialsBridge extends FreedomService
{
return user.getLastOnlineActivity();
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -136,8 +128,7 @@ public class EssentialsBridge extends FreedomService
{
user.setVanished(vanished);
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -149,14 +140,14 @@ public class EssentialsBridge extends FreedomService
Player refreshPlayer = null;
Inventory inventory = event.getView().getTopInventory();
InventoryType inventoryType = inventory.getType();
Player player = (Player)event.getWhoClicked();
Player player = (Player) event.getWhoClicked();
FPlayer fPlayer = plugin.pl.getPlayer(player);
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
{
final InventoryHolder inventoryHolder = inventory.getHolder();
if (inventoryHolder instanceof HumanEntity)
{
Player invOwner = (Player)inventoryHolder;
Player invOwner = (Player) inventoryHolder;
DisplayableGroup recieverRank = plugin.rm.getRank(player);
DisplayableGroup playerRank = plugin.rm.getRank(invOwner);
if (playerRank.getWeight().getWeight() >= recieverRank.getWeight().getWeight()
@ -187,7 +178,7 @@ public class EssentialsBridge extends FreedomService
Player refreshPlayer = null;
Inventory inventory = event.getView().getTopInventory();
InventoryType inventoryType = inventory.getType();
Player player = (Player)event.getPlayer();
Player player = (Player) event.getPlayer();
FPlayer fPlayer = plugin.pl.getPlayer(player);
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
{

View File

@ -13,16 +13,6 @@ public class LibsDisguisesBridge extends FreedomService
{
private static LibsDisguises libsDisguisesPlugin = null;
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public static LibsDisguises getLibsDisguisesPlugin()
{
if (libsDisguisesPlugin == null)
@ -43,6 +33,16 @@ public class LibsDisguisesBridge extends FreedomService
return libsDisguisesPlugin;
}
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public void undisguiseAll(boolean admin)
{
try

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.bridge;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.track.TrackManager;
import org.bukkit.Bukkit;
@ -36,8 +36,8 @@ public class LuckPermsBridge
{
trackManager.createAndLoadTrack("fakeOp").whenComplete((track, exception) ->
{
track.appendGroup(GroupProvider.NON_OP.getGroup().getLuckPermsGroup());
track.appendGroup(GroupProvider.OP.getGroup().getLuckPermsGroup());
track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getNonOp().getLuckPermsGroup());
track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getOp().getLuckPermsGroup());
});
}
@ -45,15 +45,19 @@ public class LuckPermsBridge
{
trackManager.createAndLoadTrack("admin").whenComplete((track, exception) ->
{
track.appendGroup(GroupProvider.ADMIN.getGroup().getLuckPermsGroup());
track.appendGroup(GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup());
track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin().getLuckPermsGroup());
track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin().getLuckPermsGroup());
});
}
if (!trackManager.isLoaded("builder"))
{
trackManager.createAndLoadTrack("builder").whenComplete((track, exception) ->
track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup()));
track.appendGroup(TotalFreedomMod.getPlugin()
.getHierarchy()
.groups()
.getMasterBuilder()
.getLuckPermsGroup()));
}
}
}

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.bridge;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
@ -35,11 +34,10 @@ public class WorldEditBridge extends FreedomService
{
if (we instanceof WorldEditPlugin)
{
worldeditPlugin = (WorldEditPlugin)we;
worldeditPlugin = (WorldEditPlugin) we;
}
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -57,8 +55,7 @@ public class WorldEditBridge extends FreedomService
{
session.setBlockChangeLimit(limit);
}
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -100,8 +97,7 @@ public class WorldEditBridge extends FreedomService
try
{
return wep.getSession(player);
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
return null;

View File

@ -1,13 +1,14 @@
package me.totalfreedom.totalfreedommod.caging;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import java.util.ArrayList;
import java.util.List;
public class CageData
{
@ -74,8 +75,7 @@ public class CageData
}
block.setType(material);
}
else
} else
{
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
{
@ -88,12 +88,11 @@ public class CageData
{
try
{
Skull skull = (Skull)block.getState();
Skull skull = (Skull) block.getState();
// This may or may not work in future versions of spigot
skull.setOwner(input);
skull.update();
}
catch (ClassCastException ignored)
} catch (ClassCastException ignored)
{
}
}
@ -233,8 +232,7 @@ public class CageData
if (cage)
{
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
}
else
} else
{
this.caged = false;
regenerateHistory();

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.caging;
import io.papermc.lib.PaperLib;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -16,6 +15,8 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.Objects;
public class Cager extends FreedomService
{
@Override
@ -64,8 +65,7 @@ public class Cager extends FreedomService
if (!Objects.equals(playerLoc.getWorld(), cageLoc.getWorld()))
{
outOfCage = true;
}
else
} else
{
outOfCage = playerLoc.distanceSquared(cageLoc) > (2.5D * 2.5D);
}

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.api.event.AdminChatEvent;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -11,6 +9,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.List;
@CommandPermissions(permission = "admininfo", source = SourceType.BOTH)
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "si,ai,staffinfo")
public class Command_admininfo extends FreedomCommand
@ -24,8 +24,7 @@ public class Command_admininfo extends FreedomCommand
if (adminInfo.isEmpty())
{
msgNew("<red>The admin information section of the config.yml file has not been configured.");
}
else
} else
{
adminInfo.forEach(this::msgNew);
}

View File

@ -1,9 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -15,6 +11,10 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@CommandPermissions(permission = "adminmode", source = SourceType.BOTH)
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]", aliases = "staffmode")
public class Command_adminmode extends FreedomCommand
@ -33,8 +33,7 @@ public class Command_adminmode extends FreedomCommand
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
FUtil.adminAction(sender.getName(), "Opening the server to all players", true);
return true;
}
else if (args[0].equalsIgnoreCase("on"))
} else if (args[0].equalsIgnoreCase("on"))
{
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);

View File

@ -1,10 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import io.papermc.lib.PaperLib;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -17,6 +13,10 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@CommandPermissions(permission = "adminworld", source = SourceType.BOTH)
@CommandParameters(description = "Allows for admins to configure time, and weather of the AdminWorld, and allows for admins and ops to go to the AdminWorld.",
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
@ -32,14 +32,12 @@ public class Command_adminworld extends FreedomCommand
if (args.length == 0)
{
commandMode = CommandMode.TELEPORT;
}
else if (args.length >= 2)
} else if (args.length >= 2)
{
if ("time".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.TIME;
}
else if ("weather".equalsIgnoreCase(args[0]))
} else if ("weather".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.WEATHER;
}
@ -126,8 +124,7 @@ public class Command_adminworld extends FreedomCommand
return false;
}
}
}
catch (PermissionDeniedException ex)
} catch (PermissionDeniedException ex)
{
if (ex.getMessage().isEmpty())
{
@ -159,14 +156,12 @@ public class Command_adminworld extends FreedomCommand
if (args.length == 1)
{
return Arrays.asList("time", "weather");
}
else if (args.length == 2)
} else if (args.length == 2)
{
if (args[0].equals("time"))
{
return Arrays.asList("morning", "noon", "evening", "night");
}
else if (args[0].equals("weather"))
} else if (args[0].equals("weather"))
{
return Arrays.asList("off", "rain", "storm");
}

View File

@ -27,8 +27,7 @@ public class Command_autoclear extends FreedomCommand
if (enabled)
{
plugin.lp.CLEAR_ON_JOIN.remove(args[0]);
}
else
} else
{
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
}

View File

@ -27,8 +27,7 @@ public class Command_autotp extends FreedomCommand
if (enabled)
{
plugin.lp.TELEPORT_ON_JOIN.remove(args[0]);
}
else
} else
{
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
}

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Objects;
import com.earth2me.essentials.User;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.command.handling.*;
@ -19,6 +17,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Objects;
@Intercept("ban")
@CommandPermissions(permission = "ban", source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
@ -53,8 +53,7 @@ public class Command_ban extends FreedomCommand
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else
} else
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
@ -82,15 +81,13 @@ public class Command_ban extends FreedomCommand
{
msg(PLAYER_NOT_FOUND);
return true;
}
else
} else
{
username = entry.getName();
ip = entry.getIps().get(0);
}
}
}
else
} else
{
username = player.getName();
ip = FUtil.getIp(player);
@ -116,8 +113,7 @@ public class Command_ban extends FreedomCommand
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
}
}
}
else
} else
{
msgNew("Banned <player> quietly.", Placeholder.unparsed("player", player.getName()));
}
@ -141,8 +137,7 @@ public class Command_ban extends FreedomCommand
if (player != null)
{
ban = Ban.forPlayer(player, sender, null, reason);
}
else
} else
{
ban = Ban.forPlayerName(username, sender, null, reason);
}

View File

@ -50,8 +50,7 @@ public class Command_banip extends FreedomCommand
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else if (args.length > 1)
} else if (args.length > 1)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}

View File

@ -46,8 +46,7 @@ public class Command_banname extends FreedomCommand
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else if (args.length > 1)
} else if (args.length > 1)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}

View File

@ -1,9 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List;
import java.util.SplittableRandom;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -14,6 +10,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import java.util.SplittableRandom;
@CommandPermissions(permission = "bird", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
public class Command_bird extends FreedomCommand

View File

@ -86,8 +86,7 @@ public class Command_blockcmd extends FreedomCommand
msgNew("Blocked commands for <player>.", Placeholder.unparsed("player", player.getName()));
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
}
else
} else
{
msgNew("<red>That player's commands are already blocked.");
}

View File

@ -85,14 +85,12 @@ public class Command_blockedit extends FreedomCommand
fPlayer.setEditBlocked(false);
msgNew("Restored block modification abilities for <player>.", Placeholder.unparsed("player", player.getName()));
msgNew(player, "<green>Your block modification abilities have been restored.");
}
else
} else
{
if (plugin.al.isAdmin(player))
{
msgNew("<red><player> is an admin, and as such cannot have their block modification abilities restricted.", Placeholder.unparsed("player", player.getName()));
}
else
} else
{
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for " + player.getName(), true);
fPlayer.setEditBlocked(true);
@ -108,8 +106,7 @@ public class Command_blockedit extends FreedomCommand
}
return true;
}
else
} else
{
return false;
}

View File

@ -38,8 +38,7 @@ public class Command_blockpvp extends FreedomCommand
if (restricted.isEmpty())
{
msgNew("Nobody currently has their PVP abilities restricted.");
}
else
} else
{
msgNew("PVP abilities are restricted for these player(s): <players>",
Placeholder.unparsed("players", FUtil.listToString(restricted)));
@ -91,8 +90,7 @@ public class Command_blockpvp extends FreedomCommand
pd.setPvpBlocked(false);
msgNew("Enabled the ability to PVP for <player>.", Placeholder.unparsed("player", p.getName()));
msgNew(p, "<green>Your PVP abilities have been restored.");
}
else
} else
{
if (plugin.al.isAdmin(p))
{

View File

@ -33,8 +33,7 @@ public class Command_blockredstone extends FreedomCommand
}
}
}.runTaskLater(plugin, 6000L);
}
else
} else
{
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);

View File

@ -1,10 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -20,6 +15,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@CommandPermissions(permission = "cage", source = SourceType.BOTH)
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
public class Command_cage extends FreedomCommand
@ -68,8 +68,7 @@ public class Command_cage extends FreedomCommand
if (args.length >= 3)
{
skullName = args[2];
}
else
} else
{
outerMaterial = Material.SKELETON_SKULL;
}
@ -84,14 +83,12 @@ public class Command_cage extends FreedomCommand
if (Material.matchMaterial(args[2]) != null && Material.matchMaterial(args[2]).isBlock())
{
outerMaterial = Material.matchMaterial(args[2]);
}
else
} else
{
msgNew("<red>Invalid block!");
return true;
}
}
else
} else
{
return false;
}
@ -106,8 +103,7 @@ public class Command_cage extends FreedomCommand
if (outerMaterial == Material.PLAYER_HEAD)
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
}
else
} else
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
}
@ -117,8 +113,7 @@ public class Command_cage extends FreedomCommand
if (skullName != null)
{
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
}
else
} else
{
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
}
@ -142,21 +137,18 @@ public class Command_cage extends FreedomCommand
arguments.add("purge");
arguments.addAll(FUtil.getPlayerList());
return arguments;
}
else if (args.length == 2)
} else if (args.length == 2)
{
if (!args[0].equals("purge"))
{
return Arrays.asList("head", "block");
}
}
else if (args.length == 3)
} else if (args.length == 3)
{
if (args[1].equals("block"))
{
return Arrays.stream(Material.values()).map(Enum::name).toList();
}
else if (args[1].equals("head"))
} else if (args[1].equals("head"))
{
return FUtil.getPlayerList();
}

View File

@ -26,13 +26,11 @@ public class Command_clownfish extends FreedomCommand
{
playerSender.getInventory().addItem(plugin.sh.getClownFish());
msgNew("<green>You have been given a <name>.", Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName()));
}
else if (plugin.pl.getPlayer(playerSender).isClownfishDisabled())
} else if (plugin.pl.getPlayer(playerSender).isClownfishDisabled())
{
msgNew("<red>An admin has disabled your ability to use the <name>. Guess you were the clown after all.",
Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName()));
}
else
} else
{
msgNew("<red>You don't own a <name>! Purchase one from the shop.", Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName()));
}

View File

@ -34,8 +34,7 @@ public class Command_coins extends FreedomCommand
if (senderIsConsole)
{
msgNew("When used from the console, you must define a target player.");
}
else
} else
{
PlayerData playerData = getData(playerSender);
msgNew("<green>You have <gold><coins></gold> coin<plural>.",
@ -54,8 +53,7 @@ public class Command_coins extends FreedomCommand
if (target == null)
{
msg(PLAYER_NOT_FOUND);
}
else
} else
{
PlayerData playerData = getData(target);
msgNew("<green><gold><player></gold> has <gold><coins></gold> coin<plural>.",
@ -84,8 +82,7 @@ public class Command_coins extends FreedomCommand
{
// Prevents players from trying to be cheeky with negative numbers.
coinsToTransfer = Math.max(Math.abs(Integer.parseInt(args[2])), 1);
}
catch (NumberFormatException ex)
} catch (NumberFormatException ex)
{
msgNew("<red>Invalid number: <num>", Placeholder.unparsed("num", args[2]));
return true;
@ -101,8 +98,7 @@ public class Command_coins extends FreedomCommand
if (target == null)
{
msg(PLAYER_NOT_FOUND);
}
else
} else
{
PlayerData playerData = getData(target);
playerData.setCoins(playerData.getCoins() + coinsToTransfer);

View File

@ -1,8 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.Random;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -15,6 +12,9 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collections;
import java.util.Random;
@CommandPermissions(permission = "cookie", source = SourceType.BOTH)
@CommandParameters(description = "For those who have no friends - gives a cookie to everyone on the server.", usage = "/<command>")
public class Command_cookie extends FreedomCommand

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.SplittableRandom;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -13,6 +11,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.SplittableRandom;
@CommandPermissions(permission = "deafen", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Makes random sounds.", usage = "/<command>")
public class Command_deafen extends FreedomCommand
@ -37,7 +37,7 @@ public class Command_deafen extends FreedomCommand
{
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
{
final float pitch = (float)(percent * 2.0);
final float pitch = (float) (percent * 2.0);
new BukkitRunnable()
{

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -16,6 +14,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
@CommandPermissions(permission = "debugstick", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Get a stick of happiness.", usage = "/<command>")
public class Command_debugstick extends FreedomCommand

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.handling.*;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.luckperms.api.track.DemotionResult;
@ -38,8 +38,8 @@ public class Command_deop extends FreedomCommand
}
boolean b = silent;
DemotionResult result = Hierarchy.getHierarchy()
.demoteUser(Hierarchy.getHierarchy().op(), player);
DemotionResult result = TotalFreedomMod.getPlugin().getHierarchy()
.demoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player);
if (!result.wasSuccessful())
{

View File

@ -1,10 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
import me.totalfreedom.totalfreedommod.command.handling.SourceType;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.luckperms.api.track.DemotionResult;
@ -24,12 +24,12 @@ public class Command_deopall extends FreedomCommand
server.getOnlinePlayers().forEach(player ->
{
DemotionResult result = Hierarchy.getHierarchy()
.demoteUser(Hierarchy.getHierarchy().op(), player);
DemotionResult result = TotalFreedomMod.getPlugin().getHierarchy()
.demoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player);
if (!result.wasSuccessful())
{
msgNew("<red><player> is already non-OP.", Placeholder.unparsed("player", player.getName()));
msgNew("<red><player> is already non-op.", Placeholder.unparsed("player", player.getName()));
return;
}

View File

@ -1,8 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -20,6 +17,9 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
@CommandPermissions(permission = "dispfill", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Fill nearby dispensers with a set of items of your choice.", usage = "/<command> <radius> <comma,separated,items>")
public class Command_dispfill extends FreedomCommand
@ -29,7 +29,7 @@ public class Command_dispfill extends FreedomCommand
{
if (targetBlock.getType() == Material.DISPENSER)
{
final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory();
final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory();
dispenserInv.clear();
dispenserInv.addItem(items);
}
@ -45,8 +45,7 @@ public class Command_dispfill extends FreedomCommand
try
{
radius = Math.max(5, Math.min(25, Integer.parseInt(args[0])));
}
catch (NumberFormatException ex)
} catch (NumberFormatException ex)
{
msgNew("<red>Invalid radius: <amount>", Placeholder.unparsed("amount", args[0]));
return true;
@ -62,8 +61,7 @@ public class Command_dispfill extends FreedomCommand
if (material != null)
{
items.add(new ItemStack(material, 64));
}
else
} else
{
msgNew("Skipping invalid item: <item>", Placeholder.unparsed("item", searchItem));
}
@ -98,8 +96,7 @@ public class Command_dispfill extends FreedomCommand
}
msgNew("Done. <amount> dispenser(s) filled.", Placeholder.unparsed("amount", String.valueOf(affected)));
}
else
} else
{
return false;
}

View File

@ -44,8 +44,7 @@ public class Command_eject extends FreedomCommand
msgNew("<green><count> entit<grammar> ejected.",
Placeholder.unparsed("count", String.valueOf(count)),
Placeholder.unparsed("grammar", count == 1 ? "y was" : "ies were"));
}
else
} else
{
msgNew("<green>Nothing was ejected.");
}

View File

@ -1,12 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.IntStream;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -21,6 +14,9 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.*;
import java.util.stream.IntStream;
@CommandPermissions(permission = "enchant", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> [level] | remove <name>>")
public class Command_enchant extends FreedomCommand
@ -49,33 +45,28 @@ public class Command_enchant extends FreedomCommand
if (enchants.isEmpty())
{
msgNew("<red>There are no enchantments that work with this item.");
}
else
} else
{
msgNew("Possible enchantments for this item: <enchants>", Placeholder.unparsed("enchants", FUtil.listToString(enchants)));
}
}
else if (args[0].equalsIgnoreCase("addall"))
} else if (args[0].equalsIgnoreCase("addall"))
{
Arrays.stream(Enchantment.values()).filter(enchantment -> enchantment.canEnchantItem(item)).forEach(ench ->
{
try
{
item.addEnchantment(ench, ench.getMaxLevel());
}
catch (Exception ignored)
} catch (Exception ignored)
{
}
});
msgNew("<green>Added all possible enchantments for this item.");
}
else if (args[0].equalsIgnoreCase("reset"))
} else if (args[0].equalsIgnoreCase("reset"))
{
item.getEnchantments().keySet().forEach(item::removeEnchantment);
msgNew("<green>Removed all enchantments.");
}
else
} else
{
if (args.length < 2)
{
@ -105,13 +96,11 @@ public class Command_enchant extends FreedomCommand
if (ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
{
level = Integer.parseInt(args[2]);
}
else
} else
{
level = Math.max(1, Math.min(ench.getMaxLevel(), Integer.parseInt(args[2])));
}
}
catch (NumberFormatException ex)
} catch (NumberFormatException ex)
{
msgNew("Invalid number: <number>", Placeholder.unparsed("number", args[2]));
return true;
@ -120,15 +109,13 @@ public class Command_enchant extends FreedomCommand
if (!ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
{
item.addEnchantment(ench, level);
}
else
} else
{
item.addUnsafeEnchantment(ench, level);
}
msgNew("<green>Added enchantment: <enchantment>", Placeholder.unparsed("enchantment", ench.getName()));
}
else if (args[0].equals("remove"))
} else if (args[0].equals("remove"))
{
item.removeEnchantment(ench);
@ -182,9 +169,8 @@ public class Command_enchant extends FreedomCommand
Player player;
if (sender instanceof Player)
{
player = (Player)sender;
}
else
player = (Player) sender;
} else
{
return Collections.emptyList();
}
@ -200,26 +186,22 @@ public class Command_enchant extends FreedomCommand
if (args.length == 1)
{
return Arrays.asList("list", "addall", "reset", "add", "remove");
}
else if (args.length == 2)
} else if (args.length == 2)
{
if (args[0].equals("add"))
{
if (unsafe)
{
return getAllEnchantments();
}
else
} else
{
return getAllEnchantments(item);
}
}
else if (args[0].equals("remove"))
} else if (args[0].equals("remove"))
{
return getEnchantments(item);
}
}
else if (args.length == 3 && args[0].equals("add"))
} else if (args.length == 3 && args[0].equals("add"))
{
Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase());
if (enchantment != null)
@ -227,8 +209,7 @@ public class Command_enchant extends FreedomCommand
if (!unsafe)
{
return IntStream.rangeClosed(1, enchantment.getMaxLevel()).mapToObj(String::valueOf).toList();
}
else
} else
{
return Collections.singletonList("[level]");
}

View File

@ -1,9 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -17,6 +13,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@CommandPermissions(permission = "entitywipe", source = SourceType.BOTH)
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name | -a]", aliases = "ew,rd")
public class Command_entitywipe extends FreedomCommand
@ -56,14 +56,12 @@ public class Command_entitywipe extends FreedomCommand
if (args[0].equals("-a"))
{
bypassBlacklist = true;
}
else
} else
{
try
{
type = EntityType.valueOf(args[0].toUpperCase());
}
catch (Exception e)
} catch (Exception e)
{
msg(args[0] + " is not a valid entity type.", ChatColor.RED);
return true;
@ -93,8 +91,7 @@ public class Command_entitywipe extends FreedomCommand
if (type != null)
{
count = plugin.ew.wipeEntities(type);
}
else
} else
{
count = plugin.ew.wipeEntities(bypassBlacklist);
}
@ -103,8 +100,7 @@ public class Command_entitywipe extends FreedomCommand
{
msgNew("<count> <name> removed.", Placeholder.unparsed("count", String.valueOf(count)),
Placeholder.unparsed("name", type != null ? entityName : "entity"));
}
else
} else
{
msgNew("<count> <name>s removed.", Placeholder.unparsed("count", String.valueOf(count)),
Placeholder.unparsed("name", type != null ? entityName : "entitie"));

View File

@ -1,8 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -16,6 +13,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
@CommandPermissions(permission = "expel", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Push people away from you.", usage = "/<command> [radius] [strength]")
public class Command_expel extends FreedomCommand
@ -32,8 +32,7 @@ public class Command_expel extends FreedomCommand
try
{
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
}
catch (NumberFormatException ignored)
} catch (NumberFormatException ignored)
{
}
}
@ -43,8 +42,7 @@ public class Command_expel extends FreedomCommand
try
{
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
}
catch (NumberFormatException ignored)
} catch (NumberFormatException ignored)
{
}
}
@ -67,8 +65,7 @@ public class Command_expel extends FreedomCommand
try
{
inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
}
catch (IllegalArgumentException ignored)
} catch (IllegalArgumentException ignored)
{
}
@ -84,8 +81,7 @@ public class Command_expel extends FreedomCommand
if (pushedPlayers.isEmpty())
{
msgNew("No players were pushed.");
}
else
} else
{
msgNew("Pushed <amount> players: <players>",
Placeholder.unparsed("amount", String.valueOf(pushedPlayers.size())),

View File

@ -1,8 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -15,6 +12,9 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.Collections;
import java.util.List;
@CommandPermissions(permission = "explode", source = SourceType.BOTH)
@CommandParameters(description = "Surprise someone.", usage = "/<command> <player>")
public class Command_explode extends FreedomCommand

View File

@ -25,8 +25,7 @@ public class Command_fireball extends FreedomCommand
{
playerSender.getInventory().addItem(plugin.sh.getFireBall());
msgNew("<green>You have been given the <item>.", Placeholder.unparsed("item", ShopItem.FIRE_BALL.getName()));
}
else
} else
{
msgNew("<red>You don't own the <item>! Purchase it from the shop.", Placeholder.unparsed("item", ShopItem.FIRE_BALL.getName()));
}

View File

@ -27,14 +27,13 @@ public class Command_freeze extends FreedomCommand
{
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
msgNew("Players are now free to move.");
}
else
} else
{
FUtil.adminAction(sender.getName(), "Freezing all players", false);
server.getOnlinePlayers().stream().filter(player -> !isAdmin(player)).forEach(player ->
{
FUtil.playerTitle(player, "<red>You have been frozen.", "<yellow>Please be patient and you will be unfrozen shortly.");
msgNew(player, "<red>You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.");
msgNew(player, "<red>You have been globally frozen due to an op breaking the rules, please wait and you will be unfrozen soon.");
});
msgNew("Players are now frozen.");

View File

@ -28,8 +28,7 @@ public class Command_fuckoff extends FreedomCommand
if (!args[0].equals("on"))
{
player.disableFuckoff();
}
else
} else
{
double radius = 25.0;
@ -38,8 +37,7 @@ public class Command_fuckoff extends FreedomCommand
try
{
radius = Math.max(5.0, Math.min(50, Double.parseDouble(args[1])));
}
catch (NumberFormatException ex)
} catch (NumberFormatException ex)
{
}
}

View File

@ -51,13 +51,11 @@ public class Command_gcmd extends FreedomCommand
if (server.dispatchCommand(player, outCommand))
{
msg(Component.text("Command sent.", NamedTextColor.GREEN));
}
else
} else
{
msg(Component.text("Unknown error sending command.", NamedTextColor.RED));
}
}
catch (Throwable ex)
} catch (Throwable ex)
{
msg(Component.text("Error sending command: " + ex.getMessage(), NamedTextColor.RED));
}

View File

@ -23,8 +23,7 @@ public class Command_glow extends FreedomCommand
if (playerSender.getPotionEffect(PotionEffectType.GLOWING) != null)
{
playerSender.removePotionEffect(PotionEffectType.GLOWING);
}
else
} else
{
PotionEffect glow = new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false);
playerSender.addPotionEffect(glow);

View File

@ -15,7 +15,8 @@ public class Command_grapplinghook extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (plugin.sh == null) {
if (plugin.sh == null)
{
msg("The shop is currently disabled.", ChatColor.RED);
return true;
}

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.text.DecimalFormat;
import java.util.concurrent.atomic.AtomicInteger;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
@ -16,6 +14,9 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.text.DecimalFormat;
import java.util.concurrent.atomic.AtomicInteger;
@CommandPermissions(permission = "health", source = SourceType.BOTH)
@CommandParameters(description = "View server health, such as ticks-per-second, memory, etc.", usage = "/<command>")
public class Command_health extends FreedomCommand
@ -30,10 +31,10 @@ public class Command_health extends FreedomCommand
Runtime runtime = Runtime.getRuntime();
long usedMem = runtime.totalMemory() - runtime.freeMemory();
msg("Reserved Memory: " + (double)runtime.totalMemory() / (double)BYTES_PER_MB + "mb");
msg("Used Memory: " + new DecimalFormat("#").format((double)usedMem / (double)BYTES_PER_MB)
+ "mb (" + new DecimalFormat("#").format(((double)usedMem / (double)runtime.totalMemory()) * 100.0) + "%)");
msg("Max Memory: " + (double)runtime.maxMemory() / (double)BYTES_PER_MB + "mb");
msg("Reserved Memory: " + (double) runtime.totalMemory() / (double) BYTES_PER_MB + "mb");
msg("Used Memory: " + new DecimalFormat("#").format((double) usedMem / (double) BYTES_PER_MB)
+ "mb (" + new DecimalFormat("#").format(((double) usedMem / (double) runtime.totalMemory()) * 100.0) + "%)");
msg("Max Memory: " + (double) runtime.maxMemory() / (double) BYTES_PER_MB + "mb");
msg("Calculating ticks per second, please wait...");
new BukkitRunnable()
@ -62,8 +63,7 @@ public class Command_health extends FreedomCommand
msg("Ticks per second: " + (TPS_RANGE.containsDouble(ticksPerSecond) ? ChatColor.GREEN : ChatColor.RED) + ticksPerSecond);
}
}.runTask(plugin);
}
catch (Exception ex)
} catch (Exception ex)
{
FLog.severe(ex);
}
@ -107,7 +107,7 @@ public class Command_health extends FreedomCommand
long elapsed = System.currentTimeMillis() - startTime;
int tickCount = ticks.get();
return (double)tickCount / ((double)elapsed / 1000.0);
return (double) tickCount / ((double) elapsed / 1000.0);
}
}
}

View File

@ -1,10 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.IntStream;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -15,6 +10,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.IntStream;
@CommandPermissions(permission = "inspect", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Block inspector tool for operators.", usage = "/<command> [history] [page]", aliases = "ins")
public class Command_inspect extends FreedomCommand
@ -46,8 +46,7 @@ public class Command_inspect extends FreedomCommand
try
{
pageIndex = Integer.parseInt(args[1]);
}
catch (NumberFormatException e)
} catch (NumberFormatException e)
{
msgNew("<red>Invalid number.");
return true;
@ -56,12 +55,11 @@ public class Command_inspect extends FreedomCommand
int godDammit = pageIndex;
Optional.ofNullable(plugin.cpb.getHistoryForPlayer(playerSender)).ifPresentOrElse(page ->
plugin.cpb.showPageToPlayer(playerSender, page, godDammit),
plugin.cpb.showPageToPlayer(playerSender, page, godDammit),
() -> msgNew("<red>You haven't inspected anything yet!"));
return true;
}
else
} else
{
return false;
}
@ -73,14 +71,12 @@ public class Command_inspect extends FreedomCommand
if (args.length == 1)
{
return Collections.singletonList("history");
}
else if (args.length == 2 && args[0].equalsIgnoreCase("history") && plugin.cpb.isEnabled()
} else if (args.length == 2 && args[0].equalsIgnoreCase("history") && plugin.cpb.isEnabled()
&& sender instanceof Player player && plugin.cpb.hasHistory(player))
{
return IntStream.rangeClosed(1, plugin.cpb.getHistoryForPlayer(player).getPageCount()).limit(50)
.mapToObj(String::valueOf).toList();
}
else
} else
{
return Collections.emptyList();
}

View File

@ -1,9 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -15,6 +11,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@CommandPermissions(permission = "invis", source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally clears) invisible players", usage = "/<command> [clear]")
public class Command_invis extends FreedomCommand
@ -32,14 +32,12 @@ public class Command_invis extends FreedomCommand
if (!plugin.al.isAdmin(sender))
{
return noPerms();
}
else
} else
{
FUtil.adminAction(sender.getName(), "Clearing all invisibility potion effects from all players", true);
clear = true;
}
}
else
} else
{
return false;
}
@ -70,8 +68,7 @@ public class Command_invis extends FreedomCommand
if (clear)
{
msg("Cleared " + clears + " players");
}
else
} else
{
msg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
}

View File

@ -44,8 +44,7 @@ public class Command_kick extends FreedomCommand
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else if (args.length > 1)
} else if (args.length > 1)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
@ -64,13 +63,11 @@ public class Command_kick extends FreedomCommand
if (reason != null)
{
FUtil.adminAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
}
else
} else
{
FUtil.adminAction(sender.getName(), "Kicking " + player.getName(), true);
}
}
else
} else
{
msgNew("Kicked <player> quietly.", Placeholder.unparsed("player", player.getName()));
}

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
@ -16,6 +14,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Iterator;
@CommandPermissions(permission = "landmine", source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Set a landmine trap.", usage = "/<command>")
public class Command_landmine extends FreedomCommand
@ -53,8 +53,7 @@ public class Command_landmine extends FreedomCommand
try
{
radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0])));
}
catch (NumberFormatException ignored)
} catch (NumberFormatException ignored)
{
}
}

View File

@ -1,12 +1,11 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
import me.totalfreedom.totalfreedommod.command.handling.SourceType;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
@ -126,8 +125,8 @@ public class Command_mbconfig extends FreedomCommand
{
FUtil.adminAction(sender.getName(), "Adding " + data.getName() + " to the Master Builder list", true);
data.setMasterBuilder(true);
Hierarchy.getHierarchy()
.addUserToGroup(GroupProvider.MASTER_BUILDER.getGroup(), player);
TotalFreedomMod.getPlugin().getHierarchy()
.addUserToGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getMasterBuilder(), player);
plugin.pl.save(data);
} else
{
@ -157,8 +156,8 @@ public class Command_mbconfig extends FreedomCommand
}
FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
Hierarchy.getHierarchy()
.dropUser(Hierarchy.getHierarchy().builder(), player);
TotalFreedomMod.getPlugin().getHierarchy()
.dropUser(TotalFreedomMod.getPlugin().getHierarchy().builder(), player);
data.setMasterBuilder(false);
plugin.pl.save(data);

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
@ -7,7 +8,6 @@ import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
import me.totalfreedom.totalfreedommod.command.handling.SourceType;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import me.totalfreedom.totalfreedommod.util.FConverter;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.kyori.adventure.text.minimessage.tag.Tag;
@ -171,8 +171,14 @@ public class Command_myadmin extends FreedomCommand
msgNew("Set admin chat format to \"<format>\"", Placeholder.unparsed("format", format));
msgNew("Example:");
msgNew(format, Placeholder.unparsed("name", "ExampleAdmin"),
Placeholder.unparsed("rank", GroupProvider.ADMIN.getGroup().getAbbr().toString()),
TagResolver.resolver("rankcolor", Tag.styling(styler -> styler.color(GroupProvider.ADMIN.getGroup().getColor()))),
Placeholder.unparsed("rank", TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin().getAbbr().toString()),
TagResolver.resolver("rankcolor",
Tag.styling(styler ->
styler.color(TotalFreedomMod.getPlugin()
.getHierarchy()
.groups()
.getAdmin()
.getColor()))),
Placeholder.unparsed("message", "The quick brown fox jumped over the lazy dog."));
return true;
}

View File

@ -29,7 +29,8 @@ public class Command_nickmm extends FreedomCommand
return true;
}
if (args[0].isEmpty()) {
if (args[0].isEmpty())
{
return false;
}

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.handling.*;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.luckperms.api.track.PromotionResult;
import org.bukkit.Bukkit;
@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
@Intercept("op")
@CommandPermissions(permission = "op", source = SourceType.BOTH, cooldown = 5)
@CommandParameters(description = "OP a player", usage = "/<command> <partialname>")
@CommandParameters(description = "op a player", usage = "/<command> <partialname>")
public class Command_op extends FreedomCommand
{
@ -38,12 +38,12 @@ public class Command_op extends FreedomCommand
}
boolean b = silent;
PromotionResult result = Hierarchy.getHierarchy()
.promoteUser(Hierarchy.getHierarchy().op(), player);
PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy()
.promoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player);
if (!result.wasSuccessful())
{
msgNew("<red><player> is already OP!", player(player));
msgNew("<red><player> is already op!", player(player));
return true;
}

View File

@ -1,10 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
import me.totalfreedom.totalfreedommod.command.handling.SourceType;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.luckperms.api.track.PromotionResult;
import org.bukkit.command.Command;
@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(permission = "op.all", source = SourceType.BOTH, cooldown = 30)
@CommandParameters(description = "OP everyone on the server.", usage = "/<command>")
@CommandParameters(description = "op everyone on the server.", usage = "/<command>")
public class Command_opall extends FreedomCommand
{
@Override
@ -22,12 +22,12 @@ public class Command_opall extends FreedomCommand
server.getOnlinePlayers().forEach(player ->
{
PromotionResult result = Hierarchy.getHierarchy()
.promoteUser(Hierarchy.getHierarchy().op(), player);
PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy()
.promoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player);
if (!result.wasSuccessful())
{
msgNew("<red>Player is already OP!", player(player));
msgNew("<red>Player is already op!", player(player));
return;
}

View File

@ -1,10 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand;
import me.totalfreedom.totalfreedommod.command.handling.SourceType;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.luckperms.api.track.PromotionResult;
import org.bukkit.command.Command;
@ -20,8 +20,8 @@ public class Command_opme extends FreedomCommand
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FUtil.adminAction(sender.getName(), "Opping " + sender.getName(), false);
PromotionResult result = Hierarchy.getHierarchy()
.promoteUser(Hierarchy.getHierarchy().op(), playerSender);
PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy()
.promoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), playerSender);
if (!result.wasSuccessful())
{

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.command.handling.CommandParameters;
import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions;
@ -8,8 +9,6 @@ import me.totalfreedom.totalfreedommod.command.handling.SourceType;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.PermissibleCompletion;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
@ -84,8 +83,8 @@ public class Command_saconfig extends FreedomCommand
return true;
}
PromotionResult result = Hierarchy.getHierarchy()
.promoteUser(Hierarchy.getHierarchy().admin(), player);
PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy()
.promoteUser(TotalFreedomMod.getPlugin().getHierarchy().admin(), player);
if (!result.wasSuccessful() || result.getGroupTo().isEmpty())
{
@ -102,8 +101,11 @@ public class Command_saconfig extends FreedomCommand
plugin.al.addAdmin(admin);
}
Group actual = Hierarchy.getHierarchy().getGroup(group);
DisplayableGroup rank = GroupProvider.wrappedFromLPG(actual).getGroup();
Group actual = TotalFreedomMod.getPlugin().getHierarchy().getGroup(group);
DisplayableGroup rank = TotalFreedomMod.getPlugin()
.getHierarchy()
.groups()
.fromLuckPerms(actual);
if (rank == null)
{
@ -190,8 +192,8 @@ public class Command_saconfig extends FreedomCommand
return true;
}
DemotionResult result = Hierarchy.getHierarchy()
.demoteUser(Hierarchy.getHierarchy().admin(), player);
DemotionResult result = TotalFreedomMod.getPlugin().getHierarchy()
.demoteUser(TotalFreedomMod.getPlugin().getHierarchy().admin(), player);
if (!result.wasSuccessful() || result.getGroupTo().isEmpty())
{
@ -209,8 +211,11 @@ public class Command_saconfig extends FreedomCommand
plugin.al.addAdmin(admin);
}
Group actual = Hierarchy.getHierarchy().getGroup(group);
DisplayableGroup rank = GroupProvider.wrappedFromLPG(actual).getGroup();
Group actual = TotalFreedomMod.getPlugin().getHierarchy().getGroup(group);
DisplayableGroup rank = TotalFreedomMod.getPlugin()
.getHierarchy()
.groups()
.fromLuckPerms(actual);
if (rank == null)
{
@ -259,7 +264,7 @@ public class Command_saconfig extends FreedomCommand
Admin admin = plugin.al.getAdmin(player);
plugin.al.removeAdmin(admin);
Hierarchy.getHierarchy().dropUser(Hierarchy.getHierarchy().admin(), player);
TotalFreedomMod.getPlugin().getHierarchy().dropUser(TotalFreedomMod.getPlugin().getHierarchy().admin(), player);
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
admin.setActive(false);
@ -307,7 +312,7 @@ public class Command_saconfig extends FreedomCommand
&& args[0].equals("setrank")
&& sender.hasPermission("tfm.saconfig.setrank"))
{
return Arrays.asList("ADMIN", "SENIOR_ADMIN");
return Arrays.asList("admin", "seniorAdmin");
}
return Collections.emptyList();

View File

@ -46,7 +46,8 @@ public class Command_tag extends FreedomCommand
case "list":
{
msgNew("Tags for all online players:");
server.getOnlinePlayers().stream().filter(player -> !(plugin.al.isVanished(player.getUniqueId()) && !isAdmin(sender)) && plugin.pl.getPlayer(player).getTag() != null).forEach(player -> {
server.getOnlinePlayers().stream().filter(player -> !(plugin.al.isVanished(player.getUniqueId()) && !isAdmin(sender)) && plugin.pl.getPlayer(player).getTag() != null).forEach(player ->
{
msgNew("<player>: <tag>", Placeholder.unparsed("player", player.getName()),
Placeholder.component("tag", plugin.pl.getPlayer(player).getTag()));
});
@ -83,8 +84,7 @@ public class Command_tag extends FreedomCommand
if (senderIsConsole)
{
msgNew("<red>\"/tag off\" can't be used from the console.");
}
else
} else
{
plugin.pl.getPlayer(playerSender).setTag(null);
@ -104,8 +104,7 @@ public class Command_tag extends FreedomCommand
return false;
}
}
}
else if (args.length >= 2)
} else if (args.length >= 2)
{
switch (args[0].toLowerCase())
{
@ -164,13 +163,11 @@ public class Command_tag extends FreedomCommand
FLog.debug("FUCK YOU " + steamrolled);
msgNew("<red>That tag is too long (Max is <max> characters).", Placeholder.unparsed("max", String.valueOf(tagLimit)));
return true;
}
else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word)))
} else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word)))
{
msgNew("<red>That tag contains a forbidden word.");
return true;
}
else
} else
{
plugin.pl.getPlayer(playerSender).setTag(tag);

View File

@ -36,8 +36,7 @@ public class Command_unblockcmd extends FreedomCommand
fPlayer.setCommandsBlocked(false);
FUtil.adminAction(sender.getName(), "Unblocking all commands for " + player.getName(), true);
msgNew("Unblocked commands for <player>.");
}
else
} else
{
msgNew("<red>That player's commands aren't blocked.");
}

View File

@ -36,8 +36,7 @@ public class Command_uncage extends FreedomCommand
{
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
fPlayer.getCageData().setCaged(false);
}
else
} else
{
msgNew("<red>That player is not caged!");
}

View File

@ -52,14 +52,12 @@ public class Command_unmute extends FreedomCommand
{
msgNew("Quietly unmuted <player>.", Placeholder.unparsed("player", player.getName()));
return true;
}
else
} else
{
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
msgNew("Unmuted <player>.", Placeholder.unparsed("player", player.getName()));
}
}
else
} else
{
msgNew("<red>That player is not muted.");
}

Some files were not shown because too many files have changed in this diff Show More