mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge pull request #11 from AtlasMediaGroup/paldiu-local
Removal of Lombok
This commit is contained in:
commit
ed48ce3a8f
1
.gitignore
vendored
1
.gitignore
vendored
@ -37,3 +37,4 @@ manifest.mf
|
|||||||
.Trashes
|
.Trashes
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
.idea/inspectionProfiles/Project_Default.xml
|
||||||
|
18
.idea/codeStyles/Project.xml
generated
18
.idea/codeStyles/Project.xml
generated
@ -9,24 +9,6 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</JavaCodeStyleSettings>
|
</JavaCodeStyleSettings>
|
||||||
<JetCodeStyleSettings>
|
|
||||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
|
||||||
<value>
|
|
||||||
<package name="java.util" alias="false" withSubpackages="false" />
|
|
||||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
|
||||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
|
||||||
<value>
|
|
||||||
<package name="" alias="false" withSubpackages="true" />
|
|
||||||
<package name="java" alias="false" withSubpackages="true" />
|
|
||||||
<package name="javax" alias="false" withSubpackages="true" />
|
|
||||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
|
||||||
<package name="" alias="true" withSubpackages="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
</JetCodeStyleSettings>
|
|
||||||
<codeStyleSettings language="JAVA">
|
<codeStyleSettings language="JAVA">
|
||||||
<option name="BRACE_STYLE" value="2" />
|
<option name="BRACE_STYLE" value="2" />
|
||||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||||
|
6
pom.xml
6
pom.xml
@ -117,12 +117,6 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.16</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -13,11 +12,8 @@ public class Announcer extends FreedomService
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final List<String> announcements = Lists.newArrayList();
|
private final List<String> announcements = Lists.newArrayList();
|
||||||
@Getter
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
@Getter
|
|
||||||
private long interval;
|
private long interval;
|
||||||
@Getter
|
|
||||||
private String prefix;
|
private String prefix;
|
||||||
private BukkitTask announcer;
|
private BukkitTask announcer;
|
||||||
|
|
||||||
@ -80,4 +76,23 @@ public class Announcer extends FreedomService
|
|||||||
FUtil.bcastMsg(prefix + message);
|
FUtil.bcastMsg(prefix + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getInterval()
|
||||||
|
{
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefix()
|
||||||
|
{
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BukkitTask getAnnouncer()
|
||||||
|
{
|
||||||
|
return announcer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ public class AntiNuke extends FreedomService
|
|||||||
fPlayer.resetBlockDestroyCount();
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ public class AntiSpam extends FreedomService
|
|||||||
|
|
||||||
public static final int MSG_PER_CYCLE = 8;
|
public static final int MSG_PER_CYCLE = 8;
|
||||||
public static final int TICKS_PER_CYCLE = 2 * 10;
|
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||||
List<Player> markedForDeath = new ArrayList<>();
|
|
||||||
//
|
//
|
||||||
public BukkitTask cycleTask = null;
|
public BukkitTask cycleTask = null;
|
||||||
|
List<Player> markedForDeath = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
@ -84,7 +84,6 @@ public class AntiSpam extends FreedomService
|
|||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
||||||
{
|
{
|
||||||
@ -126,10 +125,7 @@ public class AntiSpam extends FreedomService
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
{
|
|
||||||
if (markedForDeath.contains(event.getPlayer()))
|
|
||||||
{
|
{
|
||||||
markedForDeath.remove(event.getPlayer());
|
markedForDeath.remove(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -43,11 +43,7 @@ public class AutoEject extends FreedomService
|
|||||||
|
|
||||||
ejects.put(ip, kicks);
|
ejects.put(ip, kicks);
|
||||||
|
|
||||||
if (kicks <= 1)
|
if (kicks == 2)
|
||||||
{
|
|
||||||
method = EjectMethod.STRIKE_ONE;
|
|
||||||
}
|
|
||||||
else if (kicks == 2)
|
|
||||||
{
|
{
|
||||||
method = EjectMethod.STRIKE_TWO;
|
method = EjectMethod.STRIKE_TWO;
|
||||||
}
|
}
|
||||||
@ -101,10 +97,9 @@ public class AutoEject extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum EjectMethod
|
public enum EjectMethod
|
||||||
{
|
{
|
||||||
|
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE
|
||||||
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,10 @@ public class AutoKick extends FreedomService
|
|||||||
|
|
||||||
private void autoKickCheck()
|
private void autoKickCheck()
|
||||||
{
|
{
|
||||||
|
// No type cast was provided, one has been supplied.
|
||||||
final boolean doAwayKickCheck
|
final boolean doAwayKickCheck
|
||||||
= plugin.esb.isEnabled()
|
= plugin.esb.isEnabled()
|
||||||
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
&& (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
|
||||||
|
|
||||||
if (!doAwayKickCheck)
|
if (!doAwayKickCheck)
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -96,8 +96,8 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for 4chan trigger
|
// Check for 4chan trigger
|
||||||
Boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
||||||
Boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
||||||
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
if (green)
|
if (green)
|
||||||
@ -123,7 +123,7 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for mentions
|
// Check for mentions
|
||||||
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
||||||
|
@ -14,8 +14,6 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
public class EntityWiper extends FreedomService
|
public class EntityWiper extends FreedomService
|
||||||
{
|
{
|
||||||
private BukkitTask wiper;
|
|
||||||
|
|
||||||
public List<EntityType> BLACKLIST = Arrays.asList(
|
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||||
EntityType.ARMOR_STAND,
|
EntityType.ARMOR_STAND,
|
||||||
EntityType.PAINTING,
|
EntityType.PAINTING,
|
||||||
@ -24,6 +22,7 @@ public class EntityWiper extends FreedomService
|
|||||||
EntityType.ITEM_FRAME,
|
EntityType.ITEM_FRAME,
|
||||||
EntityType.MINECART
|
EntityType.MINECART
|
||||||
);
|
);
|
||||||
|
private BukkitTask wiper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -8,17 +9,18 @@ public abstract class FreedomService implements Listener
|
|||||||
{
|
{
|
||||||
protected final TotalFreedomMod plugin;
|
protected final TotalFreedomMod plugin;
|
||||||
protected final Server server;
|
protected final Server server;
|
||||||
protected final FLog logger;
|
protected final Logger logger;
|
||||||
|
|
||||||
public FreedomService()
|
public FreedomService()
|
||||||
{
|
{
|
||||||
plugin = TotalFreedomMod.getPlugin();
|
plugin = TotalFreedomMod.getPlugin();
|
||||||
server = plugin.getServer();
|
server = plugin.getServer();
|
||||||
logger = new FLog();
|
logger = FLog.getPluginLogger();
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
plugin.fsh.add(this);
|
plugin.fsh.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onStart();
|
public abstract void onStart();
|
||||||
|
|
||||||
public abstract void onStop();
|
public abstract void onStop();
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
public class FreedomServiceHandler
|
public class FreedomServiceHandler
|
||||||
{
|
{
|
||||||
@Getter
|
private final List<FreedomService> services;
|
||||||
private List<FreedomService> services;
|
|
||||||
|
|
||||||
public FreedomServiceHandler()
|
public FreedomServiceHandler()
|
||||||
{
|
{
|
||||||
@ -53,4 +51,9 @@ public class FreedomServiceHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FreedomService> getServices()
|
||||||
|
{
|
||||||
|
return services;
|
||||||
|
}
|
||||||
}
|
}
|
@ -56,6 +56,7 @@ public class GameRuleHandler extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void commitGameRules()
|
public void commitGameRules()
|
||||||
{
|
{
|
||||||
List<World> worlds = Bukkit.getWorlds();
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
|
@ -10,7 +10,6 @@ import java.security.NoSuchProviderException;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
@ -131,10 +130,10 @@ public class LogViewer extends FreedomService
|
|||||||
}.runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum LogsRegistrationMode
|
public enum LogsRegistrationMode
|
||||||
{
|
{
|
||||||
|
|
||||||
ADD, DELETE, VERIFY;
|
ADD, DELETE, VERIFY
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class URLBuilder
|
private static class URLBuilder
|
||||||
@ -157,10 +156,8 @@ public class LogViewer extends FreedomService
|
|||||||
public URL getURL() throws MalformedURLException
|
public URL getURL() throws MalformedURLException
|
||||||
{
|
{
|
||||||
List<String> pairs = new ArrayList<>();
|
List<String> pairs = new ArrayList<>();
|
||||||
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
|
for (Map.Entry<String, String> pair : queryStringMap.entrySet())
|
||||||
while (it.hasNext())
|
|
||||||
{
|
{
|
||||||
Map.Entry<String, String> pair = it.next();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
|
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
|
||||||
|
@ -4,8 +4,6 @@ import io.papermc.lib.PaperLib;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.rayzr522.jsonmessage.JSONMessage;
|
import me.rayzr522.jsonmessage.JSONMessage;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
@ -29,12 +27,19 @@ public class LoginProcess extends FreedomService
|
|||||||
public static final int MIN_USERNAME_LENGTH = 2;
|
public static final int MIN_USERNAME_LENGTH = 2;
|
||||||
public static final int MAX_USERNAME_LENGTH = 20;
|
public static final int MAX_USERNAME_LENGTH = 20;
|
||||||
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
||||||
|
private static boolean lockdownEnabled = false;
|
||||||
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
|
|
||||||
@Getter
|
public static boolean isLockdownEnabled()
|
||||||
@Setter
|
{
|
||||||
private static boolean lockdownEnabled = false;
|
return lockdownEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLockdownEnabled(boolean lockdownEnabled)
|
||||||
|
{
|
||||||
|
LoginProcess.lockdownEnabled = lockdownEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
@ -174,7 +179,6 @@ public class LoginProcess extends FreedomService
|
|||||||
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -20,7 +19,6 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
public class Monitors extends FreedomService
|
public class Monitors extends FreedomService
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
|
private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
|
||||||
private final Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>();
|
private final Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>();
|
||||||
private final List<PotionEffectType> badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS,
|
private final List<PotionEffectType> badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS,
|
||||||
@ -141,4 +139,19 @@ public class Monitors extends FreedomService
|
|||||||
|
|
||||||
return badEffectsDetected > 0;
|
return badEffectsDetected > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Map.Entry<ThrownPotion, Long>> getAllThrownPotions()
|
||||||
|
{
|
||||||
|
return allThrownPotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Player, List<ThrownPotion>> getRecentlyThrownPotions()
|
||||||
|
{
|
||||||
|
return recentlyThrownPotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PotionEffectType> getBadPotionEffects()
|
||||||
|
{
|
||||||
|
return badPotionEffects;
|
||||||
|
}
|
||||||
}
|
}
|
@ -41,7 +41,7 @@ public class MovementValidator extends FreedomService
|
|||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
{
|
{
|
||||||
// Check absolute value to account for negatives
|
// Check absolute value to account for negatives
|
||||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
if (Math.abs(Objects.requireNonNull(event.getTo()).getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
event.setCancelled(true); // illegal position, cancel it
|
event.setCancelled(true); // illegal position, cancel it
|
||||||
}
|
}
|
||||||
@ -53,6 +53,7 @@ public class MovementValidator extends FreedomService
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
|
assert to != null;
|
||||||
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
|
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -146,8 +147,9 @@ public class MovementValidator extends FreedomService
|
|||||||
{
|
{
|
||||||
if (Objects.equals(key, "Amount")) //null-safe .equals()
|
if (Objects.equals(key, "Amount")) //null-safe .equals()
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
List<MojangsonValue> values = compound.get(key);
|
List<MojangsonValue> values = compound.get(key);
|
||||||
for (MojangsonValue val : values)
|
for (MojangsonValue<?> val : values)
|
||||||
{
|
{
|
||||||
if (val.getValue().toString().equals("Infinityd"))
|
if (val.getValue().toString().equals("Infinityd"))
|
||||||
{
|
{
|
||||||
|
@ -4,10 +4,9 @@ import java.io.IOException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import joptsimple.internal.Strings;
|
import joptsimple.internal.Strings;
|
||||||
import lombok.Getter;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.Response;
|
import me.totalfreedom.totalfreedommod.util.Response;
|
||||||
@ -23,7 +22,6 @@ public class Pterodactyl extends FreedomService
|
|||||||
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
|
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
|
||||||
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
|
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
|
||||||
|
|
||||||
@Getter
|
|
||||||
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||||
|
|
||||||
public void onStart()
|
public void onStart()
|
||||||
@ -54,6 +52,7 @@ public class Pterodactyl extends FreedomService
|
|||||||
addAccountToServer(id);
|
addAccountToServer(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public String createAccount(String username, String password)
|
public String createAccount(String username, String password)
|
||||||
{
|
{
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -94,6 +93,7 @@ public class Pterodactyl extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void addAccountToServer(String id)
|
public void addAccountToServer(String id)
|
||||||
{
|
{
|
||||||
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
|
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
|
||||||
@ -161,6 +161,7 @@ public class Pterodactyl extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
|
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setPassword(String id, String password)
|
public void setPassword(String id, String password)
|
||||||
{
|
{
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -175,4 +176,39 @@ public class Pterodactyl extends FreedomService
|
|||||||
FLog.severe(e);
|
FLog.severe(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getURL()
|
||||||
|
{
|
||||||
|
return URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerKey()
|
||||||
|
{
|
||||||
|
return SERVER_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdminKey()
|
||||||
|
{
|
||||||
|
return ADMIN_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getServerHeaders()
|
||||||
|
{
|
||||||
|
return SERVER_HEADERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAdminHeaders()
|
||||||
|
{
|
||||||
|
return ADMIN_HEADERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled)
|
||||||
|
{
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
@ -26,8 +26,8 @@ public class SavedFlags extends FreedomService
|
|||||||
public Map<String, Boolean> getSavedFlags()
|
public Map<String, Boolean> getSavedFlags()
|
||||||
{
|
{
|
||||||
Map<String, Boolean> flags = null;
|
Map<String, Boolean> flags = null;
|
||||||
|
|
||||||
File input = new File(TotalFreedomMod.getPlugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
File input = new File(TotalFreedomMod.getPlugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||||
|
|
||||||
if (input.exists())
|
if (input.exists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -13,16 +13,6 @@ public class ServerInterface extends FreedomService
|
|||||||
{
|
{
|
||||||
public static final String COMPILE_NMS_VERSION = "v1_16_R3";
|
public static final String COMPILE_NMS_VERSION = "v1_16_R3";
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void warnVersion()
|
public static void warnVersion()
|
||||||
{
|
{
|
||||||
final String nms = FUtil.getNMSVersion();
|
final String nms = FUtil.getNMSVersion();
|
||||||
@ -34,6 +24,16 @@ public class ServerInterface extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void setOnlineMode(boolean mode)
|
public void setOnlineMode(boolean mode)
|
||||||
{
|
{
|
||||||
getServer().setOnlineMode(mode);
|
getServer().setOnlineMode(mode);
|
||||||
|
@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||||
@ -41,8 +43,6 @@ import me.totalfreedom.totalfreedommod.rank.RankManager;
|
|||||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||||
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||||
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
@ -54,23 +54,18 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spigotmc.SpigotConfig;
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
public class TotalFreedomMod extends JavaPlugin
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
{
|
{
|
||||||
private static TotalFreedomMod plugin;
|
|
||||||
|
|
||||||
public static TotalFreedomMod getPlugin()
|
|
||||||
{
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "config.yml";
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
//
|
//
|
||||||
public static final BuildProperties build = new BuildProperties();
|
public static final BuildProperties build = new BuildProperties();
|
||||||
//
|
//
|
||||||
public static String pluginName;
|
public static String pluginName;
|
||||||
public static String pluginVersion;
|
public static String pluginVersion;
|
||||||
|
private static TotalFreedomMod plugin;
|
||||||
//
|
//
|
||||||
public MainConfig config;
|
public MainConfig config;
|
||||||
public PermissionConfig permissions;
|
public PermissionConfig permissions;
|
||||||
@ -134,7 +129,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public Sitter st;
|
public Sitter st;
|
||||||
public VanishHandler vh;
|
public VanishHandler vh;
|
||||||
public Pterodactyl ptero;
|
public Pterodactyl ptero;
|
||||||
|
|
||||||
//public HubWorldRestrictions hwr;
|
//public HubWorldRestrictions hwr;
|
||||||
//
|
//
|
||||||
// Bridges
|
// Bridges
|
||||||
@ -146,6 +140,23 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public WorldEditBridge web;
|
public WorldEditBridge web;
|
||||||
public WorldGuardBridge wgb;
|
public WorldGuardBridge wgb;
|
||||||
|
|
||||||
|
public static TotalFreedomMod getPlugin()
|
||||||
|
{
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TotalFreedomMod plugin()
|
||||||
|
{
|
||||||
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
||||||
|
{
|
||||||
|
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||||
|
{
|
||||||
|
return (TotalFreedomMod)plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad()
|
public void onLoad()
|
||||||
{
|
{
|
||||||
@ -192,79 +203,13 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
BackupManager backups = new BackupManager();
|
BackupManager backups = new BackupManager();
|
||||||
backups.createAllBackups();
|
backups.createAllBackups();
|
||||||
|
|
||||||
permissions = new PermissionConfig(this);
|
permissions = new PermissionConfig();
|
||||||
permissions.load();
|
permissions.load();
|
||||||
|
|
||||||
// Start services
|
|
||||||
si = new ServerInterface();
|
|
||||||
sf = new SavedFlags();
|
|
||||||
wm = new WorldManager();
|
|
||||||
lv = new LogViewer();
|
|
||||||
sql = new SQLite();
|
|
||||||
al = new AdminList();
|
|
||||||
acl = new ActivityLog();
|
|
||||||
rm = new RankManager();
|
|
||||||
cb = new CommandBlocker();
|
|
||||||
eb = new EventBlocker();
|
|
||||||
bb = new BlockBlocker();
|
|
||||||
mb = new MobBlocker();
|
|
||||||
ib = new InteractBlocker();
|
|
||||||
pb = new PotionBlocker();
|
|
||||||
lp = new LoginProcess();
|
|
||||||
nu = new AntiNuke();
|
|
||||||
as = new AntiSpam();
|
|
||||||
wr = new WorldRestrictions();
|
|
||||||
pl = new PlayerList();
|
|
||||||
sh = new Shop();
|
|
||||||
vo = new Votifier();
|
|
||||||
an = new Announcer();
|
|
||||||
cm = new ChatManager();
|
|
||||||
dc = new Discord();
|
|
||||||
pul = new PunishmentList();
|
|
||||||
bm = new BanManager();
|
|
||||||
im = new IndefiniteBanList();
|
|
||||||
pem = new PermissionManager();
|
|
||||||
gr = new GameRuleHandler();
|
|
||||||
snp = new SignBlocker();
|
|
||||||
ew = new EntityWiper();
|
|
||||||
st = new Sitter();
|
|
||||||
vh = new VanishHandler();
|
|
||||||
ptero = new Pterodactyl();
|
|
||||||
|
|
||||||
// Single admin utils
|
|
||||||
cs = new CommandSpy();
|
|
||||||
ca = new Cager();
|
|
||||||
fm = new Freezer();
|
|
||||||
or = new Orbiter();
|
|
||||||
mu = new Muter();
|
|
||||||
ebl = new EditBlocker();
|
|
||||||
pbl = new PVPBlocker();
|
|
||||||
fo = new Fuckoff();
|
|
||||||
ak = new AutoKick();
|
|
||||||
ae = new AutoEject();
|
|
||||||
mo = new Monitors();
|
|
||||||
|
|
||||||
mv = new MovementValidator();
|
mv = new MovementValidator();
|
||||||
sp = new ServerPing();
|
sp = new ServerPing();
|
||||||
|
|
||||||
// Fun
|
new Initializer();
|
||||||
cul = new CurseListener();
|
|
||||||
it = new ItemFun();
|
|
||||||
lm = new Landminer();
|
|
||||||
mp = new MP44();
|
|
||||||
jp = new Jumppads();
|
|
||||||
tr = new Trailer();
|
|
||||||
// HTTPD
|
|
||||||
hd = new HTTPDaemon();
|
|
||||||
|
|
||||||
// Start bridges
|
|
||||||
btb = new BukkitTelnetBridge();
|
|
||||||
cpb = new CoreProtectBridge();
|
|
||||||
esb = new EssentialsBridge();
|
|
||||||
ldb = new LibsDisguisesBridge();
|
|
||||||
tfg = new TFGuildsBridge();
|
|
||||||
web = new WorldEditBridge();
|
|
||||||
wgb = new WorldGuardBridge();
|
|
||||||
|
|
||||||
fsh.startServices();
|
fsh.startServices();
|
||||||
|
|
||||||
@ -291,6 +236,12 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
FLog.info("Plugin disabled");
|
FLog.info("Plugin disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id)
|
||||||
|
{
|
||||||
|
return new CleanroomChunkGenerator(id);
|
||||||
|
}
|
||||||
|
|
||||||
public static class BuildProperties
|
public static class BuildProperties
|
||||||
{
|
{
|
||||||
public String author;
|
public String author;
|
||||||
@ -333,21 +284,102 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TotalFreedomMod plugin()
|
/**
|
||||||
|
* This class is provided to please Codacy.
|
||||||
|
*/
|
||||||
|
private final class Initializer
|
||||||
{
|
{
|
||||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
public Initializer()
|
||||||
{
|
{
|
||||||
if (plugin.getName().equalsIgnoreCase(pluginName))
|
initServices();
|
||||||
{
|
initAdminUtils();
|
||||||
return (TotalFreedomMod)plugin;
|
initBridges();
|
||||||
}
|
initFun();
|
||||||
}
|
initHTTPD();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void initServices()
|
||||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
|
||||||
{
|
{
|
||||||
return new CleanroomChunkGenerator(id);
|
// Start services
|
||||||
|
si = new ServerInterface();
|
||||||
|
sf = new SavedFlags();
|
||||||
|
wm = new WorldManager();
|
||||||
|
lv = new LogViewer();
|
||||||
|
sql = new SQLite();
|
||||||
|
al = new AdminList();
|
||||||
|
acl = new ActivityLog();
|
||||||
|
rm = new RankManager();
|
||||||
|
cb = new CommandBlocker();
|
||||||
|
eb = new EventBlocker();
|
||||||
|
bb = new BlockBlocker();
|
||||||
|
mb = new MobBlocker();
|
||||||
|
ib = new InteractBlocker();
|
||||||
|
pb = new PotionBlocker();
|
||||||
|
lp = new LoginProcess();
|
||||||
|
nu = new AntiNuke();
|
||||||
|
as = new AntiSpam();
|
||||||
|
wr = new WorldRestrictions();
|
||||||
|
pl = new PlayerList();
|
||||||
|
sh = new Shop();
|
||||||
|
vo = new Votifier();
|
||||||
|
an = new Announcer();
|
||||||
|
cm = new ChatManager();
|
||||||
|
dc = new Discord();
|
||||||
|
pul = new PunishmentList();
|
||||||
|
bm = new BanManager();
|
||||||
|
im = new IndefiniteBanList();
|
||||||
|
pem = new PermissionManager();
|
||||||
|
gr = new GameRuleHandler();
|
||||||
|
snp = new SignBlocker();
|
||||||
|
ew = new EntityWiper();
|
||||||
|
st = new Sitter();
|
||||||
|
vh = new VanishHandler();
|
||||||
|
ptero = new Pterodactyl();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAdminUtils()
|
||||||
|
{
|
||||||
|
// Single admin utils
|
||||||
|
cs = new CommandSpy();
|
||||||
|
ca = new Cager();
|
||||||
|
fm = new Freezer();
|
||||||
|
or = new Orbiter();
|
||||||
|
mu = new Muter();
|
||||||
|
ebl = new EditBlocker();
|
||||||
|
pbl = new PVPBlocker();
|
||||||
|
fo = new Fuckoff();
|
||||||
|
ak = new AutoKick();
|
||||||
|
ae = new AutoEject();
|
||||||
|
mo = new Monitors();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initBridges()
|
||||||
|
{
|
||||||
|
// Start bridges
|
||||||
|
btb = new BukkitTelnetBridge();
|
||||||
|
cpb = new CoreProtectBridge();
|
||||||
|
esb = new EssentialsBridge();
|
||||||
|
ldb = new LibsDisguisesBridge();
|
||||||
|
tfg = new TFGuildsBridge();
|
||||||
|
web = new WorldEditBridge();
|
||||||
|
wgb = new WorldGuardBridge();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initFun()
|
||||||
|
{
|
||||||
|
// Fun
|
||||||
|
cul = new CurseListener();
|
||||||
|
it = new ItemFun();
|
||||||
|
lm = new Landminer();
|
||||||
|
mp = new MP44();
|
||||||
|
jp = new Jumppads();
|
||||||
|
tr = new Trailer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initHTTPD()
|
||||||
|
{
|
||||||
|
// HTTPD
|
||||||
|
hd = new HTTPDaemon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.admin;
|
|||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
@ -20,7 +19,6 @@ public class ActivityLog extends FreedomService
|
|||||||
|
|
||||||
public static final String FILENAME = "activitylog.yml";
|
public static final String FILENAME = "activitylog.yml";
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
|
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
|
||||||
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
|
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
|
||||||
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
|
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
|
||||||
@ -32,6 +30,11 @@ public class ActivityLog extends FreedomService
|
|||||||
this.config = new YamlConfig(plugin, FILENAME, true);
|
this.config = new YamlConfig(plugin, FILENAME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getFILENAME()
|
||||||
|
{
|
||||||
|
return FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -56,7 +59,7 @@ public class ActivityLog extends FreedomService
|
|||||||
ConfigurationSection section = config.getConfigurationSection(key);
|
ConfigurationSection section = config.getConfigurationSection(key);
|
||||||
if (section == null)
|
if (section == null)
|
||||||
{
|
{
|
||||||
logger.warning("Invalid activity log format: " + key);
|
FLog.warning("Invalid activity log format: " + key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,4 +189,24 @@ public class ActivityLog extends FreedomService
|
|||||||
plugin.acl.updateTables();
|
plugin.acl.updateTables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, ActivityLogEntry> getAllActivityLogs()
|
||||||
|
{
|
||||||
|
return allActivityLogs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, ActivityLogEntry> getNameTable()
|
||||||
|
{
|
||||||
|
return nameTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, ActivityLogEntry> getIpTable()
|
||||||
|
{
|
||||||
|
return ipTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public YamlConfig getConfig()
|
||||||
|
{
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,8 +4,6 @@ import com.google.common.collect.Lists;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.IConfig;
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@ -14,21 +12,13 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class ActivityLogEntry implements IConfig
|
public class ActivityLogEntry implements IConfig
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
private String configKey;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String name;
|
|
||||||
@Getter
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private List<String> timestamps = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private List<String> durations = Lists.newArrayList();
|
|
||||||
|
|
||||||
public static final String FILENAME = "activitylog.yml";
|
public static final String FILENAME = "activitylog.yml";
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
private final List<String> timestamps = Lists.newArrayList();
|
||||||
|
private final List<String> durations = Lists.newArrayList();
|
||||||
|
private String configKey;
|
||||||
|
private String name;
|
||||||
|
|
||||||
public ActivityLogEntry(Player player)
|
public ActivityLogEntry(Player player)
|
||||||
{
|
{
|
||||||
@ -41,6 +31,11 @@ public class ActivityLogEntry implements IConfig
|
|||||||
this.configKey = configKey;
|
this.configKey = configKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getFILENAME()
|
||||||
|
{
|
||||||
|
return FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
public void loadFrom(Player player)
|
public void loadFrom(Player player)
|
||||||
{
|
{
|
||||||
configKey = player.getName().toLowerCase();
|
configKey = player.getName().toLowerCase();
|
||||||
@ -107,12 +102,9 @@ public class ActivityLogEntry implements IConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeIp(String ip)
|
public void removeIp(String ip)
|
||||||
{
|
|
||||||
if (ips.contains(ip))
|
|
||||||
{
|
{
|
||||||
ips.remove(ip);
|
ips.remove(ip);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void clearIPs()
|
public void clearIPs()
|
||||||
{
|
{
|
||||||
@ -138,4 +130,39 @@ public class ActivityLogEntry implements IConfig
|
|||||||
return configKey != null
|
return configKey != null
|
||||||
&& name != null;
|
&& name != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getConfigKey()
|
||||||
|
{
|
||||||
|
return configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigKey(String configKey)
|
||||||
|
{
|
||||||
|
this.configKey = configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getTimestamps()
|
||||||
|
{
|
||||||
|
return timestamps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDurations()
|
||||||
|
{
|
||||||
|
return durations;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,42 +7,35 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Admin
|
public class Admin
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String name;
|
|
||||||
@Getter
|
|
||||||
private boolean active = true;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Rank rank = Rank.ADMIN;
|
|
||||||
@Getter
|
|
||||||
private final List<String> ips = new ArrayList<>();
|
private final List<String> ips = new ArrayList<>();
|
||||||
@Getter
|
private String name;
|
||||||
@Setter
|
private boolean active = true;
|
||||||
|
private Rank rank = Rank.ADMIN;
|
||||||
private Date lastLogin = new Date();
|
private Date lastLogin = new Date();
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean commandSpy = false;
|
private Boolean commandSpy = false;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean potionSpy = false;
|
private Boolean potionSpy = false;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String acFormat = null;
|
private String acFormat = null;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String pteroID = null;
|
private String pteroID = null;
|
||||||
|
|
||||||
public Admin(Player player)
|
public Admin(Player player)
|
||||||
@ -124,24 +117,51 @@ public class Admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeIp(String ip)
|
public void removeIp(String ip)
|
||||||
{
|
|
||||||
if (ips.contains(ip))
|
|
||||||
{
|
{
|
||||||
ips.remove(ip);
|
ips.remove(ip);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void clearIPs()
|
public void clearIPs()
|
||||||
{
|
{
|
||||||
ips.clear();
|
ips.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return name != null
|
||||||
|
&& rank != null
|
||||||
|
&& !ips.isEmpty()
|
||||||
|
&& lastLogin != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive()
|
||||||
|
{
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
public void setActive(boolean active)
|
public void setActive(boolean active)
|
||||||
{
|
{
|
||||||
this.active = active;
|
this.active = active;
|
||||||
|
|
||||||
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||||
|
|
||||||
|
// Avoiding stupid NPE compiler warnings
|
||||||
|
if (plugin == null)
|
||||||
|
{
|
||||||
|
Bukkit.getLogger().severe("The plugin is null!! This is a major issue and WILL break the plugin!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!active)
|
if (!active)
|
||||||
{
|
{
|
||||||
if (getRank().isAtLeast(Rank.ADMIN))
|
if (getRank().isAtLeast(Rank.ADMIN))
|
||||||
@ -156,11 +176,68 @@ public class Admin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid()
|
public Rank getRank()
|
||||||
{
|
{
|
||||||
return name != null
|
return rank;
|
||||||
&& rank != null
|
}
|
||||||
&& !ips.isEmpty()
|
|
||||||
&& lastLogin != null;
|
public void setRank(Rank rank)
|
||||||
|
{
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastLogin()
|
||||||
|
{
|
||||||
|
return lastLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastLogin(Date lastLogin)
|
||||||
|
{
|
||||||
|
this.lastLogin = lastLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getCommandSpy()
|
||||||
|
{
|
||||||
|
return commandSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommandSpy(Boolean commandSpy)
|
||||||
|
{
|
||||||
|
this.commandSpy = commandSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getPotionSpy()
|
||||||
|
{
|
||||||
|
return potionSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPotionSpy(Boolean potionSpy)
|
||||||
|
{
|
||||||
|
this.potionSpy = potionSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAcFormat()
|
||||||
|
{
|
||||||
|
return acFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcFormat(String acFormat)
|
||||||
|
{
|
||||||
|
this.acFormat = acFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPteroID()
|
||||||
|
{
|
||||||
|
return pteroID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPteroID(String pteroID)
|
||||||
|
{
|
||||||
|
this.pteroID = pteroID;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
@ -22,16 +21,19 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class AdminList extends FreedomService
|
public class AdminList extends FreedomService
|
||||||
{
|
{
|
||||||
@Getter
|
public static final List<String> vanished = new ArrayList<>();
|
||||||
|
public final List<String> verifiedNoAdmin = new ArrayList<>();
|
||||||
|
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
||||||
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||||
// Only active admins below
|
// Only active admins below
|
||||||
@Getter
|
|
||||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||||
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
||||||
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||||
public final List<String> verifiedNoAdmin = new ArrayList<>();
|
|
||||||
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
public static List<String> getVanished()
|
||||||
public static final List<String> vanished = new ArrayList<>();
|
{
|
||||||
|
return vanished;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
@ -249,14 +251,14 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = getAdmin(player);
|
Admin admin = getAdmin(player);
|
||||||
return admin == null ? false : admin.getName().equalsIgnoreCase(player.getName());
|
return admin != null && admin.getName().equalsIgnoreCase(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAdmin(Admin admin)
|
public boolean addAdmin(Admin admin)
|
||||||
{
|
{
|
||||||
if (!admin.isValid())
|
if (!admin.isValid())
|
||||||
{
|
{
|
||||||
logger.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
|
FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,4 +382,34 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
return vanished.contains(player);
|
return vanished.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Admin> getAllAdmins()
|
||||||
|
{
|
||||||
|
return allAdmins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Admin> getActiveAdmins()
|
||||||
|
{
|
||||||
|
return activeAdmins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Admin> getNameTable()
|
||||||
|
{
|
||||||
|
return nameTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Admin> getIpTable()
|
||||||
|
{
|
||||||
|
return ipTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getVerifiedNoAdmin()
|
||||||
|
{
|
||||||
|
return verifiedNoAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<String>> getVerifiedNoAdminIps()
|
||||||
|
{
|
||||||
|
return verifiedNoAdminIps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,15 +4,12 @@ import com.google.common.collect.Lists;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -22,27 +19,19 @@ import org.bukkit.entity.Player;
|
|||||||
public class Ban
|
public class Ban
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String username = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private UUID uuid = null;
|
|
||||||
@Getter
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
@Getter
|
private String username = null;
|
||||||
@Setter
|
private UUID uuid = null;
|
||||||
private String by = null;
|
private String by = null;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Date at = null;
|
private Date at = null;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private long expiryUnix = -1;
|
private long expiryUnix = -1;
|
||||||
|
|
||||||
public Ban()
|
public Ban()
|
||||||
@ -53,7 +42,7 @@ public class Ban
|
|||||||
{
|
{
|
||||||
this(username,
|
this(username,
|
||||||
uuid,
|
uuid,
|
||||||
Arrays.asList(ip),
|
Collections.singletonList(ip),
|
||||||
by,
|
by,
|
||||||
at,
|
at,
|
||||||
expire,
|
expire,
|
||||||
@ -88,7 +77,7 @@ public class Ban
|
|||||||
|
|
||||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
return new Ban(null, null, Collections.singletonList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
@ -143,6 +132,11 @@ public class Ban
|
|||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SimpleDateFormat getDateFormat()
|
||||||
|
{
|
||||||
|
return DATE_FORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasUsername()
|
public boolean hasUsername()
|
||||||
{
|
{
|
||||||
return username != null && !username.isEmpty();
|
return username != null && !username.isEmpty();
|
||||||
@ -256,16 +250,74 @@ public class Ban
|
|||||||
|
|
||||||
private void dedupeIps()
|
private void dedupeIps()
|
||||||
{
|
{
|
||||||
|
|
||||||
Set<String> uniqueIps = new HashSet<>();
|
Set<String> uniqueIps = new HashSet<>();
|
||||||
|
|
||||||
Iterator<String> it = ips.iterator();
|
//Fancy Collections.removeIf lets you do all that while loop work in one lambda.
|
||||||
while (it.hasNext())
|
ips.removeIf(s -> !uniqueIps.add(s));
|
||||||
{
|
|
||||||
if (!uniqueIps.add(it.next()))
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUsername()
|
||||||
|
{
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username)
|
||||||
|
{
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid()
|
||||||
|
{
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(UUID uuid)
|
||||||
|
{
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBy()
|
||||||
|
{
|
||||||
|
return by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBy(String by)
|
||||||
|
{
|
||||||
|
this.by = by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getAt()
|
||||||
|
{
|
||||||
|
return at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAt(Date at)
|
||||||
|
{
|
||||||
|
this.at = at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason)
|
||||||
|
{
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiryUnix()
|
||||||
|
{
|
||||||
|
return expiryUnix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiryUnix(long expiryUnix)
|
||||||
|
{
|
||||||
|
this.expiryUnix = expiryUnix;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,6 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -74,7 +73,7 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
// Load unbannable usernames
|
// Load unbannable usernames
|
||||||
unbannableUsernames.clear();
|
unbannableUsernames.clear();
|
||||||
unbannableUsernames.addAll((Collection<? extends String>)ConfigEntry.FAMOUS_PLAYERS.getList());
|
unbannableUsernames.addAll(ConfigEntry.FAMOUS_PLAYERS.getStringList());
|
||||||
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +189,7 @@ public class BanManager extends FreedomService
|
|||||||
return getByUsername(username) != null;
|
return getByUsername(username) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addBan(Ban ban)
|
public void addBan(Ban ban)
|
||||||
{
|
{
|
||||||
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
|
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
|
||||||
{
|
{
|
||||||
@ -213,22 +212,18 @@ public class BanManager extends FreedomService
|
|||||||
{
|
{
|
||||||
plugin.sql.addBan(ban);
|
plugin.sql.addBan(ban);
|
||||||
updateViews();
|
updateViews();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeBan(Ban ban)
|
public void removeBan(Ban ban)
|
||||||
{
|
{
|
||||||
if (bans.remove(ban))
|
if (bans.remove(ban))
|
||||||
{
|
{
|
||||||
plugin.sql.removeBan(ban);
|
plugin.sql.removeBan(ban);
|
||||||
updateViews();
|
updateViews();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int purge()
|
public int purge()
|
||||||
|
@ -3,25 +3,15 @@ package me.totalfreedom.totalfreedommod.banning;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.IConfig;
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
public class IndefiniteBan implements IConfig
|
public class IndefiniteBan implements IConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String username = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private UUID uuid = null;
|
|
||||||
@Getter
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
@Getter
|
private String username = null;
|
||||||
@Setter
|
private UUID uuid = null;
|
||||||
private String reason = null;
|
private String reason = null;
|
||||||
|
|
||||||
public IndefiniteBan()
|
public IndefiniteBan()
|
||||||
@ -60,4 +50,39 @@ public class IndefiniteBan implements IConfig
|
|||||||
{
|
{
|
||||||
return username != null;
|
return username != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUsername()
|
||||||
|
{
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username)
|
||||||
|
{
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid()
|
||||||
|
{
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(UUID uuid)
|
||||||
|
{
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason)
|
||||||
|
{
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import com.google.common.base.Strings;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
@ -21,18 +20,23 @@ public class IndefiniteBanList extends FreedomService
|
|||||||
|
|
||||||
public static final String CONFIG_FILENAME = "indefinitebans.yml";
|
public static final String CONFIG_FILENAME = "indefinitebans.yml";
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
||||||
|
|
||||||
@Getter
|
|
||||||
private int nameBanCount = 0;
|
private int nameBanCount = 0;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private int uuidBanCount = 0;
|
private int uuidBanCount = 0;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private int ipBanCount = 0;
|
private int ipBanCount = 0;
|
||||||
|
|
||||||
|
public static String getConfigFilename()
|
||||||
|
{
|
||||||
|
return CONFIG_FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -51,6 +55,7 @@ public class IndefiniteBanList extends FreedomService
|
|||||||
|
|
||||||
IndefiniteBan indefBan = new IndefiniteBan();
|
IndefiniteBan indefBan = new IndefiniteBan();
|
||||||
ConfigurationSection cs = config.getConfigurationSection(name);
|
ConfigurationSection cs = config.getConfigurationSection(name);
|
||||||
|
assert cs != null;
|
||||||
indefBan.loadFrom(cs);
|
indefBan.loadFrom(cs);
|
||||||
|
|
||||||
if (!indefBan.isValid())
|
if (!indefBan.isValid())
|
||||||
@ -84,7 +89,7 @@ public class IndefiniteBanList extends FreedomService
|
|||||||
|
|
||||||
for (IndefiniteBan indefBan : indefBans)
|
for (IndefiniteBan indefBan : indefBans)
|
||||||
{
|
{
|
||||||
if (username.toLowerCase().equals(indefBan.getUsername().toLowerCase()))
|
if (username.equalsIgnoreCase(indefBan.getUsername()))
|
||||||
{
|
{
|
||||||
bannedBy = "username";
|
bannedBy = "username";
|
||||||
ban = indefBan;
|
ban = indefBan;
|
||||||
@ -137,4 +142,24 @@ public class IndefiniteBanList extends FreedomService
|
|||||||
ipBanCount += indefBan.getIps().size();
|
ipBanCount += indefBan.getIps().size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<IndefiniteBan> getIndefBans()
|
||||||
|
{
|
||||||
|
return indefBans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNameBanCount()
|
||||||
|
{
|
||||||
|
return nameBanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUuidBanCount()
|
||||||
|
{
|
||||||
|
return uuidBanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIpBanCount()
|
||||||
|
{
|
||||||
|
return ipBanCount;
|
||||||
|
}
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
@ -143,6 +144,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
|
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
ItemMeta headMeta = newHead.getItemMeta();
|
ItemMeta headMeta = newHead.getItemMeta();
|
||||||
|
assert headMeta != null;
|
||||||
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
|
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
|
||||||
newHead.setItemMeta(headMeta);
|
newHead.setItemMeta(headMeta);
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
|
||||||
@ -175,7 +177,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
Banner banner = (Banner)event.getBlockPlaced().getState();
|
Banner banner = (Banner)event.getBlockPlaced().getState();
|
||||||
List<Pattern> patterns = banner.getPatterns();
|
List<Pattern> patterns = banner.getPatterns();
|
||||||
;
|
|
||||||
if (patterns.size() >= 2)
|
if (patterns.size() >= 2)
|
||||||
{
|
{
|
||||||
banner.setPatterns(patterns.subList(0, 2));
|
banner.setPatterns(patterns.subList(0, 2));
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -24,7 +25,6 @@ import org.bukkit.event.block.BlockIgniteEvent;
|
|||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
|
||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
@ -38,6 +38,20 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
|||||||
|
|
||||||
public class EventBlocker extends FreedomService
|
public class EventBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* /@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
* /public void onBlockRedstone(BlockRedstoneEvent event)
|
||||||
|
* /{
|
||||||
|
* / if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
* / {
|
||||||
|
* / event.setNewCurrent(0);
|
||||||
|
* / }
|
||||||
|
* /}
|
||||||
|
**/
|
||||||
|
|
||||||
|
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
|
||||||
|
private final ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -120,17 +134,12 @@ public class EventBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
switch (event.getCause())
|
if ((event.getCause() == EntityDamageEvent.DamageCause.LAVA)
|
||||||
{
|
&& !ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||||
case LAVA:
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
||||||
{
|
{
|
||||||
@ -203,18 +212,6 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onBlockRedstone(BlockRedstoneEvent event)
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
|
||||||
{
|
|
||||||
event.setNewCurrent(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
|
|
||||||
private ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event)
|
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||||
{
|
{
|
||||||
@ -231,12 +228,12 @@ public class EventBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||||
{
|
{
|
||||||
double maxHealth = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
double maxHealth = Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
|
||||||
if (maxHealth < 1)
|
if (maxHealth < 1)
|
||||||
{
|
{
|
||||||
for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers())
|
for (AttributeModifier attributeModifier : Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getModifiers())
|
||||||
{
|
{
|
||||||
event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).removeModifier(attributeModifier);
|
Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).removeModifier(attributeModifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import org.bukkit.attribute.Attributable;
|
import org.bukkit.attribute.Attributable;
|
||||||
@ -42,13 +43,13 @@ public class MobBlocker extends FreedomService
|
|||||||
Entity entity = e.getEntity();
|
Entity entity = e.getEntity();
|
||||||
if (entity instanceof Attributable)
|
if (entity instanceof Attributable)
|
||||||
{
|
{
|
||||||
if (((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0)
|
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
|
||||||
{
|
{
|
||||||
((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0);
|
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
|
||||||
}
|
}
|
||||||
if (((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0)
|
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
|
||||||
{
|
{
|
||||||
((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(10.0);
|
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +118,7 @@ public class MobBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
int mobcount = 0;
|
int mobcount = 0;
|
||||||
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
for (Entity entity : Objects.requireNonNull(event.getLocation().getWorld()).getLivingEntities())
|
||||||
{
|
{
|
||||||
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,7 @@ public class SignBlocker extends FreedomService
|
|||||||
ItemStack sign = event.getItemInHand();
|
ItemStack sign = event.getItemInHand();
|
||||||
net.minecraft.server.v1_16_R3.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
net.minecraft.server.v1_16_R3.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||||
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||||
|
assert compound != null;
|
||||||
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||||
String line1 = bet.getString("Text1");
|
String line1 = bet.getString("Text1");
|
||||||
String line2 = bet.getString("Text2");
|
String line2 = bet.getString("Text2");
|
||||||
|
@ -30,6 +30,24 @@ public class CommandBlocker extends FreedomService
|
|||||||
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||||
private final List<String> unknownCommands = Lists.newArrayList();
|
private final List<String> unknownCommands = Lists.newArrayList();
|
||||||
|
|
||||||
|
public static CommandMap getCommandMap()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||||
|
commandMapField.setAccessible(true);
|
||||||
|
|
||||||
|
return (SimpleCommandMap)commandMapField.get(simplePluginManager);
|
||||||
|
}
|
||||||
|
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -42,25 +60,6 @@ public class CommandBlocker extends FreedomService
|
|||||||
entryList.clear();
|
entryList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandMap getCommandMap()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
|
|
||||||
|
|
||||||
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
|
||||||
commandMapField.setAccessible(true);
|
|
||||||
|
|
||||||
SimpleCommandMap simpleCommandMap = (SimpleCommandMap)commandMapField.get(simplePluginManager);
|
|
||||||
return simpleCommandMap;
|
|
||||||
}
|
|
||||||
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
|
||||||
{
|
|
||||||
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
entryList.clear();
|
entryList.clear();
|
||||||
@ -84,7 +83,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
String commandName = parts[2].toLowerCase().substring(1);
|
String commandName = parts[2].toLowerCase().substring(1);
|
||||||
final String message = (parts.length > 3 ? parts[3] : null);
|
final String message = (parts.length > 3 ? parts[3] : null);
|
||||||
|
|
||||||
if (rank == null || action == null || commandName == null || commandName.isEmpty())
|
if (rank == null || action == null || commandName.isEmpty())
|
||||||
{
|
{
|
||||||
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
||||||
continue;
|
continue;
|
||||||
@ -98,6 +97,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
|
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert commandMap != null;
|
||||||
final Command command = commandMap.getCommand(commandName);
|
final Command command = commandMap.getCommand(commandName);
|
||||||
|
|
||||||
// Obtain command from alias
|
// Obtain command from alias
|
||||||
|
@ -13,11 +13,6 @@ public enum CommandBlockerAction
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getToken()
|
|
||||||
{
|
|
||||||
return this.token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandBlockerAction fromToken(String token)
|
public static CommandBlockerAction fromToken(String token)
|
||||||
{
|
{
|
||||||
for (CommandBlockerAction action : CommandBlockerAction.values())
|
for (CommandBlockerAction action : CommandBlockerAction.values())
|
||||||
@ -29,4 +24,9 @@ public enum CommandBlockerAction
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -11,15 +10,15 @@ import org.spigotmc.SpigotConfig;
|
|||||||
public class CommandBlockerEntry
|
public class CommandBlockerEntry
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final CommandBlockerRank rank;
|
private final CommandBlockerRank rank;
|
||||||
@Getter
|
|
||||||
private final CommandBlockerAction action;
|
private final CommandBlockerAction action;
|
||||||
@Getter
|
|
||||||
private final String command;
|
private final String command;
|
||||||
@Getter
|
|
||||||
private final String subCommand;
|
private final String subCommand;
|
||||||
@Getter
|
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||||
@ -51,4 +50,29 @@ public class CommandBlockerEntry
|
|||||||
}
|
}
|
||||||
FUtil.playerMsg(sender, FUtil.colorize(message));
|
FUtil.playerMsg(sender, FUtil.colorize(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommandBlockerRank getRank()
|
||||||
|
{
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandBlockerAction getAction()
|
||||||
|
{
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCommand()
|
||||||
|
{
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubCommand()
|
||||||
|
{
|
||||||
|
return subCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public enum CommandBlockerRank
|
public enum CommandBlockerRank
|
||||||
@ -20,16 +20,6 @@ public enum CommandBlockerRank
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getToken()
|
|
||||||
{
|
|
||||||
return this.token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPermission(CommandSender sender)
|
|
||||||
{
|
|
||||||
return fromSender(sender).ordinal() >= ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandBlockerRank fromSender(CommandSender sender)
|
public static CommandBlockerRank fromSender(CommandSender sender)
|
||||||
{
|
{
|
||||||
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
|
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
|
||||||
@ -61,4 +51,14 @@ public enum CommandBlockerRank
|
|||||||
}
|
}
|
||||||
return EVERYONE;
|
return EVERYONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return fromSender(sender).ordinal() >= ordinal();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||||
@ -10,8 +9,8 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
|||||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -36,16 +36,47 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
public class CoreProtectBridge extends FreedomService
|
public class CoreProtectBridge extends FreedomService
|
||||||
{
|
{
|
||||||
private CoreProtectAPI coreProtectAPI = null;
|
public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
|
||||||
|
|
||||||
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
||||||
|
|
||||||
private final HashMap<String, Long> cooldown = new HashMap<>();
|
private final HashMap<String, Long> cooldown = new HashMap<>();
|
||||||
|
private CoreProtectAPI coreProtectAPI = null;
|
||||||
public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
|
|
||||||
|
|
||||||
private BukkitTask wiper;
|
private BukkitTask wiper;
|
||||||
|
|
||||||
|
public static Long getSecondsLeft(long prevTime, int timeAdd)
|
||||||
|
{
|
||||||
|
return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unix timestamp converter taken from Functions class in CoreProtect, not my code
|
||||||
|
public static String getTimeAgo(int logTime, int currentTime)
|
||||||
|
{
|
||||||
|
StringBuilder message = new StringBuilder();
|
||||||
|
double timeSince = (double)currentTime - ((double)logTime + 0.0D);
|
||||||
|
timeSince /= 60.0D;
|
||||||
|
if (timeSince < 60.0D)
|
||||||
|
{
|
||||||
|
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/m ago");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.length() == 0)
|
||||||
|
{
|
||||||
|
timeSince /= 60.0D;
|
||||||
|
if (timeSince < 24.0D)
|
||||||
|
{
|
||||||
|
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/h ago");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.length() == 0)
|
||||||
|
{
|
||||||
|
timeSince /= 24.0D;
|
||||||
|
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/d ago");
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -62,8 +93,8 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
|
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
|
||||||
|
assert coreProtectPlugin != null;
|
||||||
if (coreProtectPlugin != null && coreProtectPlugin instanceof CoreProtect)
|
if (coreProtectPlugin instanceof CoreProtect)
|
||||||
{
|
{
|
||||||
coreProtect = (CoreProtect)coreProtectPlugin;
|
coreProtect = (CoreProtect)coreProtectPlugin;
|
||||||
}
|
}
|
||||||
@ -187,7 +218,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
|
|
||||||
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
|
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
|
||||||
we have to do this manually via SQL */
|
we have to do this manually via SQL */
|
||||||
Connection connection = null;
|
Connection connection;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
|
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
|
||||||
@ -237,40 +268,6 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Long getSecondsLeft(long prevTime, int timeAdd)
|
|
||||||
{
|
|
||||||
return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unix timestamp converter taken from Functions class in CoreProtect, not my code
|
|
||||||
public static String getTimeAgo(int logTime, int currentTime)
|
|
||||||
{
|
|
||||||
StringBuilder message = new StringBuilder();
|
|
||||||
double timeSince = (double)currentTime - ((double)logTime + 0.0D);
|
|
||||||
timeSince /= 60.0D;
|
|
||||||
if (timeSince < 60.0D)
|
|
||||||
{
|
|
||||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/m ago");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.length() == 0)
|
|
||||||
{
|
|
||||||
timeSince /= 60.0D;
|
|
||||||
if (timeSince < 24.0D)
|
|
||||||
{
|
|
||||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/h ago");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.length() == 0)
|
|
||||||
{
|
|
||||||
timeSince /= 24.0D;
|
|
||||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/d ago");
|
|
||||||
}
|
|
||||||
|
|
||||||
return message.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,8 @@ public class EssentialsBridge extends FreedomService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
||||||
if (essentials != null && essentials instanceof Essentials)
|
assert essentials != null;
|
||||||
|
if (essentials instanceof Essentials)
|
||||||
{
|
{
|
||||||
essentialsPlugin = (Essentials)essentials;
|
essentialsPlugin = (Essentials)essentials;
|
||||||
}
|
}
|
||||||
@ -113,7 +114,8 @@ public class EssentialsBridge extends FreedomService
|
|||||||
User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return FUtil.getField(user, "lastActivity");
|
Long l = FUtil.getField(user, "lastActivity");
|
||||||
|
return (l != null) ? l : 0L;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -150,7 +152,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||||
{
|
{
|
||||||
final InventoryHolder inventoryHolder = inventory.getHolder();
|
final InventoryHolder inventoryHolder = inventory.getHolder();
|
||||||
if (inventoryHolder != null && inventoryHolder instanceof HumanEntity)
|
if (inventoryHolder instanceof HumanEntity)
|
||||||
{
|
{
|
||||||
Player invOwner = (Player)inventoryHolder;
|
Player invOwner = (Player)inventoryHolder;
|
||||||
Rank recieverRank = plugin.rm.getRank(player);
|
Rank recieverRank = plugin.rm.getRank(player);
|
||||||
@ -203,6 +205,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Actually use this for something or remove it.
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,11 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDisguisesEnabled()
|
||||||
|
{
|
||||||
|
return !BlockedDisguises.disabled;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDisguisesEnabled(boolean state)
|
public void setDisguisesEnabled(boolean state)
|
||||||
{
|
{
|
||||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
@ -87,11 +92,6 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
BlockedDisguises.disabled = !state;
|
BlockedDisguises.disabled = !state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisguisesEnabled()
|
|
||||||
{
|
|
||||||
return !BlockedDisguises.disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
@ -60,8 +60,7 @@ public class WorldEditBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
com.sk89q.worldedit.entity.Player fuckyou = bukkitPlayer;
|
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||||
session.undo(session.getBlockBag(fuckyou), fuckyou);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,8 +83,7 @@ public class WorldEditBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
session.redo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||||
session.redo(session.getBlockBag(fuckyou), fuckyou);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.caging;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -12,141 +11,21 @@ import org.bukkit.block.Skull;
|
|||||||
public class CageData
|
public class CageData
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static String input = null;
|
||||||
private final FPlayer fPlayer;
|
private final FPlayer fPlayer;
|
||||||
//
|
//
|
||||||
private final List<BlockData> cageHistory = new ArrayList<>();
|
|
||||||
//
|
//
|
||||||
@Getter
|
private final List<BlockData> cageHistory = new ArrayList<>();
|
||||||
private boolean caged = false;
|
private boolean caged = false;
|
||||||
@Getter
|
|
||||||
private Location location;
|
private Location location;
|
||||||
@Getter
|
|
||||||
private Material outerMaterial = Material.GLASS;
|
private Material outerMaterial = Material.GLASS;
|
||||||
@Getter
|
|
||||||
private Material innerMaterial = Material.AIR;
|
private Material innerMaterial = Material.AIR;
|
||||||
@Getter
|
|
||||||
private static String input = null;
|
|
||||||
|
|
||||||
public CageData(FPlayer player)
|
public CageData(FPlayer player)
|
||||||
{
|
{
|
||||||
this.fPlayer = player;
|
this.fPlayer = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCaged(boolean cage)
|
|
||||||
{
|
|
||||||
if (cage)
|
|
||||||
{
|
|
||||||
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.caged = false;
|
|
||||||
regenerateHistory();
|
|
||||||
clearHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cage(Location location, Material outer, Material inner)
|
|
||||||
{
|
|
||||||
if (isCaged())
|
|
||||||
{
|
|
||||||
setCaged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.caged = true;
|
|
||||||
this.location = location;
|
|
||||||
this.outerMaterial = outer;
|
|
||||||
this.innerMaterial = inner;
|
|
||||||
this.input = null;
|
|
||||||
|
|
||||||
buildHistory(location, 2, fPlayer);
|
|
||||||
regenerate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cage(Location location, Material outer, Material inner, String input)
|
|
||||||
{
|
|
||||||
if (isCaged())
|
|
||||||
{
|
|
||||||
setCaged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.caged = true;
|
|
||||||
this.location = location;
|
|
||||||
this.outerMaterial = outer;
|
|
||||||
this.innerMaterial = inner;
|
|
||||||
this.input = input;
|
|
||||||
|
|
||||||
buildHistory(location, 2, fPlayer);
|
|
||||||
regenerate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void regenerate()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!caged
|
|
||||||
|| location == null
|
|
||||||
|| outerMaterial == null
|
|
||||||
|| innerMaterial == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
generateHollowCube(location, 2, outerMaterial);
|
|
||||||
generateCube(location, 1, innerMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: EventHandlerize this?
|
|
||||||
public void playerJoin()
|
|
||||||
{
|
|
||||||
if (!isCaged())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playerQuit()
|
|
||||||
{
|
|
||||||
regenerateHistory();
|
|
||||||
clearHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearHistory()
|
|
||||||
{
|
|
||||||
cageHistory.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void insertHistoryBlock(Location location, Material material)
|
|
||||||
{
|
|
||||||
cageHistory.add(new BlockData(location, material));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void regenerateHistory()
|
|
||||||
{
|
|
||||||
for (BlockData blockdata : this.cageHistory)
|
|
||||||
{
|
|
||||||
blockdata.location.getBlock().setType(blockdata.material);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildHistory(Location location, int length, FPlayer playerdata)
|
|
||||||
{
|
|
||||||
final Block center = location.getBlock();
|
|
||||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
|
||||||
{
|
|
||||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
|
||||||
{
|
|
||||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
|
||||||
{
|
|
||||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
|
||||||
insertHistoryBlock(block.getLocation(), block.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Util methods
|
// Util methods
|
||||||
public static void generateCube(Location location, int length, Material material)
|
public static void generateCube(Location location, int length, Material material)
|
||||||
{
|
{
|
||||||
@ -167,6 +46,7 @@ public class CageData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static void generateHollowCube(Location location, int length, Material material)
|
public static void generateHollowCube(Location location, int length, Material material)
|
||||||
{
|
{
|
||||||
final Block center = location.getBlock();
|
final Block center = location.getBlock();
|
||||||
@ -213,7 +93,7 @@ public class CageData
|
|||||||
skull.setOwner(input);
|
skull.setOwner(input);
|
||||||
skull.update();
|
skull.update();
|
||||||
}
|
}
|
||||||
catch (ClassCastException e)
|
catch (ClassCastException ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,6 +103,176 @@ public class CageData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getInput()
|
||||||
|
{
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setInput(String input)
|
||||||
|
{
|
||||||
|
CageData.input = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
input = null;
|
||||||
|
|
||||||
|
buildHistory(location);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner, String input)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
CageData.input = input;
|
||||||
|
|
||||||
|
buildHistory(location);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void regenerate()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!caged
|
||||||
|
|| location == null
|
||||||
|
|| outerMaterial == null
|
||||||
|
|| innerMaterial == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateHollowCube(location, 2, outerMaterial);
|
||||||
|
generateCube(location, 1, innerMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: EventHandler this?
|
||||||
|
public void playerJoin()
|
||||||
|
{
|
||||||
|
if (!isCaged())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerQuit()
|
||||||
|
{
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearHistory()
|
||||||
|
{
|
||||||
|
cageHistory.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertHistoryBlock(Location location, Material material)
|
||||||
|
{
|
||||||
|
cageHistory.add(new BlockData(location, material));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void regenerateHistory()
|
||||||
|
{
|
||||||
|
for (BlockData blockdata : this.cageHistory)
|
||||||
|
{
|
||||||
|
blockdata.location.getBlock().setType(blockdata.material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildHistory(Location location)
|
||||||
|
{
|
||||||
|
final Block center = location.getBlock();
|
||||||
|
for (int xOffset = -2; xOffset <= 2; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -2; yOffset <= 2; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -2; zOffset <= 2; zOffset++)
|
||||||
|
{
|
||||||
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
insertHistoryBlock(block.getLocation(), block.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FPlayer getfPlayer()
|
||||||
|
{
|
||||||
|
return fPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BlockData> getCageHistory()
|
||||||
|
{
|
||||||
|
return cageHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCaged()
|
||||||
|
{
|
||||||
|
return caged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaged(boolean cage)
|
||||||
|
{
|
||||||
|
if (cage)
|
||||||
|
{
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caged = false;
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation()
|
||||||
|
{
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(Location location)
|
||||||
|
{
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getOuterMaterial()
|
||||||
|
{
|
||||||
|
return outerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOuterMaterial(Material outerMaterial)
|
||||||
|
{
|
||||||
|
this.outerMaterial = outerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getInnerMaterial()
|
||||||
|
{
|
||||||
|
return innerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInnerMaterial(Material innerMaterial)
|
||||||
|
{
|
||||||
|
this.innerMaterial = innerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
private static class BlockData
|
private static class BlockData
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.caging;
|
package me.totalfreedom.totalfreedommod.caging;
|
||||||
|
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -31,7 +32,7 @@ public class Cager extends FreedomService
|
|||||||
public void onBreakBlock(BlockBreakEvent event)
|
public void onBreakBlock(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player == null || plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -60,7 +61,7 @@ public class Cager extends FreedomService
|
|||||||
Location cageLoc = cage.getLocation();
|
Location cageLoc = cage.getLocation();
|
||||||
|
|
||||||
final boolean outOfCage;
|
final boolean outOfCage;
|
||||||
if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
|
if (!Objects.equals(playerLoc.getWorld(), cageLoc.getWorld()))
|
||||||
{
|
{
|
||||||
outOfCage = true;
|
outOfCage = true;
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
public class CommandLoader extends FreedomService
|
public class CommandLoader extends FreedomService
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
private final List<FreedomCommand> commands;
|
private final List<FreedomCommand> commands;
|
||||||
|
|
||||||
public CommandLoader()
|
public CommandLoader()
|
||||||
@ -79,4 +77,9 @@ public class CommandLoader extends FreedomService
|
|||||||
|
|
||||||
FLog.info("Loaded " + commands.size() + " commands");
|
FLog.info("Loaded " + commands.size() + " commands");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FreedomCommand> getCommands()
|
||||||
|
{
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,11 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_adminworld extends FreedomCommand
|
public class Command_adminworld extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private enum CommandMode
|
|
||||||
{
|
|
||||||
TELEPORT, TIME, WEATHER
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -66,7 +61,7 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
{
|
{
|
||||||
adminWorld = plugin.wm.adminworld.getWorld();
|
adminWorld = plugin.wm.adminworld.getWorld();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,22 +153,6 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PermissionDeniedException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private PermissionDeniedException()
|
|
||||||
{
|
|
||||||
super("");
|
|
||||||
}
|
|
||||||
|
|
||||||
private PermissionDeniedException(String string)
|
|
||||||
{
|
|
||||||
super(string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
@ -198,4 +177,25 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum CommandMode
|
||||||
|
{
|
||||||
|
TELEPORT, TIME, WEATHER
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PermissionDeniedException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private PermissionDeniedException()
|
||||||
|
{
|
||||||
|
super("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private PermissionDeniedException(String string)
|
||||||
|
{
|
||||||
|
super(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,17 +14,17 @@ public class Command_attributelist extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
String list = "All possible attributes: ";
|
StringBuilder list = new StringBuilder("All possible attributes: ");
|
||||||
|
|
||||||
for (Attribute attribute : Attribute.values())
|
for (Attribute attribute : Attribute.values())
|
||||||
{
|
{
|
||||||
list += attribute.name() + ", ";
|
list.append(attribute.name()).append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove extra comma at the end of the list
|
// Remove extra comma at the end of the list
|
||||||
list = list.substring(0, list.length() - 2);
|
list = new StringBuilder(list.substring(0, list.length() - 2));
|
||||||
|
|
||||||
msg(list);
|
msg(list.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
@ -31,8 +32,8 @@ public class Command_ban extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
String reason = null;
|
String reason = null;
|
||||||
Boolean silent = false;
|
boolean silent = false;
|
||||||
Boolean cancelRollback = false;
|
boolean cancelRollback = false;
|
||||||
if (args.length >= 2)
|
if (args.length >= 2)
|
||||||
{
|
{
|
||||||
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
@ -100,7 +101,7 @@ public class Command_ban extends FreedomCommand
|
|||||||
for (int z = -1; z <= 1; z++)
|
for (int z = -1; z <= 1; z++)
|
||||||
{
|
{
|
||||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||||
targetPos.getWorld().strikeLightning(strike_pos);
|
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +155,7 @@ public class Command_ban extends FreedomCommand
|
|||||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||||
}
|
}
|
||||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||||
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
|
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kick player and handle others on IP
|
// Kick player and handle others on IP
|
||||||
|
@ -30,7 +30,7 @@ public class Command_banip extends FreedomCommand
|
|||||||
|
|
||||||
String ip = args[0];
|
String ip = args[0];
|
||||||
|
|
||||||
if (!FUtil.isValidIPv4(ip))
|
if (FUtil.isValidIPv4(ip))
|
||||||
{
|
{
|
||||||
msg(ip + " is not a valid IP address", ChatColor.RED);
|
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.SplittableRandom;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -27,7 +27,7 @@ public class Command_bird extends FreedomCommand
|
|||||||
public EntityType getRandomFish()
|
public EntityType getRandomFish()
|
||||||
{
|
{
|
||||||
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
||||||
Random random = new Random();
|
SplittableRandom random = new SplittableRandom();
|
||||||
return fishTypes.get(random.nextInt(fishTypes.size()));
|
return fishTypes.get(random.nextInt(fishTypes.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ public class Command_cake extends FreedomCommand
|
|||||||
|
|
||||||
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
|
assert heldItemMeta != null;
|
||||||
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -38,7 +39,7 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
|
|
||||||
if (targetPlayer.isInsideVehicle())
|
if (targetPlayer.isInsideVehicle())
|
||||||
{
|
{
|
||||||
targetPlayer.getVehicle().eject();
|
Objects.requireNonNull(targetPlayer.getVehicle()).eject();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -30,16 +30,13 @@ public class Command_commandlist extends FreedomCommand
|
|||||||
PluginDescriptionFile desc = targetPlugin.getDescription();
|
PluginDescriptionFile desc = targetPlugin.getDescription();
|
||||||
Map<String, Map<String, Object>> map = desc.getCommands();
|
Map<String, Map<String, Object>> map = desc.getCommands();
|
||||||
|
|
||||||
if (map != null)
|
|
||||||
{
|
|
||||||
for (Entry<String, Map<String, Object>> entry : map.entrySet())
|
for (Entry<String, Map<String, Object>> entry : map.entrySet())
|
||||||
{
|
{
|
||||||
String command_name = entry.getKey();
|
String command_name = entry.getKey();
|
||||||
commands.add(command_name);
|
commands.add(command_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Throwable ignored)
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,15 +28,6 @@ public class Command_cookie extends FreedomCommand
|
|||||||
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder name = new StringBuilder();
|
|
||||||
|
|
||||||
name.append(ChatColor.DARK_RED).append("C")
|
|
||||||
.append(ChatColor.GOLD).append("o")
|
|
||||||
.append(ChatColor.YELLOW).append("o")
|
|
||||||
.append(ChatColor.DARK_GREEN).append("k")
|
|
||||||
.append(ChatColor.DARK_BLUE).append("i")
|
|
||||||
.append(ChatColor.DARK_PURPLE).append("e");
|
|
||||||
|
|
||||||
final StringBuilder lore = new StringBuilder();
|
final StringBuilder lore = new StringBuilder();
|
||||||
|
|
||||||
for (final String word : LORE.split(" "))
|
for (final String word : LORE.split(" "))
|
||||||
@ -46,7 +37,14 @@ public class Command_cookie extends FreedomCommand
|
|||||||
|
|
||||||
final ItemStack heldItem = new ItemStack(Material.COOKIE);
|
final ItemStack heldItem = new ItemStack(Material.COOKIE);
|
||||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
heldItemMeta.setDisplayName(name.toString());
|
String name = ChatColor.DARK_RED + "C" +
|
||||||
|
ChatColor.GOLD + "o" +
|
||||||
|
ChatColor.YELLOW + "o" +
|
||||||
|
ChatColor.DARK_GREEN + "k" +
|
||||||
|
ChatColor.DARK_BLUE + "i" +
|
||||||
|
ChatColor.DARK_PURPLE + "e";
|
||||||
|
assert heldItemMeta != null;
|
||||||
|
heldItemMeta.setDisplayName(name);
|
||||||
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
|
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.SplittableRandom;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -14,8 +14,18 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
public class Command_deafen extends FreedomCommand
|
public class Command_deafen extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Random random = new Random();
|
|
||||||
public static final double STEPS = 10.0;
|
public static final double STEPS = 10.0;
|
||||||
|
private static final SplittableRandom random = new SplittableRandom();
|
||||||
|
|
||||||
|
private static Location randomOffset(Location a)
|
||||||
|
{
|
||||||
|
return a.clone().add(randomDoubleRange() * 5.0, randomDoubleRange() * 5.0, randomDoubleRange() * 5.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Double randomDoubleRange()
|
||||||
|
{
|
||||||
|
return -1.0 + (random.nextDouble() * ((1.0 - -1.0) + 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
@ -30,7 +40,7 @@ public class Command_deafen extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
playerSender.playSound(randomOffset(playerSender.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
playerSender.playSound(randomOffset(playerSender.getLocation()), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
||||||
}
|
}
|
||||||
@ -38,14 +48,4 @@ public class Command_deafen extends FreedomCommand
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Location randomOffset(Location a, double magnitude)
|
|
||||||
{
|
|
||||||
return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Double randomDoubleRange(double min, double max)
|
|
||||||
{
|
|
||||||
return min + (random.nextDouble() * ((max - min) + 1.0));
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -21,6 +21,7 @@ public class Command_debugstick extends FreedomCommand
|
|||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.DEBUG_STICK);
|
ItemStack itemStack = new ItemStack(Material.DEBUG_STICK);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Stick of Happiness");
|
itemMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Stick of Happiness");
|
||||||
List<String> lore = Arrays.asList(
|
List<String> lore = Arrays.asList(
|
||||||
ChatColor.RED + "This is the most powerful stick in the game.",
|
ChatColor.RED + "This is the most powerful stick in the game.",
|
||||||
|
@ -20,6 +20,16 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class Command_dispfill extends FreedomCommand
|
public class Command_dispfill extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
|
||||||
|
{
|
||||||
|
if (targetBlock.getType() == Material.DISPENSER)
|
||||||
|
{
|
||||||
|
final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory();
|
||||||
|
dispenserInv.clear();
|
||||||
|
dispenserInv.addItem(items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -54,7 +64,7 @@ public class Command_dispfill extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ItemStack[] itemsArray = items.toArray(new ItemStack[items.size()]);
|
final ItemStack[] itemsArray = items.toArray(new ItemStack[0]);
|
||||||
|
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
final Location centerLocation = playerSender.getLocation();
|
final Location centerLocation = playerSender.getLocation();
|
||||||
@ -88,14 +98,4 @@ public class Command_dispfill extends FreedomCommand
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
|
|
||||||
{
|
|
||||||
if (targetBlock.getType() == Material.DISPENSER)
|
|
||||||
{
|
|
||||||
final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory();
|
|
||||||
dispenserInv.clear();
|
|
||||||
dispenserInv.addItem(items);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -41,7 +43,7 @@ public class Command_doom extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
||||||
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||||
|
|
||||||
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
final String ip = Objects.requireNonNull(player.getAddress()).getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
// Remove from admin
|
// Remove from admin
|
||||||
Admin admin = getAdmin(player);
|
Admin admin = getAdmin(player);
|
||||||
@ -54,7 +56,7 @@ public class Command_doom extends FreedomCommand
|
|||||||
plugin.ptero.updateAccountStatus(admin);
|
plugin.ptero.updateAccountStatus(admin);
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +127,6 @@ public class Command_doom extends FreedomCommand
|
|||||||
|
|
||||||
// generate explosion
|
// generate explosion
|
||||||
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||||
;
|
|
||||||
|
|
||||||
// kick player
|
// kick player
|
||||||
player.kickPlayer(ChatColor.RED + kickReason);
|
player.kickPlayer(ChatColor.RED + kickReason);
|
||||||
|
@ -19,7 +19,7 @@ public class Command_eject extends FreedomCommand
|
|||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
List<String> names = new ArrayList();
|
List<String> names = new ArrayList<>();
|
||||||
|
|
||||||
for (Entity entity : playerSender.getPassengers())
|
for (Entity entity : playerSender.getPassengers())
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -19,6 +20,18 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class Command_enchant extends FreedomCommand
|
public class Command_enchant extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static List<String> stringNumberRange(int min, int max)
|
||||||
|
{
|
||||||
|
List<String> range = new ArrayList<>();
|
||||||
|
for (int i = min; i <= max; i++)
|
||||||
|
{
|
||||||
|
range.add(String.valueOf(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -27,9 +40,9 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack item = playerSender.getEquipment().getItemInMainHand();
|
ItemStack item = Objects.requireNonNull(playerSender.getEquipment()).getItemInMainHand();
|
||||||
|
|
||||||
if (item == null || item.getType() == Material.AIR)
|
if (item.getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
msg("You have to hold an item to enchant it");
|
msg("You have to hold an item to enchant it");
|
||||||
return true;
|
return true;
|
||||||
@ -99,7 +112,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
{
|
{
|
||||||
ench = Enchantment.getByName(args[1].toUpperCase());
|
ench = Enchantment.getByName(args[1].toUpperCase());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +136,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
if (ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
||||||
{
|
{
|
||||||
level = Integer.valueOf(args[2]);
|
level = Integer.parseInt(args[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -158,9 +171,10 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<String> getAllEnchantments()
|
public List<String> getAllEnchantments()
|
||||||
{
|
{
|
||||||
List<String> enchantments = new ArrayList();
|
List<String> enchantments = new ArrayList<>();
|
||||||
for (Enchantment enchantment : Enchantment.values())
|
for (Enchantment enchantment : Enchantment.values())
|
||||||
{
|
{
|
||||||
enchantments.add(enchantment.getName());
|
enchantments.add(enchantment.getName());
|
||||||
@ -168,9 +182,10 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return enchantments;
|
return enchantments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<String> getAllEnchantments(ItemStack item)
|
public List<String> getAllEnchantments(ItemStack item)
|
||||||
{
|
{
|
||||||
List<String> enchantments = new ArrayList();
|
List<String> enchantments = new ArrayList<>();
|
||||||
for (Enchantment enchantment : Enchantment.values())
|
for (Enchantment enchantment : Enchantment.values())
|
||||||
{
|
{
|
||||||
if (enchantment.canEnchantItem(item))
|
if (enchantment.canEnchantItem(item))
|
||||||
@ -181,9 +196,10 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return enchantments;
|
return enchantments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<String> getEnchantments(ItemStack item)
|
public List<String> getEnchantments(ItemStack item)
|
||||||
{
|
{
|
||||||
List<String> enchantments = new ArrayList();
|
List<String> enchantments = new ArrayList<>();
|
||||||
for (Enchantment enchantment : item.getEnchantments().keySet())
|
for (Enchantment enchantment : item.getEnchantments().keySet())
|
||||||
{
|
{
|
||||||
enchantments.add(enchantment.getName());
|
enchantments.add(enchantment.getName());
|
||||||
@ -191,17 +207,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return enchantments;
|
return enchantments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> stringNumberRange(int min, int max)
|
@SuppressWarnings("deprecation")
|
||||||
{
|
|
||||||
List<String> range = new ArrayList();
|
|
||||||
for (int i = min; i <= max; i++)
|
|
||||||
{
|
|
||||||
range.add(String.valueOf(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return range;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
@ -214,9 +220,9 @@ public class Command_enchant extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
ItemStack item = player.getEquipment().getItemInMainHand();
|
ItemStack item = Objects.requireNonNull(player.getEquipment()).getItemInMainHand();
|
||||||
|
|
||||||
if (item == null || item.getType() == Material.AIR)
|
if (item.getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -258,7 +264,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Arrays.asList("[level]");
|
return Collections.singletonList("[level]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,29 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_entitywipe extends FreedomCommand
|
public class Command_entitywipe extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static List<EntityType> getAllEntities()
|
||||||
|
{
|
||||||
|
List<EntityType> entityTypes = new ArrayList<>();
|
||||||
|
for (EntityType entityType : EntityType.values())
|
||||||
|
{
|
||||||
|
if (!Groups.MOB_TYPES.contains(entityType))
|
||||||
|
{
|
||||||
|
entityTypes.add(entityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entityTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getAllEntityNames()
|
||||||
|
{
|
||||||
|
List<String> names = new ArrayList<>();
|
||||||
|
for (EntityType entityType : getAllEntities())
|
||||||
|
{
|
||||||
|
names.add(entityType.name());
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -75,29 +98,6 @@ public class Command_entitywipe extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<EntityType> getAllEntities()
|
|
||||||
{
|
|
||||||
List<EntityType> entityTypes = new ArrayList<>();
|
|
||||||
for (EntityType entityType : EntityType.values())
|
|
||||||
{
|
|
||||||
if (!Groups.MOB_TYPES.contains(entityType))
|
|
||||||
{
|
|
||||||
entityTypes.add(entityType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entityTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAllEntityNames()
|
|
||||||
{
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
for (EntityType entityType : getAllEntities())
|
|
||||||
{
|
|
||||||
names.add(entityType.name());
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ public class Command_expel extends FreedomCommand
|
|||||||
{
|
{
|
||||||
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
|
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ public class Command_expel extends FreedomCommand
|
|||||||
{
|
{
|
||||||
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
|
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class Command_expel extends FreedomCommand
|
|||||||
{
|
{
|
||||||
inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
|
inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex)
|
catch (IllegalArgumentException ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class Command_health extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TFM_TickMeter
|
private static class TFM_TickMeter
|
||||||
{
|
{
|
||||||
|
|
||||||
private final AtomicInteger ticks = new AtomicInteger();
|
private final AtomicInteger ticks = new AtomicInteger();
|
||||||
|
@ -19,11 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_hubworld extends FreedomCommand
|
public class Command_hubworld extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private enum CommandMode
|
|
||||||
{
|
|
||||||
TELEPORT, TIME, WEATHER
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -66,7 +61,7 @@ public class Command_hubworld extends FreedomCommand
|
|||||||
{
|
{
|
||||||
hubWorld = plugin.wm.hubworld.getWorld();
|
hubWorld = plugin.wm.hubworld.getWorld();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +179,12 @@ public class Command_hubworld extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PermissionDeniedException extends Exception
|
private enum CommandMode
|
||||||
|
{
|
||||||
|
TELEPORT, TIME, WEATHER
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PermissionDeniedException extends Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
@ -42,7 +41,7 @@ public class Command_invis extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> players = new ArrayList<String>();
|
List<String> players = new ArrayList<>();
|
||||||
int clears = 0;
|
int clears = 0;
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
@ -81,7 +80,7 @@ public class Command_invis extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
return Arrays.asList("clear");
|
return Collections.singletonList("clear");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -47,11 +47,6 @@ public class Command_invsee extends FreedomCommand
|
|||||||
if (args[1].equals("offhand"))
|
if (args[1].equals("offhand"))
|
||||||
{
|
{
|
||||||
ItemStack offhand = player.getInventory().getItemInOffHand();
|
ItemStack offhand = player.getInventory().getItemInOffHand();
|
||||||
if (offhand == null)
|
|
||||||
{
|
|
||||||
msg("That player has nothing in their offhand.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Inventory inventory = server.createInventory(null, 9, player.getName() + "'s offhand");
|
Inventory inventory = server.createInventory(null, 9, player.getName() + "'s offhand");
|
||||||
inventory.setItem(1, offhand);
|
inventory.setItem(1, offhand);
|
||||||
playerSender.openInventory(inventory);
|
playerSender.openInventory(inventory);
|
||||||
|
@ -50,7 +50,7 @@ public class Command_landmine extends FreedomCommand
|
|||||||
{
|
{
|
||||||
radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0])));
|
radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class Command_linkdiscord extends FreedomCommand
|
|||||||
|
|
||||||
if (Discord.LINK_CODES.containsValue(data))
|
if (Discord.LINK_CODES.containsValue(data))
|
||||||
{
|
{
|
||||||
code = plugin.dc.getCode(data);
|
code = Discord.getCode(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2,11 +2,11 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -17,7 +17,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
Boolean silent = (args[args.length - 1].equalsIgnoreCase("-q"));
|
boolean silent = (args[args.length - 1].equalsIgnoreCase("-q"));
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("all"))
|
if (args[0].equalsIgnoreCase("all"))
|
||||||
|
@ -81,7 +81,7 @@ public class Command_makeopregion extends FreedomCommand
|
|||||||
region.setOwners(owners);
|
region.setOwners(owners);
|
||||||
region.setFlags(flags);
|
region.setFlags(flags);
|
||||||
|
|
||||||
for (Flag flag : flags.keySet())
|
for (Flag<?> flag : flags.keySet())
|
||||||
{
|
{
|
||||||
region.setFlag(flag.getRegionGroupFlag(), RegionGroup.MEMBERS);
|
region.setFlag(flag.getRegionGroupFlag(), RegionGroup.MEMBERS);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -68,8 +67,8 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
@ -100,7 +99,6 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -116,8 +114,8 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -19,11 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_masterbuilderworld extends FreedomCommand
|
public class Command_masterbuilderworld extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private enum CommandMode
|
|
||||||
{
|
|
||||||
TELEPORT, TIME, WEATHER
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -66,7 +61,7 @@ public class Command_masterbuilderworld extends FreedomCommand
|
|||||||
{
|
{
|
||||||
masterBuilderWorld = plugin.wm.masterBuilderWorld.getWorld();
|
masterBuilderWorld = plugin.wm.masterBuilderWorld.getWorld();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +179,12 @@ public class Command_masterbuilderworld extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PermissionDeniedException extends Exception
|
private enum CommandMode
|
||||||
|
{
|
||||||
|
TELEPORT, TIME, WEATHER
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PermissionDeniedException extends Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -101,7 +101,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
if (plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||||
{
|
{
|
||||||
return noPerms();
|
return noPerms();
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ public class Command_mbconfig extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
if (plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||||
{
|
{
|
||||||
return noPerms();
|
return noPerms();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class Command_moblimiter extends FreedomCommand
|
|||||||
{
|
{
|
||||||
ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
|
ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,16 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_mobpurge extends FreedomCommand
|
public class Command_mobpurge extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static List<String> getAllMobNames()
|
||||||
|
{
|
||||||
|
List<String> names = new ArrayList<>();
|
||||||
|
for (EntityType entityType : Groups.MOB_TYPES)
|
||||||
|
{
|
||||||
|
names.add(entityType.name());
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -52,16 +62,6 @@ public class Command_mobpurge extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getAllMobNames()
|
|
||||||
{
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
for (EntityType entityType : Groups.MOB_TYPES)
|
|
||||||
{
|
|
||||||
names.add(entityType.name());
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.SplittableRandom;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.minecraft.server.v1_16_R3.NBTTagCompound;
|
import net.minecraft.server.v1_16_R3.NBTTagCompound;
|
||||||
@ -24,6 +24,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
public class Command_modifyitem extends FreedomCommand
|
public class Command_modifyitem extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -52,6 +53,7 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
switch (args[0])
|
switch (args[0])
|
||||||
{
|
{
|
||||||
case "name":
|
case "name":
|
||||||
@ -178,7 +180,7 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
}
|
}
|
||||||
cmpnd.setDouble("Amount", amount);
|
cmpnd.setDouble("Amount", amount);
|
||||||
cmpnd.setInt("Operation", 0);
|
cmpnd.setInt("Operation", 0);
|
||||||
Random random = new Random();
|
SplittableRandom random = new SplittableRandom();
|
||||||
cmpnd.setIntArray("UUID", new int[]
|
cmpnd.setIntArray("UUID", new int[]
|
||||||
{
|
{
|
||||||
random.nextInt(),
|
random.nextInt(),
|
||||||
@ -188,6 +190,7 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
});
|
});
|
||||||
cmpnd.setString("Slot", "mainhand");
|
cmpnd.setString("Slot", "mainhand");
|
||||||
modifiers.add(cmpnd);
|
modifiers.add(cmpnd);
|
||||||
|
assert compound != null;
|
||||||
compound.set("AttributeModifiers", modifiers);
|
compound.set("AttributeModifiers", modifiers);
|
||||||
nmsStack.setTag(compound);
|
nmsStack.setTag(compound);
|
||||||
item = CraftItemStack.asBukkitCopy(nmsStack);
|
item = CraftItemStack.asBukkitCopy(nmsStack);
|
||||||
@ -237,17 +240,6 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
this.attribute = attribute;
|
this.attribute = attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAttribute()
|
|
||||||
{
|
|
||||||
return attribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attribute getByName(String name)
|
public static Attribute getByName(String name)
|
||||||
{
|
{
|
||||||
for (Attribute attr : Attribute.values())
|
for (Attribute attr : Attribute.values())
|
||||||
@ -259,5 +251,16 @@ public class Command_modifyitem extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAttribute()
|
||||||
|
{
|
||||||
|
return attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
@ -38,7 +39,7 @@ public class Command_mp44 extends FreedomCommand
|
|||||||
msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
|
msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
|
||||||
msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
|
msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
|
||||||
|
|
||||||
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.GUNPOWDER, 1));
|
Objects.requireNonNull(playerSender.getEquipment()).setItemInMainHand(new ItemStack(Material.GUNPOWDER, 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -20,7 +20,7 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/<command> [player]", aliases = "nc")
|
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/<command> [player]", aliases = "nc")
|
||||||
public class Command_nickclean extends FreedomCommand
|
public class Command_nickclean extends FreedomCommand
|
||||||
{
|
{
|
||||||
private Map<String, Color> colorCodes = new HashMap<String, Color>()
|
private final Map<String, Color> colorCodes = new HashMap<String, Color>()
|
||||||
{{
|
{{
|
||||||
put("&0", Color.BLACK);
|
put("&0", Color.BLACK);
|
||||||
put("&1", Color.BLUE);
|
put("&1", Color.BLUE);
|
||||||
@ -81,7 +81,7 @@ public class Command_nickclean extends FreedomCommand
|
|||||||
for (String split : nickName.split("§x"))
|
for (String split : nickName.split("§x"))
|
||||||
{
|
{
|
||||||
List<Color> colors = new ArrayList<>();
|
List<Color> colors = new ArrayList<>();
|
||||||
String hexColorSub = null;
|
String hexColorSub;
|
||||||
if (split.length() >= 12 && split.contains("§"))
|
if (split.length() >= 12 && split.contains("§"))
|
||||||
{
|
{
|
||||||
hexColorSub = split.substring(0, 12);
|
hexColorSub = split.substring(0, 12);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -20,6 +19,42 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_nickfilter extends FreedomCommand
|
public class Command_nickfilter extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static Player getPlayerByDisplayName(String needle)
|
||||||
|
{
|
||||||
|
needle = needle.toLowerCase().trim();
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (player.getDisplayName().toLowerCase().trim().contains(needle))
|
||||||
|
{
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Player getPlayerByDisplayNameAlt(String needle)
|
||||||
|
{
|
||||||
|
needle = needle.toLowerCase().trim();
|
||||||
|
|
||||||
|
Integer minEditDistance = null;
|
||||||
|
Player minEditMatch = null;
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
String haystack = player.getDisplayName().toLowerCase().trim();
|
||||||
|
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
|
||||||
|
if (minEditDistance == null || minEditDistance > editDistance)
|
||||||
|
{
|
||||||
|
minEditDistance = editDistance;
|
||||||
|
minEditMatch = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return minEditMatch;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -29,8 +64,7 @@ public class Command_nickfilter extends FreedomCommand
|
|||||||
|
|
||||||
if (args.length >= 1)
|
if (args.length >= 1)
|
||||||
{
|
{
|
||||||
final List<String> argsList = Arrays.asList(args);
|
for (String arg : args)
|
||||||
for (String arg : argsList)
|
|
||||||
{
|
{
|
||||||
Player player = null;
|
Player player = null;
|
||||||
|
|
||||||
@ -84,40 +118,4 @@ public class Command_nickfilter extends FreedomCommand
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Player getPlayerByDisplayName(String needle)
|
|
||||||
{
|
|
||||||
needle = needle.toLowerCase().trim();
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (player.getDisplayName().toLowerCase().trim().contains(needle))
|
|
||||||
{
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Player getPlayerByDisplayNameAlt(String needle)
|
|
||||||
{
|
|
||||||
needle = needle.toLowerCase().trim();
|
|
||||||
|
|
||||||
Integer minEditDistance = null;
|
|
||||||
Player minEditMatch = null;
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
String haystack = player.getDisplayName().toLowerCase().trim();
|
|
||||||
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
|
|
||||||
if (minEditDistance == null || minEditDistance.intValue() > editDistance)
|
|
||||||
{
|
|
||||||
minEditDistance = editDistance;
|
|
||||||
minEditMatch = player;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return minEditMatch;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -51,12 +51,12 @@ public class Command_notes extends FreedomCommand
|
|||||||
case "list":
|
case "list":
|
||||||
{
|
{
|
||||||
final StringBuilder noteList = new StringBuilder();
|
final StringBuilder noteList = new StringBuilder();
|
||||||
noteList.append(ChatColor.GREEN + "Player notes for " + playerData.getName() + ":");
|
noteList.append(ChatColor.GREEN).append("Player notes for ").append(playerData.getName()).append(":");
|
||||||
int id = 1;
|
int id = 1;
|
||||||
for (String note : playerData.getNotes())
|
for (String note : playerData.getNotes())
|
||||||
{
|
{
|
||||||
String noteLine = id + ". " + note;
|
String noteLine = id + ". " + note;
|
||||||
noteList.append("\n" + ChatColor.GOLD + noteLine);
|
noteList.append("\n").append(ChatColor.GOLD).append(noteLine);
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
msg(noteList.toString());
|
msg(noteList.toString());
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -54,7 +55,7 @@ public class Command_ops extends FreedomCommand
|
|||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
{
|
{
|
||||||
msg(player.getPlayer(), FreedomCommand.YOU_ARE_NOT_OP);
|
msg(Objects.requireNonNull(player.getPlayer()), FreedomCommand.YOU_ARE_NOT_OP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,9 +4,9 @@ import com.google.common.base.Strings;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -98,27 +98,6 @@ public class Command_panel extends FreedomCommand
|
|||||||
msg("Successfully deleted your Pterodactyl account.", ChatColor.GREEN);
|
msg("Successfully deleted your Pterodactyl account.", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*else if (args[0].equals("resetpassword"))
|
|
||||||
{
|
|
||||||
Admin admin = getAdmin(playerSender);
|
|
||||||
|
|
||||||
if (admin.getAmpUsername() == null)
|
|
||||||
{
|
|
||||||
msg("You do not have a Pterodactyl account.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Resetting your password...", ChatColor.GREEN);
|
|
||||||
|
|
||||||
String id = admin.getPteroID();
|
|
||||||
String password = FUtil.randomString(30);
|
|
||||||
plugin.ptero.setPassword(id, password);
|
|
||||||
plugin.dc.sendPteroInfo(playerData, null, password);
|
|
||||||
|
|
||||||
msg("Successfully reset your AMP account password. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,7 @@ public class Command_playerverification extends FreedomCommand
|
|||||||
{
|
{
|
||||||
PlayerData target = plugin.pl.getData(playerSender);
|
PlayerData target = plugin.pl.getData(playerSender);
|
||||||
boolean verificationEnabled = ConfigEntry.DISCORD_VERIFICATION.getBoolean();
|
boolean verificationEnabled = ConfigEntry.DISCORD_VERIFICATION.getBoolean();
|
||||||
List<String> ips = new ArrayList<>();
|
List<String> ips = new ArrayList<>(target.getIps());
|
||||||
ips.addAll(target.getIps());
|
|
||||||
|
|
||||||
if (verificationEnabled)
|
if (verificationEnabled)
|
||||||
{
|
{
|
||||||
@ -48,17 +47,9 @@ public class Command_playerverification extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("clearip"))
|
else if (args[0].equalsIgnoreCase("clearip"))
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
target.removeIp(args[1]);
|
|
||||||
msg("Removed" + args[1] + " from your list of IPs");
|
|
||||||
plugin.pl.save(target);
|
|
||||||
plugin.pl.syncIps(target);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
|
@ -3,8 +3,8 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.ActivityLogEntry;
|
import me.totalfreedom.totalfreedommod.admin.ActivityLogEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -45,16 +45,32 @@ public class Command_playtime extends FreedomCommand
|
|||||||
long cminutes = duration / (60 * 1000) % 60;
|
long cminutes = duration / (60 * 1000) % 60;
|
||||||
long chours = duration / (60 * 60 * 1000);
|
long chours = duration / (60 * 60 * 1000);
|
||||||
StringBuilder sb = new StringBuilder()
|
StringBuilder sb = new StringBuilder()
|
||||||
.append("Playtime - " + sender.getName() + "\n")
|
.append("Playtime - ")
|
||||||
.append("Current Session: " + chours + " hours, " + cminutes + " minutes, and " + cseconds + " seconds" + "\n")
|
.append(sender.getName())
|
||||||
.append("Overall: " + hours + " hours, " + minutes + " minutes, and " + seconds + " seconds" + "\n");
|
.append("\n")
|
||||||
|
.append("Current Session: ")
|
||||||
|
.append(chours)
|
||||||
|
.append(" hours, ")
|
||||||
|
.append(cminutes)
|
||||||
|
.append(" minutes, and ")
|
||||||
|
.append(cseconds)
|
||||||
|
.append(" seconds")
|
||||||
|
.append("\n")
|
||||||
|
.append("Overall: ")
|
||||||
|
.append(hours)
|
||||||
|
.append(" hours, ")
|
||||||
|
.append(minutes)
|
||||||
|
.append(" minutes, and ")
|
||||||
|
.append(seconds)
|
||||||
|
.append(" seconds")
|
||||||
|
.append("\n");
|
||||||
List<String> durations = entry.getDurations();
|
List<String> durations = entry.getDurations();
|
||||||
if (durations.size() >= 3)
|
if (durations.size() >= 3)
|
||||||
{
|
{
|
||||||
sb.append("Recent Sessions:");
|
sb.append("Recent Sessions:");
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
sb.append("\n" + " - " + durations.get((durations.size() - 1) - i));
|
sb.append("\n" + " - ").append(durations.get((durations.size() - 1) - i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg(sb.toString());
|
msg(sb.toString());
|
||||||
|
@ -38,7 +38,7 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
{
|
{
|
||||||
final String version = serverPlugin.getDescription().getVersion();
|
final String version = serverPlugin.getDescription().getVersion();
|
||||||
msg(ChatColor.GRAY + "- " + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + serverPlugin.getName()
|
msg(ChatColor.GRAY + "- " + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + serverPlugin.getName()
|
||||||
+ ChatColor.GOLD + (version != null && !version.isEmpty() ? " v" + version : "") + " by "
|
+ ChatColor.GOLD + (!version.isEmpty() ? " v" + version : "") + " by "
|
||||||
+ StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
|
+ StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
public class Command_potion extends FreedomCommand
|
public class Command_potion extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -178,8 +179,7 @@ public class Command_potion extends FreedomCommand
|
|||||||
switch (args.length)
|
switch (args.length)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
List<String> arguments = new ArrayList<>();
|
List<String> arguments = new ArrayList<>(Arrays.asList("list", "clear", "add"));
|
||||||
arguments.addAll(Arrays.asList("list", "clear", "add"));
|
|
||||||
if (plugin.al.isAdmin(sender))
|
if (plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
arguments.add("clearall");
|
arguments.add("clearall");
|
||||||
@ -203,14 +203,14 @@ public class Command_potion extends FreedomCommand
|
|||||||
case 3:
|
case 3:
|
||||||
if (args[0].equals("add"))
|
if (args[0].equals("add"))
|
||||||
{
|
{
|
||||||
return Arrays.asList("<duration>");
|
return Collections.singletonList("<duration>");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
if (args[0].equals("add"))
|
if (args[0].equals("add"))
|
||||||
{
|
{
|
||||||
return Arrays.asList("<amplifier>");
|
return Collections.singletonList("<amplifier>");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -19,11 +19,6 @@ import org.bukkit.entity.ThrownPotion;
|
|||||||
@CommandParameters(description = "Allows admins to see potions that are thrown.", usage = "/<command> <enable | on | disable | off> | history [player] <page>", aliases = "potspy")
|
@CommandParameters(description = "Allows admins to see potions that are thrown.", usage = "/<command> <enable | on | disable | off> | history [player] <page>", aliases = "potspy")
|
||||||
public class Command_potionspy extends FreedomCommand
|
public class Command_potionspy extends FreedomCommand
|
||||||
{
|
{
|
||||||
private String titleText = "&8&m------------------&r &ePotionSpy &8&m------------------&r";
|
|
||||||
private String validPageText = "Please specify a valid page number between 1 and %s.";
|
|
||||||
private String noPlayerRecord = "That player has not thrown any potions yet.";
|
|
||||||
private String splashedText = "&r%s splashed a potion at &eX: %s Y: %s Z: %s&r\nin the world '&e%s&r' about &e%s &rago%s.";
|
|
||||||
private String bottomText = "&8&m--------------------&r &e%s / %s &8&m--------------------&r";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
@ -37,6 +32,11 @@ public class Command_potionspy extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
String titleText = "&8&m------------------&r &ePotionSpy &8&m------------------&r";
|
||||||
|
String validPageText = "Please specify a valid page number between 1 and %s.";
|
||||||
|
String noPlayerRecord = "That player has not thrown any potions yet.";
|
||||||
|
String splashedText = "&r%s splashed a potion at &eX: %s Y: %s Z: %s&r\nin the world '&e%s&r' about &e%s &rago%s.";
|
||||||
|
String bottomText = "&8&m--------------------&r &e%s / %s &8&m--------------------&r";
|
||||||
switch (args[0].toLowerCase())
|
switch (args[0].toLowerCase())
|
||||||
{
|
{
|
||||||
case "enable":
|
case "enable":
|
||||||
@ -59,8 +59,7 @@ public class Command_potionspy extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>();
|
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>(plugin.mo.getPlayerThrownPotions(player)); // Make a copy of the list to avoid modifying the original.
|
||||||
thrownPotions.addAll(plugin.mo.getPlayerThrownPotions(player)); // Make a copy of the list to avoid modifying the original.
|
|
||||||
|
|
||||||
List<String> potionThrowNotifications = new ArrayList<>();
|
List<String> potionThrowNotifications = new ArrayList<>();
|
||||||
int lastPage = (int)Math.ceil(thrownPotions.size() / 5.0);
|
int lastPage = (int)Math.ceil(thrownPotions.size() / 5.0);
|
||||||
|
@ -47,7 +47,7 @@ public class Command_premium extends FreedomCommand
|
|||||||
final URL getUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
|
final URL getUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
|
||||||
final HttpURLConnection urlConnection = (HttpURLConnection)getUrl.openConnection();
|
final HttpURLConnection urlConnection = (HttpURLConnection)getUrl.openConnection();
|
||||||
urlConnection.setRequestProperty("User-Agent", "");
|
urlConnection.setRequestProperty("User-Agent", "");
|
||||||
String message = "";
|
String message;
|
||||||
/*old code
|
/*old code
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
|
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
|
||||||
//message = (!"PREMIUM".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
|
//message = (!"PREMIUM".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_releaseparrots extends FreedomCommand
|
public class Command_releaseparrots extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,46 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_ro extends FreedomCommand
|
public class Command_ro extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius)
|
||||||
|
{
|
||||||
|
int affected = 0;
|
||||||
|
|
||||||
|
Block centerBlock = center.getBlock();
|
||||||
|
for (int xOffset = -radius; xOffset <= radius; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -radius; yOffset <= radius; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||||
|
{
|
||||||
|
Block block = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
BlockData data = block.getBlockData();
|
||||||
|
if (block.getLocation().distanceSquared(center) < (radius * radius))
|
||||||
|
{
|
||||||
|
if (fromMaterial.equals(Material.WATER) && data instanceof Waterlogged)
|
||||||
|
{
|
||||||
|
Waterlogged waterloggedData = (Waterlogged)data;
|
||||||
|
if (waterloggedData.isWaterlogged())
|
||||||
|
{
|
||||||
|
waterloggedData.setWaterlogged(false);
|
||||||
|
block.setBlockData(waterloggedData);
|
||||||
|
affected++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
block.setType(toMaterial);
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
else if (block.getType().equals(fromMaterial))
|
||||||
|
{
|
||||||
|
block.setType(toMaterial);
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return affected;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -97,7 +137,7 @@ public class Command_ro extends FreedomCommand
|
|||||||
{
|
{
|
||||||
adminWorld = plugin.wm.adminworld.getWorld();
|
adminWorld = plugin.wm.adminworld.getWorld();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,47 +174,4 @@ public class Command_ro extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Remove complete! " + affected + " blocks removed.", false);
|
FUtil.adminAction(sender.getName(), "Remove complete! " + affected + " blocks removed.", false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius)
|
|
||||||
{
|
|
||||||
int affected = 0;
|
|
||||||
|
|
||||||
Block centerBlock = center.getBlock();
|
|
||||||
for (int xOffset = -radius; xOffset <= radius; xOffset++)
|
|
||||||
{
|
|
||||||
for (int yOffset = -radius; yOffset <= radius; yOffset++)
|
|
||||||
{
|
|
||||||
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
|
||||||
{
|
|
||||||
Block block = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
|
||||||
BlockData data = block.getBlockData();
|
|
||||||
if (block.getLocation().distanceSquared(center) < (radius * radius))
|
|
||||||
{
|
|
||||||
if (fromMaterial.equals(Material.WATER) && data instanceof Waterlogged)
|
|
||||||
{
|
|
||||||
if (data instanceof Waterlogged)
|
|
||||||
{
|
|
||||||
Waterlogged waterloggedData = (Waterlogged)data;
|
|
||||||
if (waterloggedData.isWaterlogged())
|
|
||||||
{
|
|
||||||
waterloggedData.setWaterlogged(false);
|
|
||||||
block.setBlockData(waterloggedData);
|
|
||||||
affected++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
block.setType(toMaterial);
|
|
||||||
affected++;
|
|
||||||
}
|
|
||||||
else if (block.getType().equals(fromMaterial))
|
|
||||||
{
|
|
||||||
block.setType(toMaterial);
|
|
||||||
affected++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return affected;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ public class Command_rock extends FreedomCommand
|
|||||||
{
|
{
|
||||||
final ItemStack heldItem = new ItemStack(Material.STONE);
|
final ItemStack heldItem = new ItemStack(Material.STONE);
|
||||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
|
assert heldItemMeta != null;
|
||||||
heldItemMeta.setDisplayName(ChatColor.BLUE + "Rock");
|
heldItemMeta.setDisplayName(ChatColor.BLUE + "Rock");
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -176,7 +176,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the old admin entry
|
// Find the old admin entry
|
||||||
String name = player != null ? player.getName() : args[1];
|
String name = player.getName();
|
||||||
Admin admin = null;
|
Admin admin = null;
|
||||||
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||||
{
|
{
|
||||||
@ -195,33 +195,24 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (admin == null) // New admin
|
if (admin == null) // New admin
|
||||||
{
|
{
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||||
admin = new Admin(player);
|
admin = new Admin(player);
|
||||||
|
|
||||||
plugin.al.addAdmin(admin);
|
plugin.al.addAdmin(admin);
|
||||||
plugin.rm.updateDisplay(player);
|
plugin.rm.updateDisplay(player);
|
||||||
plugin.ptero.updateAccountStatus(admin);
|
|
||||||
}
|
}
|
||||||
else // Existing admin
|
else // Existing admin
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the admin list", true);
|
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the admin list", true);
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
String oldName = admin.getName();
|
String oldName = admin.getName();
|
||||||
if (oldName != player.getName())
|
if (!oldName.equals(player.getName()))
|
||||||
{
|
{
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||||
}
|
}
|
||||||
admin.addIp(FUtil.getIp(player));
|
admin.addIp(FUtil.getIp(player));
|
||||||
}
|
|
||||||
|
|
||||||
admin.setActive(true);
|
admin.setActive(true);
|
||||||
admin.setLastLogin(new Date());
|
admin.setLastLogin(new Date());
|
||||||
@ -234,20 +225,15 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
plugin.al.save(admin);
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
plugin.rm.updateDisplay(player);
|
plugin.rm.updateDisplay(player);
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
plugin.ptero.updateAccountStatus(admin);
|
plugin.ptero.updateAccountStatus(admin);
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
if (fPlayer.getFreezeData().isFrozen())
|
if (fPlayer.getFreezeData().isFrozen())
|
||||||
{
|
{
|
||||||
@ -260,7 +246,6 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
player.sendMessage(YOU_ARE_OP);
|
player.sendMessage(YOU_ARE_OP);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.type.Switch;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.material.Lever;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on|off>")
|
@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on|off>")
|
||||||
@ -65,9 +66,11 @@ public class Command_setlever extends FreedomCommand
|
|||||||
if (targetBlock.getType() == Material.LEVER)
|
if (targetBlock.getType() == Material.LEVER)
|
||||||
{
|
{
|
||||||
BlockState state = targetBlock.getState();
|
BlockState state = targetBlock.getState();
|
||||||
Lever lever = (Lever)state.getData();
|
BlockData data = state.getBlockData();
|
||||||
lever.setPowered(leverOn);
|
Switch caster = (Switch)data;
|
||||||
state.setData(lever);
|
|
||||||
|
caster.setPowered(leverOn);
|
||||||
|
state.setBlockData(data);
|
||||||
state.update();
|
state.update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -59,6 +59,7 @@ public class Command_setplayerlimit extends FreedomCommand
|
|||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
assert player != null;
|
||||||
FUtil.adminAction(sender.getName(), "Setting " + player.getName() + "'s WorldEdit block modification limit to " + amount + ".", true);
|
FUtil.adminAction(sender.getName(), "Setting " + player.getName() + "'s WorldEdit block modification limit to " + amount + ".", true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -19,51 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_smite extends FreedomCommand
|
public class Command_smite extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String reason = null;
|
|
||||||
boolean silent = false;
|
|
||||||
if (args.length >= 2)
|
|
||||||
{
|
|
||||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
|
||||||
{
|
|
||||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
|
||||||
{
|
|
||||||
silent = 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), " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
smite(sender, player, reason, silent);
|
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void smite(CommandSender sender, Player player)
|
public static void smite(CommandSender sender, Player player)
|
||||||
{
|
{
|
||||||
smite(sender, player, null, false);
|
smite(sender, player, null, false);
|
||||||
@ -122,4 +77,49 @@ public class Command_smite extends FreedomCommand
|
|||||||
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Reason: " + reason, 20, 100, 60);
|
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Reason: " + reason, 20, 100, 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
boolean silent = false;
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = 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), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
smite(sender, player, reason, silent);
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user