hubworld is no longer necessary

This commit is contained in:
Ivan 2019-11-01 21:35:13 -04:00
parent ac850bc41d
commit aad33958f0
6 changed files with 0 additions and 454 deletions

View File

@ -39,7 +39,6 @@ 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.hub.HubWorldRestrictions;
import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
@ -128,7 +127,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public MasterBuilderWorldRestrictions mbwr;
public SignBlocker snp;
public PlayerVerification pv;
public HubWorldRestrictions hwr;
//
// Bridges
public ServiceManager<TotalFreedomMod> bridges;
@ -203,7 +201,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
as = services.registerService(AntiSpam.class);
mbl = services.registerService(MasterBuilderList.class);
mbwr = services.registerService(MasterBuilderWorldRestrictions.class);
hwr = services.registerService(HubWorldRestrictions.class);
pl = services.registerService(PlayerList.class);
an = services.registerService(Announcer.class);

View File

@ -1,203 +0,0 @@
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.util.FUtil;
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 = "Go to the MasterBuilderWorld.",
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
aliases = "hw,hworld")
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 masterBuilderWorld = null;
try
{
masterBuilderWorld = plugin.wm.hubworld.getWorld();
}
catch (Exception ex)
{
}
if (masterBuilderWorld == null || playerSender.getWorld() == masterBuilderWorld)
{
msg("Going to the main world.");
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
}
else
{
msg("Going to the Hub");
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 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 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);
}
}
}

View File

@ -141,11 +141,6 @@ public class ItemFun extends FreedomService
{
break;
}
if (player.getWorld().equals(plugin.wm.hubworld.getWorld()) && plugin.hwr.doRestrict(player))
{
break;
}
Location location = player.getLocation().clone();

View File

@ -1,132 +0,0 @@
package me.totalfreedom.totalfreedommod.hub;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
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.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class HubWorldRestrictions extends FreedomService
{
public final List<String> ALLOWED_COMMANDS = Arrays.asList(
"list", "opall", "gmc", "gms", "gma", "gmsp", "purgeall", "stfu", "tempban", "gtfo", "noob", "flatlands", "adminworld", "masterbuilderworld", "world", "nether", "spawn", "tpo", "tp", "expel", "item", "i", "give", "adminchat", "adventure", "creative", "survival", "spectator", "say", "blockcmd", "blockpvp", "blockredstone", "stoplag", "halt-activity", "nickclean", "nick", "nicknyan", "vanish", "verify", "verifynoadmin", "co", "coreprotect", "core", "mobpurge", "logs", "links", "vote", "o", "linkdiscord");
public HubWorldRestrictions(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public boolean doRestrict(Player player)
{
if (!FUtil.isExecutive(player.getName()) && player.getWorld().equals(plugin.wm.hubworld.getWorld()))
{
return true;
}
return false;
}
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockPlace(BlockPlaceEvent event)
{
final Player player = event.getPlayer();
if (doRestrict(player))
{
player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!");
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
final Player player = event.getPlayer();
if (doRestrict(player))
{
player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!");
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event)
{
final Player player = event.getPlayer();
if (doRestrict(player))
{
player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!");
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event)
{
final Player player = event.getPlayer();
if (doRestrict(player))
{
player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!");
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{
if (event.getDamager() instanceof Player)
{
Player player = (Player)event.getDamager();
if (doRestrict(player))
{
player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!");
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onCommandPreprocess(PlayerCommandPreprocessEvent event)
{
final Player player = event.getPlayer();
if (doRestrict(player))
{
String command = event.getMessage().split("\\s+")[0].substring(1, event.getMessage().split("\\s+")[0].length()).toLowerCase();
if (ALLOWED_COMMANDS.contains(command))
{
event.setCancelled(false);
}
else if (command.startsWith(""))
{
player.sendMessage(ChatColor.RED + "Only Executives are allowed to execute commands in the Hub World!");
event.setCancelled(true);
}
}
}
}

View File

@ -1,99 +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);
}
@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);
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 ex)
{
}
}
public WorldTime getTimeOfDay()
{
return time;
}
public void setTimeOfDay(final WorldTime timeOfDay)
{
this.time = timeOfDay;
try
{
timeOfDay.setWorldToTime(getWorld());
}
catch (Exception ex)
{
}
}
}

View File

@ -23,7 +23,6 @@ public class WorldManager extends FreedomService
public Flatlands flatlands;
public AdminWorld adminworld;
public MasterBuilderWorld masterBuilderWorld;
public HubWorld hubworld;
public WorldManager(TotalFreedomMod plugin)
{
@ -32,7 +31,6 @@ public class WorldManager extends FreedomService
this.flatlands = new Flatlands();
this.adminworld = new AdminWorld();
this.masterBuilderWorld = new MasterBuilderWorld();
this.hubworld = new HubWorld();
}
@Override
@ -41,7 +39,6 @@ public class WorldManager extends FreedomService
flatlands.getWorld();
adminworld.getWorld();
masterBuilderWorld.getWorld();
hubworld.getWorld();
// Disable weather
if (ConfigEntry.DISABLE_WEATHER.getBoolean())
@ -62,7 +59,6 @@ public class WorldManager extends FreedomService
flatlands.getWorld().save();
adminworld.getWorld().save();
masterBuilderWorld.getWorld().save();
hubworld.getWorld().save();
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -113,10 +109,6 @@ public class WorldManager extends FreedomService
{
return;
}
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
{
return;
}
}
catch (Exception ex)
{
@ -141,10 +133,6 @@ public class WorldManager extends FreedomService
{
return;
}
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
{
return;
}
}
catch (Exception ex)
{