mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
4ddcc3b8d7 | |||
43ee17807a | |||
d1cc694742 | |||
abbadb55ee | |||
a2a4a8a0b8 | |||
c49abd1f4a | |||
dd5e256c84 | |||
321d9f97e0 | |||
721c2dc18e | |||
a523cc313c |
@ -61,9 +61,59 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldguard-bukkit:7.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.16.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino:1.7.11" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.16.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:NMSProvider:2.16.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:UpdatedMetaProvider:2.16.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R1Provider:2.16.1" level="project" />
|
||||
@ -87,20 +137,11 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.16.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: rhino:js:1.7R2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
@ -117,5 +158,8 @@
|
||||
<orderEntry type="library" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.vexsoftware:votifier:v1.9" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ConnorLinfoot:ActionBarAPI:5b2d642d3d" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.goldtreeservers:worldguardextraflags:4.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.boydti:fawe-api:17.07.12-6b6f285-750-13.7.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13-SNAPSHOT" level="project" />
|
||||
</component>
|
||||
</module>
|
7
pom.xml
7
pom.xml
@ -225,6 +225,13 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.goldtreeservers</groupId>
|
||||
<artifactId>worldguardextraflags</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -159,7 +159,7 @@ public class ChatManager extends FreedomService
|
||||
// Send to discord
|
||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist())
|
||||
{
|
||||
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,8 @@ public class EntityWiper extends FreedomService
|
||||
EntityType.PAINTING,
|
||||
EntityType.BOAT,
|
||||
EntityType.LEASH_HITCH,
|
||||
EntityType.ITEM_FRAME
|
||||
EntityType.ITEM_FRAME,
|
||||
EntityType.MINECART
|
||||
);
|
||||
|
||||
@Override
|
||||
@ -61,7 +62,7 @@ public class EntityWiper extends FreedomService
|
||||
{
|
||||
if (!(entity instanceof Player))
|
||||
{
|
||||
if (!bypassBlacklist && (BLACKLIST.contains(entity.getType()) || Groups.MOB_TYPES.contains(entity.getType())))
|
||||
if ((!bypassBlacklist && BLACKLIST.contains(entity.getType())) || Groups.MOB_TYPES.contains(entity.getType()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class Fuckoff extends FreedomService
|
||||
|
||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||
{
|
||||
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
||||
onlinePlayer.setVelocity(onlinePlayer.getLocation().toVector().subtract(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public class LoginProcess extends FreedomService
|
||||
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
|
||||
player.setOp(true);
|
||||
|
||||
if (TELEPORT_ON_JOIN.contains(player.getName()))
|
||||
if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
|
||||
{
|
||||
int x = FUtil.randomInteger(-10000, 10000);
|
||||
int z = FUtil.randomInteger(-10000, 10000);
|
||||
@ -210,7 +210,7 @@ public class LoginProcess extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (CLEAR_ON_JOIN.contains(player.getName()))
|
||||
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
||||
{
|
||||
player.getInventory().clear();
|
||||
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
||||
|
@ -45,6 +45,8 @@ public class Muter extends FreedomService
|
||||
|
||||
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||
|
||||
FLog.info("checking mute");
|
||||
|
||||
if (!fPlayer.isMuted())
|
||||
{
|
||||
return;
|
||||
@ -57,14 +59,7 @@ public class Muter extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (fPlayer.isQuietMuted())
|
||||
{
|
||||
FSync.playerMsg(event.getPlayer(), event.getFormat());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
|
||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,8 @@ import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.amp.AMP;
|
||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
||||
import me.totalfreedom.totalfreedommod.banning.VPNBanList;
|
||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||
@ -40,15 +38,15 @@ import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderWorldRestrictions;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||
@ -97,6 +95,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
public AntiSpam as;
|
||||
public PlayerList pl;
|
||||
public Shop sh;
|
||||
public SQLite sql;
|
||||
public Announcer an;
|
||||
public ChatManager cm;
|
||||
public Discord dc;
|
||||
@ -104,10 +103,8 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
public BanManager bm;
|
||||
public PermbanList pm;
|
||||
public PermissionManager pem;
|
||||
public VPNBanList vn;
|
||||
public ProtectArea pa;
|
||||
public GameRuleHandler gr;
|
||||
public RollbackManager rb;
|
||||
public CommandSpy cs;
|
||||
public Cager ca;
|
||||
public Freezer fm;
|
||||
@ -130,7 +127,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
public Trailer tr;
|
||||
public HTTPDaemon hd;
|
||||
public MasterBuilderList mbl;
|
||||
public MasterBuilderWorldRestrictions mbwr;
|
||||
public WorldRestrictions wr;
|
||||
public SignBlocker snp;
|
||||
public PlayerVerification pv;
|
||||
public EntityWiper ew;
|
||||
@ -145,7 +142,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
public CoreProtectBridge cpb;
|
||||
public WorldEditBridge web;
|
||||
public WorldGuardBridge wgb;
|
||||
public AMP amp;
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
@ -181,9 +177,9 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
backups.createBackups(AdminList.CONFIG_FILENAME);
|
||||
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
||||
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
||||
backups.createBackups(VPNBanList.CONFIG_FILENAME);
|
||||
backups.createBackups(MasterBuilder.CONFIG_FILENAME);
|
||||
backups.createBackups(PunishmentList.CONFIG_FILENAME);
|
||||
backups.createBackups("");
|
||||
|
||||
config = new MainConfig(this);
|
||||
config.load();
|
||||
@ -197,6 +193,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
sf = services.registerService(SavedFlags.class);
|
||||
wm = services.registerService(WorldManager.class);
|
||||
lv = services.registerService(LogViewer.class);
|
||||
sql = services.registerService(SQLite.class);
|
||||
al = services.registerService(AdminList.class);
|
||||
acl = services.registerService(ActivityLog.class);
|
||||
rm = services.registerService(RankManager.class);
|
||||
@ -211,8 +208,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
nu = services.registerService(AntiNuke.class);
|
||||
as = services.registerService(AntiSpam.class);
|
||||
mbl = services.registerService(MasterBuilderList.class);
|
||||
mbwr = services.registerService(MasterBuilderWorldRestrictions.class);
|
||||
//hwr = services.registerService(HubWorldRestrictions.class);
|
||||
wr = services.registerService(WorldRestrictions.class);
|
||||
pl = services.registerService(PlayerList.class);
|
||||
sh = services.registerService(Shop.class);
|
||||
an = services.registerService(Announcer.class);
|
||||
@ -222,14 +218,12 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
bm = services.registerService(BanManager.class);
|
||||
pm = services.registerService(PermbanList.class);
|
||||
pem = services.registerService(PermissionManager.class);
|
||||
vn = services.registerService(VPNBanList.class);
|
||||
pa = services.registerService(ProtectArea.class);
|
||||
gr = services.registerService(GameRuleHandler.class);
|
||||
snp = services.registerService(SignBlocker.class);
|
||||
ew = services.registerService(EntityWiper.class);
|
||||
|
||||
// Single admin utils
|
||||
rb = services.registerService(RollbackManager.class);
|
||||
cs = services.registerService(CommandSpy.class);
|
||||
ca = services.registerService(Cager.class);
|
||||
fm = services.registerService(Freezer.class);
|
||||
@ -269,7 +263,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
ldb = bridges.registerService(LibsDisguisesBridge.class);
|
||||
web = bridges.registerService(WorldEditBridge.class);
|
||||
wgb = bridges.registerService(WorldGuardBridge.class);
|
||||
amp = bridges.registerService(AMP.class);
|
||||
bridges.start();
|
||||
|
||||
timer.update();
|
||||
|
@ -1,30 +1,26 @@
|
||||
package me.totalfreedom.totalfreedommod.admin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.base.ConfigLoadable;
|
||||
import net.pravian.aero.base.ConfigSavable;
|
||||
import net.pravian.aero.base.Validatable;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||
public class Admin
|
||||
{
|
||||
|
||||
@Getter
|
||||
private String configKey;
|
||||
@Getter
|
||||
@Setter
|
||||
private String name;
|
||||
@ -68,14 +64,28 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||
|
||||
public Admin(Player player)
|
||||
{
|
||||
this.configKey = player.getName().toLowerCase();
|
||||
this.name = player.getName();
|
||||
this.ips.add(Ips.getIp(player));
|
||||
}
|
||||
|
||||
public Admin(String configKey)
|
||||
public Admin(String username, List<String> ips, Rank rank, Boolean active, Date lastLogin, String loginMessage, String tag, String discordID, List<String> backupCodes, Boolean commandSpy, Boolean potionSpy, String acFormat, Boolean oldTags, Boolean logStick)
|
||||
{
|
||||
this.configKey = configKey;
|
||||
this.name = username;
|
||||
this.active = active;
|
||||
this.rank = rank;
|
||||
this.ips.clear();
|
||||
this.ips.addAll(ips);
|
||||
this.lastLogin = lastLogin;
|
||||
this.loginMessage = loginMessage;
|
||||
this.tag = tag;
|
||||
this.discordID = discordID;
|
||||
this.backupCodes.clear();
|
||||
this.backupCodes.addAll(backupCodes);
|
||||
this.commandSpy = commandSpy;
|
||||
this.potionSpy = potionSpy;
|
||||
this.acFormat = acFormat;
|
||||
this.oldTags = oldTags;
|
||||
this.logStick = logStick;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,59 +104,39 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
||||
.append("- Old Tags: ").append(oldTags).append("\n")
|
||||
.append("- Log Stick: ").append(logStick)
|
||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
|
||||
.append("- Log Stick: ").append(logStick).append("\n")
|
||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10");
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
public void loadFrom(Player player)
|
||||
{
|
||||
configKey = player.getName().toLowerCase();
|
||||
name = player.getName();
|
||||
ips.clear();
|
||||
ips.add(Ips.getIp(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFrom(ConfigurationSection cs)
|
||||
public Map<String, Object> toSQLStorable()
|
||||
{
|
||||
name = cs.getString("username", configKey);
|
||||
active = cs.getBoolean("active", true);
|
||||
rank = Rank.findRank(cs.getString("rank"));
|
||||
ips.clear();
|
||||
ips.addAll(cs.getStringList("ips"));
|
||||
backupCodes.clear();
|
||||
backupCodes.addAll(cs.getStringList("backupCodes"));
|
||||
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
|
||||
loginMessage = cs.getString("login_message", null);
|
||||
discordID = cs.getString("discord_id", null);
|
||||
tag = cs.getString("tag", null);
|
||||
commandSpy = cs.getBoolean("command_spy", false);
|
||||
potionSpy = cs.getBoolean("potion_spy", false);
|
||||
acFormat = cs.getString("acformat", null);
|
||||
oldTags = cs.getBoolean("oldtags", false);
|
||||
logStick = cs.getBoolean("logstick", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTo(ConfigurationSection cs)
|
||||
{
|
||||
Validate.isTrue(isValid(), "Could not save admin entry: " + name + ". Entry not valid!");
|
||||
cs.set("username", name);
|
||||
cs.set("active", active);
|
||||
cs.set("rank", rank.toString());
|
||||
cs.set("ips", Lists.newArrayList(ips));
|
||||
cs.set("backupCodes", Lists.newArrayList(backupCodes));
|
||||
cs.set("last_login", FUtil.dateToString(lastLogin));
|
||||
cs.set("login_message", loginMessage);
|
||||
cs.set("discord_id", discordID);
|
||||
cs.set("tag", tag);
|
||||
cs.set("command_spy", commandSpy);
|
||||
cs.set("potion_spy", potionSpy);
|
||||
cs.set("acformat", acFormat);
|
||||
cs.set("oldtags", oldTags);
|
||||
cs.set("logstick", logStick);
|
||||
Map<String, Object> map = new HashMap<String, Object>()
|
||||
{{
|
||||
put("username", name);
|
||||
put("active", active);
|
||||
put("rank", rank.toString());
|
||||
put("ips", FUtil.listToString(ips));
|
||||
put("backup_codes", FUtil.listToString(backupCodes));
|
||||
put("last_login", lastLogin.getTime());
|
||||
put("login_message", loginMessage);
|
||||
put("discord_id", discordID);
|
||||
put("tag", tag);
|
||||
put("command_spy", commandSpy);
|
||||
put("potion_spy", potionSpy);
|
||||
put("ac_format", acFormat);
|
||||
put("old_tags", oldTags);
|
||||
put("log_stick", logStick);
|
||||
}};
|
||||
return map;
|
||||
}
|
||||
|
||||
public boolean isAtLeast(Rank pRank)
|
||||
@ -225,11 +215,9 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return configKey != null
|
||||
&& name != null
|
||||
return name != null
|
||||
&& rank != null
|
||||
&& !ips.isEmpty()
|
||||
&& lastLogin != null;
|
||||
|
@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod.admin;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -20,7 +22,6 @@ import net.pravian.aero.config.YamlConfig;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
@ -30,7 +31,7 @@ public class AdminList extends FreedomService
|
||||
public static final String CONFIG_FILENAME = "admins.yml";
|
||||
|
||||
@Getter
|
||||
private final Map<String, Admin> allAdmins = Maps.newHashMap(); // Includes disabled admins
|
||||
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||
// Only active admins below
|
||||
@Getter
|
||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||
@ -69,7 +70,6 @@ public class AdminList extends FreedomService
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
public void load()
|
||||
@ -77,47 +77,40 @@ public class AdminList extends FreedomService
|
||||
config.load();
|
||||
|
||||
allAdmins.clear();
|
||||
for (String key : config.getKeys(false))
|
||||
try
|
||||
{
|
||||
ConfigurationSection section = config.getConfigurationSection(key);
|
||||
if (section == null)
|
||||
ResultSet adminSet = plugin.sql.getAdminList();
|
||||
{
|
||||
logger.warning("Invalid admin list format: " + key);
|
||||
continue;
|
||||
while (adminSet.next())
|
||||
{
|
||||
String name = adminSet.getString("username");
|
||||
List<String> ips = FUtil.stringToList(adminSet.getString("ips"));
|
||||
Rank rank = Rank.findRank(adminSet.getString("rank"));
|
||||
Boolean active = adminSet.getBoolean("active");;
|
||||
Date lastLogin = new Date(adminSet.getLong("last_login"));
|
||||
String loginMessage = adminSet.getString("login_message");
|
||||
String tag = adminSet.getString("tag");
|
||||
String discordID = adminSet.getString("discord_id");
|
||||
List<String> backupCodes = FUtil.stringToList(adminSet.getString("backup_codes"));
|
||||
Boolean commandSpy = adminSet.getBoolean("command_spy");
|
||||
Boolean potionSpy = adminSet.getBoolean("potion_spy");
|
||||
String acFormat = adminSet.getString("ac_format");
|
||||
Boolean oldTags = adminSet.getBoolean("old_tags");
|
||||
Boolean logStick = adminSet.getBoolean("log_stick");
|
||||
Admin admin = new Admin(name, ips, rank, active, lastLogin, loginMessage, tag, discordID, backupCodes, commandSpy, potionSpy, acFormat, oldTags, logStick);
|
||||
allAdmins.add(admin);
|
||||
}
|
||||
}
|
||||
|
||||
Admin admin = new Admin(key);
|
||||
admin.loadFrom(section);
|
||||
|
||||
if (!admin.isValid())
|
||||
{
|
||||
FLog.warning("Could not load admin: " + key + ". Missing details!");
|
||||
continue;
|
||||
}
|
||||
|
||||
allAdmins.put(key, admin);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to get adminlist: " + e.getMessage());
|
||||
}
|
||||
|
||||
updateTables();
|
||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
// Clear the config
|
||||
for (String key : config.getKeys(false))
|
||||
{
|
||||
config.set(key, null);
|
||||
}
|
||||
|
||||
for (Admin admin : allAdmins.values())
|
||||
{
|
||||
admin.saveTo(config.createSection(admin.getConfigKey()));
|
||||
}
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void messageAllAdmins(String message)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
@ -194,7 +187,7 @@ public class AdminList extends FreedomService
|
||||
{
|
||||
// Add the new IP if we have to
|
||||
admin.addIp(ip);
|
||||
save();
|
||||
save(admin);
|
||||
updateTables();
|
||||
}
|
||||
return admin;
|
||||
@ -206,8 +199,9 @@ public class AdminList extends FreedomService
|
||||
if (admin != null)
|
||||
{
|
||||
// Set the new username
|
||||
String oldName = admin.getName();
|
||||
admin.setName(player.getName());
|
||||
save();
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
updateTables();
|
||||
}
|
||||
|
||||
@ -253,7 +247,7 @@ public class AdminList extends FreedomService
|
||||
|
||||
admin.setLastLogin(new Date());
|
||||
admin.setName(player.getName());
|
||||
save();
|
||||
save(admin);
|
||||
}
|
||||
|
||||
public boolean isAdminImpostor(Player player)
|
||||
@ -281,19 +275,16 @@ public class AdminList extends FreedomService
|
||||
{
|
||||
if (!admin.isValid())
|
||||
{
|
||||
logger.warning("Could not add admin: " + admin.getConfigKey() + " Admin is missing details!");
|
||||
logger.warning("Could not add admin: " + admin.getName() + " Admin is missing details!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String key = admin.getConfigKey();
|
||||
|
||||
// Store admin, update views
|
||||
allAdmins.put(key, admin);
|
||||
allAdmins.add(admin);
|
||||
updateTables();
|
||||
|
||||
// Save admin
|
||||
admin.saveTo(config.createSection(key));
|
||||
config.save();
|
||||
plugin.sql.addAdmin(admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -309,15 +300,14 @@ public class AdminList extends FreedomService
|
||||
}
|
||||
|
||||
// Remove admin, update views
|
||||
if (allAdmins.remove(admin.getConfigKey()) == null)
|
||||
if (!allAdmins.remove(admin))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
updateTables();
|
||||
|
||||
// 'Unsave' admin
|
||||
config.set(admin.getConfigKey(), null);
|
||||
config.save();
|
||||
// Unsave admin
|
||||
plugin.sql.removeAdmin(admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -328,7 +318,7 @@ public class AdminList extends FreedomService
|
||||
nameTable.clear();
|
||||
ipTable.clear();
|
||||
|
||||
for (Admin admin : allAdmins.values())
|
||||
for (Admin admin : allAdmins)
|
||||
{
|
||||
if (!admin.isActive())
|
||||
{
|
||||
@ -358,9 +348,29 @@ public class AdminList extends FreedomService
|
||||
return ipTable.keySet();
|
||||
}
|
||||
|
||||
public void save(Admin admin)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
|
||||
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
||||
{
|
||||
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
||||
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null)
|
||||
{
|
||||
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to save admin: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivateOldEntries(boolean verbose)
|
||||
{
|
||||
for (Admin admin : allAdmins.values())
|
||||
for (Admin admin : allAdmins)
|
||||
{
|
||||
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
||||
{
|
||||
@ -381,9 +391,9 @@ public class AdminList extends FreedomService
|
||||
}
|
||||
|
||||
admin.setActive(false);
|
||||
save(admin);
|
||||
}
|
||||
|
||||
save();
|
||||
updateTables();
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.amp;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
|
||||
|
||||
public class AMP extends FreedomService
|
||||
{
|
||||
public AMPManager ampManager;
|
||||
public Boolean enabled = false;
|
||||
|
||||
public AMP(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
if (!plugin.config.getBoolean(ConfigEntry.AMP_ENABLED))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ampManager = new AMPManager(plugin, plugin.config.getString(ConfigEntry.AMP_URL), plugin.config.getString(ConfigEntry.AMP_USERNAME), plugin.config.getString(ConfigEntry.AMP_PASSWORD));
|
||||
LoginCallback callback = new LoginCallback()
|
||||
{
|
||||
@Override
|
||||
public void loginDone(boolean success)
|
||||
{
|
||||
enabled = success;
|
||||
}
|
||||
};
|
||||
ampManager.connectAsync(callback);
|
||||
|
||||
}
|
||||
|
||||
public void restartServer()
|
||||
{
|
||||
ampManager.restartAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.amp;
|
||||
|
||||
|
||||
public enum AMPEndpoints
|
||||
{
|
||||
LOGIN("/API/Core/Login", "{username:\"%s\", password:\"%s\", token:\"\", rememberMe:false}"),
|
||||
RESTART("/API/Core/Restart", "{SESSIONID:\"%s\"}");
|
||||
|
||||
private final String text;
|
||||
private final String parameters;
|
||||
|
||||
AMPEndpoints(String text, String parameters)
|
||||
{
|
||||
this.text = text;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getParameters()
|
||||
{
|
||||
return parameters;
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.amp;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class AMPManager
|
||||
{
|
||||
private TotalFreedomMod plugin;
|
||||
private String url, username, password;
|
||||
private String sessionID;
|
||||
|
||||
|
||||
public AMPManager(TotalFreedomMod plugin, String url, String username, String password)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.url = url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void connectAsync(final LoginCallback callback)
|
||||
{
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String apiEndpoint = url + AMPEndpoints.LOGIN.toString();
|
||||
String body = String.format(AMPEndpoints.LOGIN.getParameters(), username, password);
|
||||
try
|
||||
{
|
||||
LoginResult resp = new Gson().fromJson(postRequestToEndpoint(apiEndpoint, body), LoginResult.class);
|
||||
if (!resp.getSuccess())
|
||||
{
|
||||
FLog.severe("AMP login unsuccessful. Check if login details are correct.");
|
||||
sessionID = "";
|
||||
callback.loginDone(false);
|
||||
return;
|
||||
}
|
||||
sessionID = resp.getSessionID();
|
||||
callback.loginDone(true);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
FLog.severe("Could not login to AMP. Check if URL is correct. Stacktrace: " + ex.getMessage());
|
||||
sessionID = "";
|
||||
callback.loginDone(false);
|
||||
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
public void restartAsync()
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final String apiEndpoint = url + AMPEndpoints.RESTART.toString();
|
||||
final String body = String.format(AMPEndpoints.RESTART.getParameters(), sessionID);
|
||||
try
|
||||
{
|
||||
String resp = postRequestToEndpoint(apiEndpoint, body);
|
||||
if (resp.contains("Unauthorized Access"))
|
||||
{
|
||||
//try connecting one more time
|
||||
LoginCallback callback = new LoginCallback()
|
||||
{
|
||||
@Override
|
||||
public void loginDone(boolean success)
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
FLog.severe("Failed to connect to AMP. Did the panel go down? Were panel user details changed/deleted? Check for more info above. Connection was successful when plugin started, but unsuccessful now." +
|
||||
" Using server.shutdown() instead.");
|
||||
plugin.getServer().shutdown();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String response = postRequestToEndpoint(apiEndpoint, body);
|
||||
if (response.contains("Unauthorized Access"))
|
||||
{
|
||||
FLog.severe("Contact a developer. Panel gives Session ID but trying to use it gives a no perms error. The panel user set in config doesn't" +
|
||||
" have perms to restart server. Using server.shutdown() instead. ");
|
||||
plugin.getServer().shutdown();
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace" + e.getMessage());
|
||||
plugin.getServer().shutdown();
|
||||
}
|
||||
}
|
||||
};
|
||||
plugin.amp.ampManager.connectAsync(callback);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace: " + ex.getMessage());
|
||||
plugin.getServer().shutdown();
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
|
||||
private String postRequestToEndpoint(String endpoint, String body) throws IOException
|
||||
{
|
||||
URL url = new URL(endpoint);
|
||||
if (endpoint.startsWith("https://"))
|
||||
{
|
||||
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.writeBytes(body);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
|
||||
while ((inputLine = in.readLine()) != null)
|
||||
{
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
return response.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.writeBytes(body);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
|
||||
while ((inputLine = in.readLine()) != null)
|
||||
{
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
return response.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.amp;
|
||||
|
||||
public interface LoginCallback
|
||||
{
|
||||
void loginDone(boolean success);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.amp;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class LoginResult
|
||||
{
|
||||
|
||||
@SerializedName("result")
|
||||
@Expose
|
||||
@Getter
|
||||
@Setter
|
||||
private Integer result;
|
||||
@SerializedName("success")
|
||||
@Expose
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean success;
|
||||
@SerializedName("permissions")
|
||||
@Expose
|
||||
@Getter
|
||||
@Setter
|
||||
private List<String> permissions = null;
|
||||
@SerializedName("sessionID")
|
||||
@Expose
|
||||
@Getter
|
||||
@Setter
|
||||
private String sessionID;
|
||||
@SerializedName("rememberMeToken")
|
||||
@Expose
|
||||
@Getter
|
||||
@Setter
|
||||
private String rememberMeToken;
|
||||
@SerializedName("gravatarHash")
|
||||
@Expose
|
||||
@Getter
|
||||
@Setter
|
||||
private String gravatarHash;
|
||||
@SerializedName("username")
|
||||
@Expose
|
||||
@Getter
|
||||
@Setter
|
||||
private String username;
|
||||
private final static long serialVersionUID = -523050232433919883L;
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@ -14,16 +15,13 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.base.ConfigLoadable;
|
||||
import net.pravian.aero.base.ConfigSavable;
|
||||
import net.pravian.aero.base.Validatable;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||
public class Ban implements Validatable
|
||||
{
|
||||
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
@ -53,22 +51,19 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
|
||||
{
|
||||
this(username,
|
||||
new String[]
|
||||
{
|
||||
ip
|
||||
},
|
||||
Arrays.asList(ip),
|
||||
by,
|
||||
at,
|
||||
expire,
|
||||
reason);
|
||||
}
|
||||
|
||||
public Ban(String username, String[] ips, String by, Date at, Date expire, String reason)
|
||||
public Ban(String username, List<String> ips, String by, Date at, Date expire, String reason)
|
||||
{
|
||||
this.username = username;
|
||||
if (ips != null)
|
||||
{
|
||||
this.ips.addAll(Arrays.asList(ips));
|
||||
this.ips.addAll(ips);
|
||||
}
|
||||
dedupeIps();
|
||||
this.by = by;
|
||||
@ -86,10 +81,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||
|
||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||
{
|
||||
return new Ban(null, new String[]
|
||||
{
|
||||
Ips.getIp(player)
|
||||
}, by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||
return new Ban(null, Arrays.asList(Ips.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||
}
|
||||
|
||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||
@ -107,7 +99,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||
{
|
||||
return new Ban(player,
|
||||
(String[])null,
|
||||
new ArrayList<String>(),
|
||||
by.getName(),
|
||||
Date.from(Instant.now()),
|
||||
expiry,
|
||||
@ -171,7 +163,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||
}
|
||||
|
||||
public String bakeKickMessage(String ip)
|
||||
public String bakeKickMessage()
|
||||
{
|
||||
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
||||
|
||||
@ -203,9 +195,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
||||
}
|
||||
|
||||
message.append("\n").append(ChatColor.RED).append("IP Address: ").append(ChatColor.GOLD)
|
||||
.append(ip);
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
@ -246,31 +235,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFrom(ConfigurationSection cs)
|
||||
{
|
||||
this.username = cs.getString("username", null);
|
||||
this.ips.clear();
|
||||
this.ips.addAll(cs.getStringList("ips"));
|
||||
this.by = cs.getString("by", null);
|
||||
this.at = FUtil.stringToDate(cs.getString("at", null));
|
||||
this.reason = cs.getString("reason", null);
|
||||
this.expiryUnix = cs.getLong("expiry_unix", 0);
|
||||
dedupeIps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTo(ConfigurationSection cs)
|
||||
{
|
||||
dedupeIps();
|
||||
cs.set("username", username);
|
||||
cs.set("ips", ips.isEmpty() ? null : ips);
|
||||
cs.set("by", by);
|
||||
cs.set("at", FUtil.dateToString(at));
|
||||
cs.set("reason", reason);
|
||||
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
|
@ -3,8 +3,12 @@ package me.totalfreedom.totalfreedommod.banning;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -15,7 +19,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.config.YamlConfig;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -30,41 +33,38 @@ public class BanManager extends FreedomService
|
||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||
public static final String CONFIG_FILENAME = "bans.yml";
|
||||
|
||||
//
|
||||
private final YamlConfig config;
|
||||
|
||||
public BanManager(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
this.config = new YamlConfig(plugin, "bans.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
config.load();
|
||||
|
||||
bans.clear();
|
||||
for (String id : config.getKeys(false))
|
||||
try
|
||||
{
|
||||
if (!config.isConfigurationSection(id))
|
||||
ResultSet banSet = plugin.sql.getBanList();
|
||||
{
|
||||
FLog.warning("Could not load username ban: " + id + ". Invalid format!");
|
||||
continue;
|
||||
while (banSet.next())
|
||||
{
|
||||
String name = banSet.getString("name");
|
||||
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
|
||||
String by = banSet.getString("by");
|
||||
Date at = new Date(banSet.getLong("at"));
|
||||
Date expires = new Date(banSet.getLong("expires"));
|
||||
String reason = banSet.getString("reason");
|
||||
Ban ban = new Ban(name, ips, by, at, expires, reason);
|
||||
bans.add(ban);
|
||||
}
|
||||
}
|
||||
|
||||
Ban ban = new Ban();
|
||||
ban.loadFrom(config.getConfigurationSection(id));
|
||||
|
||||
if (!ban.isValid())
|
||||
{
|
||||
FLog.warning("Not adding username ban: " + id + ". Missing information.");
|
||||
continue;
|
||||
}
|
||||
|
||||
bans.add(ban);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to load ban list: " + e.getMessage());
|
||||
}
|
||||
|
||||
// Remove expired bans, repopulate ipBans and nameBans,
|
||||
@ -81,8 +81,6 @@ public class BanManager extends FreedomService
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
saveAll();
|
||||
logger.info("Saved " + bans.size() + " player bans");
|
||||
}
|
||||
|
||||
public Set<Ban> getAllBans()
|
||||
@ -100,21 +98,6 @@ public class BanManager extends FreedomService
|
||||
return Collections.unmodifiableCollection(nameBans.values());
|
||||
}
|
||||
|
||||
public void saveAll()
|
||||
{
|
||||
// Remove expired
|
||||
updateViews();
|
||||
|
||||
config.clear();
|
||||
for (Ban ban : bans)
|
||||
{
|
||||
ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
|
||||
}
|
||||
|
||||
// Save config
|
||||
config.save();
|
||||
}
|
||||
|
||||
public Ban getByIp(String ip)
|
||||
{
|
||||
final Ban directBan = ipBans.get(ip);
|
||||
@ -168,7 +151,6 @@ public class BanManager extends FreedomService
|
||||
if (ban != null)
|
||||
{
|
||||
bans.remove(ban);
|
||||
saveAll();
|
||||
}
|
||||
|
||||
return ban;
|
||||
@ -181,7 +163,6 @@ public class BanManager extends FreedomService
|
||||
if (ban != null)
|
||||
{
|
||||
bans.remove(ban);
|
||||
saveAll();
|
||||
}
|
||||
|
||||
return ban;
|
||||
@ -199,9 +180,14 @@ public class BanManager extends FreedomService
|
||||
|
||||
public boolean addBan(Ban ban)
|
||||
{
|
||||
if (getByUsername(ban.getUsername()) != null)
|
||||
{
|
||||
removeBan(ban);
|
||||
}
|
||||
if (bans.add(ban))
|
||||
{
|
||||
saveAll();
|
||||
plugin.sql.addBan(ban);
|
||||
updateViews();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -212,7 +198,8 @@ public class BanManager extends FreedomService
|
||||
{
|
||||
if (bans.remove(ban))
|
||||
{
|
||||
saveAll();
|
||||
plugin.sql.removeBan(ban);
|
||||
updateViews();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -221,17 +208,14 @@ public class BanManager extends FreedomService
|
||||
|
||||
public int purge()
|
||||
{
|
||||
config.clear();
|
||||
config.save();
|
||||
|
||||
int size = bans.size();
|
||||
bans.clear();
|
||||
updateViews();
|
||||
|
||||
plugin.sql.truncate("bans");
|
||||
return size;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
final String username = event.getPlayer().getName();
|
||||
@ -246,11 +230,11 @@ public class BanManager extends FreedomService
|
||||
|
||||
if (ban != null && !ban.isExpired())
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage(ip));
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
@ -275,11 +259,12 @@ public class BanManager extends FreedomService
|
||||
private void updateViews()
|
||||
{
|
||||
// Remove expired bans
|
||||
for (Iterator<Ban> it = bans.iterator(); it.hasNext(); )
|
||||
for (Ban ban : new ArrayList<>(bans))
|
||||
{
|
||||
if (it.next().isExpired())
|
||||
if (ban.isExpired())
|
||||
{
|
||||
it.remove();
|
||||
bans.remove(ban);
|
||||
plugin.sql.removeBan(ban);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,76 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.banning;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.config.YamlConfig;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
public class VPNBanList extends FreedomService
|
||||
{
|
||||
|
||||
public static final String CONFIG_FILENAME = "vpnbans.yml";
|
||||
|
||||
@Getter
|
||||
private final Set<String> vpnIps = Sets.newHashSet();
|
||||
|
||||
public VPNBanList(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
vpnIps.clear();
|
||||
|
||||
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||
config.load();
|
||||
|
||||
for (String name : config.getKeys(false))
|
||||
{
|
||||
vpnIps.addAll(config.getStringList(name));
|
||||
}
|
||||
|
||||
FLog.info("Loaded " + vpnIps.size() + " VPN ips.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
final String ip = Ips.getIp(event);
|
||||
|
||||
// Permbanned IPs
|
||||
for (String testIp : getVPNIps())
|
||||
{
|
||||
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||
ChatColor.RED + "Your IP address is detected as a VPN\n"
|
||||
+ "If you believe this is an error, release procedures are available at\n"
|
||||
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getVPNIps()
|
||||
{
|
||||
return this.vpnIps;
|
||||
}
|
||||
}
|
@ -48,11 +48,7 @@ public class BlockBlocker extends FreedomService
|
||||
{
|
||||
case LAVA:
|
||||
{
|
||||
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
||||
}
|
||||
else
|
||||
if (!ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||
@ -62,11 +58,7 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
case WATER:
|
||||
{
|
||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
||||
}
|
||||
else
|
||||
if (!ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||
@ -77,11 +69,7 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
case FIRE:
|
||||
{
|
||||
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||
{
|
||||
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
||||
}
|
||||
else
|
||||
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||
{
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||
@ -89,14 +77,6 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TNT:
|
||||
{
|
||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STRUCTURE_BLOCK:
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
||||
@ -152,7 +132,7 @@ public class BlockBlocker extends FreedomService
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Bee hives are disabled.");
|
||||
player.sendMessage(ChatColor.GRAY + "Beehives are disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -164,9 +144,9 @@ public class BlockBlocker extends FreedomService
|
||||
Skull skull = (Skull) event.getBlockPlaced().getState();
|
||||
if (skull.hasOwner())
|
||||
{
|
||||
if (skull.getOwner().contains("§"))
|
||||
if (skull.getOwner().contains("\u00A7"))
|
||||
{
|
||||
skull.setOwner(skull.getOwner().replace("§", ""));
|
||||
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
|
||||
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
||||
if (meta != null)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -88,6 +89,13 @@ public class InteractBlocker extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (Groups.BED_COLORS.contains(event.getMaterial()) && event.getClickedBlock().getBiome().equals(Biome.NETHER))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "You can't sleep in hell.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.getMaterial())
|
||||
{
|
||||
case WATER_BUCKET:
|
||||
@ -153,6 +161,13 @@ public class InteractBlocker extends FreedomService
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
case WRITTEN_BOOK:
|
||||
{
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
player.sendMessage(ChatColor.GRAY + "Books are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +127,24 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
return bukkitTelnetPlugin;
|
||||
}
|
||||
|
||||
public List<Admin> getConnectedAdmins()
|
||||
{
|
||||
List<Admin> admins = new ArrayList<>();
|
||||
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||
if (telnet != null)
|
||||
{
|
||||
for (ClientSession session : telnet.appender.getSessions())
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
|
||||
if (admin != null && !admins.contains(admin))
|
||||
{
|
||||
admins.add(admin);
|
||||
}
|
||||
}
|
||||
}
|
||||
return admins;
|
||||
}
|
||||
|
||||
public void killTelnetSessions(final String name)
|
||||
{
|
||||
try
|
||||
|
@ -183,7 +183,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
||||
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + url);
|
||||
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
||||
final Statement statement = connection.createStatement();
|
||||
statement.setQueryTimeout(30);
|
||||
|
||||
@ -196,6 +196,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
}
|
||||
|
||||
// Ensure the world ID is not null
|
||||
|
||||
if (worldID == null)
|
||||
{
|
||||
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
||||
@ -219,14 +220,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
// This exits for flatlands wipes
|
||||
if (shutdown)
|
||||
{
|
||||
if (plugin.amp.enabled)
|
||||
{
|
||||
plugin.amp.restartServer();
|
||||
}
|
||||
else
|
||||
{
|
||||
server.shutdown();
|
||||
}
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ public class WorldGuardBridge extends FreedomService
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
|
||||
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -19,12 +18,10 @@ import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb]", aliases = "ban")
|
||||
public class Command_gtfo extends FreedomCommand
|
||||
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
||||
public class Command_ban extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
@ -35,6 +32,34 @@ public class Command_gtfo extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
Boolean silent = false;
|
||||
Boolean cancelRollback = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
|
||||
{
|
||||
cancelRollback = true;
|
||||
}
|
||||
|
||||
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 String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
@ -56,7 +81,7 @@ public class Command_gtfo extends FreedomCommand
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
//ips.addAll(entry.getIps());
|
||||
//ips.addAll(entry.getIps());/
|
||||
ips.add(Ips.getIp(player));
|
||||
|
||||
// Deop
|
||||
@ -68,14 +93,17 @@ public class Command_gtfo extends FreedomCommand
|
||||
// Clear inventory
|
||||
player.getInventory().clear();
|
||||
|
||||
// Strike with lightning
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
if (!silent)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
// Strike with lightning
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,77 +111,13 @@ public class Command_gtfo extends FreedomCommand
|
||||
player.setHealth(0.0);
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
Boolean cancelRollback = false;
|
||||
Boolean epicFail = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
|
||||
{
|
||||
cancelRollback = true;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
if (args[args.length - 1].equalsIgnoreCase("-ef"))
|
||||
{
|
||||
epicFail = 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), " ");
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if CoreProtect is loaded and installed, and skips the rollback and uses CoreProtect directly
|
||||
if (!cancelRollback)
|
||||
{
|
||||
if (!plugin.cpb.isEnabled())
|
||||
{
|
||||
// Undo WorldEdits
|
||||
try
|
||||
{
|
||||
plugin.web.undo(player, 15);
|
||||
}
|
||||
catch (NoClassDefFoundError | NullPointerException ex)
|
||||
{
|
||||
}
|
||||
|
||||
// Rollback
|
||||
plugin.rb.rollback(username);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.cpb.rollback(username);
|
||||
}
|
||||
plugin.cpb.rollback(username);
|
||||
}
|
||||
|
||||
if (epicFail)
|
||||
{
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
|
||||
new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
player.getWorld().strikeLightning(player.getLocation());
|
||||
//FUtil.
|
||||
}
|
||||
}
|
||||
}.runTaskLater(plugin, 2L * 20L);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
if (player != null && !silent)
|
||||
{
|
||||
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||
}
|
||||
@ -163,24 +127,29 @@ public class Command_gtfo extends FreedomCommand
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
// Broadcast
|
||||
final StringBuilder bcast = new StringBuilder()
|
||||
.append("Banning: ")
|
||||
.append(username);
|
||||
if (reason != null)
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
// Broadcast
|
||||
final StringBuilder bcast = new StringBuilder()
|
||||
.append("Banning: ")
|
||||
.append(username);
|
||||
if (reason != null)
|
||||
{
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
|
||||
}
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
|
||||
|
||||
// Kick player and handle others on IP
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(ban.bakeKickMessage(Ips.getIp(player)));
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (Ips.getIp(p).equals(Ips.getIp(player)))
|
@ -67,7 +67,7 @@ public class Command_blockedit extends FreedomCommand
|
||||
int counter = 0;
|
||||
for (final Player player : this.server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin((CommandSender)player))
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
playerdata.setEditBlocked(true);
|
||||
@ -82,7 +82,7 @@ public class Command_blockedit extends FreedomCommand
|
||||
final boolean smite = args[0].equals("-s");
|
||||
if (smite)
|
||||
{
|
||||
args = (String[])ArrayUtils.subarray((Object[])args, 1, args.length);
|
||||
args = (String[])ArrayUtils.subarray(args, 1, args.length);
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
@ -99,7 +99,7 @@ public class Command_blockedit extends FreedomCommand
|
||||
String reason = null;
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join((Object[])args, " ", 1, args.length);
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
}
|
||||
|
||||
final FPlayer pd = plugin.pl.getPlayer(player2);
|
||||
@ -112,7 +112,7 @@ public class Command_blockedit extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin((CommandSender)player2))
|
||||
if (plugin.al.isAdmin(player2))
|
||||
{
|
||||
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
|
||||
return true;
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | off | <partialname> [head | block] [playername | blockname]")
|
||||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||
public class Command_cage extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -26,14 +26,8 @@ public class Command_cage extends FreedomCommand
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String skullName = null;
|
||||
if ("off".equals(args[0]) && sender instanceof Player)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||
playerdata.getCageData().setCaged(false);
|
||||
return true;
|
||||
}
|
||||
if ("purge".equals(args[0]))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
||||
@ -44,13 +38,24 @@ public class Command_cage extends FreedomCommand
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
|
||||
if (fPlayer.getCageData().isCaged())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||
playerdata.getCageData().setCaged(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
Material outerMaterial = Material.GLASS;
|
||||
Material innerMaterial = Material.AIR;
|
||||
if (args.length >= 2 && args[1] != null)
|
||||
@ -58,12 +63,6 @@ public class Command_cage extends FreedomCommand
|
||||
final String s = args[1];
|
||||
switch (s)
|
||||
{
|
||||
case "off":
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
||||
fPlayer.getCageData().setCaged(false);
|
||||
return true;
|
||||
}
|
||||
case "head":
|
||||
{
|
||||
outerMaterial = Material.PLAYER_HEAD;
|
||||
@ -91,6 +90,7 @@ public class Command_cage extends FreedomCommand
|
||||
}
|
||||
|
||||
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
||||
|
||||
if (skullName != null)
|
||||
{
|
||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
||||
@ -99,7 +99,9 @@ public class Command_cage extends FreedomCommand
|
||||
{
|
||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||
}
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
if (outerMaterial == Material.PLAYER_HEAD)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||
@ -130,7 +132,7 @@ public class Command_cage extends FreedomCommand
|
||||
{
|
||||
if (!args[0].equals("purge"))
|
||||
{
|
||||
return Arrays.asList("off", "head", "block");
|
||||
return Arrays.asList("head", "block");
|
||||
}
|
||||
}
|
||||
else if (args.length == 3)
|
||||
|
@ -16,12 +16,12 @@ public class Command_cartsit extends FreedomCommand
|
||||
{
|
||||
Player targetPlayer = playerSender;
|
||||
|
||||
if (args.length == 1)
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
|
||||
targetPlayer = getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer == null || plugin.al.vanished.contains(targetPlayer) && !plugin.al.isAdmin(sender))
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
@ -36,11 +36,6 @@ public class Command_cartsit extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (targetPlayer != playerSender && !isAdmin(sender))
|
||||
{
|
||||
sender.sendMessage("Only admins can select another player as a /cartsit target.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (targetPlayer.isInsideVehicle())
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ public class Command_cmdspy extends FreedomCommand
|
||||
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
admin.setCommandSpy(!admin.getCommandSpy());
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
||||
|
||||
|
@ -24,13 +24,8 @@ public class Command_consolesay extends FreedomCommand
|
||||
}
|
||||
|
||||
String message = StringUtils.join(args, " ");
|
||||
FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8» §f%s", sender.getName(), StringUtils.join(args, " ")));
|
||||
|
||||
// Send the message to Discord
|
||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist())
|
||||
{
|
||||
plugin.dc.messageChatChannel("[CONSOLE] " + sender.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||
}
|
||||
FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8\u00BB §f%s", sender.getName(), StringUtils.join(args, " ")));
|
||||
plugin.dc.messageChatChannel("[CONSOLE] " + plugin.dc.deformat(sender.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "For developers only - debug things via reflection.", usage = "/<command>")
|
||||
public class Command_debug extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
String className = args[0];
|
||||
String fieldName = args[1];
|
||||
String newValue = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
||||
|
||||
if (className.equalsIgnoreCase("_"))
|
||||
{
|
||||
className = "me.totalfreedom.totalfreedommod.TotalFreedomMod";
|
||||
}
|
||||
|
||||
setStaticValue(className, fieldName, newValue);
|
||||
|
||||
sender.sendMessage("Debug: OK");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setStaticValue(final String className, final String fieldName, final String newValueString) throws Exception
|
||||
{
|
||||
Class<?> forName = Class.forName(className);
|
||||
if (forName != null)
|
||||
{
|
||||
final Field field = forName.getDeclaredField(fieldName);
|
||||
if (field != null)
|
||||
{
|
||||
Object newValue;
|
||||
|
||||
Class<?> type = field.getType();
|
||||
if (type.isPrimitive())
|
||||
{
|
||||
if (type.getName().equals("int"))
|
||||
{
|
||||
newValue = Integer.parseInt(newValueString);
|
||||
}
|
||||
else if (type.getName().equals("double"))
|
||||
{
|
||||
newValue = Double.parseDouble(newValueString);
|
||||
}
|
||||
else if (type.getName().equals("boolean"))
|
||||
{
|
||||
newValue = Boolean.parseBoolean(newValueString);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unknown primitive field type.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type.isAssignableFrom(Integer.class))
|
||||
{
|
||||
newValue = new Integer(newValueString);
|
||||
}
|
||||
else if (type.isAssignableFrom(Double.class))
|
||||
{
|
||||
newValue = new Double(newValueString);
|
||||
}
|
||||
else if (type.isAssignableFrom(Boolean.class))
|
||||
{
|
||||
newValue = Boolean.valueOf(newValueString);
|
||||
}
|
||||
else if (type.isAssignableFrom(String.class))
|
||||
{
|
||||
newValue = newValueString;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unknown complex field type.");
|
||||
}
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
|
||||
final Object oldValue = field.get(Class.forName(className));
|
||||
if (oldValue != null)
|
||||
{
|
||||
field.set(oldValue, newValue);
|
||||
}
|
||||
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -13,7 +14,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Deop a player", usage = "/<command> <partialname>")
|
||||
public class Command_deop extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -33,9 +33,10 @@ public class Command_deop extends FreedomCommand
|
||||
final List<String> matchedPlayerNames = new ArrayList<>();
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
|
||||
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
|
||||
{
|
||||
if (player.isOp() && !plugin.al.vanished.contains(player))
|
||||
if (player.isOp() && !AdminList.vanished.contains(player))
|
||||
{
|
||||
matchedPlayerNames.add(player.getName());
|
||||
player.setOp(false);
|
||||
@ -53,7 +54,7 @@ public class Command_deop extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("No targets matched.");
|
||||
msg("Either the player is already deopped, or the player could not be found.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ public class Command_doom extends FreedomCommand
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the admin list", true);
|
||||
admin.setActive(false);
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ public class Command_enchant extends FreedomCommand
|
||||
|
||||
try
|
||||
{
|
||||
ench = Enchantment.getByName(args[1]);
|
||||
ench = Enchantment.getByName(args[1].toUpperCase());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,30 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Lists all possible enchantments.", usage = "/<command>")
|
||||
public class Command_enchantments extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
String list = "All possible enchantments: ";
|
||||
|
||||
for (Enchantment enchantment : Enchantment.values())
|
||||
{
|
||||
list += enchantment.getName() + ", ";
|
||||
}
|
||||
|
||||
// Remove extra comma at the end of the list
|
||||
list = list.substring(0, list.length() - 2);
|
||||
|
||||
msg(list);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -6,8 +6,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to \"The End\".", usage = "/<command>", aliases = "end")
|
||||
public class Command_ender extends FreedomCommand
|
||||
@CommandParameters(description = "Go to \"The End\".", usage = "/<command>")
|
||||
public class Command_end extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
@ -1,150 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Executive only commands - more items will be added shortly!", usage = "/<command> [hell: <username>]", aliases = "exec")
|
||||
public class Command_executive extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!FUtil.isExecutive(sender.getName()))
|
||||
{
|
||||
msg("You aren't an executive, have a cookie instead!");
|
||||
if (!senderIsConsole)
|
||||
{
|
||||
final int firstEmpty = playerSender.getInventory().firstEmpty();
|
||||
final ItemStack cakeItem = new ItemStack(Material.COOKIE);
|
||||
playerSender.getInventory().setItem(firstEmpty, cakeItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Sorry, you're not an in-game player, so it's impossible to give you a cookie :(");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (args.length > 0)
|
||||
{
|
||||
switch (args[0])
|
||||
{
|
||||
case "hell":
|
||||
{
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (getPlayer(args[1]) == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
final Player player = getPlayer(args[1]);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Calling Satan to open the gates of hell for " + player.getName(), true);
|
||||
FUtil.bcastMsg(player.getName() + " is going to have a bad time!", ChatColor.RED);
|
||||
final String IP = player.getAddress().getAddress().getHostAddress().trim();
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
admin.setActive(false);
|
||||
plugin.al.save();
|
||||
plugin.al.updateTables();
|
||||
}
|
||||
player.setVelocity(new Vector(0, Math.max(1.0, Math.min(150, 30)), 0));
|
||||
player.setWhitelisted(false);
|
||||
player.setOp(false);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.closeInventory();
|
||||
player.getInventory().clear();
|
||||
player.setFireTicks(10000);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_DEATH, 100, -1f);
|
||||
player.getEnderChest().clear();
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, null));
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.getWorld().strikeLightning(player.getLocation());
|
||||
}
|
||||
}.runTaskLater(plugin, 20L * 2L);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.getWorld().strikeLightning(player.getLocation());
|
||||
}
|
||||
}.runTaskLater(plugin, 20L * 2L);
|
||||
FUtil.bcastMsg("The gates to hell have opened, let the wrath of " + sender.getName() + " condem " + player.getName() + "!", ChatColor.RED);
|
||||
player.setFireTicks(10000);
|
||||
final CommandSender cSender = sender;
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
banPlayer(player.getName(), "Get your fucking shit together and then call back kthx", true, false);
|
||||
FUtil.adminAction(cSender.getName(), "Has sent " + player.getName() + " to hell, IP: " + IP, true);
|
||||
player.kickPlayer(ChatColor.RED + "Welcome to hell you fucking cuck");
|
||||
}
|
||||
}.runTaskLater(plugin, 40L * 4L);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void banPlayer(String playerName, String reason, Boolean silent, Boolean kick)
|
||||
{
|
||||
PlayerData playerData = plugin.pl.getData(playerName);
|
||||
final List<String> ips = new ArrayList<>();
|
||||
ips.addAll(playerData.getIps());
|
||||
String username;
|
||||
final Player player = getPlayer(args[1]);
|
||||
username = playerName;
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Banning " + username, true);
|
||||
msg(sender, player.getName() + " has been banned and IP is: " + ips);
|
||||
}
|
||||
Ban ban = Ban.forPlayerName(username, sender, null, reason);
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
if (player != null && kick)
|
||||
{
|
||||
player.kickPlayer(ban.bakeKickMessage(Ips.getIp(player)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Send a chat message as the specified player.", usage = "/<command> <fromname> <outmessage>")
|
||||
public class Command_gchat extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!FUtil.isExecutive(sender.getName()) && plugin.al.isAdmin(player))
|
||||
{
|
||||
msg("Only Executives may use this command on admins", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
final String outMessage = StringUtils.join(args, " ", 1, args.length);
|
||||
msg("Sending message as " + player.getName() + ": " + outMessage);
|
||||
player.chat(outMessage);
|
||||
msg("Message sent.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Send a command as the specified player.", usage = "/<command> <fromname> <outcommand>")
|
||||
public class Command_gcmd extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!FUtil.isExecutive(sender.getName()) && plugin.al.isAdmin(player))
|
||||
{
|
||||
msg("Only Executives may use this command on admins", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
final String outCommand = StringUtils.join(args, " ", 1, args.length);
|
||||
|
||||
if (plugin.cb.isCommandBlocked(outCommand, sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
msg("Sending command as " + player.getName() + ": " + outCommand);
|
||||
if (server.dispatchCommand(player, outCommand))
|
||||
{
|
||||
msg("Command sent.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Unknown error sending command.");
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
msg("Error sending command: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -104,7 +104,7 @@ public class Command_glist extends FreedomCommand
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(playerBan.bakeKickMessage(Ips.getIp(player)));
|
||||
player.kickPlayer(playerBan.bakeKickMessage());
|
||||
}
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, null));
|
||||
@ -149,7 +149,7 @@ public class Command_glist extends FreedomCommand
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(nameBan.bakeKickMessage(Ips.getIp(player)));
|
||||
player.kickPlayer(nameBan.bakeKickMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -0,0 +1,202 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "HubWorld management stuff",
|
||||
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
||||
aliases = "hw,hub")
|
||||
public class Command_hubworld extends FreedomCommand
|
||||
{
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
CommandMode commandMode = null;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
commandMode = CommandMode.TELEPORT;
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
if ("time".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.TIME;
|
||||
}
|
||||
else if ("weather".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.WEATHER;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandMode == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (commandMode)
|
||||
{
|
||||
case TELEPORT:
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
World hubWorld = null;
|
||||
try
|
||||
{
|
||||
hubWorld = plugin.wm.hubworld.getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (hubWorld == null || playerSender.getWorld() == hubWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Going to the hub world");
|
||||
plugin.wm.hubworld.sendToWorld(playerSender);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TIME:
|
||||
{
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
|
||||
if (timeOfDay != null)
|
||||
{
|
||||
plugin.wm.hubworld.setTimeOfDay(timeOfDay);
|
||||
msg("Hub world time set to: " + timeOfDay.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WEATHER:
|
||||
{
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
|
||||
if (weatherMode != null)
|
||||
{
|
||||
plugin.wm.hubworld.setWeatherMode(weatherMode);
|
||||
msg("Hub world weather set to: " + weatherMode.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid weather mode. Can be: off, rain, storm");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (PermissionDeniedException ex)
|
||||
{
|
||||
if (ex.getMessage().isEmpty())
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("time", "weather");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("time"))
|
||||
{
|
||||
return Arrays.asList("morning", "noon", "evening", "night");
|
||||
}
|
||||
else if (args[0].equals("weather"))
|
||||
{
|
||||
return Arrays.asList("off", "rain", "storm");
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// TODO: Redo this properly
|
||||
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
|
||||
{
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionDeniedException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PermissionDeniedException()
|
||||
{
|
||||
super("");
|
||||
}
|
||||
|
||||
private PermissionDeniedException(String string)
|
||||
{
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -21,11 +21,11 @@ public class Command_invsee extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[0]);
|
||||
Player player = getPlayer(args[0], true);
|
||||
|
||||
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
|
||||
if (player == null)
|
||||
{
|
||||
msg("This player is not online.");
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggles jumppads on/off, view the status of jumppads, or make them sideways.", usage = "/<command> <on | off | info | sideways <on | off>>", aliases = "launchpads,jp")
|
||||
public class Command_jumppads extends FreedomCommand
|
||||
{
|
||||
|
@ -2,9 +2,12 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -49,6 +52,12 @@ public class Command_list extends FreedomCommand
|
||||
listFilter = ListFilter.VANISHED_ADMINS;
|
||||
break;
|
||||
}
|
||||
case "-t":
|
||||
{
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
listFilter = ListFilter.TELNET_SESSIONS;
|
||||
break;
|
||||
}
|
||||
case "-i":
|
||||
{
|
||||
listFilter = ListFilter.IMPOSTORS;
|
||||
@ -71,49 +80,65 @@ public class Command_list extends FreedomCommand
|
||||
}
|
||||
StringBuilder onlineStats = new StringBuilder();
|
||||
StringBuilder onlineUsers = new StringBuilder();
|
||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - plugin.al.vanished.size())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" out of a maximum ")
|
||||
.append(ChatColor.RED)
|
||||
.append(server.getMaxPlayers())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" players online.");
|
||||
List<String> n = new ArrayList<>();
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.ADMINS && plugin.al.vanished.contains(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.vanished.contains(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.IMPOSTORS && !plugin.al.isAdminImpostor(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(p.getName().toLowerCase()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.PLAYERS && plugin.al.vanished.contains(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Displayable display = plugin.rm.getDisplay(p);
|
||||
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldTags())
|
||||
List<String> n = new ArrayList<>();
|
||||
|
||||
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender) && plugin.al.getAdmin(sender).getRank().isAtLeast(Rank.TELNET_ADMIN))
|
||||
{
|
||||
List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
|
||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" admins connected to telnet.");
|
||||
for (Admin admin : connectedAdmins)
|
||||
{
|
||||
n.add(getOldPrefix(display) + p.getName());
|
||||
n.add(plugin.rm.getDisplay(admin).getColoredTag() + admin.getName());
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" out of a maximum ")
|
||||
.append(ChatColor.RED)
|
||||
.append(server.getMaxPlayers())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" players online.");
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
n.add(display.getColoredTag() + p.getName());
|
||||
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.ADMINS && AdminList.vanished.contains(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.VANISHED_ADMINS && !AdminList.vanished.contains(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.IMPOSTORS && !plugin.al.isAdminImpostor(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(p.getName().toLowerCase()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.PLAYERS && AdminList.vanished.contains(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Displayable display = plugin.rm.getDisplay(p);
|
||||
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldTags())
|
||||
{
|
||||
n.add(getOldPrefix(display) + p.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
n.add(display.getColoredTag() + p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
||||
@ -122,11 +147,13 @@ public class Command_list extends FreedomCommand
|
||||
.append(": ")
|
||||
.append(StringUtils.join(n, ChatColor.WHITE + ", "));
|
||||
if (senderIsConsole)
|
||||
|
||||
{
|
||||
sender.sendMessage(ChatColor.stripColor(onlineStats.toString()));
|
||||
sender.sendMessage(ChatColor.stripColor(onlineUsers.toString()));
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
sender.sendMessage(onlineStats.toString());
|
||||
sender.sendMessage(onlineUsers.toString());
|
||||
@ -158,7 +185,8 @@ public class Command_list extends FreedomCommand
|
||||
PLAYERS,
|
||||
ADMINS,
|
||||
VANISHED_ADMINS,
|
||||
TELNET_SESSIONS,
|
||||
FAMOUS_PLAYERS,
|
||||
IMPOSTORS
|
||||
}
|
||||
}
|
||||
}
|
@ -10,13 +10,14 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "This is evil, and I never should have wrote it - blocks specified player's input.", usage = "/<command> <all | purge | <<partialname> on | off>>")
|
||||
@CommandParameters(description = "This is evil, and I never should have wrote it - blocks specified player's input.", usage = "/<command> <all | purge | <<partialname> on | off> [-q]>")
|
||||
public class Command_lockup extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Boolean silent = (args[args.length - 1].equalsIgnoreCase("-q"));
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("all"))
|
||||
@ -56,7 +57,10 @@ public class Command_lockup extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
||||
}
|
||||
startLockup(player);
|
||||
msg("Locked up " + player.getName() + ".");
|
||||
}
|
||||
@ -70,7 +74,10 @@ public class Command_lockup extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
||||
}
|
||||
cancelLockup(player);
|
||||
msg("Unlocked " + player.getName() + ".");
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public class Command_makeopregion extends FreedomCommand
|
||||
put(Flags.DESTROY_VEHICLE, StateFlag.State.ALLOW);
|
||||
put(Flags.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.ALLOW);
|
||||
put(Flags.ENTITY_PAINTING_DESTROY, StateFlag.State.ALLOW);
|
||||
put(net.goldtreeservers.worldguardextraflags.flags.Flags.WORLDEDIT, StateFlag.State.ALLOW);
|
||||
}};
|
||||
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
|
@ -18,8 +18,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [[-s | -q] <player> [reason] | list | purge | all]", aliases = "mute")
|
||||
public class Command_stfu extends FreedomCommand
|
||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
||||
public class Command_mute extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
@ -121,41 +121,29 @@ public class Command_stfu extends FreedomCommand
|
||||
}
|
||||
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
if (playerdata.isMuted())
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
if (quiet || playerdata.isQuietMuted())
|
||||
{
|
||||
playerdata.setMuted(false);
|
||||
playerdata.setQuietMuted(false);
|
||||
msg("Unmuted " + player.getName() + " quietly");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||
playerdata.setMuted(false);
|
||||
msg("Unmuted " + player.getName());
|
||||
|
||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
msg(player.getName() + " is an admin, and can't be muted.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg(player.getName() + " is an admin, and can't be muted.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!playerdata.isMuted())
|
||||
{
|
||||
playerdata.setMuted(true);
|
||||
player.sendTitle(ChatColor.RED + "You've been muted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
if (reason != null)
|
||||
{
|
||||
msg(player, ChatColor.RED + "Reason: " + ChatColor.YELLOW + reason);
|
||||
}
|
||||
if (quiet)
|
||||
{
|
||||
playerdata.setMuted(true);
|
||||
playerdata.setQuietMuted(true);
|
||||
msg("Muted " + player.getName() + " quietly");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
||||
playerdata.setMuted(true);
|
||||
|
||||
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
|
||||
if (smite)
|
||||
{
|
||||
@ -163,15 +151,13 @@ public class Command_stfu extends FreedomCommand
|
||||
}
|
||||
|
||||
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been muted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
if (reason != null)
|
||||
{
|
||||
msg(player, "Reason: " + ChatColor.YELLOW + reason);
|
||||
}
|
||||
msg("Muted " + player.getName());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(ChatColor.RED + "That player is already muted.");
|
||||
}
|
||||
|
||||
return true;
|
@ -83,7 +83,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
target.clearIPs();
|
||||
target.addIp(targetIp);
|
||||
|
||||
plugin.al.save();
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
|
||||
msg(counter + " IPs removed.");
|
||||
@ -127,7 +127,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Removing a supered IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
||||
|
||||
target.removeIp(args[1]);
|
||||
plugin.al.save();
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
|
||||
msg("Removed IP " + args[1]);
|
||||
@ -142,17 +142,24 @@ public class Command_myadmin extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
String msg = StringUtils.join(args, " ", 1, args.length);
|
||||
if (!msg.contains("%rank%") && !msg.contains("%coloredrank%"))
|
||||
String message = StringUtils.join(args, " ", 1, args.length);
|
||||
if (!message.contains("%rank%") && !message.contains("%coloredrank%"))
|
||||
{
|
||||
msg("Your login message must contain your rank. Use either %rank% or %coloredrank% to specify where you want the rank", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
int length = message.replace("%name%", "").replace("%rank%", "").replace("%coloredrank%", "").length();
|
||||
if (length > 64)
|
||||
{
|
||||
msg("Your login message cannot be more than 64 characters (excluding your rank and your name)", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
|
||||
FUtil.adminAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||
target.setLoginMessage(msg);
|
||||
target.setLoginMessage(message);
|
||||
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
|
||||
msg("> " + ChatColor.AQUA + (msg.contains("%name%") ? "" : target.getName() + " is ") + FUtil.colorize(msg).replace("%name%", targetPlayer.getName()).replace("%rank%", plugin.rm.getDisplay(target).getName()).replace("%coloredrank%", plugin.rm.getDisplay(target).getColoredName()));
|
||||
plugin.al.save();
|
||||
msg("> " + previewMessage);
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
return true;
|
||||
}
|
||||
@ -161,7 +168,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Clearing personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||
target.setLoginMessage(null);
|
||||
plugin.al.save();
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
return true;
|
||||
}
|
||||
@ -181,7 +188,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
{
|
||||
String format = StringUtils.join(args, " ", 1, args.length);
|
||||
target.setAcFormat(format);
|
||||
plugin.al.save();
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY);
|
||||
String example = format.replace("%name%", "ExampleAdmin").replace("%rank%", Rank.TELNET_ADMIN.getAbbr()).replace("%rankcolor%", Rank.TELNET_ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog.");
|
||||
@ -191,7 +198,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
case "clearacformat":
|
||||
{
|
||||
target.setAcFormat(null);
|
||||
plugin.al.save();
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
msg("Cleared admin chat format.", ChatColor.GRAY);
|
||||
return true;
|
||||
@ -199,7 +206,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
case "oldtags":
|
||||
{
|
||||
target.setOldTags(!target.getOldTags());
|
||||
plugin.al.save();
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
msg((target.getOldTags() ? "Enabled" : "Disabled") + " old tags.");
|
||||
return true;
|
||||
@ -207,7 +214,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
case "logstick":
|
||||
{
|
||||
target.setLogStick(!target.getLogStick());
|
||||
plugin.al.save();
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
msg((target.getLogStick() ? "Enabled" : "Disabled") + " log-stick lookup.");
|
||||
return true;
|
||||
|
@ -100,7 +100,7 @@ public class Command_notes extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("No note with the ID of " + args[2] + "exists.", ChatColor.RED);
|
||||
msg("No note with the ID of " + args[2] + " exists.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -13,7 +14,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "OP a player", usage = "/<command> <partialname>")
|
||||
public class Command_op extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -30,12 +30,13 @@ public class Command_op extends FreedomCommand
|
||||
|
||||
final String targetName = args[0].toLowerCase();
|
||||
|
||||
final List<String> matchedPlayerNames = new ArrayList<>();
|
||||
List<String> matchedPlayerNames = new ArrayList<>();
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
|
||||
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
|
||||
{
|
||||
if (!player.isOp() && !plugin.al.vanished.contains(player))
|
||||
if (!player.isOp() && !AdminList.vanished.contains(player))
|
||||
{
|
||||
matchedPlayerNames.add(player.getName());
|
||||
player.setOp(true);
|
||||
@ -53,7 +54,7 @@ public class Command_op extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("No targets matched.");
|
||||
msg("Either the player is already opped, or the player could not be found.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -18,6 +18,8 @@ import org.bukkit.plugin.PluginManager;
|
||||
public class Command_plugincontrol extends FreedomCommand
|
||||
{
|
||||
|
||||
private final List<String> UNTOUCHABLE_PLUGINS = Arrays.asList(plugin.getName(), "BukkitTelnet");
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -88,9 +90,9 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.getName().equals(plugin.getName()))
|
||||
if (UNTOUCHABLE_PLUGINS.contains(target.getName()))
|
||||
{
|
||||
msg("You cannot disable " + plugin.getName());
|
||||
msg("You cannot disable " + target.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -115,9 +117,9 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.getName().equals(plugin.getName()))
|
||||
if (UNTOUCHABLE_PLUGINS.contains(target.getName()))
|
||||
{
|
||||
msg("Use /tfm reload to reload instead.");
|
||||
msg("You cannot reload " + target.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -157,7 +159,10 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Plugin plugin : server.getPluginManager().getPlugins())
|
||||
{
|
||||
names.add(plugin.getName());
|
||||
if (!UNTOUCHABLE_PLUGINS.contains(plugin.getName()))
|
||||
{
|
||||
names.add(plugin.getName());
|
||||
}
|
||||
}
|
||||
names.remove(plugin.getName());
|
||||
return names;
|
||||
|
@ -17,7 +17,8 @@ import org.bukkit.potion.PotionEffectType;
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Manipulate your potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
||||
usage = "/<command> <list | clear [target name] | add <type> <duration> <amplifier> [target name]>")
|
||||
usage = "/<command> <list | clear [target name] | add <type> <duration> <amplifier> [target name]>",
|
||||
aliases="effect")
|
||||
public class Command_potion extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -60,9 +61,9 @@ public class Command_potion extends FreedomCommand
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
target = getPlayer(args[1]);
|
||||
target = getPlayer(args[1], true);
|
||||
|
||||
if (target == null || plugin.al.vanished.contains(target) && !plugin.al.isAdmin(sender))
|
||||
if (target == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
||||
return true;
|
||||
|
@ -16,7 +16,7 @@ public class Command_potionspy extends FreedomCommand
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
admin.setPotionSpy(!admin.getPotionSpy());
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
msg("PotionSpy is now " + (admin.getPotionSpy() ? "enabled." : "disabled."));
|
||||
return true;
|
||||
|
@ -35,9 +35,9 @@ public class Command_rank extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final Player player = getPlayer(args[0], true);
|
||||
|
||||
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
|
@ -15,7 +15,6 @@ public class Command_reactionbar extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (!plugin.sh.reactionString.isEmpty())
|
||||
{
|
||||
ActionBarAPI.sendActionBar(playerSender, ChatColor.BOLD + plugin.sh.reactionString, 15 * 20);
|
||||
|
@ -21,9 +21,9 @@ public class Command_report extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[0]);
|
||||
Player player = getPlayer(args[0], true);
|
||||
|
||||
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
|
@ -1,35 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Kicks everyone and restarts the server.", usage = "/<command>")
|
||||
public class Command_restart extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.amp.enabled)
|
||||
{
|
||||
msg(ChatColor.RED + "AMP integration is not enabled. Please use /stop instead.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + "Server is going offline, come back in about 20 seconds.");
|
||||
}
|
||||
|
||||
plugin.amp.restartServer();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -83,8 +83,8 @@ public class Command_ride extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
|
||||
final Player player = getPlayer(args[0], true);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
|
@ -156,10 +156,13 @@ public class Command_ro extends FreedomCommand
|
||||
if (data instanceof Waterlogged)
|
||||
{
|
||||
Waterlogged waterloggedData = (Waterlogged)data;
|
||||
waterloggedData.setWaterlogged(false);
|
||||
block.setBlockData(waterloggedData);
|
||||
affected++;
|
||||
continue;
|
||||
if (waterloggedData.isWaterlogged())
|
||||
{
|
||||
waterloggedData.setWaterlogged(false);
|
||||
block.setBlockData(waterloggedData);
|
||||
affected++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
block.setType(toMaterial);
|
||||
affected++;
|
||||
|
@ -1,85 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | undo [partialname] purge [partialname] | purgeall>", aliases = "rb")
|
||||
public class Command_rollback extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0 || args.length > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
if ("purgeall".equals(args[0]))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Purging all rollback history", false);
|
||||
msg("Purged all rollback history for " + plugin.rb.purgeEntries() + " players.");
|
||||
}
|
||||
else
|
||||
{
|
||||
final String playerName = plugin.rb.findPlayer(args[0]);
|
||||
|
||||
if (playerName == null)
|
||||
{
|
||||
msg("That player has no entries stored.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.rb.canUndoRollback(playerName))
|
||||
{
|
||||
msg("That player has just been rolled back.");
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
|
||||
msg("Rolled back " + plugin.rb.rollback(playerName) + " edits for " + playerName + ".");
|
||||
msg("If this rollback was a mistake, use /rollback undo " + playerName + " within 40 seconds to reverse the rollback.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
if ("purge".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
final String playerName = plugin.rb.findPlayer(args[1]);
|
||||
|
||||
if (playerName == null)
|
||||
{
|
||||
msg("That player has no entries stored.");
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Purged " + plugin.rb.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("undo".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
final String playerName = plugin.rb.findPlayer(args[1]);
|
||||
|
||||
if (playerName == null)
|
||||
{
|
||||
msg("That player hasn't been rolled back recently.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Reverting rollback for player: " + playerName, false);
|
||||
msg("Reverted " + plugin.rb.undoRollback(playerName) + " edits for " + playerName + ".");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Setting " + admin.getName() + "'s rank to " + rank.getName(), true);
|
||||
|
||||
admin.setRank(rank);
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
|
||||
Player player = getPlayer(admin.getName());
|
||||
if (player != null)
|
||||
@ -175,7 +175,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
// Find the old admin entry
|
||||
String name = player != null ? player.getName() : args[1];
|
||||
Admin admin = null;
|
||||
for (Admin loopAdmin : plugin.al.getAllAdmins().values())
|
||||
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||
{
|
||||
if (loopAdmin.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
@ -204,11 +204,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||
plugin.al.addAdmin(new Admin(player));
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
admin = new Admin(player);
|
||||
|
||||
// Attempt to find discord account
|
||||
if (plugin.mbl.isMasterBuilder(player))
|
||||
@ -224,6 +220,8 @@ public class Command_saconfig extends FreedomCommand
|
||||
admin.setDiscordID(vPlayer.getDiscordId());
|
||||
}
|
||||
}
|
||||
plugin.al.addAdmin(admin);
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
else // Existing admin
|
||||
{
|
||||
@ -231,7 +229,9 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
String oldName = admin.getName();
|
||||
admin.setName(player.getName());
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
admin.addIp(Ips.getIp(player));
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
plugin.al.verifiedNoAdminIps.remove(player.getName());
|
||||
}
|
||||
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
if (player != null)
|
||||
{
|
||||
@ -339,7 +339,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
|
||||
admin.setActive(false);
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
if (player != null)
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ public class Command_say extends FreedomCommand
|
||||
}
|
||||
|
||||
FUtil.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE);
|
||||
plugin.dc.messageChatChannel(String.format("[Server:%s] \u00BB %s", plugin.dc.deformat(sender.getName()), message));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public class Command_scare extends FreedomCommand
|
||||
}
|
||||
|
||||
msg("Scared " + player.getName());
|
||||
player.sendMessage(ChatColor.RED + "ZING");
|
||||
|
||||
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
@ -58,4 +59,4 @@ public class Command_scare extends FreedomCommand
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Set your compass to the specified position.", usage = "/<command> <x> <y> <z>")
|
||||
public class Command_setcompass extends FreedomCommand
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@ -15,7 +16,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason]")
|
||||
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-q]")
|
||||
public class Command_smite extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -27,21 +28,37 @@ public class Command_smite extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
String reason = null;
|
||||
if (args.length > 1)
|
||||
Boolean silent = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
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);
|
||||
smite(sender, player, reason, silent);
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||
|
||||
@ -50,10 +67,15 @@ public class Command_smite extends FreedomCommand
|
||||
|
||||
public static void smite(CommandSender sender, Player player)
|
||||
{
|
||||
smite(sender, player, null);
|
||||
smite(sender, player, null, false);
|
||||
}
|
||||
|
||||
public static void smite(CommandSender sender, Player player, String reason)
|
||||
{
|
||||
smite(sender, player, reason, false);
|
||||
}
|
||||
|
||||
public static void smite(CommandSender sender, Player player, String reason, Boolean silent)
|
||||
{
|
||||
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
@ -62,7 +84,11 @@ public class Command_smite extends FreedomCommand
|
||||
{
|
||||
FUtil.bcastMsg(" Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
|
||||
}
|
||||
FUtil.bcastMsg(" Smitten by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.bcastMsg(" Smitten by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
}
|
||||
|
||||
// Deop
|
||||
player.setOp(false);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -7,16 +9,30 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Kicks everyone and stops the server.", usage = "/<command> [reason]")
|
||||
public class Command_stop extends FreedomCommand
|
||||
{
|
||||
private static final Map<CommandSender, String> STOP_CONFIRM = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||
if (STOP_CONFIRM.containsKey(sender))
|
||||
{
|
||||
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + STOP_CONFIRM.get(sender));
|
||||
}
|
||||
|
||||
STOP_CONFIRM.remove(sender);
|
||||
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
String reason = "Server is going offline, come back in about 20 seconds.";
|
||||
|
||||
@ -25,13 +41,21 @@ public class Command_stop extends FreedomCommand
|
||||
reason = StringUtils.join(args, " ");
|
||||
}
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
msg("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
|
||||
|
||||
STOP_CONFIRM.put(sender, reason);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + reason);
|
||||
}
|
||||
|
||||
server.shutdown();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (STOP_CONFIRM.containsKey(sender))
|
||||
{
|
||||
STOP_CONFIRM.remove(sender);
|
||||
msg("Stop request expired.");
|
||||
}
|
||||
}
|
||||
}.runTaskLater(plugin, 15 * 20);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public class Command_tag extends FreedomCommand
|
||||
plugin.pl.getPlayer(playerSender).setTag(outputTag);
|
||||
if (save)
|
||||
{
|
||||
save(playerSender, outputTag);
|
||||
save(playerSender, strippedTag);
|
||||
}
|
||||
msg("Tag set to '" + outputTag + ChatColor.GRAY + "'." + (save ? " (Saved)" : ""));
|
||||
|
||||
@ -203,7 +203,7 @@ public class Command_tag extends FreedomCommand
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
admin.setTag(tag);
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilder(player))
|
||||
|
@ -69,7 +69,7 @@ public class Command_tempban extends FreedomCommand
|
||||
}
|
||||
message.append(" until ").append(date_format.format(expires));
|
||||
|
||||
String reason = "Banned by " + sender.getName();
|
||||
String reason = null;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ") + " (" + sender.getName() + ")";
|
||||
@ -95,7 +95,7 @@ public class Command_tempban extends FreedomCommand
|
||||
ban.addIp(ip);
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
player.kickPlayer(sender.getName() + " - " + message.toString());
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
|
||||
|
@ -46,6 +46,8 @@ public class Command_toggle extends FreedomCommand
|
||||
msg("- spawners");
|
||||
msg("- 4chan");
|
||||
msg("- beehives");
|
||||
msg("- autotp");
|
||||
msg("- autoclear");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -213,6 +215,16 @@ public class Command_toggle extends FreedomCommand
|
||||
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("autotp"))
|
||||
{
|
||||
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("autoclear"))
|
||||
{
|
||||
toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
@ -232,7 +244,8 @@ public class Command_toggle extends FreedomCommand
|
||||
return Arrays.asList(
|
||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
|
||||
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives");
|
||||
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
|
||||
"autotp", "autoclear");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -10,11 +10,9 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r[estore]]")
|
||||
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r]")
|
||||
public class Command_unban extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -26,7 +24,6 @@ public class Command_unban extends FreedomCommand
|
||||
String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
@ -38,30 +35,14 @@ public class Command_unban extends FreedomCommand
|
||||
ips.addAll(entry.getIps());
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||
playerMsg(sender, ChatColor.GRAY + username + " has been unbanned and IP is: " + StringUtils.join(ips, ", "));
|
||||
msg(username + " has been unbanned along with the following IPs: " + StringUtils.join(ips, ", "));
|
||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("-r") || args[1].equalsIgnoreCase("-restore"))
|
||||
if (args[1].equalsIgnoreCase("-r"))
|
||||
{
|
||||
if (!plugin.cpb.isEnabled())
|
||||
{
|
||||
// Redo WorldEdits
|
||||
try
|
||||
{
|
||||
plugin.web.redo(player, 15);
|
||||
}
|
||||
catch (NoClassDefFoundError | NullPointerException ex)
|
||||
{
|
||||
}
|
||||
// Rollback
|
||||
plugin.rb.undoRollback(username);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.cpb.restore(username);
|
||||
}
|
||||
plugin.cpb.restore(username);
|
||||
msg("Restored edits for: " + username);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class Command_unlinkdiscord extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
admin.setDiscordID(null);
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,99 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unmutes a player", usage = "/<command> [-q] <player>")
|
||||
public class Command_unmute extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// -q option (shadowmute)
|
||||
boolean quiet = args[0].equals("-q");
|
||||
if (quiet)
|
||||
{
|
||||
args = ArrayUtils.subarray(args, 1, args.length);
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg(player.getName() + " is an admin, and can't be muted.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerdata.isMuted())
|
||||
{
|
||||
playerdata.setMuted(false);
|
||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
if (quiet)
|
||||
{
|
||||
playerdata.setMuted(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||
playerdata.setMuted(false);
|
||||
msg("Unmuted " + player.getName());
|
||||
|
||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(ChatColor.RED + "That player is not muted.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.addAll(FUtil.getPlayerList());
|
||||
arguments.addAll(Arrays.asList("list", "purge", "all"));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -44,12 +44,7 @@ public class Command_vanish extends FreedomCommand
|
||||
}
|
||||
if (!silent)
|
||||
{
|
||||
String beginning = sender.getName() + " is ";
|
||||
if (admin.getLoginMessage().contains("%name%"))
|
||||
{
|
||||
beginning = "";
|
||||
}
|
||||
FUtil.bcastMsg(ChatColor.AQUA + beginning + loginMsg);
|
||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
||||
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
|
||||
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**");
|
||||
}
|
||||
@ -62,8 +57,10 @@ public class Command_vanish extends FreedomCommand
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has unvanished and is now visible to everyone." );
|
||||
player.showPlayer(plugin, playerSender);
|
||||
{
|
||||
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has unvanished and is now visible to everyone.");
|
||||
player.showPlayer(plugin, playerSender);
|
||||
}
|
||||
}
|
||||
plugin.esb.setVanished(playerSender.getName(), false);
|
||||
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||
|
@ -149,7 +149,6 @@ public class Command_verify extends FreedomCommand
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||
plugin.rm.updateDisplay(playerSender);
|
||||
playerSender.setOp(true);
|
||||
msg(YOU_ARE_OP);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
@ -158,6 +157,7 @@ public class Command_verify extends FreedomCommand
|
||||
msg("You have been unfrozen.");
|
||||
}
|
||||
plugin.pv.verifyPlayer(playerSender, backupCode);
|
||||
plugin.rm.updateDisplay(playerSender);
|
||||
return true;
|
||||
}
|
||||
else if (plugin.al.isAdminImpostor(playerSender))
|
||||
@ -218,7 +218,7 @@ public class Command_verify extends FreedomCommand
|
||||
|
||||
admin.setActive(true);
|
||||
admin.setLastLogin(new Date());
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
plugin.rm.updateDisplay(playerSender);
|
||||
playerSender.setOp(true);
|
||||
|
@ -1,35 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Reload the banned VPN IP list.", usage = "/<command> reload")
|
||||
public class Command_vpnbanlist extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
msg("Reloading VPN ban list...", ChatColor.RED);
|
||||
plugin.vn.stop();
|
||||
plugin.vn.start();
|
||||
msg("Reloaded VPN ban list.");
|
||||
msg(plugin.vn.getVPNIps().size() + " IPs loaded");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -27,9 +28,11 @@ public class Command_wipeflatlands extends FreedomCommand
|
||||
|
||||
FUtil.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY);
|
||||
|
||||
World flatlands = plugin.wm.flatlands.getWorld();
|
||||
|
||||
if (plugin.wgb.isEnabled())
|
||||
{
|
||||
plugin.wgb.wipeRegions(plugin.wm.flatlands.getWorld());
|
||||
plugin.wgb.wipeRegions(flatlands);
|
||||
}
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
@ -37,13 +40,13 @@ public class Command_wipeflatlands extends FreedomCommand
|
||||
player.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes.");
|
||||
}
|
||||
|
||||
if (!plugin.amp.enabled)
|
||||
if (plugin.cpb.isEnabled())
|
||||
{
|
||||
server.shutdown();
|
||||
plugin.cpb.clearDatabase(flatlands, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.amp.restartServer();
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -71,12 +71,6 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
}
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
return null;
|
||||
}*/
|
||||
// Doesn't need to do any starts-with checks
|
||||
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return null;
|
||||
}
|
||||
@ -85,7 +79,8 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
List<String> options = getTabCompleteOptions(sender, command, alias, args);
|
||||
if (options == null) {
|
||||
if (options == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
|
||||
@ -140,6 +135,16 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
return Players.getPlayer(name);
|
||||
}
|
||||
|
||||
protected Player getPlayer(String name, Boolean nullVanished)
|
||||
{
|
||||
Player player = Players.getPlayer(name);
|
||||
if (nullVanished && plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return Players.getPlayer(name);
|
||||
}
|
||||
|
||||
protected void msg(final CommandSender sender, final String message, final ChatColor color)
|
||||
{
|
||||
if (sender == null)
|
||||
|
@ -31,6 +31,8 @@ public enum ConfigEntry
|
||||
ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"),
|
||||
ALLOW_SPAWNERS(Boolean.class, "allow.spawners"),
|
||||
ALLOW_BEEHIVES(Boolean.class, "allow.beehives"),
|
||||
AUTO_TP(Boolean.class, "allow.auto_tp"),
|
||||
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
|
||||
//
|
||||
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
|
||||
//
|
||||
@ -150,12 +152,7 @@ public enum ConfigEntry
|
||||
VOTING_INFO(List.class, "votinginfo"),
|
||||
MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"),
|
||||
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
|
||||
TOGGLE_CHAT(Boolean.class, "toggle_chat"),
|
||||
//
|
||||
AMP_ENABLED(Boolean.class, "amp.enabled"),
|
||||
AMP_USERNAME(String.class, "amp.username"),
|
||||
AMP_PASSWORD(String.class, "amp.password"),
|
||||
AMP_URL(String.class, "amp.url");
|
||||
TOGGLE_CHAT(Boolean.class, "toggle_chat");
|
||||
//
|
||||
private final Class<?> type;
|
||||
private final String configName;
|
||||
|
@ -184,7 +184,7 @@ public class Discord extends FreedomService
|
||||
PrivateChannel privateChannel = user.openPrivateChannel().complete();
|
||||
privateChannel.sendMessage("Do not share these codes with anyone as they can be used to impose as you.").addFile(file).complete();
|
||||
admin.setBackupCodes(encryptedCodes);
|
||||
plugin.al.save();
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
file.delete();
|
||||
return true;
|
||||
@ -331,13 +331,13 @@ public class Discord extends FreedomService
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
messageChatChannel("**" + event.getPlayer().getName() + " joined the server" + "**");
|
||||
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " joined the server" + "**");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLeave(PlayerQuitEvent event)
|
||||
{
|
||||
messageChatChannel("**" + event.getPlayer().getName() + " left the server" + "**");
|
||||
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " left the server" + "**");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -354,7 +354,7 @@ public class Discord extends FreedomService
|
||||
{
|
||||
}
|
||||
|
||||
messageChatChannel("**" + event.getDeathMessage() + "**");
|
||||
messageChatChannel("**" + deformat(event.getDeathMessage()) + "**");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -430,6 +430,11 @@ public class Discord extends FreedomService
|
||||
FLog.info("Discord verification bot has successfully shutdown.");
|
||||
}
|
||||
|
||||
public String deformat(String input)
|
||||
{
|
||||
return input.replace("_", "\\_");
|
||||
}
|
||||
|
||||
public boolean sendReport(Player reporter, Player reported, String reason)
|
||||
{
|
||||
if (ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString().isEmpty())
|
||||
|
@ -23,7 +23,7 @@ public class PrivateMessageListener extends ListenerAdapter
|
||||
Admin admin = Discord.ADMIN_LINK_CODES.get(code);
|
||||
name = admin.getName();
|
||||
admin.setDiscordID(event.getMessage().getAuthor().getId());
|
||||
TotalFreedomMod.plugin().al.save();
|
||||
TotalFreedomMod.plugin().al.save(admin);
|
||||
TotalFreedomMod.plugin().al.updateTables();
|
||||
Discord.ADMIN_LINK_CODES.remove(code);
|
||||
Discord.syncRoles(admin);
|
||||
|
@ -189,17 +189,7 @@ public class ItemFun extends FreedomService
|
||||
|
||||
case CARROT:
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!plugin.al.isSeniorAdmin(player))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()) && plugin.mbwr.doRestrict(player))
|
||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean() || !plugin.al.isSeniorAdmin(player) || plugin.wr.doRestrict(player))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_permbans;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_vpnbans;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -70,7 +69,6 @@ public class HTTPDaemon extends FreedomService
|
||||
module("players", Module_players.class, false);
|
||||
module("punishments", Module_punishments.class, true);
|
||||
module("schematic", Module_schematic.class, true);
|
||||
module("vpnbans", Module_vpnbans.class, true);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -17,7 +17,10 @@ public class Module_admins extends HTTPDModule
|
||||
@Override
|
||||
public NanoHTTPD.Response getResponse()
|
||||
{
|
||||
File adminFile = new File(plugin.getDataFolder(), Admin.CONFIG_FILENAME);
|
||||
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"Error 404: Not Found - i have to re-work this");
|
||||
/*File adminFile = new File(plugin.getDataFolder(), Admin.CONFIG_FILENAME);
|
||||
if (adminFile.exists())
|
||||
{
|
||||
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||
@ -36,7 +39,7 @@ public class Module_admins extends HTTPDModule
|
||||
{
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private boolean isAuthorized(String remoteAddress)
|
||||
|
@ -18,7 +18,9 @@ public class Module_bans extends HTTPDModule
|
||||
@Override
|
||||
public NanoHTTPD.Response getResponse()
|
||||
{
|
||||
File banFile = new File(plugin.getDataFolder(), BanManager.CONFIG_FILENAME);
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"Error 404: Not Found - i have to re-work this");
|
||||
/*File banFile = new File(plugin.getDataFolder(), BanManager.CONFIG_FILENAME);
|
||||
if (banFile.exists())
|
||||
{
|
||||
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||
@ -37,7 +39,7 @@ public class Module_bans extends HTTPDModule
|
||||
{
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private boolean isAuthorized(String remoteAddress)
|
||||
|
@ -40,6 +40,11 @@ public class Module_list extends HTTPDModule
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
|
||||
if (plugin.al.vanished.contains(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isImposter(player))
|
||||
{
|
||||
imposters.add(player.getName());
|
||||
@ -123,6 +128,10 @@ public class Module_list extends HTTPDModule
|
||||
|
||||
for (Player player : onlinePlayers)
|
||||
{
|
||||
if (plugin.al.vanished.contains(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String tag = plugin.rm.getDisplay(player).getTag();
|
||||
body.append("<li>").append(tag).append(player.getName()).append("</li>\r\n");
|
||||
}
|
||||
|
@ -37,10 +37,13 @@ public class Module_players extends HTTPDModule
|
||||
// All online players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
players.add(player.getName());
|
||||
if (plugin.al.isAdmin(player) && !plugin.al.isAdminImpostor(player))
|
||||
if (!plugin.al.vanished.contains(player))
|
||||
{
|
||||
onlineadmins.add(player.getName());
|
||||
players.add(player.getName());
|
||||
if (plugin.al.isAdmin(player) && !plugin.al.isAdminImpostor(player))
|
||||
{
|
||||
onlineadmins.add(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
@ -269,8 +270,9 @@ public class Module_schematic extends HTTPDModule
|
||||
|
||||
private boolean isAuthorized(String remoteAddress)
|
||||
{
|
||||
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||
return entry != null && entry.isActive();
|
||||
Admin adminEntry = plugin.al.getEntryByIp(remoteAddress);
|
||||
MasterBuilder masterBuilderEntry = plugin.mbl.getEntryByIp(remoteAddress);
|
||||
return ((adminEntry != null && adminEntry.isActive()) || masterBuilderEntry != null);
|
||||
}
|
||||
|
||||
private static class SchematicTransferException extends Exception
|
||||
|
@ -1,32 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||
|
||||
import java.io.File;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.banning.VPNBanList;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
|
||||
public class Module_vpnbans extends HTTPDModule
|
||||
{
|
||||
|
||||
public Module_vpnbans(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(plugin, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NanoHTTPD.Response getResponse()
|
||||
{
|
||||
File vpnbanFile = new File(plugin.getDataFolder(), VPNBanList.CONFIG_FILENAME);
|
||||
|
||||
if (vpnbanFile.exists())
|
||||
{
|
||||
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), VPNBanList.CONFIG_FILENAME));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||
}
|
||||
}
|
||||
}
|
@ -84,7 +84,7 @@ public class MasterBuilderList extends FreedomService
|
||||
}
|
||||
|
||||
updateTables();
|
||||
FLog.info("Loaded " + masterBuilders.size() + " master builders with " + ipTable.size() + " IPs)");
|
||||
FLog.info("Loaded " + masterBuilders.size() + " master builders with " + ipTable.size() + " IPs");
|
||||
}
|
||||
|
||||
public void save()
|
||||
|
@ -76,9 +76,6 @@ public class FPlayer
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean invSee = false;
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean quietMuted = false;
|
||||
|
||||
public FPlayer(TotalFreedomMod plugin, Player player)
|
||||
{
|
||||
|
@ -19,4 +19,6 @@ public interface Displayable
|
||||
|
||||
public String getColoredLoginMessage();
|
||||
|
||||
public boolean hasTeam();
|
||||
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ import org.bukkit.ChatColor;
|
||||
public enum Rank implements Displayable
|
||||
{
|
||||
|
||||
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW),
|
||||
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE),
|
||||
OP("an", "Op", Type.PLAYER, "OP", ChatColor.GREEN),
|
||||
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA),
|
||||
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN),
|
||||
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD),
|
||||
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE),
|
||||
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE);
|
||||
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW, false),
|
||||
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE, false),
|
||||
OP("an", "Operator", Type.PLAYER, "OP", ChatColor.GREEN, false),
|
||||
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA, true),
|
||||
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN, true),
|
||||
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD, true),
|
||||
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false),
|
||||
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false);
|
||||
@Getter
|
||||
private final Type type;
|
||||
@Getter
|
||||
@ -27,8 +27,10 @@ public enum Rank implements Displayable
|
||||
private final String coloredTag;
|
||||
@Getter
|
||||
private final ChatColor color;
|
||||
@Getter
|
||||
private final boolean hasTeam;
|
||||
|
||||
private Rank(String determiner, String name, Type type, String abbr, ChatColor color)
|
||||
private Rank(String determiner, String name, Type type, String abbr, ChatColor color, Boolean hasTeam)
|
||||
{
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
@ -37,6 +39,7 @@ public enum Rank implements Displayable
|
||||
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
||||
this.coloredTag = abbr.isEmpty() ? "" : ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
||||
this.color = color;
|
||||
this.hasTeam = hasTeam;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,6 +54,12 @@ public enum Rank implements Displayable
|
||||
return determiner + " " + color + ChatColor.ITALIC + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTeam()
|
||||
{
|
||||
return hasTeam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAbbr()
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.ChatUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -16,6 +17,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class RankManager extends FreedomService
|
||||
{
|
||||
@ -175,6 +178,7 @@ public class RankManager extends FreedomService
|
||||
fPlayer.setTag(null);
|
||||
player.setPlayerListName(null);
|
||||
}
|
||||
updatePlayerTeam(player);
|
||||
plugin.pem.setPermissions(player);
|
||||
}
|
||||
|
||||
@ -239,36 +243,10 @@ public class RankManager extends FreedomService
|
||||
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.mbl.isMasterBuilder(player))
|
||||
{
|
||||
final Displayable display = getDisplay(player);
|
||||
String loginMsg = display.getColoredLoginMessage();
|
||||
|
||||
if (isAdmin)
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
if (admin.hasLoginMessage())
|
||||
{
|
||||
loginMsg = ChatUtils.colorize(admin.getLoginMessage()).replace("%rank%", plugin.rm.getDisplay(admin).getName()).replace("%coloredrank%", plugin.rm.getDisplay(admin).getColoredName());
|
||||
}
|
||||
}
|
||||
FUtil.bcastMsg(ChatColor.AQUA + (loginMsg.contains("%name%") ? "" : player.getName() + " is ") + FUtil.colorize(loginMsg).replace("%name%", player.getName()));
|
||||
plugin.pl.getPlayer(player).setTag(display.getColoredTag());
|
||||
FUtil.bcastMsg(craftLoginMessage(player, null));
|
||||
|
||||
if (isAdmin)
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
if (admin.getTag() != null)
|
||||
{
|
||||
plugin.pl.getPlayer(player).setTag(FUtil.colorize(admin.getTag()));
|
||||
}
|
||||
}
|
||||
|
||||
String displayName = display.getColor() + player.getName();
|
||||
try
|
||||
{
|
||||
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
updateDisplay(player);
|
||||
}
|
||||
|
||||
if (!plugin.pv.isPlayerImpostor(player) && target.getEnabled())
|
||||
@ -279,4 +257,50 @@ public class RankManager extends FreedomService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String craftLoginMessage(Player player, String message)
|
||||
{
|
||||
Displayable display = plugin.rm.getDisplay(player);
|
||||
String loginMessage = ChatColor.AQUA + player.getName() + " is " + display.getColoredLoginMessage();
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
if (admin.hasLoginMessage())
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
message = admin.getLoginMessage();
|
||||
}
|
||||
loginMessage = FUtil.colorize(ChatColor.AQUA + (message.contains("%name%") ? "" : player.getName() + " is ")
|
||||
+ FUtil.colorize(message).replace("%name%", player.getName())
|
||||
.replace("%rank%", display.getName())
|
||||
.replace("%coloredrank%", display.getColoredName()));
|
||||
}
|
||||
}
|
||||
return loginMessage;
|
||||
}
|
||||
|
||||
public void updatePlayerTeam(Player player)
|
||||
{
|
||||
FLog.info("Updating team data...");
|
||||
Displayable display = getDisplay(player);
|
||||
Scoreboard scoreboard = server.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getPlayerTeam(player);
|
||||
if (team != null && !display.hasTeam())
|
||||
{
|
||||
FLog.info("Removing from team");
|
||||
team.removePlayer(player);
|
||||
return;
|
||||
}
|
||||
team = scoreboard.getTeam(display.toString());
|
||||
if (team == null)
|
||||
{
|
||||
FLog.info("Creating team...");
|
||||
team = scoreboard.registerNewTeam(display.toString());
|
||||
FLog.info("Created team " + team.getName());
|
||||
team.setColor(display.getColor());
|
||||
}
|
||||
team.addPlayer(player);
|
||||
FLog.info("Added player to team");
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ import org.bukkit.ChatColor;
|
||||
public enum Title implements Displayable
|
||||
{
|
||||
|
||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB"),
|
||||
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, "VA"),
|
||||
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, "Asst Exec"),
|
||||
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec"),
|
||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev"),
|
||||
OWNER("the", "Owner", ChatColor.DARK_RED, "Owner");
|
||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB", false),
|
||||
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, "VA", false),
|
||||
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, "Asst Exec", false),
|
||||
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec", true),
|
||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev", true),
|
||||
OWNER("the", "Owner", ChatColor.DARK_RED, "Owner", true);
|
||||
|
||||
private final String determiner;
|
||||
@Getter
|
||||
@ -24,8 +24,10 @@ public enum Title implements Displayable
|
||||
private final String coloredTag;
|
||||
@Getter
|
||||
private final ChatColor color;
|
||||
@Getter
|
||||
private final boolean hasTeam;
|
||||
|
||||
private Title(String determiner, String name, ChatColor color, String tag)
|
||||
private Title(String determiner, String name, ChatColor color, String tag, Boolean hasTeam)
|
||||
{
|
||||
this.determiner = determiner;
|
||||
this.name = name;
|
||||
@ -33,6 +35,7 @@ public enum Title implements Displayable
|
||||
this.abbr = tag;
|
||||
this.tag = "[" + tag + "]";
|
||||
this.color = color;
|
||||
this.hasTeam = hasTeam;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,6 +44,12 @@ public enum Title implements Displayable
|
||||
return color + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTeam()
|
||||
{
|
||||
return hasTeam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColoredLoginMessage()
|
||||
{
|
||||
|
@ -1,20 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.rollback;
|
||||
|
||||
public enum EntryType
|
||||
{
|
||||
|
||||
BLOCK_PLACE("placed"),
|
||||
BLOCK_BREAK("broke");
|
||||
private final String action;
|
||||
|
||||
private EntryType(String action)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return action;
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.rollback;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class RollbackEntry
|
||||
{
|
||||
|
||||
// Use of primitives to decrease overhead
|
||||
public final String author;
|
||||
public final String worldName;
|
||||
public final int x;
|
||||
public final short y;
|
||||
public final int z;
|
||||
public final BlockData data;
|
||||
public final Material blockMaterial;
|
||||
private final boolean isBreak;
|
||||
|
||||
public RollbackEntry(String author, Block block, EntryType entryType)
|
||||
{
|
||||
final Location location = block.getLocation();
|
||||
|
||||
this.x = location.getBlockX();
|
||||
this.y = (short)location.getBlockY();
|
||||
this.z = location.getBlockZ();
|
||||
this.worldName = location.getWorld().getName();
|
||||
this.author = author;
|
||||
|
||||
if (entryType == EntryType.BLOCK_BREAK)
|
||||
{
|
||||
this.blockMaterial = block.getType();
|
||||
this.data = block.getBlockData();
|
||||
this.isBreak = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.blockMaterial = block.getType();
|
||||
this.data = block.getBlockData();
|
||||
this.isBreak = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Location(Bukkit.getWorld(worldName), x, (int)y, z);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.warning("Could not get location of rollback entry at (" + worldName + ":" + x + "," + y + "," + x + ")!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Material getMaterial()
|
||||
{
|
||||
return blockMaterial;
|
||||
}
|
||||
|
||||
public EntryType getType()
|
||||
{
|
||||
return (isBreak ? EntryType.BLOCK_BREAK : EntryType.BLOCK_PLACE);
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
final Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
|
||||
if (isBreak)
|
||||
{
|
||||
block.setType(getMaterial());
|
||||
block.setBlockData(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
public void redo()
|
||||
{
|
||||
final Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
|
||||
|
||||
if (isBreak)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(getMaterial());
|
||||
block.setBlockData(data);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,295 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.rollback;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.coreprotect.CoreProtectAPI.ParseResult;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class RollbackManager extends FreedomService
|
||||
{
|
||||
|
||||
private static final Map<String, List<RollbackEntry>> history = Maps.newHashMap();
|
||||
private static final List<String> removeHistory = Lists.newArrayList();
|
||||
|
||||
public RollbackManager(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void blockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_PLACE));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void blockBreak(BlockBreakEvent event)
|
||||
{
|
||||
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_BREAK));
|
||||
}
|
||||
|
||||
private void storeEntry(Player player, RollbackEntry entry)
|
||||
{
|
||||
List<RollbackEntry> playerEntryList = getEntriesByPlayer(player.getName());
|
||||
|
||||
if (playerEntryList != null)
|
||||
{
|
||||
playerEntryList.add(0, entry);
|
||||
}
|
||||
}
|
||||
|
||||
// May return null
|
||||
public String findPlayer(String partial)
|
||||
{
|
||||
partial = partial.toLowerCase();
|
||||
|
||||
for (String player : history.keySet())
|
||||
{
|
||||
if (player.toLowerCase().equals(partial))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
for (String player : history.keySet())
|
||||
{
|
||||
if (player.toLowerCase().contains(partial))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int purgeEntries()
|
||||
{
|
||||
Iterator<List<RollbackEntry>> it = history.values().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
List<RollbackEntry> playerEntryList = it.next();
|
||||
if (playerEntryList != null)
|
||||
{
|
||||
playerEntryList.clear();
|
||||
}
|
||||
}
|
||||
return history.size();
|
||||
}
|
||||
|
||||
public int purgeEntries(String playerName)
|
||||
{
|
||||
List<RollbackEntry> playerEntryList = getEntriesByPlayer(playerName);
|
||||
|
||||
if (playerEntryList == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = playerEntryList.size();
|
||||
playerEntryList.clear();
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
public boolean canRollback(String playerName)
|
||||
{
|
||||
return history.containsKey(playerName.toLowerCase()) && !history.get(playerName.toLowerCase()).isEmpty();
|
||||
}
|
||||
|
||||
public boolean canUndoRollback(String playerName)
|
||||
{
|
||||
return removeHistory.contains(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
public int rollback(final String playerName)
|
||||
{
|
||||
final List<RollbackEntry> entries = getEntriesByPlayer(playerName);
|
||||
if (entries == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = entries.size();
|
||||
for (RollbackEntry entry : entries)
|
||||
{
|
||||
if (entry != null)
|
||||
{
|
||||
entry.restore();
|
||||
}
|
||||
}
|
||||
|
||||
if (!removeHistory.contains(playerName.toLowerCase()))
|
||||
{
|
||||
removeHistory.add(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (removeHistory.contains(playerName.toLowerCase()))
|
||||
{
|
||||
removeHistory.remove(playerName.toLowerCase());
|
||||
purgeEntries(playerName);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(plugin, 40L * 20L);
|
||||
return count;
|
||||
}
|
||||
|
||||
public int undoRollback(String playerName)
|
||||
{
|
||||
final List<RollbackEntry> entries = getEntriesByPlayer(playerName);
|
||||
|
||||
if (entries == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final int count = entries.size();
|
||||
|
||||
final ListIterator<RollbackEntry> it = entries.listIterator(count);
|
||||
while (it.hasPrevious())
|
||||
{
|
||||
RollbackEntry entry = it.previous();
|
||||
if (entry != null)
|
||||
{
|
||||
entry.redo();
|
||||
}
|
||||
}
|
||||
|
||||
if (removeHistory.contains(playerName.toLowerCase()))
|
||||
{
|
||||
removeHistory.remove(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public List<RollbackEntry> getEntriesAtLocation(final Location location)
|
||||
{
|
||||
final int testX = location.getBlockX();
|
||||
final short testY = (short)location.getBlockY();
|
||||
final int testZ = location.getBlockZ();
|
||||
final String testWorldName = location.getWorld().getName();
|
||||
|
||||
List<RollbackEntry> entries = new ArrayList<>();
|
||||
for (String playername : history.keySet())
|
||||
{
|
||||
for (RollbackEntry entry : history.get(playername.toLowerCase()))
|
||||
{
|
||||
if (testX == entry.x && testY == entry.y && testZ == entry.z && testWorldName.equals(entry.worldName))
|
||||
{
|
||||
entries.add(0, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = false)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (!event.hasItem()
|
||||
|| event.getItem().getType() != Material.STICK
|
||||
|| !plugin.al.isAdmin(player)
|
||||
|| !plugin.al.getAdmin(player).getLogStick())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
final Block block = DepreciationAggregator.getTargetBlock(player, null, 5);
|
||||
|
||||
if (plugin.cpb.isEnabled())
|
||||
{
|
||||
final List<String[]> entries = plugin.cpb.getCoreProtect().getAPI().blockLookup(block, 86400);
|
||||
|
||||
if (entries.isEmpty())
|
||||
{
|
||||
FUtil.playerMsg(player, "No block edits at that location.");
|
||||
return;
|
||||
}
|
||||
|
||||
FUtil.playerMsg(player, "Block edits at ("
|
||||
+ ChatColor.WHITE + "x" + block.getX()
|
||||
+ ", y" + block.getY()
|
||||
+ ", z" + block.getZ()
|
||||
+ ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
for (String[] entry : Lists.reverse(entries))
|
||||
{
|
||||
ParseResult parsedEntry = plugin.cpb.getCoreProtect().getAPI().parseResult(entry);
|
||||
FUtil.playerMsg(player, ChatColor.BLUE + parsedEntry.getActionString() + " of " + StringUtils.capitalize(parsedEntry.getType().name()) + " - " + parsedEntry.getPlayer());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final List<RollbackEntry> entries = plugin.rb.getEntriesAtLocation(block.getLocation());
|
||||
|
||||
if (entries.isEmpty())
|
||||
{
|
||||
FUtil.playerMsg(player, "No block edits at that location.");
|
||||
return;
|
||||
}
|
||||
|
||||
FUtil.playerMsg(player, "Block edits at ("
|
||||
+ ChatColor.WHITE + "x" + block.getX()
|
||||
+ ", y" + block.getY()
|
||||
+ ", z" + block.getZ()
|
||||
+ ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
for (RollbackEntry entry : entries)
|
||||
{
|
||||
FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " "
|
||||
+ StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == null ? "" : ":" + entry.data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<RollbackEntry> getEntriesByPlayer(String playerName)
|
||||
{
|
||||
playerName = playerName.toLowerCase();
|
||||
List<RollbackEntry> playerEntryList = history.get(playerName.toLowerCase());
|
||||
if (playerEntryList == null)
|
||||
{
|
||||
playerEntryList = new ArrayList<>();
|
||||
history.put(playerName.toLowerCase(), playerEntryList);
|
||||
}
|
||||
return playerEntryList;
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ import me.rayzr522.jsonmessage.JSONMessage;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.config.YamlConfig;
|
||||
@ -37,7 +38,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
public class Shop extends FreedomService
|
||||
{
|
||||
@Getter
|
||||
public final Map<UUID, ShopData> dataMap = Maps.newHashMap();
|
||||
public final Map<String, ShopData> dataMap = Maps.newHashMap();
|
||||
@Getter
|
||||
private final File configFolder;
|
||||
private BukkitTask reactions;
|
||||
@ -102,8 +103,8 @@ public class Shop extends FreedomService
|
||||
YamlConfig config = getConfig(data);
|
||||
data.saveTo(config);
|
||||
config.save();
|
||||
dataMap.remove(data.getUUID());
|
||||
dataMap.put(data.getUUID(), data);
|
||||
dataMap.remove(data.getUsername());
|
||||
dataMap.put(data.getUsername(), data);
|
||||
}
|
||||
|
||||
public String getShopPrefix()
|
||||
@ -119,30 +120,29 @@ public class Shop extends FreedomService
|
||||
// May not return null
|
||||
public ShopData getData(Player player)
|
||||
{
|
||||
// Check already loaded
|
||||
ShopData data = dataMap.get(player.getUniqueId());
|
||||
// Check for existing data
|
||||
ShopData data = dataMap.get(player.getName());
|
||||
if (data != null)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
// Load data
|
||||
data = getData(player.getUniqueId());
|
||||
data = getData(player.getName());
|
||||
|
||||
// Create data if nonexistent
|
||||
String ip = Ips.getIp(player);
|
||||
|
||||
// Create new data if nonexistent
|
||||
if (data == null)
|
||||
{
|
||||
FLog.info("Creating new shop data entry for " + player.getName());
|
||||
FLog.info("Creating new player verification entry for " + player.getName());
|
||||
|
||||
// Create new player
|
||||
data = new ShopData(player);
|
||||
data.setUsername(player.getName());
|
||||
|
||||
// Set defaults
|
||||
data.setCoins(0);
|
||||
data.addIp(Ips.getIp(player));
|
||||
|
||||
// Store player
|
||||
dataMap.put(player.getUniqueId(), data);
|
||||
dataMap.put(player.getName(), data);
|
||||
|
||||
// Save player
|
||||
YamlConfig config = getConfig(data);
|
||||
@ -150,34 +150,46 @@ public class Shop extends FreedomService
|
||||
config.save();
|
||||
}
|
||||
|
||||
dataMap.put(player.getUniqueId(), data);
|
||||
if (!data.getsIps().contains(ip))
|
||||
{
|
||||
data.addIp(ip);
|
||||
save(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public ShopData getData(String username)
|
||||
{
|
||||
UUID uuid = FUtil.nameToUUID(username);
|
||||
if (uuid != null)
|
||||
{
|
||||
return getData(uuid);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
username = username.toLowerCase();
|
||||
|
||||
public ShopData getData(UUID uuid)
|
||||
{
|
||||
// Check if the player is a known player
|
||||
final File configFile = getConfigFile(uuid);
|
||||
final File configFile = getConfigFile(username);
|
||||
if (!configFile.exists())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Load entry
|
||||
final ShopData data = new ShopData(uuid);
|
||||
data.loadFrom(getConfig(data));
|
||||
return data;
|
||||
final ShopData shopData = new ShopData(username);
|
||||
shopData.loadFrom(getConfig(shopData));
|
||||
|
||||
if (!shopData.isValid())
|
||||
{
|
||||
FLog.warning("Could not load player verification entry for " + username + ". Entry is not valid!");
|
||||
configFile.delete();
|
||||
return null;
|
||||
}
|
||||
|
||||
// Only store data in map if the player is online
|
||||
for (Player players : server.getOnlinePlayers())
|
||||
{
|
||||
if (players.getName().equals(username))
|
||||
{
|
||||
dataMap.put(username, shopData);
|
||||
return shopData;
|
||||
}
|
||||
}
|
||||
|
||||
return shopData;
|
||||
}
|
||||
|
||||
public Inventory generateShopGUI(ShopData shopData)
|
||||
@ -329,7 +341,7 @@ public class Shop extends FreedomService
|
||||
}
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
ShopData shopData = getData(player);
|
||||
int price = shopItem.getCost();
|
||||
int coins = shopData.getCoins();
|
||||
|
||||
@ -420,14 +432,14 @@ public class Shop extends FreedomService
|
||||
return dataMap.values();
|
||||
}
|
||||
|
||||
protected File getConfigFile(UUID uuid)
|
||||
protected File getConfigFile(String name)
|
||||
{
|
||||
return new File(getConfigFolder(), uuid + ".yml");
|
||||
return new File(getConfigFolder(), name.toLowerCase() + ".yml");
|
||||
}
|
||||
|
||||
protected YamlConfig getConfig(ShopData data)
|
||||
{
|
||||
final YamlConfig config = new YamlConfig(plugin, getConfigFile(data.getUUID()), false);
|
||||
final YamlConfig config = new YamlConfig(plugin, getConfigFile(data.getUsername()), false);
|
||||
config.load();
|
||||
return config;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
|
||||
public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
|
||||
{
|
||||
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
@Getter
|
||||
@Setter
|
||||
private String username;
|
||||
@ -30,19 +31,19 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
|
||||
|
||||
public ShopData(Player player)
|
||||
{
|
||||
this(player.getUniqueId());
|
||||
this(player.getName());
|
||||
}
|
||||
|
||||
public ShopData(UUID uuid)
|
||||
public ShopData(String name)
|
||||
{
|
||||
this.uuid = uuid.toString();
|
||||
this.username = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFrom(ConfigurationSection cs)
|
||||
{
|
||||
this.username = cs.getString("username", username);
|
||||
this.uuid = cs.getString("uuid", uuid);
|
||||
this.ips.addAll(cs.getStringList("ips"));
|
||||
this.coins = cs.getInt("coins", coins);
|
||||
this.items.addAll(cs.getStringList("items"));
|
||||
this.totalVotes = cs.getInt("totalVotes");
|
||||
@ -53,7 +54,7 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
|
||||
{
|
||||
Validate.isTrue(isValid(), "Could not save shop entry: " + username + ". Entry not valid!");
|
||||
cs.set("username", username);
|
||||
cs.set("uuid", uuid);
|
||||
cs.set("ips", ips);
|
||||
cs.set("coins", coins);
|
||||
cs.set("items", items);
|
||||
cs.set("totalVotes", totalVotes);
|
||||
@ -64,16 +65,6 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
|
||||
return Collections.unmodifiableList(items);
|
||||
}
|
||||
|
||||
public void setUUID(UUID id)
|
||||
{
|
||||
uuid = id.toString();
|
||||
}
|
||||
|
||||
public UUID getUUID()
|
||||
{
|
||||
return UUID.fromString(uuid);
|
||||
}
|
||||
|
||||
public void giveItem(ShopItem item)
|
||||
{
|
||||
items.add(item.getDataName());
|
||||
@ -88,6 +79,21 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addIp(String ip)
|
||||
{
|
||||
return !ips.contains(ip) && ips.add(ip);
|
||||
}
|
||||
|
||||
public void removeIp(String ip)
|
||||
{
|
||||
ips.remove(ip);
|
||||
}
|
||||
|
||||
public List<String> getsIps()
|
||||
{
|
||||
return Collections.unmodifiableList(ips);
|
||||
}
|
||||
|
||||
public void removeItem(ShopItem item)
|
||||
{
|
||||
items.remove(item.getDataName());
|
||||
|
301
src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java
Normal file
301
src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java
Normal file
@ -0,0 +1,301 @@
|
||||
package me.totalfreedom.totalfreedommod.sql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.MessageFormat;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
||||
public class SQLite extends FreedomService
|
||||
{
|
||||
private final String FILE_NAME = "database.db";
|
||||
|
||||
private Connection connection;
|
||||
|
||||
public SQLite(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
connect();
|
||||
checkTables();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void connect()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder() + "/" + FILE_NAME);
|
||||
FLog.info("Successfully connected to the database.");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to connect to the database: " + e.getMessage());
|
||||
FLog.info("Successfully disconnected from the database.");
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (connection != null)
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to disconnect from the database: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void checkTables()
|
||||
{
|
||||
try
|
||||
{
|
||||
DatabaseMetaData meta = connection.getMetaData();
|
||||
if (!tableExists(meta, "bans"))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.createStatement().execute("CREATE TABLE `bans` ( `name` VARCHAR NOT NULL, `ips` VARCHAR, `by` VARCHAR NOT NULL, `at` LONG NOT NULL, `expires` LONG, `reason` VARCHAR );");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to create the bans table: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!tableExists(meta, "admins"))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.createStatement().execute("CREATE TABLE `admins` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `rank` VARCHAR NOT NULL, `active` BOOLEAN NOT NULL, `last_login` LONG NOT NULL, `login_message` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `backup_codes` VARCHAR, `command_spy` BOOLEAN NOT NULL, `potion_spy` BOOLEAN NOT NULL, `ac_format` VARCHAR, `old_tags` BOOLEAN NOT NULL, `log_stick` BOOLEAN NOT NULL, `discord_chat` BOOLEAN NOT NULL);");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to create the admins table: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to check tables on database: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void truncate(String table)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.createStatement().execute("TRUNCATE TABLE " + table);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to truncate " + table + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public ResultSet getBanList() throws SQLException
|
||||
{
|
||||
return connection.createStatement().executeQuery("SELECT * FROM bans");
|
||||
}
|
||||
|
||||
|
||||
public ResultSet getAdminList() throws SQLException
|
||||
{
|
||||
return connection.createStatement().executeQuery("SELECT * FROM admins");
|
||||
}
|
||||
|
||||
public void setAdminValue(Admin admin, String key, Object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object[] data = {key, admin.getName()};
|
||||
PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE admins SET {0}=? WHERE username=''{1}''", data));
|
||||
statement = setUnknownType(statement, 1, value);
|
||||
statement.executeUpdate();
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to update value: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAdminName(String oldName, String newName)
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE admins SET username=? WHERE username=''{0}''", oldName));
|
||||
statement = setUnknownType(statement, 1, newName);
|
||||
statement.executeUpdate();
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to update value: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public PreparedStatement setUnknownType(PreparedStatement statement, int index, Object value) throws SQLException
|
||||
{
|
||||
if (value.getClass().equals(String.class))
|
||||
{
|
||||
String v = (String)value;
|
||||
statement.setString(index, v);
|
||||
}
|
||||
else if (value.getClass().equals(Integer.class))
|
||||
{
|
||||
int v = (int)value;
|
||||
statement.setInt(index, v);
|
||||
}
|
||||
else if (value.getClass().equals(Boolean.class))
|
||||
{
|
||||
boolean v = (boolean)value;
|
||||
statement.setBoolean(index, v);
|
||||
}
|
||||
else if (value.getClass().equals(Long.class))
|
||||
{
|
||||
long v = (long)value;
|
||||
statement.setLong(index, v);
|
||||
}
|
||||
return statement;
|
||||
}
|
||||
|
||||
public Object getValue(ResultSet resultSet, String key, Object value) throws SQLException
|
||||
{
|
||||
Object result = null;
|
||||
if (value instanceof String)
|
||||
{
|
||||
result = resultSet.getString(key);
|
||||
}
|
||||
else if (value instanceof Integer)
|
||||
{
|
||||
result = resultSet.getInt(key);
|
||||
}
|
||||
else if (value instanceof Boolean)
|
||||
{
|
||||
result = resultSet.getBoolean(key);
|
||||
}
|
||||
else if (value instanceof Long)
|
||||
{
|
||||
result = resultSet.getLong(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addAdmin(Admin admin)
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO admins VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
statement.setString(1, admin.getName());
|
||||
statement.setString(2, FUtil.listToString(admin.getIps()));
|
||||
statement.setString(3, admin.getRank().toString());
|
||||
statement.setBoolean(4, admin.isActive());
|
||||
statement.setLong(5, admin.getLastLogin().getTime());
|
||||
statement.setString(6, admin.getLoginMessage());
|
||||
statement.setString(7, admin.getTag());
|
||||
statement.setString(8, admin.getDiscordID());
|
||||
statement.setString(9, FUtil.listToString(admin.getBackupCodes()));
|
||||
statement.setBoolean(10, admin.getCommandSpy());
|
||||
statement.setBoolean(11, admin.getPotionSpy());
|
||||
statement.setString(12, admin.getAcFormat());
|
||||
statement.setBoolean(13, admin.getOldTags());
|
||||
statement.setBoolean(14, admin.getLogStick());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to add admin: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public ResultSet getAdminByName(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResultSet resultSet = connection.createStatement().executeQuery(MessageFormat.format("SELECT * FROM admins WHERE username=''{0}''", name));
|
||||
if (resultSet.next())
|
||||
{
|
||||
return resultSet;
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to get admin by name: " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeAdmin(Admin admin)
|
||||
{
|
||||
Object[] data = {admin.getName(), FUtil.listToString(admin.getBackupCodes())};
|
||||
try
|
||||
{
|
||||
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans where name=''{0}'' and ips=''{1}''", data));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to remove admin: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void addBan(Ban ban)
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO bans VALUES (?, ?, ?, ?, ?, ?)");
|
||||
statement.setString(1, ban.getUsername());
|
||||
statement.setString(2, FUtil.listToString(ban.getIps()));
|
||||
statement.setString(3, ban.getBy());
|
||||
statement.setLong(4, ban.getAt().getTime());
|
||||
statement.setLong(5, ban.getExpiryUnix());
|
||||
statement.setString(6, ban.getReason());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to add ban: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBan(Ban ban)
|
||||
{
|
||||
Object[] data = {ban.getUsername(), String.join(", ", ban.getIps())};
|
||||
try
|
||||
{
|
||||
connection.createStatement().executeUpdate(MessageFormat.format("DELETE FROM bans where name=''{0}'' and ips=''{1}''", data));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to remove ban: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tableExists(DatabaseMetaData meta, String name) throws SQLException
|
||||
{
|
||||
return meta.getTables(null, null, name, null).next();
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -51,7 +52,7 @@ public class FUtil
|
||||
//
|
||||
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
|
||||
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
|
||||
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "Demonic_Mario", "OxLemonxO");
|
||||
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "Demonic_Mario");
|
||||
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
||||
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
||||
@ -147,11 +148,33 @@ public class FUtil
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
names.add(player.getName());
|
||||
if (!TotalFreedomMod.plugin().al.vanished.contains(player))
|
||||
{
|
||||
names.add(player.getName());
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static String listToString(List<String> list)
|
||||
{
|
||||
if (list.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.join(", ", list);
|
||||
}
|
||||
|
||||
public static List<String> stringToList(String string)
|
||||
{
|
||||
if (string == null)
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return Arrays.asList(string.split(", "));
|
||||
}
|
||||
public static List<String> getAllMaterialNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user