From de9209b270376891d16f77e5ec672312183072b6 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sun, 31 Jul 2011 07:41:09 -0600 Subject: [PATCH] Remove debug, Add warning if users have spawn-monsters set to false. --- .../MultiverseCore/MVTeleport.java | 4 +-- .../MultiverseCore/MultiverseCore.java | 30 +++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVTeleport.java b/src/main/java/com/onarandombox/MultiverseCore/MVTeleport.java index eb494aaf..e329690c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVTeleport.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVTeleport.java @@ -176,7 +176,7 @@ public class MVTeleport { public boolean safelyTeleport(Entity e, Location l) { if (this.bs.playerCanSpawnHereSafely(l)) { e.teleport(l); - // System.out.print("The first location you gave me was safe!"); + //this.plugin.log(Level.WARNING, "The first location you gave me was safe."); return true; } if(e instanceof Minecart) { @@ -198,7 +198,7 @@ public class MVTeleport { safeLocation.setY(safeLocation.getBlockY() + .5); } e.teleport(safeLocation); - // System.out.print("Had to look for a bit, but I found a safe place for ya!" + safeLocation); + //this.plugin.log(Level.WARNING, "Had to look for a bit, but I found a safe place for ya!"); return true; } if (e instanceof Player) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index e9dd5198..c8a2b70c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -1,6 +1,11 @@ package com.onarandombox.MultiverseCore; +import java.io.BufferedReader; +import java.io.DataInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -126,7 +131,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { public void onEnable() { // Output a little snippet to show it's enabled. this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors()); - + this.checkServerProps(); // Setup all the Events the plugin needs to Monitor. this.initializeDestinationFactory(); this.registerEvents(); @@ -730,7 +735,26 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { public void teleportPlayer(Player p, Location l) { p.teleport(l); } - - public void displayHelp(CommandSender sender, List args) { + + private void checkServerProps() { + File serverFolder = new File(this.getDataFolder().getAbsolutePath()).getParentFile().getParentFile(); + File serverProperties = new File(serverFolder.getAbsolutePath() + File.separator + "server.properties"); + try { + FileInputStream fileStream = new FileInputStream(serverProperties); + DataInputStream in = new DataInputStream(fileStream); + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + String propLine; + while ((propLine = br.readLine()) != null) { + // Print the content on the console + if (propLine.matches(".*spawn-monsters.*") && !propLine.matches(".*spawn-monsters\\s*=\\s*true.*")) { + this.log(Level.SEVERE, "Monster spawning has been DISABLED."); + this.log(Level.SEVERE, "In order to let Multiverse fully control your worlds:"); + this.log(Level.SEVERE, "Please set 'spawn-monsters=true' in your server.properties file!"); + } + } + } catch (IOException e) { + // This should never happen... + this.log(Level.SEVERE, e.getMessage()); + } } }