Browse Source

Changed WorldGenerator and added full 1.8-1.13.2 support

master
pintux98 6 years ago
parent
commit
d5114b40c8
  1. 6
      MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java
  2. 11
      MultiArena-TheBridge/src/cx/sfy/TheBridge/controllers/WorldController.java
  3. 1
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_13_R2.java
  4. 52
      MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java

6
MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java

@ -21,11 +21,11 @@ import cx.sfy.TheBridge.database.Cosmeticbase;
import cx.sfy.TheBridge.database.Database;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.game.InventoryData;
import cx.sfy.TheBridge.game.PlayerData;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.hooks.PlaceholderHook;
import cx.sfy.TheBridge.kit.Hotbar;
import cx.sfy.TheBridge.kit.Kit;
@ -218,7 +218,7 @@ public class Main extends JavaPlugin {
public void onDisable() {
stop = true;
getTOP().removeHolo();
getServer().getScheduler().cancelAllTasks();
getServer().getScheduler().cancelTasks(this);
for (InventoryData inv : InventoryData.getInventoryData().values()) {
inv.restore();
}

11
MultiArena-TheBridge/src/cx/sfy/TheBridge/controllers/WorldController.java

@ -48,7 +48,7 @@ public class WorldController {
world = Bukkit.getWorld(name);
if (world != null) {
world.getBlockAt(0, 80, 0).setType(Material.STONE);
p.teleport(new Location(world, 0, 81, 0));
p.teleport(new Location(world, 0, 82, 0));
p.sendMessage(plugin.getLang().get("setup.worldCreated").replaceAll("<name>", world.getName()));
return world;
}
@ -95,7 +95,6 @@ public class WorldController {
world.setGameRuleValue("mobGriefing", "false");
world.setGameRuleValue("doFireTick", "false");
world.setGameRuleValue("showDeathMessages", "false");
world.getBlockAt(0, 81, 0).setType(Material.STONE);
for(final World w : plugin.getServer().getWorlds())
if(w.getName().equals(world.getName())) {
loaded = true;
@ -103,6 +102,10 @@ public class WorldController {
}
return loaded;
}
protected void generate() {
}
public void copyWorld(World world) {
world.save();
@ -122,6 +125,10 @@ public class WorldController {
world.setAnimalSpawnLimit(0);
world.setAmbientSpawnLimit(0);
world.setGameRuleValue("doDaylightCycle", "false");
world.setGameRuleValue("doMobSpawning", "false");
world.setGameRuleValue("mobGriefing", "false");
world.setGameRuleValue("doFireTick", "false");
world.setGameRuleValue("showDeathMessages", "false");
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Restarting map " + ChatColor.YELLOW + newWorldName + ChatColor.GREEN + ".");
}

1
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_13_R2.java

@ -11,7 +11,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_13_R2.EntityArmorStand;
import net.minecraft.server.v1_13_R2.IChatBaseComponent.ChatSerializer;
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_13_R2.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_13_R2.WorldServer;

52
MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java

@ -4,8 +4,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
@ -34,11 +37,58 @@ public class GenericNMS implements NMS {
@Override
public Location getFixedSpawnLocation(World world, Random random) {
return new Location(world, 0.0D, 64.0D, 0.0D);
return new Location(world, 0.0D, 83.0D, 0.0D);
}
@Override
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid biome) {
final ChunkGenerator.ChunkData chunkData = this.createChunkData(world);
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
biome.setBiome(x, z, bm());
}
}
if (0 >= cx << 4 && 0 < cx + 1 << 4 && 0 >= cz << 4 && 0 < cz + 1 << 4) {
chunkData.setBlock(0, 81, 0, Material.STONE);
}
return chunkData;
}
};
}
private static Biome bm() {
String serverVersion = null;
Biome b;
try {
serverVersion = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
} catch (ArrayIndexOutOfBoundsException ex) {
b = Biome.PLAINS;
}
final String s = serverVersion;
switch (s) {
case "v1_8_R1":
case "v1_8_R2":
case "v1_8_R3": {
b = Biome.PLAINS;
break;
}
case "v1_9_R1":
case "v1_9_R2":
case "v1_10_R1":
case "v1_11_R1":
case "v1_12_R1":
case "v1_13_R1":{
b = Biome.valueOf("VOID");
break;
}
default: {
b = Biome.valueOf("THE_VOID");
break;
}
}
return b;
}
@Override
public void sendTitle(Player player, int fadein, int stay, int fadeout, String title, String subtitle) {
Reflection.sendTitle(player, fadein, stay, fadeout, title, subtitle);

Loading…
Cancel
Save