Compare commits

..

66 Commits

Author SHA1 Message Date
9e676143b8 2021.04 Release
Formal Release for 2021.04
2021-05-03 15:19:42 +01:00
c8b20bc255 RC2 Release 2021-05-02 13:12:37 +01:00
f240a15af3 Force the count to be zero if the value is negative (FS-216) (#56) 2021-05-01 23:58:03 +10:00
6073712fdf Bump Version
Bump Version to 2021.04-RC01
2021-04-26 20:46:11 +01:00
d11d55b218 Vanished admins are no longer being counted (FS-148) (#41) 2021-04-24 14:06:28 +10:00
debb95fb4c video dev man (#51) 2021-04-24 13:03:11 +10:00
b9f7ab3ec3 Change punishment from kicking to muting on spam (FS-97) (#45) 2021-04-22 21:54:29 +10:00
2cdf1e66a6 Disables block gravity and makes it togglable (FS-89) (#50)
* Disables block gravity by default (FS-89)

* Combine these checks as Codacy ever so kindly suggested
2021-04-19 17:34:36 +10:00
20c2c4c96e Delete /wipeuserdata (FS-196) (#49) 2021-04-15 22:07:22 +10:00
d5238150d0 Curse be gone (#47)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2021-04-13 14:13:47 +10:00
64a4e70c41 Merge pull request #48 from AtlasMediaGroup/abhi-fix
Strip role/user mentions (FS-191)
2021-04-12 16:45:13 -05:00
0c2f0a714c [+] Fix #replace() 2021-04-12 16:31:48 +05:30
4c67553bdd [+] Whitespace change! 2021-04-12 16:26:06 +05:30
ffab5e3c12 [+] Allman style formating 2021-04-12 16:01:31 +05:30
f7556a4861 [+] Remove redundant comments 2021-04-12 15:59:27 +05:30
385fc77771 [+] Done all the requested changes! 2021-04-12 15:44:51 +05:30
b852ea1822 [+] Update my account in developers list 2021-04-12 14:44:27 +05:30
4a5a3a1a2d [+] Fix FS-191 2021-04-12 13:57:58 +05:30
37762e5470 Merge pull request #39 from AtlasMediaGroup/Elmon11-patch-2
clearinv option in smite (FS-161)
2021-04-11 22:15:26 +01:00
85d90090c8 Merge branch 'development' into Elmon11-patch-2 2021-04-11 18:41:54 +01:00
09930c2d9a Merge pull request #43 from VideoGameSmash12/development
Consistency fixes (across 46 commands), additional CoreProtect integration (/dispfill and /setlever), and a critical bugfix (/setlever) (FS-162)
2021-04-10 12:56:32 +01:00
7ae1ab035a Merge branch 'development' into development 2021-04-10 12:50:52 +01:00
2bd1787663 Updated supported versions for TFM. 2021-04-10 12:45:56 +01:00
765b7dcc4b Merge branch 'development' into development 2021-04-10 12:39:47 +01:00
091381a076 Merge pull request #44 from AtlasMediaGroup/FS-145
Update JDA version and location (FS-145)
2021-04-10 12:39:08 +01:00
27dfd71b2e Update JDA version and location (FS-145) 2021-04-09 21:20:33 +10:00
16e06bd932 Forgot I had this there 2021-04-07 19:45:03 -06:00
a33c310757 Fucking shit 2021-04-07 19:41:13 -06:00
df21bdfa7e Other bug fixes
Credit to Fleek for some of the code here.

Bugs that were fixed:
* [Media] showing up with an extra space at the beginning of blank messages with attachments
* Admin chat using incorrect colors for its ranks in messages from Discord to Minecraft
* Admin notes not sending to admins, only admin impostors
2021-04-07 19:40:19 -06:00
d7e2c0da42 Merge branch 'development' into Elmon11-patch-2 2021-04-07 11:52:16 +10:00
a7529b41fb Oops 2021-04-05 18:08:24 -06:00
c4fce3f0f9 Right, so this change applies only to commands. For the sake of code consistency, I tried to change as many as possible to use FreedomCommand.msg instead of CommandSender.sendMessage for their messages. Here are a list of the files containing those changes:
* Command_adminworld.java
* Command_adventure.java
* Command_banip.java
* Command_blockedit.java
* Command_blockpvp.java
* Command_cage.java
* Command_cartsit.java
* Command_clearchat.java
* Command_clearinventory.java
* Command_commandlist.java
* Command_creative.java
* Command_deop.java
* Command_deopall.java
* Command_dispfill.java
* Command_doom.java
* Command_gcmd.java
* Command_hubworld.java
* Command_inspect.java
* Command_list.java
* Command_lockup.java
* Command_manageshop.java
* Command_manuallyverify.java
* Command_masterbuilderworld.java
* Command_mbconfig.java
* Command_moblimiter.java
* Command_mp44.java
* Command_mute.java
* Command_nickfilter.java
* Command_op.java
* Command_opall.java
* Command_opme.java
* Command_potion.java (Also corrected the inconsistent "player not found" message's color)
* Command_rank.java
* Command_ride.java
* Command_saconfig.java
* Command_scare.java
* Command_setplayerlimit.java
* Command_settotalvotes.java
* Command_smite.java
* Command_spectator.java
* Command_survival.java
* Command_unblockcmd.java
* Command_uncage.java
* Command_unmute.java
* Command_verifynoadmin.java

Here are some commands I added functionality to:
* Command_dispfill.java: Added some code that hooks into the CoreProtect API to log the items being removed from and added into the dispensers.
* Command_setlever.java: Added some code that hooks into the CoreProtect API to log the levers being interacted with.

Here's a command I fixed a critical bug in:
* Command_setlever.java
2021-04-05 17:13:26 -06:00
27f5f18962 FS-143 Resolution (#42)
* Bump to patch version.

* Fixes FS-143

Various changes to make it work better with logging and things like that.
2021-04-06 07:11:12 +10:00
dca5e30291 Actually display assistant exec in game (#37)
* Actually display assistant exec in game

* Update RankManager.java

* Update ConfigEntry.java

* Update FUtil.java

Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2021-04-04 22:24:06 +10:00
09a435053e Merge pull request #40 from AtlasMediaGroup/phoenix-patch-1
Remove /premium
2021-03-31 17:12:56 -05:00
14309275fb Remove /premium 2021-03-31 15:16:01 -05:00
2375e92d90 Merge pull request #36 from AtlasMediaGroup/tfm-bugfix-001
FS-143
2021-03-26 15:43:22 +00:00
97672c2fff Update DiscordToAdminChatListener.java
This is the only way we can load media after [Discord] and [Formatting] without rewriting the method
2021-03-22 09:57:09 -05:00
5837b05a35 Merge branch 'tfm-bugfix-001' of https://github.com/AtlasMediaGroup/TotalFreedomMod into tfm-bugfix-001 2021-03-21 14:02:51 -05:00
b3b68ebd13 Switch to Allman Formatting 2021-03-21 14:02:43 -05:00
2dbbb5c262 Intellij says this is fine so if it breaks again gg 2021-03-21 19:07:07 +01:00
e45655edbb im a clown 2021-03-21 18:33:38 +01:00
9713fcabd6 Should work fingers crossed 2021-03-21 18:25:28 +01:00
dc10c40578 noclear option in smite 2021-03-21 13:57:24 +01:00
db3c190b2b Merge branch 'development' into tfm-bugfix-001 2021-03-21 16:11:13 +11:00
2725857364 Merge pull request #38 from AtlasMediaGroup/FS-147
Fix ban expiration (FS-147)
2021-03-20 22:14:10 -05:00
9f291f675c Use 'toEpochMilli()' instead (FS-147) 2021-03-21 13:44:55 +11:00
561c192c27 Fix bans not expiring (FS-147) 2021-03-21 12:21:15 +11:00
086dec28ac Merge branch 'development' into tfm-bugfix-001 2021-03-19 23:31:31 +00:00
b03870c0aa SQL Fixes
:)
2021-03-19 10:39:58 -05:00
f5c08cd28b Merge pull request #34 from AtlasMediaGroup/2021.02-release
Bump version to 2021.02 Release
2021-03-19 14:26:02 +00:00
2a87271642 Should fix FS-143 2021-03-19 08:58:29 -05:00
3b57aec0e8 Merge branch 'development' into 2021.02-release 2021-03-18 23:57:10 +00:00
efac65bc76 Merge pull request #35 from AtlasMediaGroup/FS-58
Fix checkstyle & other formatting
2021-03-18 23:17:25 +00:00
9c8fe6c590 Fix checkstyle & other formatting
This should help clear a lot of the "Security" alerts resolving FS-58
2021-03-18 22:42:52 +00:00
9f52cdf753 Merge branch 'development' into 2021.02-release 2021-03-18 22:28:53 +00:00
216234ea01 Merge pull request #32 from AtlasMediaGroup/FS-33
Properly fix FS-33
2021-03-18 16:20:06 -05:00
881dead392 Merge branch 'development' into 2021.02-release 2021-03-19 08:04:36 +11:00
ff2bca26aa Merge branch 'development' into FS-33 2021-03-18 19:58:10 +00:00
89ad934aa6 Bump version to 2021.02 Release 2021-03-18 19:18:11 +00:00
d0a195647c Merge pull request #33 from AtlasMediaGroup/FS-93
Fixed permission not setting for new players (FS-93)
2021-03-17 09:06:45 -05:00
eb05b05042 Fixed FS-93
- Players no longer need to relog, just need to be opped to get permissions.
- Removed redundant PlayerJoinEvent code as it's already been executed (See RankManager class).
2021-03-16 20:21:31 +11:00
b9c1970d20 Update player's permission when opping. 2021-03-16 19:56:29 +11:00
9eca9ac5b2 Remove double storage
It is unnecessary as the information is already stored in a map (Username, IPs)
2021-03-08 11:34:48 +11:00
5b577fae07 Add myself to developer list 2021-03-07 20:46:30 +11:00
452a8755c2 Properly fix FS-33 2021-03-07 20:43:25 +11:00
77 changed files with 356 additions and 526 deletions

View File

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

View File

@ -1,4 +1,5 @@
# TotalFreedom General License #
# TotalFreedom General License
_Version 2.0, 27th February 2015_
Copyright (c) 2011 Steven Lawson
@ -7,7 +8,8 @@ Copyright (c) 2012 Jerom van der Sar
All rights reserved.
##### 1. Definitions #####
##### 1. Definitions
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
@ -30,8 +32,9 @@ All rights reserved.
"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:
##### 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:
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor.
@ -47,8 +50,10 @@ All rights reserved.
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
##### 3. Submission of Contributions #####
##### 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.
##### 4. Disclaimer of Warranty #####
##### 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.

View File

@ -1,16 +1,17 @@
# TotalFreedomMod [![Build Status](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod.svg?branch=development)](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/29c0f964da304666bd654bc7b1d556db)](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=AtlasMediaGroup/TotalFreedomMod&amp;utm_campaign=Badge_Grade)
# TotalFreedomMod [![Build Status](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod.svg?branch=development)](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod) [![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)
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.
### Contributing ###
### Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod.
For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
For information on our security policy and reporting an issue, please see [SECURITY.md](SECURITY.md)
### Compiling ###
### Compiling
You need Maven to build. You'd also need to set the JDK version to Java 8 as that is the current standard as of now.

View File

@ -6,12 +6,14 @@ We currently support the code running on the "development" branch of this reposi
In terms of plugin releases, we support the following versions:
| Version | Supported |
| ------- | ------------------ |
| 2020.11 | :white_check_mark: |
| 6.0.x (Pre-Release) | :x: |
| < 2020.11 | :x: |
| < 5.x | :x: |
| Version | Supported |
| ------------------- | ------------------ |
| 2021.04 | :white_check_mark: |
| 2021.02 | :white_check_mark: |
| 2020.11 | :white_check_mark: |
| 6.0.x (Pre-Release) | :x: |
| < 2020.11 | :x: |
| < 5.x | :x: |
## Reporting a Vulnerability

View File

@ -2,20 +2,16 @@
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="SuppressionFilter">
<property name="file" value="supressions.xml"/>
</module>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
@ -91,7 +87,7 @@
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9][_]*[T]$)"/>
<property name="format" value="(^[A-Z][a-zA-Z0-9]*$)|([A-Z][a-zA-Z0-9]*[_][a-zA-Z0-9]*$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
@ -112,7 +108,8 @@
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="CustomImportOrder"/><!-- http://checkstyle.sourceforge.net/config_imports.html -->
<module name="CustomImportOrder"/>
<!-- http://checkstyle.sourceforge.net/config_imports.html -->
<module name="MethodParamPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>

10
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId>
<version>2021.02-RC03</version>
<version>2021.04</version>
<packaging>jar</packaging>
<properties>
@ -75,9 +75,9 @@
</repository>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases/</url>
</repository>
<repository>
@ -191,7 +191,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_224</version>
<version>4.2.1_255</version>
<scope>provided</scope>
</dependency>

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -11,10 +10,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap;
import java.util.Map;
public class AntiSpam extends FreedomService
{
@ -22,7 +23,7 @@ public class AntiSpam extends FreedomService
public static final int TICKS_PER_CYCLE = 2 * 10;
//
public BukkitTask cycleTask = null;
List<Player> markedForDeath = new ArrayList<>();
private Map<Player, Integer> muteCounts = new HashMap<>();
@Override
public void onStart()
@ -67,23 +68,26 @@ public class AntiSpam extends FreedomService
return;
}
String message = event.getMessage().trim();
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
int count = muteCounts.getOrDefault(player, 0);
int minutes = ConfigEntry.ANTISPAM_MINUTES.getInteger();
// Check for spam
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE && !playerdata.isMuted())
{
if (!markedForDeath.contains(player))
{
markedForDeath.add(player);
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
FSync.autoEject(player, "Kicked for spamming chat.");
count++;
muteCounts.put(player, count);
playerdata.resetMsgCount();
int time = count * minutes;
playerdata.setMuted(true, time);
event.setCancelled(true);
}
FSync.bcastMsg(String.format("%s has automatically been muted for %d minutes for spamming chat.",
player.getName(),
time),
ChatColor.RED);
playerdata.resetMsgCount();
event.setCancelled(true);
}
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
{
@ -122,10 +126,4 @@ public class AntiSpam extends FreedomService
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerKick(PlayerKickEvent event)
{
markedForDeath.remove(event.getPlayer());
}
}

View File

@ -159,24 +159,20 @@ public class ChatManager extends FreedomService
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
for (Player player : server.getOnlinePlayers())
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
{
if (plugin.al.isAdmin(player))
{
Admin admin = plugin.al.getAdmin(player);
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
{
String format = admin.getAcFormat();
ChatColor color = getColor(display);
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
player.sendMessage(FUtil.colorize(msg));
}
else
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
}
Admin admin = plugin.al.getAdmin(player);
if (!Strings.isNullOrEmpty(admin.getAcFormat())) {
String format = admin.getAcFormat();
ChatColor color = getColor(display);
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
player.sendMessage(FUtil.colorize(msg));
}
}
else
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
}
});
}
public void reportAction(Player reporter, Player reported, String report)

View File

@ -246,7 +246,7 @@ public class LoginProcess extends FreedomService
FLog.info(noteMessage);
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdminImpostor(p))
if (plugin.al.isAdmin(p))
{
notice.send(p);
}

View File

@ -28,7 +28,6 @@ import me.totalfreedom.totalfreedommod.command.CommandLoader;
import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.freeze.Freezer;
import me.totalfreedom.totalfreedommod.fun.CurseListener;
import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer;
@ -116,7 +115,6 @@ public class TotalFreedomMod extends JavaPlugin
public Monitors mo;
public MovementValidator mv;
public ServerPing sp;
public CurseListener cul;
public ItemFun it;
public Landminer lm;
public MP44 mp;
@ -368,7 +366,6 @@ public class TotalFreedomMod extends JavaPlugin
private void initFun()
{
// Fun
cul = new CurseListener();
it = new ItemFun();
lm = new Landminer();
mp = new MP44();

View File

@ -25,17 +25,9 @@ public class Admin
private boolean active = true;
private Rank rank = Rank.ADMIN;
private Date lastLogin = new Date();
private Boolean commandSpy = false;
private Boolean potionSpy = false;
private String acFormat = null;
private String pteroID = null;
public Admin(Player player)

View File

@ -22,8 +22,7 @@ import org.bukkit.entity.Player;
public class AdminList extends FreedomService
{
public static final List<String> vanished = new ArrayList<>();
public final List<String> verifiedNoAdmin = new ArrayList<>();
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
public final Map<String, List<String>> verifiedNoAdmin = Maps.newHashMap();
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
// Only active admins below
private final Set<Admin> activeAdmins = Sets.newHashSet();
@ -240,8 +239,7 @@ public class AdminList extends FreedomService
public boolean isVerifiedAdmin(Player player)
{
// Fix of issue FS-33
return !verifiedNoAdmin.contains(player.getName()) || verifiedNoAdminIps.containsKey(player.getName()) && !verifiedNoAdminIps.get(player.getName()).contains(FUtil.getIp(player));
return verifiedNoAdmin.containsKey(player.getName()) && verifiedNoAdmin.get(player.getName()).contains(FUtil.getIp(player));
}
public boolean isIdentityMatched(Player player)
@ -404,13 +402,8 @@ public class AdminList extends FreedomService
return ipTable;
}
public List<String> getVerifiedNoAdmin()
public Map<String, List<String>> getVerifiedNoAdmin()
{
return verifiedNoAdmin;
}
public Map<String, List<String>> getVerifiedNoAdminIps()
{
return verifiedNoAdminIps;
}
}

View File

@ -169,7 +169,7 @@ public class Ban
public boolean isExpired()
{
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
return hasExpiry() && FUtil.getUnixDate(expiryUnix).before(new Date(FUtil.getUnixTime()));
}
public String bakeKickMessage()

View File

@ -14,6 +14,7 @@ import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.data.AnaloguePowerable;
import org.bukkit.block.data.Powerable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -30,6 +31,7 @@ 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;
@ -212,6 +214,15 @@ public class EventBlocker extends FreedomService
}
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event)
{
if (!ConfigEntry.ALLOW_GRAVITY.getBoolean() && event.getEntity() instanceof FallingBlock)
{
event.setCancelled(true);
}
}
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event)
{

View File

@ -1,11 +1,7 @@
package me.totalfreedom.totalfreedommod.bridge;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collections;
@ -228,11 +224,12 @@ public class CoreProtectBridge extends FreedomService
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
connection = DriverManager.getConnection("jdbc:sql://" + url);
final Statement statement = connection.createStatement();
final PreparedStatement statement = connection.prepareStatement("SELECT id FROM co_world WHERE world = ?");
statement.setQueryTimeout(30);
// Obtain world ID from CoreProtect database
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'");
statement.setString(1, world.getName());
ResultSet resultSet = statement.executeQuery();
String worldID = null;
while (resultSet.next())
{
@ -250,7 +247,10 @@ public class CoreProtectBridge extends FreedomService
// Iterate through each table and delete their data if the world ID matches
for (String table : tables)
{
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID);
final PreparedStatement statement1 = connection.prepareStatement("DELETE FROM ? WHERE wid = ?");
statement1.setString(1, table);
statement1.setString(2, worldID);
statement1.executeQuery();
}
connection.close();

View File

@ -137,7 +137,7 @@ public class Command_adminworld extends FreedomCommand
{
return noPerms();
}
sender.sendMessage(ex.getMessage());
msg(ex.getMessage());
return true;
}

View File

@ -19,7 +19,7 @@ public class Command_adventure extends FreedomCommand
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
msg("When used from the console, you must define a target player.");
return true;
}
@ -46,7 +46,7 @@ public class Command_adventure extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -72,8 +72,8 @@ public class Command_banip extends FreedomCommand
{
// Broadcast
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
player.sendMessage(message);
String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
msg(player, message, ChatColor.RED);
}
}

View File

@ -92,7 +92,7 @@ public class Command_blockedit extends FreedomCommand
final Player player2 = getPlayer(args[0]);
if (player2 == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -93,7 +93,7 @@ public class Command_blockpvp extends FreedomCommand
final Player p = getPlayer(args[0]);
if (p == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -42,14 +42,14 @@ public class Command_cage extends FreedomCommand
Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (fPlayer.getCageData().isCaged())
{
sender.sendMessage(ChatColor.RED + "That player is already caged.");
msg("That player is already caged.", ChatColor.RED);
return true;
}
@ -80,7 +80,7 @@ public class Command_cage extends FreedomCommand
outerMaterial = Material.matchMaterial(args[2]);
break;
}
sender.sendMessage(ChatColor.RED + "Invalid block!");
msg("Invalid block!", ChatColor.RED);
break;
}
}

View File

@ -23,7 +23,7 @@ public class Command_cartsit extends FreedomCommand
if (targetPlayer == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
}
@ -32,7 +32,7 @@ public class Command_cartsit extends FreedomCommand
{
if (targetPlayer == null)
{
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>");
msg("When used from the console, you must define a target player: /cartsit <player>");
return true;
}
}

View File

@ -20,7 +20,7 @@ public class Command_clearchat extends FreedomCommand
{
for (int i = 0; i < 100; i++)
{
player.sendMessage("");
msg(player, "");
}
}
}

View File

@ -52,7 +52,7 @@ public class Command_clearinventory extends FreedomCommand
player.getInventory().clear();
msg("Cleared " + player.getName() + "'s inventory.");
player.sendMessage(sender.getName() + " has cleared your inventory.");
msg(player, sender.getName() + " has cleared your inventory.");
}
}
else

View File

@ -43,7 +43,7 @@ public class Command_commandlist extends FreedomCommand
Collections.sort(commands);
sender.sendMessage(StringUtils.join(commands, ", "));
msg(StringUtils.join(commands, ", "));
return true;
}

View File

@ -19,7 +19,7 @@ public class Command_creative extends FreedomCommand
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
msg("When used from the console, you must define a target player.");
return true;
}
@ -46,7 +46,7 @@ public class Command_creative extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -1,64 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Curse someone - sends a cursed texture pack to the specified player.", usage = "/<command> <player>")
public class Command_curse extends FreedomCommand
{
/* The only problem with this is someone can prevent themself from being cursed by declining to download the
resource pack. However, if they hit yes, then you can curse them whenever you want and they can't stop it unless
they go into their server settings. and set server resource packs to prompt or disabled */
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!FUtil.isExecutive(sender.getName()))
{
return noPerms();
}
if (args.length == 0)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (plugin.cul.cursedPlayers.containsKey(player))
{
msg("Already attempting to curse!", ChatColor.RED);
return true;
}
player.setResourcePack("http://play.totalfreedom.me/cursed.zip");
msg("Attempting to curse " + player.getName(), ChatColor.GREEN);
plugin.cul.cursedPlayers.put(player, playerSender);
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender) && FUtil.isExecutive(sender.getName()))
{
return FUtil.getPlayerList();
}
return Collections.emptyList();
}
}

View File

@ -39,7 +39,8 @@ public class Command_deop extends FreedomCommand
{
matchedPlayerNames.add(player.getName());
player.setOp(false);
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
msg(player, YOU_ARE_NOT_OP);
plugin.rm.updateDisplay(player);
}
}
}

View File

@ -19,7 +19,8 @@ public class Command_deopall extends FreedomCommand
for (Player player : server.getOnlinePlayers())
{
player.setOp(false);
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
msg(player, YOU_ARE_NOT_OP);
plugin.rm.updateDisplay(player);
}
return true;

View File

@ -43,7 +43,7 @@ public class Command_dispfill extends FreedomCommand
}
catch (NumberFormatException ex)
{
sender.sendMessage("Invalid radius.");
msg("Invalid radius.");
return true;
}
@ -60,7 +60,7 @@ public class Command_dispfill extends FreedomCommand
}
else
{
sender.sendMessage("Skipping invalid item: " + searchItem);
msg("Skipping invalid item: " + searchItem);
}
}
@ -80,7 +80,8 @@ public class Command_dispfill extends FreedomCommand
{
if (targetBlock.getType().equals(Material.DISPENSER))
{
sender.sendMessage("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
msg("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
plugin.cpb.getCoreProtectAPI().logContainerTransaction(sender.getName(), targetBlock.getLocation());
setDispenserContents(targetBlock, itemsArray);
affected++;
}
@ -89,7 +90,7 @@ public class Command_dispfill extends FreedomCommand
}
}
sender.sendMessage("Done. " + affected + " dispenser(s) filled.");
msg("Done. " + affected + " dispenser(s) filled.");
}
else
{

View File

@ -36,7 +36,7 @@ public class Command_doom extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -23,7 +23,7 @@ public class Command_gcmd extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -138,7 +138,7 @@ public class Command_hubworld extends FreedomCommand
{
return noPerms();
}
sender.sendMessage(ex.getMessage());
msg(ex.getMessage());
return true;
}

View File

@ -39,7 +39,7 @@ public class Command_inspect extends FreedomCommand
}
catch (NumberFormatException e)
{
sender.sendMessage(ChatColor.RED + "Invalid number");
msg("Invalid number", ChatColor.RED);
}
}
@ -48,19 +48,19 @@ public class Command_inspect extends FreedomCommand
{
if (pageIndex < 1 || pageIndex > paged.getPageCount())
{
sender.sendMessage(ChatColor.RED + "Not a valid page number");
msg("Not a valid page number", ChatColor.RED);
return true;
}
sender.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- ");
msg("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- ", ChatColor.WHITE);
List<String> page = paged.getPage(pageIndex);
for (String entries : page)
{
sender.sendMessage(entries);
msg(entries);
}
sender.sendMessage("Page " + pageIndex + "/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
msg("Page " + pageIndex + "/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>", ChatColor.WHITE);
return true;
}
}

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -14,10 +12,14 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-s | -i | -f | -v]", aliases = "who,lsit")
public class Command_list extends FreedomCommand
{
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
if (args.length > 1)
@ -29,7 +31,10 @@ public class Command_list extends FreedomCommand
List<String> names = new ArrayList<>();
for (Player player : server.getOnlinePlayers())
{
names.add(player.getName());
if (!plugin.al.isVanished(player.getName()))
{
names.add(player.getName());
}
}
msg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE);
return true;
@ -96,7 +101,8 @@ public class Command_list extends FreedomCommand
}
else
{
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size())
int count = server.getOnlinePlayers().size() - AdminList.vanished.size();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(count < 0 ? 0 : count)
.append(ChatColor.BLUE)
.append(" out of a maximum ")
.append(ChatColor.RED)
@ -141,13 +147,13 @@ public class Command_list extends FreedomCommand
.append(StringUtils.join(n, ChatColor.WHITE + ", "));
if (senderIsConsole)
{
sender.sendMessage(ChatColor.stripColor(onlineStats.toString()));
sender.sendMessage(ChatColor.stripColor(onlineUsers.toString()));
msg(ChatColor.stripColor(onlineStats.toString()));
msg(ChatColor.stripColor(onlineUsers.toString()));
}
else
{
sender.sendMessage(onlineStats.toString());
sender.sendMessage(onlineUsers.toString());
msg(onlineStats.toString());
msg(onlineUsers.toString());
}
n.clear();
return true;

View File

@ -53,7 +53,7 @@ public class Command_lockup extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
@ -70,7 +70,7 @@ public class Command_lockup extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -54,7 +54,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]);
if (player != null)
{
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN);
}
}
else
@ -64,7 +64,7 @@ public class Command_manageshop extends FreedomCommand
PlayerData playerData = plugin.pl.getData(player);
playerData.setCoins(playerData.getCoins() + amount);
plugin.pl.save(playerData);
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN);
}
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
}
@ -97,7 +97,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]);
if (player != null)
{
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED);
}
}
else
@ -111,7 +111,7 @@ public class Command_manageshop extends FreedomCommand
playerData.setCoins(0);
}
plugin.pl.save(playerData);
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED);
}
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
}
@ -138,7 +138,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]);
if (player != null)
{
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
msg(player, sender.getName() + " set your coin balance to " + amount, ChatColor.GREEN);
}
return true;
}
@ -183,7 +183,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]);
if (player != null)
{
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
msg(player, sender.getName() + " gave the " + item.getName() + " to you", ChatColor.GREEN);
}
return true;
}
@ -208,7 +208,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]);
if (player != null)
{
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
msg(player, sender.getName() + " took the " + item.getName() + " from you", ChatColor.RED);
}
return true;
}

View File

@ -48,12 +48,12 @@ public class Command_manuallyverify extends FreedomCommand
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
player.setOp(true);
player.sendMessage(YOU_ARE_OP);
msg(player, YOU_ARE_OP);
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
{
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
msg(player, "You have been unfrozen.");
}
plugin.pl.verify(player, null);

View File

@ -138,7 +138,7 @@ public class Command_masterbuilderworld extends FreedomCommand
{
return noPerms();
}
sender.sendMessage(ex.getMessage());
msg(ex.getMessage());
return true;
}

View File

@ -129,7 +129,7 @@ public class Command_mbconfig extends FreedomCommand
plugin.pl.verify(player, null);
plugin.rm.updateDisplay(player);
player.setOp(true);
player.sendMessage(YOU_ARE_OP);
msg(player, YOU_ARE_OP);
}
}
else if (!data.isMasterBuilder())

View File

@ -65,7 +65,7 @@ public class Command_moblimiter extends FreedomCommand
if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
{
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
msg("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
msg("Dragon: " + (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + ".");
msg("Giant: " + (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + ".");

View File

@ -45,7 +45,7 @@ public class Command_mp44 extends FreedomCommand
{
playerdata.disarmMP44();
sender.sendMessage(ChatColor.GREEN + "mp44 Disarmed.");
msg("mp44 Disarmed.", ChatColor.GREEN);
}
return true;

View File

@ -109,7 +109,7 @@ public class Command_mute extends FreedomCommand
final Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -7,7 +7,6 @@ import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -81,7 +80,7 @@ public class Command_nickfilter extends FreedomCommand
if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
msg("Can't find player by nickname: " + displayName);
return true;
}
}
@ -101,7 +100,7 @@ public class Command_nickfilter extends FreedomCommand
if (!nickMatched)
{
sender.sendMessage("No nicknames replaced in command.");
msg("No nicknames replaced in command.");
return true;
}
@ -113,7 +112,7 @@ public class Command_nickfilter extends FreedomCommand
return true;
}
sender.sendMessage("Sending command: \"" + newCommand + "\".");
msg("Sending command: \"" + newCommand + "\".");
server.dispatchCommand(sender, newCommand);
return true;

View File

@ -40,7 +40,8 @@ public class Command_op extends FreedomCommand
{
matchedPlayerNames.add(player.getName());
player.setOp(true);
player.sendMessage(FreedomCommand.YOU_ARE_OP);
msg(player, YOU_ARE_OP);
plugin.rm.updateDisplay(player);
}
}
}

View File

@ -21,7 +21,8 @@ public class Command_opall extends FreedomCommand
if (!player.isOp())
{
player.setOp(true);
player.sendMessage(FreedomCommand.YOU_ARE_OP);
msg(player, YOU_ARE_OP);
plugin.rm.updateDisplay(player);
}
}

View File

@ -16,7 +16,8 @@ public class Command_opme extends FreedomCommand
{
FUtil.adminAction(sender.getName(), "Opping " + sender.getName(), false);
sender.setOp(true);
sender.sendMessage(FreedomCommand.YOU_ARE_OP);
msg(YOU_ARE_OP);
plugin.rm.updateDisplay(playerSender);
return true;
}
}

View File

@ -106,7 +106,7 @@ public class Command_potion extends FreedomCommand
{
if (!plugin.al.isAdmin(sender) && !getPlayer(args[4]).equals(getPlayer(sender.getName())))
{
sender.sendMessage(ChatColor.RED + "Only admins can apply potion effects to other players.");
msg("Only admins can apply potion effects to other players.", ChatColor.RED);
return true;
}
@ -114,7 +114,7 @@ public class Command_potion extends FreedomCommand
if (target == null || plugin.al.isVanished(target.getName()) && !plugin.al.isAdmin(sender))
{
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
msg(PLAYER_NOT_FOUND);
return true;
}
}
@ -122,7 +122,7 @@ public class Command_potion extends FreedomCommand
{
if (senderIsConsole)
{
sender.sendMessage("You must specify a target player when using this command from the console.");
msg("You must specify a target player when using this command from the console.");
return true;
}
}
@ -130,7 +130,7 @@ public class Command_potion extends FreedomCommand
PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]);
if (potion_effect_type == null)
{
sender.sendMessage(ChatColor.AQUA + "Invalid potion effect type.");
msg("Invalid potion effect type.", ChatColor.AQUA);
return true;
}

View File

@ -1,83 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Validates if a given account is premium, or cracked.", usage = "/<command> <player>", aliases = "prem")
public class Command_premium extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
final Player player = getPlayer(args[0]);
final String name;
if (player != null)
{
name = player.getName();
}
else
{
name = args[0];
}
new BukkitRunnable()
{
@Override
public void run()
{
try
{
final URL getUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
final HttpURLConnection urlConnection = (HttpURLConnection)getUrl.openConnection();
urlConnection.setRequestProperty("User-Agent", "");
String message;
/*old code
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
//message = (!"PREMIUM".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
*/
try
{
if (urlConnection.getResponseCode() == 200)
{
message = ChatColor.GREEN + "Yes";
}
else
{
message = ChatColor.RED + "No";
}
FSync.playerMsg(sender, "Player " + name + " is premium: " + message);
}
catch (IOException e)
{
FSync.playerMsg(sender, ChatColor.RED + "There was an error on trying to connect to the API server");
}
}
catch (IOException ex)
{
FLog.severe(ex);
msg("There was an error querying the API server.", ChatColor.RED);
}
}
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -39,7 +39,7 @@ public class Command_rank extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -52,7 +52,7 @@ public class Command_ride extends FreedomCommand
}
msg("Request accepted.");
requester.sendMessage(ChatColor.GRAY + "Your request has been accepted.");
msg(requester, "Your request has been accepted.");
if (requester.getWorld() != playerSender.getWorld())
{
@ -80,7 +80,7 @@ public class Command_ride extends FreedomCommand
}
msg("Request denied.");
RIDE_REQUESTS.remove(playerSender);
requester.sendMessage(ChatColor.GRAY + "Your request has been denied.");
msg(requester, "Your request has been denied.");
return true;
}
@ -123,10 +123,10 @@ public class Command_ride extends FreedomCommand
if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
{
msg("Sent a request to the player.", ChatColor.GREEN);
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you.");
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.");
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.");
player.sendMessage(ChatColor.AQUA + "Request will expire in 30 seconds.");
msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA);
msg(player, "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.", ChatColor.AQUA);
msg(player, "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.", ChatColor.AQUA);
msg(player, "Request will expire in 30 seconds.", ChatColor.AQUA);
RIDE_REQUESTS.put(player, playerSender);
new BukkitRunnable()
@ -139,8 +139,8 @@ public class Command_ride extends FreedomCommand
}
RIDE_REQUESTS.remove(player);
playerSender.sendMessage(ChatColor.RED + "It has been 30 seconds and " + player.getName() + " has not accepted your request.");
player.sendMessage(ChatColor.RED + "Request expired.");
msg(playerSender, "It has been 30 seconds and " + player.getName() + " has not accepted your request.", ChatColor.RED);
msg(player, "Request expired.", ChatColor.RED);
}
}.runTaskLater(plugin, 20 * 30);
return true;

View File

@ -220,7 +220,6 @@ public class Command_saconfig extends FreedomCommand
if (plugin.al.isVerifiedAdmin(player))
{
plugin.al.verifiedNoAdmin.remove(player.getName());
plugin.al.verifiedNoAdminIps.remove(player.getName());
}
plugin.al.save(admin);
@ -244,7 +243,7 @@ public class Command_saconfig extends FreedomCommand
if (!player.isOp())
{
player.setOp(true);
player.sendMessage(YOU_ARE_OP);
msg(player, YOU_ARE_OP);
}
return true;
}

View File

@ -38,7 +38,7 @@ public class Command_scare extends FreedomCommand
}
msg("Scared " + player.getName());
player.sendMessage(ChatColor.RED + "ZING");
msg(player, "ZING", ChatColor.RED);
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
for (int i = 0; i < 10; ++i)

View File

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Location;
import org.bukkit.Material;
@ -39,6 +40,12 @@ public class Command_setlever extends FreedomCommand
return true;
}
if (x > 29999998 || x < -29999998 || y > 29999998 || y < -29999998 || z > 29999998 || z < -29999998)
{
msg("Coordinates cannot be larger than 29999998 or smaller than -29999998 blocks.");
return true;
}
World world = null;
final String needleWorldName = args[3].trim();
final List<World> worlds = server.getWorlds();
@ -72,6 +79,8 @@ public class Command_setlever extends FreedomCommand
caster.setPowered(leverOn);
state.setBlockData(data);
state.update();
plugin.cpb.getCoreProtectAPI().logInteraction(sender.getName(), leverLocation);
}
else
{

View File

@ -21,7 +21,7 @@ public class Command_setplayerlimit extends FreedomCommand
Player player = Bukkit.getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -55,7 +55,7 @@ public class Command_settotalvotes extends FreedomCommand
if (player != null)
{
player.sendMessage(ChatColor.GREEN + sender.getName() + " has set your total votes to " + votes);
msg(player, sender.getName() + " has set your total votes to " + votes, ChatColor.GREEN);
}
return true;

View File

@ -15,21 +15,21 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-q]")
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-c | -q]")
public class Command_smite extends FreedomCommand
{
public static void smite(CommandSender sender, Player player)
{
smite(sender, player, null, false);
smite(sender, player, null, false, false);
}
public static void smite(CommandSender sender, Player player, String reason)
{
smite(sender, player, reason, false);
smite(sender, player, reason, false, false);
}
public static void smite(CommandSender sender, Player player, String reason, Boolean silent)
public static void smite(CommandSender sender, Player player, String reason, Boolean silent, Boolean clearinv)
{
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
@ -44,7 +44,7 @@ public class Command_smite extends FreedomCommand
}
else
{
sender.sendMessage(ChatColor.GRAY + "Smitten " + player.getName() + " quietly.");
sender.sendMessage("Smitten " + player.getName() + " quietly.");
}
// Deop
@ -54,7 +54,10 @@ public class Command_smite extends FreedomCommand
player.setGameMode(GameMode.SURVIVAL);
// Clear inventory
player.getInventory().clear();
if (clearinv)
{
player.getInventory().clear();
}
// Strike with lightning effect
final Location targetPos = player.getLocation();
@ -88,6 +91,7 @@ public class Command_smite extends FreedomCommand
String reason = null;
boolean silent = false;
boolean clearinv = false;
if (args.length >= 2)
{
if (args[args.length - 1].equalsIgnoreCase("-q"))
@ -102,6 +106,18 @@ public class Command_smite extends FreedomCommand
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else if (args[args.length - 1].equalsIgnoreCase("-c"))
{
if (args[args.length - 1].equalsIgnoreCase("-c"))
{
clearinv = true;
}
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
@ -112,11 +128,11 @@ public class Command_smite extends FreedomCommand
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
smite(sender, player, reason, silent);
smite(sender, player, reason, silent, clearinv);
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));

View File

@ -18,7 +18,7 @@ public class Command_spectator extends FreedomCommand
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
msg("When used from the console, you must define a target player.");
return true;
}
@ -31,7 +31,7 @@ public class Command_spectator extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -19,7 +19,7 @@ public class Command_survival extends FreedomCommand
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
msg("When used from the console, you must define a target player.");
return true;
}
@ -46,7 +46,7 @@ public class Command_survival extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -54,6 +54,7 @@ public class Command_toggle extends FreedomCommand
msg("- landmines");
msg("- mp44");
msg("- tossmob");
msg("- gravity");
return false;
}
@ -297,6 +298,12 @@ public class Command_toggle extends FreedomCommand
toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
break;
}
case "gravity":
{
toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
break;
}
}
return true;
}
@ -320,7 +327,7 @@ public class Command_toggle extends FreedomCommand
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob");
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity");
}
return Collections.emptyList();
}

View File

@ -24,7 +24,7 @@ public class Command_unblockcmd extends FreedomCommand
Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -25,7 +25,7 @@ public class Command_uncage extends FreedomCommand
Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -37,7 +37,7 @@ public class Command_unmute extends FreedomCommand
final Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View File

@ -34,36 +34,32 @@ public class Command_verifynoadmin extends FreedomCommand
if (plugin.al.isAdminImpostor(player))
{
if (!plugin.al.verifiedNoAdmin.contains(player.getName()))
{
plugin.al.verifiedNoAdmin.add(player.getName());
}
String ip = FUtil.getIp(player);
if (!plugin.al.verifiedNoAdminIps.containsKey(player.getName()))
if (!plugin.al.verifiedNoAdmin.containsKey(player.getName()))
{
List<String> ips = new ArrayList<>();
ips.add(ip);
plugin.al.verifiedNoAdminIps.put(player.getName(), ips);
plugin.al.verifiedNoAdmin.put(player.getName(), ips);
}
else
{
List<String> ips = plugin.al.verifiedNoAdminIps.get(player.getName());
List<String> ips = plugin.al.verifiedNoAdmin.get(player.getName());
if (!ips.contains(ip))
{
ips.add(ip);
plugin.al.verifiedNoAdmin.remove(player.getName());
plugin.al.verifiedNoAdminIps.put(player.getName(), ips);
plugin.al.verifiedNoAdmin.put(player.getName(), ips);
}
}
plugin.rm.updateDisplay(player);
FUtil.adminAction(sender.getName(), "Verified " + player.getName() + ", without admin permissions.", true);
player.setOp(true);
player.sendMessage(YOU_ARE_OP);
msg(player, YOU_ARE_OP);
final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (fPlayer.getFreezeData().isFrozen())
{
fPlayer.getFreezeData().setFrozen(false);
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
msg(player, "You have been unfrozen.");
}
msg("Verified " + player.getName() + " but didn't give them admin permissions", ChatColor.GREEN);
}

View File

@ -1,46 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.io.File;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes all essentials playerdata", usage = "/<command>")
public class Command_wipeuserdata extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!server.getPluginManager().isPluginEnabled("Essentials"))
{
msg("Essentials is not enabled on this server.");
return true;
}
FUtil.adminAction(sender.getName(), "Wiping Essentials and world player data", true);
for (World w : Bukkit.getWorlds())
{
if (w.getName().equals(plugin.wm.adminworld.getWorld().getName()))
{
continue;
}
FUtil.deleteFolder(new File(Objects.requireNonNull(server.getPluginManager().getPlugin("Essentials")).getDataFolder(), "userdata"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "playerdata"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "stats"));
FUtil.deleteFolder(new File(Objects.requireNonNull(Bukkit.getServer().getWorld(w.getName())).getWorldFolder().getName() + "stats"));
FUtil.deleteFolder(new File(Objects.requireNonNull(Bukkit.getServer().getWorld(w.getName())).getWorldFolder().getName() + "playerdata"));
msg("Deleted all player data.");
return true;
}
return false;
}
}

View File

@ -34,6 +34,7 @@ public enum ConfigEntry
ALLOW_RESPAWN_ANCHORS(Boolean.class, "allow.respawnanchors"),
AUTO_TP(Boolean.class, "allow.auto_tp"),
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
ALLOW_GRAVITY(Boolean.class, "allow.gravity"),
//
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
//
@ -57,7 +58,7 @@ public enum ConfigEntry
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
SERVER_OWNERS(List.class, "server.owners"),
SERVER_EXECUTIVES(List.class, "server.executives"),
SERVER_ASSTISTANT_EXECUTIVES(List.class, "server.assistant_executives"),
SERVER_ASSISTANT_EXECUTIVES(List.class, "server.assistant_executives"),
SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"),
SERVER_BAN_URL(String.class, "server.ban_url"),
SERVER_INDEFBAN_URL(String.class, "server.indefban_url"),
@ -162,7 +163,8 @@ public enum ConfigEntry
MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"),
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
TOGGLE_CHAT(Boolean.class, "toggle_chat"),
DEVELOPER_MODE(Boolean.class, "developer_mode");
DEVELOPER_MODE(Boolean.class, "developer_mode"),
ANTISPAM_MINUTES(Integer.class, "antispam_minutes");
//
private final Class<?> type;
private final String configName;

View File

@ -13,6 +13,8 @@ import java.util.Objects;
import java.util.SplittableRandom;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.security.auth.login.LoginException;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.admin.Admin;
@ -60,6 +62,7 @@ public class Discord extends FreedomService
public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR;
public List<CompletableFuture<Message>> sentMessages = new ArrayList<>();
public Boolean enabled = false;
private final Pattern DISCORD_MENTION_PATTERN = Pattern.compile("(<@!?([0-9]{16,20})>)");
public static String getMD5(String string)
{
@ -408,6 +411,15 @@ public class Discord extends FreedomService
message = StringUtils.remove(message, "§");
}
Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message);
while (DISCORD_MENTION_MATCHER.find())
{
String mention = DISCORD_MENTION_MATCHER.group(1);
message = message.replace(mention, mention.replace("@",""));
}
if (enabled && !chat_channel_id.isEmpty())
{
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true);
@ -433,6 +445,15 @@ public class Discord extends FreedomService
message = StringUtils.remove(message, "§");
}
Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message);
while (DISCORD_MENTION_MATCHER.find())
{
String mention = DISCORD_MENTION_MATCHER.group(1);
message = message.replace(mention, mention.replace("@",""));
}
if (enabled && !chat_channel_id.isEmpty())
{
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true);

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.discord;
import com.google.common.base.Strings;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -18,10 +19,10 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class DiscordToAdminChatListener extends ListenerAdapter
{
DiscordToMinecraftListener dtml = new DiscordToMinecraftListener();
public static net.md_5.bungee.api.ChatColor getColor(Displayable display)
@ -36,100 +37,107 @@ public class DiscordToAdminChatListener extends ListenerAdapter
{
Member member = event.getMember();
String tag = dtml.getDisplay(member);
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
Message msg = event.getMessage();
for (Player player : Bukkit.getOnlinePlayers())
{
if (TotalFreedomMod.getPlugin().al.isAdmin(player))
{
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player);
String format = admin.getAcFormat();
if (format != null)
{
Displayable display = TotalFreedomMod.getPlugin().rm.getDisplay(player);
net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", getDisplay(member))
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
message.append(FUtil.colorize(m));
}
else
{
String m = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
message.append(m);
}
}
}
String mediamessage = ChatColor.YELLOW + "[Media]";
StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
String lm = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
logmessage.append(lm);
ComponentBuilder builder = new ComponentBuilder(message.toString());
if (!msg.getAttachments().isEmpty())
{
for (Message.Attachment attachment : msg.getAttachments())
{
if (attachment.getUrl() == null)
{
continue;
}
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]");
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
builder.append(text);
message.append("[Media]"); // for logging
}
logmessage.append(mediamessage); // Actually for logging...
}
FLog.info(logmessage.toString());
for (Player player : Bukkit.getOnlinePlayers())
Bukkit.getOnlinePlayers().stream().filter(player -> TotalFreedomMod.getPlugin().al.isAdmin(player)).forEach(player ->
{
if (TotalFreedomMod.getPlugin().al.isAdmin(player))
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
ComponentBuilder builder = new ComponentBuilder(message.toString());
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player);
String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(format))
{
player.spigot().sendMessage(builder.create());
Displayable display = getDisplay(member);
net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", display.getAbbr())
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
builder.append(FUtil.colorize(m));
}
}
FLog.info(message.toString());
else
{
String m = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
builder.append(m);
}
if (!msg.getAttachments().isEmpty())
{
for (Message.Attachment attachment : msg.getAttachments())
{
TextComponent text = new TextComponent(mediamessage);
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
if (!msg.getContentDisplay().isEmpty())
{
builder.append(" ");
}
builder.append(text);
}
}
player.spigot().sendMessage(builder.create());
});
}
}
// Needed to display tags in custom AC messages
public String getDisplay(Member member)
public Displayable getDisplay(Member member)
{
Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString());
// Server Owner
if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString())))
{
return Title.OWNER.getAbbr();
return Title.OWNER;
}
// Developers
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString())))
{
return Title.DEVELOPER.getAbbr();
return Title.DEVELOPER;
}
// Executives
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString())))
{
return Title.EXECUTIVE.getAbbr();
return Title.EXECUTIVE;
}
// Senior Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString())))
{
return Rank.SENIOR_ADMIN.getAbbr();
return Rank.SENIOR_ADMIN;
}
// Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString())))
{
return Rank.ADMIN.getAbbr();
return Rank.ADMIN;
}
// Master Builders
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString())))
{
return Title.MASTER_BUILDER.getAbbr();
return Title.MASTER_BUILDER;
}
// OP, returning null breaks?
else
{
return Rank.OP.getAbbr();
return Rank.OP;
}
}
}

View File

@ -1,52 +0,0 @@
package me.totalfreedom.totalfreedommod.fun;
import java.util.HashMap;
import me.totalfreedom.totalfreedommod.FreedomService;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
import static org.bukkit.event.player.PlayerResourcePackStatusEvent.Status;
public class CurseListener extends FreedomService
{
public HashMap<Player, Player> cursedPlayers = new HashMap<Player, Player>();
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@EventHandler(priority = EventPriority.MONITOR)
public void onResourcePackStatus(PlayerResourcePackStatusEvent event)
{
Player player = event.getPlayer();
PlayerResourcePackStatusEvent.Status cursed = event.getStatus();
Player cursedBy = cursedPlayers.get(player);
if (cursed.equals(Status.ACCEPTED))
{
cursedBy.sendMessage(ChatColor.GREEN + "Casting curse on " + player.getName() + "...");
}
else if (cursed.equals(Status.DECLINED))
{
cursedBy.sendMessage(ChatColor.RED + "Failed to start cast on " + player.getName() + "!");
cursedPlayers.remove(player);
}
else if (cursed.equals(Status.SUCCESSFULLY_LOADED))
{
cursedBy.sendMessage(ChatColor.GREEN + "Successfully cursed + " + player.getName() + "!");
cursedPlayers.remove(player);
}
else if (cursed.equals(Status.FAILED_DOWNLOAD))
{
cursedBy.sendMessage(ChatColor.RED + "Failed to cast curse on " + player.getName() + "!");
cursedPlayers.remove(player);
}
}
}

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import java.util.Collection;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.util.Collection;
public class Module_list extends HTTPDModule
{
@ -86,6 +88,8 @@ public class Module_list extends HTTPDModule
}
}
int count = server.getOnlinePlayers().size() - AdminList.vanished.size();
// for future refernce - any multi-worded ranks are to be delimited by underscores in the json; eg. senior_admins
responseObject.put("owners", owners);
responseObject.put("executives", executives);
@ -95,7 +99,7 @@ public class Module_list extends HTTPDModule
responseObject.put("master_builders", masterbuilders);
responseObject.put("operators", operators);
responseObject.put("imposters", imposters);
responseObject.put("online", server.getOnlinePlayers().size());
responseObject.put("online", count < 0 ? 0 : count);
responseObject.put("max", server.getMaxPlayers());
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString());
@ -108,7 +112,9 @@ public class Module_list extends HTTPDModule
final Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
body.append("<p>There are ").append(onlinePlayers.size()).append("/").append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n");
int count = onlinePlayers.size() - AdminList.vanished.size();
body.append("<p>There are ").append(count < 0 ? 0 : count).append("/")
.append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n");
body.append("<ul>\r\n");

View File

@ -117,10 +117,4 @@ public class PermissionManager extends FreedomService
setPermissions(player);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerJoin(PlayerJoinEvent event)
{
setPermissions(event.getPlayer());
}
}

View File

@ -289,7 +289,7 @@ public class FPlayer
return unmuteTask != null;
}
public void setMuted(boolean muted)
public void setMuted(boolean muted, int minutes)
{
FUtil.cancel(unmuteTask);
plugin.mu.MUTED_PLAYERS.remove(getPlayer().getName());
@ -324,7 +324,12 @@ public class FPlayer
plugin.mu.MUTED_PLAYERS.remove(getName());
}
}
}.runTaskLater(plugin, AUTO_PURGE_TICKS);
}.runTaskLater(plugin, minutes * (60L * 20L));
}
public void setMuted(boolean muted)
{
setMuted(muted, 5);
}
public BukkitTask getLockupScheduleID()

View File

@ -62,6 +62,11 @@ public class RankManager extends FreedomService
return Title.EXECUTIVE;
}
if (ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getList().contains(player.getName()) && plugin.al.isAdmin(player))
{
return Title.ASSTEXEC;
}
if (plugin.al.isVerifiedAdmin(player))
{
return Title.VERIFIED_ADMIN;

View File

@ -72,9 +72,11 @@ public class FUtil
"c8e5af82-6aba-4dd7-83e8-474381380cc9", // Paldiu
"38ea7c82-7bdc-4f48-b7fd-0e93fc26813d", // AwesomePinch
"ba5aafba-9012-418f-9819-a7020d591068", // TFTWPhoenix
"b051abdf-66d1-48c0-96ef-67fb8af96f2a" // Abhi
"d6dd9740-40db-45f5-ab16-4ee16a633009", // Abhi
"2e06e049-24c8-42e4-8bcf-d35372af31e6", // unsuperiordev
"f97c0d7b-6413-4558-a409-88f09a8f9adb" // videogamesm12
);
public static final List<String> DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix","Spigot_Abhiram");
public static final List<String> DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix","abhithedev", "unsuperiordev", "videogamesm12");
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
ChatColor.DARK_RED,
@ -138,7 +140,7 @@ public class FUtil
public static boolean isExecutive(String name)
{
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSTISTANT_EXECUTIVES.getStringList().contains(name);
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getStringList().contains(name);
}
public static boolean isDeveloper(Player player)
@ -611,7 +613,7 @@ public class FUtil
public static long getUnixTime()
{
return Instant.now().getEpochSecond();
return Instant.now().toEpochMilli();
}
public static long getUnixTime(Date date)

View File

@ -139,7 +139,7 @@ public class WorldRestrictions extends FreedomService
event.setCancelled(true);
}
if (command.equals("coreprotect") || command.equals("core") || command.equals("co"))
if (command.equalsIgnoreCase("coreprotect") || command.equalsIgnoreCase("core") || command.equalsIgnoreCase("co"))
{
player.sendMessage(ChatColor.RED + "Only " + allowed + " are allowed to use CoreProtect here.");
event.setCancelled(true);

View File

@ -226,6 +226,7 @@ allow:
respawnanchors: false
auto_tp: false
auto_clear: false
gravity: false
# Blocked commands:
#
@ -737,3 +738,6 @@ blocked_chatcodes: '&0,&k,&m,&n'
# Enables certain things like debug logs and console bypasses
developer_mode: false
# AntiSpam Time (minutes)
antispam_minutes: 2

View File

@ -1,9 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files="Metrics\.java" checks="[a-zA-Z0-9]*"/>
<suppress files="NanoHTTPD\.java" checks="[a-zA-Z0-9]*"/>