A feature-rich Minecraft plugin which enhances gaming experience
git clone git://soophie.de/poppy
11
public static final int MIN_FEE = 1;12
public static final int MAX_FEE = 64;14
public static final class Worlds15
{16
public static final String DEFAULT = "world";17
public static final String SURVIVAL = "survival";18
public static final String SURVIVAL_NETHER = "survival_nether";19
public static final String SURVIVAL_THE_END = "survival_the_end";20
public static final String BACKROOMS = "creative";21
}23
public static final class Messages24
{25
public static final String NOT_ENOUGH_PERMISSION = ChatColor.RED + "You don't have enough Permission to perform this command!";
110
FurnaceRecipe recipe = new FurnaceRecipe(key, new ItemStack(Material.LEATHER), Material.ROTTEN_FLESH, 1, 200);111
Bukkit.addRecipe(recipe);113
new WorldCreator("creative")113
new WorldCreator(Constants.Worlds.BACKROOMS)114
.type(WorldType.FLAT)115
.generateStructures(false)116
.createWorld();118
new WorldCreator("survival")118
new WorldCreator(Constants.Worlds.SURVIVAL)119
.type(WorldType.NORMAL)120
.generateStructures(true)121
.createWorld();123
new WorldCreator("survival_nether")123
new WorldCreator(Constants.Worlds.SURVIVAL_NETHER)124
.environment(Environment.NETHER)125
.generateStructures(true)126
.createWorld();128
new WorldCreator("survival_the_end")128
new WorldCreator(Constants.Worlds.SURVIVAL_THE_END)129
.environment(Environment.THE_END)130
.generateStructures(true)131
.createWorld();
190
public void onPlayerPortal(final PlayerPortalEvent event)191
{192
final Player player = event.getPlayer();193
final String worldName = player.getWorld().getName();194
if (event.getCause() == TeleportCause.NETHER_PORTAL);195
if (event.getCause() == TeleportCause.NETHER_PORTAL)196
{196
if (player.getWorld().getName().equals("survival"))197
if (worldName.equals(Constants.Worlds.SURVIVAL))198
{198
event.setTo(new Location(Bukkit.getWorld("survival_nether"), event.getFrom().getBlockX() / 8, event.getFrom().getBlockY(), event.getFrom().getBlockZ() / 8));199
final Location location = new Location(200
Bukkit.getWorld(Constants.Worlds.SURVIVAL_NETHER),201
event.getFrom().getBlockX() / 8,202
event.getFrom().getBlockY(),203
event.getFrom().getBlockZ() / 8204
);205
event.setTo(location);206
}201
else if (player.getWorld().getName().equals("survival_nether"))207
else if (worldName.equals(Constants.Worlds.SURVIVAL_NETHER))208
{203
event.setTo(new Location(Bukkit.getWorld("survival"), event.getFrom().getBlockX() * 8, event.getFrom().getBlockY(), event.getFrom().getBlockZ() * 8));209
final Location location = new Location(210
Bukkit.getWorld(Constants.Worlds.SURVIVAL),211
event.getFrom().getBlockX() * 8,212
event.getFrom().getBlockY(),213
event.getFrom().getBlockZ() * 8214
);215
event.setTo(location);216
}217
}207
// TODO ugly code quick fix only!!!219
if (event.getCause() == TeleportCause.END_PORTAL)220
{211
if (player.getWorld().getName().equals("survival")) {212
Location loc = new Location(Bukkit.getWorld("survival_the_end"), 100, 50, 0);213
event.setTo(loc);214
Block block = loc.getBlock();215
for (int x = block.getX() - 2; x <= block.getX() + 2; x++) {216
for (int z = block.getZ() - 2; z <= block.getZ() + 2; z++) {217
Block platformBlock = loc.getWorld().getBlockAt(x, block.getY() - 1, z);218
if (platformBlock.getType() != Material.OBSIDIAN) {219
platformBlock.setType(Material.OBSIDIAN);220
}221
for (int yMod = 1; yMod <= 3; yMod++) {222
Block b = platformBlock.getRelative(BlockFace.UP, yMod);223
if (b.getType() != Material.AIR) {224
b.setType(Material.AIR);225
}226
}227
}228
}229
} else if (player.getWorld().getName().equals("survival_the_end")) {230
event.setTo(Bukkit.getWorld("survival").getSpawnLocation());221
if (worldName.equals(Constants.Worlds.SURVIVAL))222
{223
final Location location = new Location(224
Bukkit.getWorld(Constants.Worlds.SURVIVAL_THE_END),225
100,226
50,227
0228
);229
event.setTo(location);231
final Block block = location.getBlock();233
for (int x = block.getX() - 2; x <= block.getX() + 2; x++)234
{235
for (int z = block.getZ() - 2; z <= block.getZ() + 2; z++)236
{237
final Block platformBlock = location.getWorld().getBlockAt(x, block.getY() - 1, z);239
if (platformBlock.getType() != Material.OBSIDIAN)240
{241
platformBlock.setType(Material.OBSIDIAN);242
}244
for (int yMod = 1; yMod <= 3; yMod++)245
{246
final Block b = platformBlock.getRelative(BlockFace.UP, yMod);248
if (b.getType() != Material.AIR)249
{250
b.setType(Material.AIR);251
}252
}253
}254
}255
}256
else if (worldName.equals(Constants.Worlds.SURVIVAL_THE_END))257
{258
event.setTo(Bukkit.getWorld(Constants.Worlds.SURVIVAL).getSpawnLocation());259
}260
}261
}
540
}542
player.teleport(world.getSpawnLocation());515
player.setGameMode(GameMode.SURVIVAL);544
if (world.getName().equals(Constants.Worlds.BACKROOMS))545
{546
player.setGameMode(GameMode.ADVENTURE);547
}548
else549
{550
player.setGameMode(GameMode.SURVIVAL);551
}553
player.sendMessage(ChatColor.GRAY + "You've been teleported to world " + name + ".");555
return true;
558
private boolean changeGameMode(final Player player)559
{523
if (!"world".equals(player.getWorld().getName())) {560
if (!Constants.Worlds.DEFAULT.equals(player.getWorld().getName())) {561
player.sendMessage(ChatColor.RED + "This is not a creative world!");562
return true;563
}