Skip to content

Commit

Permalink
0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Sep 19, 2019
1 parent d4e67ec commit 4756828
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 11 deletions.
18 changes: 18 additions & 0 deletions src/jaredbgreat/dldungeons/builder/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ public static void placeDungeon(Random random, int chunkX, int chunkZ, World wor
// MinecraftForge.TERRAIN_GEN_BUS.post(new DLDEvent.PlaceDungeonFinish(random, chunkX, chunkZ, world, dungeon));
// DoomlikeDungeons.profiler.endTask("Create Dungeons");
}

public static boolean commandPlaceDungeon(Random random, int chunkX, int chunkZ, World world) throws Throwable {
// if(world.isRemote) return; // Do not perform world-gen on the client!
// if (MinecraftForge.TERRAIN_GEN_BUS.post(new DLDEvent.PlaceDungeonBegin(random, chunkX, chunkZ, world))) return;
// DoomlikeDungeons.profiler.startTask("Create Dungeons");
Dungeon dungeon = new Dungeon(random,
world.getBiome(chunkX * 16, chunkZ * 16),
world, chunkX, chunkZ);
boolean res = (dungeon.theme != null);

buildDungeon(dungeon);
dungeon.preFinalize();
dungeon = null;

return res;
// MinecraftForge.TERRAIN_GEN_BUS.post(new DLDEvent.PlaceDungeonFinish(random, chunkX, chunkZ, world, dungeon));
// DoomlikeDungeons.profiler.endTask("Create Dungeons");
}


/**
Expand Down
70 changes: 60 additions & 10 deletions src/me/zhehe/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
package me.zhehe;

import jaredbgreat.dldungeons.ConfigHandler;
import static jaredbgreat.dldungeons.builder.Builder.commandPlaceDungeon;
import static jaredbgreat.dldungeons.builder.Builder.placeDungeon;
import jaredbgreat.dldungeons.themes.ThemeReader;
import jaredbgreat.dldungeons.themes.ThemeType;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.Command;
Expand Down Expand Up @@ -50,6 +54,25 @@ public void onEnable() {
wc.load();

getServer().getPluginManager().registerEvents(new DLDWorldListener(), this);

Bukkit.getLogger().log(Level.INFO, " _____ _ _ _ ");
Bukkit.getLogger().log(Level.INFO, " | __ \\ | (_) | ");
Bukkit.getLogger().log(Level.INFO, " | | | | ___ ___ _ __ ___ | |_| | _____ ");
Bukkit.getLogger().log(Level.INFO, " | | | |/ _ \\ / _ \\| '_ ` _ \\| | | |/ / _ \\");
Bukkit.getLogger().log(Level.INFO, " | |__| | (_) | (_) | | | | | | | | < __/");
Bukkit.getLogger().log(Level.INFO, " |_____/ \\___/ \\___/|_| |_| |_|_|_|_|\\_\\___|");
Bukkit.getLogger().log(Level.INFO, " | __ \\ ");
Bukkit.getLogger().log(Level.INFO, " | | | |_ _ _ __ __ _ ___ ___ _ __ ");
Bukkit.getLogger().log(Level.INFO, " | | | | | | | '_ \\ / _` |/ _ \\/ _ \\| '_ \\ ");
Bukkit.getLogger().log(Level.INFO, " | |__| | |_| | | | | (_| | __/ (_) | | | |");
Bukkit.getLogger().log(Level.INFO, " |_____/ \\__,_|_| |_|\\__, |\\___|\\___/|_| |_|");
Bukkit.getLogger().log(Level.INFO, " / ____| (_) __/ | | | ");
Bukkit.getLogger().log(Level.INFO, " | (___ _ __ _ __ |___/_ | |_ ");
Bukkit.getLogger().log(Level.INFO, " \\___ \\| '_ \\| |/ _` |/ _ \\| __| ");
Bukkit.getLogger().log(Level.INFO, " ____) | |_) | | (_| | (_) | |_ ");
Bukkit.getLogger().log(Level.INFO, " |_____/| .__/|_|\\__, |\\___/ \\__| ");
Bukkit.getLogger().log(Level.INFO, " | | __/ | ");
Bukkit.getLogger().log(Level.INFO, " |_| |___/ ");
}

@Override
Expand All @@ -63,31 +86,58 @@ public void onWorldInit(WorldInitEvent event) {
if(!enable) return;
String world_name = event.getWorld().getName();
if(wc.world.contains(world_name)) {
Logging.logInfo("Add DoomlikeDungeon Populator to world: " + world_name);
Logging.logInfo("[Doomlike Dungeons] Add DoomlikeDungeon Populator to world: " + world_name);
event.getWorld().getPopulators().add(new DungeonPopulator());
} else {
Logging.logInfo("DoomlikeDungeon Populator is not used in " + world_name);
Logging.logInfo("[Doomlike Dungeons] DoomlikeDungeon Populator is not used in " + world_name);
}
}
}

@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
if (!player.hasPermission("DoomlikeDungeonSpigot.command")) {
player.sendMessage("You don't have the permission required to use this plugin");
return true;
}
}
if (command.getName().equalsIgnoreCase("doomlikedungeonspigot")) {
if(sender instanceof Player) {
Player player = (Player) sender;
if (!player.hasPermission("dld.admin")) {
player.sendMessage("You don't have the permission required to use this plugin");
return true;
}
}
String worldName;
if(args.length == 0) {
sender.sendMessage("Wrong world name");
sender.sendMessage("[Doomlike Dungeon] Invalid world name");
return true;
}
worldName = args[0];
wc.addWorld(worldName);
sender.sendMessage("[Doomlike Dungeon] Done");
return true;
} else if (command.getName().equalsIgnoreCase("doomlikedungeonspigot_place")) {
if(!(sender instanceof Player)) {
sender.sendMessage("[Doomlike Dungeon] Player only command...");
return true;
}
Player player = (Player) sender;
if (!player.hasPermission("dld.place")) {
player.sendMessage("You don't have the permission required to place a dungeon");
return true;
}
Location loc = player.getLocation();
Chunk chunk = loc.getChunk();
World world = loc.getWorld();

try {
boolean res = commandPlaceDungeon(new Random(), chunk.getX(), chunk.getZ(), world);
if(!res) {
sender.sendMessage("Fail: No theme available for this chunk...");
} else {
sender.sendMessage("Done");
}
} catch (Throwable ex) {
sender.sendMessage("Internal Error when placing a dungeon in this chunk...");
}

return true;
}
return false;
Expand Down
6 changes: 5 additions & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ authors: [JaredBGreat,zhehe]
main: me.zhehe.Main
load: startup
api-version: 1.13
version: 0.7
version: 0.8
commands:
doomlikedungeonspigot:
aliases: [dld]
permission: dld.admin
doomlikedungeonspigot_place:
aliases: [dld_place]
permission: dld.place

0 comments on commit 4756828

Please sign in to comment.