Fixes, added /hub, removed CONSOLE restrictions on some commands

This commit is contained in:
Ivan
2019-08-18 21:06:47 -04:00
parent 1c3970b984
commit 7d0ea0837e
22 changed files with 523 additions and 152 deletions

View File

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