mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
chee
This commit is contained in:
parent
4dc63fb756
commit
59cbc05a4a
@ -16,13 +16,13 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.18" 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" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
|
||||
@ -48,7 +48,7 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:16.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.neovisionaries:nv-websocket-client:2.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
||||
@ -59,7 +59,7 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.15.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13-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.github.TFPatches:TF-WorldGuard:50fd4cb470" level="project" />
|
||||
@ -71,10 +71,5 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.opencsv:opencsv:2.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldGuard:worldguard-legacy:50fd4cb470" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.TFPatches:BukkitSSH:master-1.2-ge9214e4-23" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.sshd:sshd-core:1.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.mina:mina-core:2.0.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-jdk14:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: jline:jline:2.12.1" level="project" />
|
||||
</component>
|
||||
</module>
|
6
pom.xml
6
pom.xml
@ -168,12 +168,6 @@
|
||||
<version>50fd4cb470</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.TFPatches</groupId>
|
||||
<artifactId>BukkitSSH</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -481,14 +481,6 @@ public class FrontDoor extends FreedomService
|
||||
|
||||
case 10: // Enable Jumppads
|
||||
{
|
||||
if (plugin.jp.getMode().isOn())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
|
||||
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
||||
break;
|
||||
}
|
||||
|
||||
case 11: // Give everyone a book explaining how awesome TotalFreedom is
|
||||
|
@ -16,7 +16,6 @@ import me.totalfreedom.totalfreedommod.blocking.PVPBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.SignBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||
import me.totalfreedom.totalfreedommod.bridge.BukkitSSHBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||
@ -127,7 +126,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
// Bridges
|
||||
public ServiceManager<TotalFreedomMod> bridges;
|
||||
public BukkitTelnetBridge btb;
|
||||
public BukkitSSHBridge bsb;
|
||||
public EssentialsBridge esb;
|
||||
public LibsDisguisesBridge ldb;
|
||||
public CoreProtectBridge cpb;
|
||||
@ -245,7 +243,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
// Start bridges
|
||||
bridges = new ServiceManager<>(plugin);
|
||||
btb = bridges.registerService(BukkitTelnetBridge.class);
|
||||
bsb = bridges.registerService(BukkitSSHBridge.class);
|
||||
cpb = bridges.registerService(CoreProtectBridge.class);
|
||||
esb = bridges.registerService(EssentialsBridge.class);
|
||||
ldb = bridges.registerService(LibsDisguisesBridge.class);
|
||||
|
@ -1,94 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import com.ryanmichela.bukkitssh.BukkitSSH;
|
||||
import com.ryanmichela.bukkitssh.SshTerminal;
|
||||
import me.totalfreedom.bukkitssh.SSHCommandEvent;
|
||||
import me.totalfreedom.bukkitssh.SSHPreLoginEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BukkitSSHBridge extends FreedomService
|
||||
{
|
||||
|
||||
private BukkitSSH BukkitSSHPlugin = null;
|
||||
|
||||
public BukkitSSHBridge(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetPreLogin(SSHPreLoginEvent event)
|
||||
{
|
||||
|
||||
final String ip = event.getIp();
|
||||
if (ip == null || ip.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
||||
|
||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setBypassPassword(true);
|
||||
event.setName(admin.getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetCommand(SSHCommandEvent event)
|
||||
{
|
||||
if (plugin.cb.isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
public BukkitSSH getBukkitSSHPlugin()
|
||||
{
|
||||
if (BukkitSSHPlugin == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Plugin BukkitSSH = server.getPluginManager().getPlugin("BukkitSSH");
|
||||
if (BukkitSSH != null)
|
||||
{
|
||||
if (BukkitSSH instanceof BukkitSSH)
|
||||
{
|
||||
BukkitSSHPlugin = (BukkitSSH)BukkitSSH;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return BukkitSSHPlugin;
|
||||
}
|
||||
}
|
@ -1,5 +1,19 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@ -8,6 +22,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -18,10 +33,13 @@ import net.coreprotect.CoreProtectAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
|
||||
public class CoreProtectBridge extends FreedomService
|
||||
{
|
||||
@ -39,10 +57,6 @@ public class CoreProtectBridge extends FreedomService
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
if (ConfigEntry.COREPROTECT_AUTO_WIPING_ENABLED.getBoolean() && getCoreProtect() != null)
|
||||
{
|
||||
createAutomaticWiper();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,41 +165,6 @@ public class CoreProtectBridge extends FreedomService
|
||||
return (new File(getCoreProtect().getDataFolder(), "database.db"));
|
||||
}
|
||||
|
||||
private void createAutomaticWiper()
|
||||
{
|
||||
final long interval = 10 * 20L;
|
||||
final File databaseFile = getDatabase();
|
||||
|
||||
wiper = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final CoreProtect coreProtect = getCoreProtect();
|
||||
if (getDBSize() > ConfigEntry.COREPROTECT_FILE_LIMIT.getInteger())
|
||||
{
|
||||
FLog.info("The CoreProtect log file has grown too big for the server to cope, the data is being wiped!");
|
||||
FUtil.bcastMsg("The CoreProtect log file has grown too big for the server to cope, the data is being wiped!", ChatColor.RED);
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
pluginManager.disablePlugin(coreProtect);
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
if (!world.equals(plugin.wm.adminworld.getWorld()))
|
||||
{
|
||||
clearDatabase(world);
|
||||
}
|
||||
}
|
||||
//check if still too big, if so delete all data
|
||||
if (getDBSize() > ConfigEntry.COREPROTECT_FILE_LIMIT.getInteger())
|
||||
{
|
||||
FUtil.deleteFolder(databaseFile);
|
||||
}
|
||||
pluginManager.enablePlugin(coreProtect);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, interval, interval);
|
||||
}
|
||||
|
||||
public double getDBSize()
|
||||
{
|
||||
double bytes = getDatabase().length();
|
||||
@ -203,6 +182,10 @@ public class CoreProtectBridge extends FreedomService
|
||||
// Wipes DB for the specified world
|
||||
public void clearDatabase(World world, Boolean shutdown)
|
||||
{
|
||||
if (!ConfigEntry.COREPROTECT_MYSQL_ENABLED.getBoolean())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final CoreProtect coreProtect = getCoreProtect();
|
||||
|
||||
if (coreProtect == null)
|
||||
@ -212,11 +195,16 @@ public class CoreProtectBridge extends FreedomService
|
||||
|
||||
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
|
||||
we have to do this manually via SQL */
|
||||
File databaseFile = getDatabase();
|
||||
Connection connection = null;
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + databaseFile);
|
||||
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
|
||||
String port = ConfigEntry.COREPROTECT_MYSQL_PORT.getString();
|
||||
String username = ConfigEntry.COREPROTECT_MYSQL_USERNAME.getString();
|
||||
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);
|
||||
final Statement statement = connection.createStatement();
|
||||
statement.setQueryTimeout(30);
|
||||
|
||||
@ -238,12 +226,9 @@ public class CoreProtectBridge extends FreedomService
|
||||
// Iterate through each table and delete their data if the world ID matches
|
||||
for (String table : tables)
|
||||
{
|
||||
statement.executeUpdate("DELETE FROM " + table + " WHERE wid = " + worldID);
|
||||
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID);
|
||||
}
|
||||
|
||||
// This shrinks down the file size
|
||||
statement.executeUpdate("VACUUM");
|
||||
|
||||
connection.close();
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class WorldEditBridge extends FreedomService
|
||||
listener.unregister();
|
||||
}
|
||||
|
||||
private WorldEditPlugin getWorldEditPlugin()
|
||||
public WorldEditPlugin getWorldEditPlugin()
|
||||
{
|
||||
if (worldeditPlugin == null)
|
||||
{
|
||||
|
@ -0,0 +1,33 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.Random;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = ":goodbird:", usage = "/<command>")
|
||||
public class Command_bird extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
||||
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
||||
msg(":goodbird:");
|
||||
return true;
|
||||
}
|
||||
|
||||
public EntityType getRandomFish()
|
||||
{
|
||||
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
||||
Random random = new Random();
|
||||
return fishTypes.get(random.nextInt(fishTypes.size()));
|
||||
}
|
||||
}
|
@ -1,6 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -9,7 +16,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> | remove <name>>")
|
||||
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> [level] | remove <name>>")
|
||||
public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -105,16 +112,41 @@ public class Command_enchant extends FreedomCommand
|
||||
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
if (ench.canEnchantItem(item))
|
||||
if (!ench.canEnchantItem(item) && !ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
||||
{
|
||||
item.addEnchantment(ench, ench.getMaxLevel());
|
||||
|
||||
msg("Added enchantment: " + ench.getName());
|
||||
msg("Can't use this enchantment on held item.");
|
||||
return true;
|
||||
}
|
||||
int level = ench.getMaxLevel();
|
||||
if (args.length > 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
||||
{
|
||||
level = Integer.valueOf(args[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = Math.max(1, Math.min(ench.getMaxLevel(), Integer.parseInt(args[2])));
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("\"" + args[2] + "\" is not a valid number", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
||||
{
|
||||
item.addEnchantment(ench, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Can't use this enchantment on held item.");
|
||||
item.addUnsafeEnchantment(ench, level);
|
||||
}
|
||||
|
||||
msg("Added enchantment: " + ench.getName());
|
||||
}
|
||||
else if (args[0].equals("remove"))
|
||||
{
|
||||
@ -126,4 +158,114 @@ public class Command_enchant extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getAllEnchantments()
|
||||
{
|
||||
List<String> enchantments = new ArrayList();
|
||||
for (Enchantment enchantment : Enchantment.values())
|
||||
{
|
||||
enchantments.add(enchantment.getName());
|
||||
}
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
public List<String> getAllEnchantments(ItemStack item)
|
||||
{
|
||||
List<String> enchantments = new ArrayList();
|
||||
for (Enchantment enchantment : Enchantment.values())
|
||||
{
|
||||
if (enchantment.canEnchantItem(item))
|
||||
{
|
||||
enchantments.add(enchantment.getName());
|
||||
}
|
||||
}
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
public List<String> getEnchantments(ItemStack item)
|
||||
{
|
||||
List<String> enchantments = new ArrayList();
|
||||
for (Enchantment enchantment : item.getEnchantments().keySet())
|
||||
{
|
||||
enchantments.add(enchantment.getName());
|
||||
}
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
public static List<String> stringNumberRange(int min, int max)
|
||||
{
|
||||
List<String> range = new ArrayList();
|
||||
for (int i = min; i <= max; i++)
|
||||
{
|
||||
range.add(String.valueOf(i));
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
Player player;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
player = (Player)sender;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ItemStack item = player.getEquipment().getItemInMainHand();
|
||||
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
boolean unsafe = ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean();
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("list", "addall", "reset", "add", "remove");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
if (unsafe)
|
||||
{
|
||||
return getAllEnchantments();
|
||||
}
|
||||
else
|
||||
{
|
||||
return getAllEnchantments(item);
|
||||
}
|
||||
}
|
||||
else if (args[0].equals("remove"))
|
||||
{
|
||||
return getEnchantments(item);
|
||||
}
|
||||
}
|
||||
else if (args.length == 3)
|
||||
{
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase());
|
||||
if (enchantment != null)
|
||||
{
|
||||
if (!unsafe)
|
||||
{
|
||||
return stringNumberRange(1, enchantment.getMaxLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
return Arrays.asList("[level]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Goto the plot world", usage = "/<command>", aliases = "pw")
|
||||
public class Command_plotworld extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
World plotworld = server.getWorld("plotworld");
|
||||
if (plotworld != null)
|
||||
{
|
||||
playerSender.teleport(plotworld.getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("\"plotworld\" doesn't exist.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ public class Command_toggle extends FreedomCommand
|
||||
msg("- entitywipe");
|
||||
msg("- nonuke [range] [count]");
|
||||
msg("- explosives [radius]");
|
||||
msg("- unsafeenchs");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -153,6 +154,11 @@ public class Command_toggle extends FreedomCommand
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unsafeenchs"))
|
||||
{
|
||||
toggle("Invalid enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
@ -171,7 +177,7 @@ public class Command_toggle extends FreedomCommand
|
||||
{
|
||||
return Arrays.asList(
|
||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives");
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -21,6 +21,7 @@ public enum ConfigEntry
|
||||
ALLOW_REDSTONE(Boolean.class, "allow.redstone"),
|
||||
ALLOW_FIREWORK_EXPLOSION(Boolean.class, "allow.fireworks"),
|
||||
ALLOW_FROSTWALKER(Boolean.class, "allow.frostwalker"),
|
||||
ALLOW_UNSAFE_ENCHANTMENTS(Boolean.class, "allow.unsafe_enchantments"),
|
||||
//
|
||||
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
|
||||
//
|
||||
@ -49,8 +50,12 @@ public enum ConfigEntry
|
||||
ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"),
|
||||
ADMINLIST_CONSOLE_IS_SENIOR(Boolean.class, "adminlist.console_is_senior"),
|
||||
//
|
||||
COREPROTECT_AUTO_WIPING_ENABLED(Boolean.class, "coreprotect.auto_wipe"),
|
||||
COREPROTECT_FILE_LIMIT(Integer.class, "coreprotect.file_limit"),
|
||||
COREPROTECT_MYSQL_ENABLED(Boolean.class, "coreprotect.enabled"),
|
||||
COREPROTECT_MYSQL_HOST(String.class, "coreprotect.host"),
|
||||
COREPROTECT_MYSQL_PORT(String.class, "coreprotect.port"),
|
||||
COREPROTECT_MYSQL_USERNAME(String.class, "coreprotect.username"),
|
||||
COREPROTECT_MYSQL_PASSWORD(String.class, "coreprotect.password"),
|
||||
COREPROTECT_MYSQL_DATABASE(String.class, "coreprotect.database"),
|
||||
//
|
||||
DISABLE_NIGHT(Boolean.class, "disable.night"),
|
||||
DISABLE_WEATHER(Boolean.class, "disable.weather"),
|
||||
|
@ -19,8 +19,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
public class MasterBuilderWorldRestrictions extends FreedomService
|
||||
{
|
||||
|
||||
private final List<String> BLOCKED_WORLDEDIT_COMMANDS = Arrays.asList(
|
||||
"green", "fixlava", "fixwater", "br", "brush", "tool", "mat", "range", "cs", "up", "fill", "setblock");
|
||||
public final List<String> BLOCKED_WORLDEDIT_COMMANDS = Arrays.asList(
|
||||
"green", "fixlava", "fixwater", "br", "brush", "tool", "mat", "range", "cs", "up", "fill", "setblock", "tree");
|
||||
|
||||
public MasterBuilderWorldRestrictions(TotalFreedomMod plugin)
|
||||
{
|
||||
@ -111,19 +111,23 @@ public class MasterBuilderWorldRestrictions extends FreedomService
|
||||
final Player player = event.getPlayer();
|
||||
if (doRestrict(player))
|
||||
{
|
||||
// This is a very poor way of blocking WorldEdit commands, all the methods I know of
|
||||
// obtaining a list of a plugin's commands are returning null for world edit.
|
||||
String message = event.getMessage();
|
||||
if (message.startsWith("//") || BLOCKED_WORLDEDIT_COMMANDS.contains(message.split("\\s+")[0].replace("/", "")))
|
||||
/* This is a very poor way of blocking WorldEdit commands, all the methods I know of
|
||||
for obtaining a list of a plugin's commands are returning null for world edit. */
|
||||
String command = event.getMessage().split("\\s+")[0].substring(1, event.getMessage().split("\\s+")[0].length()).toLowerCase();
|
||||
|
||||
if (command.startsWith("/") || BLOCKED_WORLDEDIT_COMMANDS.contains(command))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Master Builders are allowed to use this WorldEdit command in the Master Builder world.");
|
||||
player.sendMessage(ChatColor.RED + "Only Master Builders are allowed to use WorldEdit in the Master Builder world.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player) && !plugin.al.isSeniorAdmin(player) && message.startsWith("/co"))
|
||||
if (!plugin.al.isSeniorAdmin(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Senior Admins are allowed to use CoreProtect in the Master Builder world.");
|
||||
event.setCancelled(true);
|
||||
if (command.equals("coreprotect") || command.equals("co"))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Senior Admins are allowed to use CoreProtect in the Master Builder world.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public enum Title implements Displayable
|
||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB"),
|
||||
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec"),
|
||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev"),
|
||||
OWNER("the", "Owner", ChatColor.BLUE, "Owner");
|
||||
OWNER("the", "Owner", ChatColor.DARK_RED, "Owner");
|
||||
|
||||
private final String determiner;
|
||||
@Getter
|
||||
|
@ -47,9 +47,12 @@ adminlist:
|
||||
|
||||
# CoreProtect
|
||||
coreprotect:
|
||||
auto_wipe: false
|
||||
|
||||
file_limit: 5000
|
||||
enabled: false
|
||||
host: 'localhost'
|
||||
port: '3306'
|
||||
username: ''
|
||||
password: ''
|
||||
database: 'coreprotect'
|
||||
|
||||
# ForceIP configuration
|
||||
forceip:
|
||||
@ -117,7 +120,7 @@ allow:
|
||||
# - 'n:b:/ban:_'
|
||||
#
|
||||
blocked_commands:
|
||||
# Disabled commands
|
||||
# Disabled commands
|
||||
- 'n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.'
|
||||
- 'n:b:/gamemode:Use /creative and /survival to set your gamemode.'
|
||||
- 'n:b:/pardon:_'
|
||||
@ -143,6 +146,8 @@ blocked_commands:
|
||||
- 'n:b:/function:_'
|
||||
- 'n:b:/data:_'
|
||||
- 'n:b:/datapack:_'
|
||||
- 'n:b:/bossbar:_'
|
||||
- 'n:b://forceload:_'
|
||||
|
||||
# Admin commands
|
||||
- 's:b:/save-all:_'
|
||||
@ -182,7 +187,6 @@ blocked_commands:
|
||||
- 's:b:/fill:_'
|
||||
- 's:b:/flood:_'
|
||||
- 's:b:/team:_'
|
||||
- 'n:b:/bossbar:_'
|
||||
|
||||
# Automatically wipe dropped objects
|
||||
auto_wipe: true
|
||||
|
Loading…
Reference in New Issue
Block a user