Bug fixes, improvements, and removals (FS-192) (#46)

* Three fixes

* Fixes /tempban throwing a NullPointerException when trying to get a player who isn't on the server but was in the past
* Fixes /tempban banning players for 24 hours regardless of the duration defined
* Fixes /list -t throwing a NullPointerException when performed from a non-player source (such as Telnet)

* Removes hubworld entriely

* Configurable blacklists for tag, muted commands, and wildcard

Changes:
* Moves globally blocked commands to the `global` subsection of the original `blocked_commands` section. You *will* need to update your configurations
* /wildcard's command blacklist is now configurable under the `wildcard` section in `blocked_commands`.
* The commands muted players can't use are now configurable under the `muted` section in `blocked_commands`.
* Removes some commented-out globally blocked command entries.

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
This commit is contained in:
Video
2021-05-09 09:42:31 -06:00
committed by Ryan
parent 6fb9507a4c
commit 07b5076717
15 changed files with 301 additions and 568 deletions

View File

@ -1,102 +0,0 @@
package me.totalfreedom.totalfreedommod.world;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public final class HubWorld extends CustomWorld
{
private static final String GENERATION_PARAMETERS = ConfigEntry.FLATLANDS_GENERATE_PARAMS.getString();
//
private WorldWeather weather = WorldWeather.OFF;
private WorldTime time = WorldTime.INHERIT;
public HubWorld()
{
super("hubworld");
}
@Override
public void sendToWorld(Player player)
{
super.sendToWorld(player);
}
// TODO: Replace instances of org.bukkit.Sign with a non deprecated version. This might include more boilerplate.
@SuppressWarnings("deprecation")
@Override
protected World generateWorld()
{
final WorldCreator worldCreator = new WorldCreator(getName());
worldCreator.generateStructures(false);
worldCreator.type(WorldType.NORMAL);
worldCreator.environment(World.Environment.NORMAL);
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
final World world = server.createWorld(worldCreator);
assert world != null;
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
welcomeSignBlock.setType(Material.OAK_SIGN);
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign)welcomeSignBlock.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)welcomeSign.getData();
signData.setFacingDirection(BlockFace.NORTH);
welcomeSign.setLine(0, ChatColor.GREEN + "Hub World");
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
welcomeSign.update();
plugin.gr.commitGameRules();
return world;
}
public WorldWeather getWeatherMode()
{
return weather;
}
public void setWeatherMode(final WorldWeather weatherMode)
{
this.weather = weatherMode;
try
{
weatherMode.setWorldToWeather(getWorld());
}
catch (Exception ignored)
{
}
}
public WorldTime getTimeOfDay()
{
return time;
}
public void setTimeOfDay(final WorldTime timeOfDay)
{
this.time = timeOfDay;
try
{
timeOfDay.setWorldToTime(getWorld());
}
catch (Exception ignored)
{
}
}
}

View File

@ -20,14 +20,12 @@ public class WorldManager extends FreedomService
public Flatlands flatlands;
public AdminWorld adminworld;
public MasterBuilderWorld masterBuilderWorld;
public HubWorld hubworld;
public WorldManager()
{
this.flatlands = new Flatlands();
this.adminworld = new AdminWorld();
this.masterBuilderWorld = new MasterBuilderWorld();
this.hubworld = new HubWorld();
}
@Override
@ -36,7 +34,6 @@ public class WorldManager extends FreedomService
flatlands.getWorld();
adminworld.getWorld();
masterBuilderWorld.getWorld();
hubworld.getWorld();
// Disable weather
if (ConfigEntry.DISABLE_WEATHER.getBoolean())
@ -57,7 +54,6 @@ public class WorldManager extends FreedomService
flatlands.getWorld().save();
adminworld.getWorld().save();
masterBuilderWorld.getWorld().save();
hubworld.getWorld().save();
}
@EventHandler(priority = EventPriority.HIGH)
@ -73,10 +69,6 @@ public class WorldManager extends FreedomService
{
return;
}
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
{
return;
}
}
catch (Exception ignored)
{
@ -101,10 +93,6 @@ public class WorldManager extends FreedomService
{
return;
}
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
{
return;
}
}
catch (Exception ignored)
{

View File

@ -54,7 +54,7 @@ public class WorldRestrictions extends FreedomService
{
if (!plugin.pl.getData(player).isMasterBuilder() && plugin.pl.canManageMasterBuilders(player.getName()))
{
if (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()) || player.getWorld().equals(plugin.wm.hubworld.getWorld()))
if (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()))
{
return true;
}