New code format

This commit is contained in:
Eric Stokes 2011-09-25 09:14:17 -06:00
parent 65dce752d4
commit d63c043368
21 changed files with 101 additions and 115 deletions

View File

@ -7,10 +7,10 @@
package com.onarandombox.MultiverseCore;
import java.util.logging.Level;
import org.bukkit.Server;
import java.util.logging.Level;
public interface LoggablePlugin {
public void log(Level level, String msg);

View File

@ -7,20 +7,19 @@
package com.onarandombox.MultiverseCore;
import java.util.List;
import java.util.logging.Level;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.onarandombox.utils.MVDestination;
import com.onarandombox.utils.WorldManager;
import com.pneumaticraft.commandhandler.PermissionsInterface;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.onarandombox.utils.MVDestination;
import com.onarandombox.utils.WorldManager;
import com.pneumaticraft.commandhandler.PermissionsInterface;
import java.util.List;
import java.util.logging.Level;
public class MVPermissions implements PermissionsInterface {
@ -48,6 +47,7 @@ public class MVPermissions implements PermissionsInterface {
*
* @param p
* @param w
*
* @return
*/
public Boolean canTravelFromWorld(Player p, MVWorld w) {
@ -66,7 +66,7 @@ public class MVPermissions implements PermissionsInterface {
}
public boolean canTravelFromLocation(CommandSender sender, Location location) {
if(!(sender instanceof Player)) {
if (!(sender instanceof Player)) {
return true;
}
Player teleporter = (Player) sender;
@ -81,6 +81,7 @@ public class MVPermissions implements PermissionsInterface {
*
* @param p
* @param w
*
* @return
*/
public Boolean canEnterWorld(Player p, MVWorld w) {
@ -99,7 +100,7 @@ public class MVPermissions implements PermissionsInterface {
}
public Boolean canEnterDestination(CommandSender sender, MVDestination d) {
if(!(sender instanceof Player)) {
if (!(sender instanceof Player)) {
return true;
}
Player p = (Player) sender;
@ -252,6 +253,7 @@ public class MVPermissions implements PermissionsInterface {
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
*
* @param seperated
*
* @return
*/
private String getParentPerm(String[] seperated) {

View File

@ -7,11 +7,11 @@
package com.onarandombox.MultiverseCore;
import java.util.Date;
import org.bukkit.entity.Player;
import org.bukkit.util.config.Configuration;
import java.util.Date;
public class MVPlayerSession {
private Player player; // Player holder, may be unnecessary.
@ -28,9 +28,7 @@ public class MVPlayerSession {
// this.bedSpawn = null;
}
/**
* Update the Teleport time.
*/
/** Update the Teleport time. */
public void teleport() {
this.teleportLast = (new Date()).getTime();
}
@ -52,6 +50,7 @@ public class MVPlayerSession {
public void setCachedHunger() {
this.cachedHunger = this.player.getFoodLevel();
}
public int getCachedHunger() {
return this.cachedHunger;
}

View File

@ -9,6 +9,8 @@ package com.onarandombox.MultiverseCore;
public interface MVPlugin extends LoggablePlugin {
public String dumpVersionInfo(String buffer);
public MultiverseCore getCore();
public void setCore(MultiverseCore core);
}

View File

@ -7,8 +7,10 @@
package com.onarandombox.MultiverseCore;
import java.util.logging.Level;
import com.onarandombox.utils.BlockSafety;
import com.onarandombox.utils.InvalidDestination;
import com.onarandombox.utils.LocationManipulation;
import com.onarandombox.utils.MVDestination;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Minecart;
@ -16,10 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.util.Vector;
import com.onarandombox.utils.BlockSafety;
import com.onarandombox.utils.InvalidDestination;
import com.onarandombox.utils.LocationManipulation;
import com.onarandombox.utils.MVDestination;
import java.util.logging.Level;
public class MVTeleport {
@ -113,6 +112,7 @@ public class MVTeleport {
*
* @param l
* @param radius
*
* @return
*/
private Location checkAroundLocation(Location l, int diameter) {
@ -196,6 +196,7 @@ public class MVTeleport {
*
* @param e
* @param l
*
* @return
*/
@Deprecated
@ -209,9 +210,9 @@ public class MVTeleport {
}
/**
*
* @param e
* @param l
*
* @return
*/
@Deprecated
@ -225,8 +226,7 @@ public class MVTeleport {
if (!this.bs.canSpawnCartSafely(m)) {
return null;
}
}
else if (e instanceof Vehicle) {
} else if (e instanceof Vehicle) {
Vehicle v = (Vehicle) e;
if (!this.bs.canSpawnVehicleSafely(v)) {
return null;
@ -246,8 +246,7 @@ public class MVTeleport {
Player p = (Player) e;
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
}
else if (e.getPassenger() instanceof Player) {
} else if (e.getPassenger() instanceof Player) {
Player p = (Player) e.getPassenger();
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
@ -257,28 +256,31 @@ public class MVTeleport {
}
/**
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if it's not, will adjust the final destination accordingly.
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
* it's not, will adjust the final destination accordingly.
*
* @param e Entity to teleport
* @param d Destination to teleport them to
*
* @return true for success, false for failure
*/
public boolean safelyTeleport(Entity e, MVDestination d) {
if(d instanceof InvalidDestination) {
if (d instanceof InvalidDestination) {
this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination");
return false;
}
Location safeLoc = d.getLocation(e);
if(d.useSafeTeleporter()) {
if (d.useSafeTeleporter()) {
safeLoc = this.getSafeLocation(e, d);
}
if (safeLoc != null) {
if(e.teleport(safeLoc)) {
if (e.teleport(safeLoc)) {
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
e.setVelocity(d.getVelocity());
}
return true;
return true;
}
}
return false;
@ -289,6 +291,7 @@ public class MVTeleport {
*
* @param e The entity to spawn
* @param d The MVDestination to take the entity to.
*
* @return A new location to spawn the entity at.
*/
public Location getSafeLocation(Entity e, MVDestination d) {
@ -302,8 +305,7 @@ public class MVTeleport {
if (!this.bs.canSpawnCartSafely(m)) {
return null;
}
}
else if (e instanceof Vehicle) {
} else if (e instanceof Vehicle) {
Vehicle v = (Vehicle) e;
if (!this.bs.canSpawnVehicleSafely(v)) {
return null;
@ -323,8 +325,7 @@ public class MVTeleport {
Player p = (Player) e;
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
}
else if (e.getPassenger() instanceof Player) {
} else if (e.getPassenger() instanceof Player) {
Player p = (Player) e.getPassenger();
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());

View File

@ -11,6 +11,7 @@ import org.getspout.spoutapi.SpoutManager;
public class SpoutInterface {
private SpoutManager spoutManager;
public SpoutInterface() {
this.spoutManager = SpoutManager.getInstance();
}

View File

@ -7,9 +7,7 @@
package com.onarandombox.MultiverseCore.api;
/**
* The API for a Multiverse Handled World.
*/
/** The API for a Multiverse Handled World. */
public interface MultiverseWorld {
}

View File

@ -67,6 +67,5 @@ public class CreateCommand extends MultiverseCommand {
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
}
return;
}
}

View File

@ -29,7 +29,7 @@ public class DeleteCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
Class<?> paramTypes[] = { String.class };
Class<?> paramTypes[] = {String.class};
List<Object> objectArgs = new ArrayList<Object>(args);
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs, paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!");
}

View File

@ -43,8 +43,7 @@ public class HelpCommand extends MultiverseCommand {
String filter = "";
if (args.size() == 0)
{
if (args.size() == 0) {
filter = "";
page = 1;
} else if (args.size() == 1) {

View File

@ -10,8 +10,6 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.*;
// Will use when we can compile with JDK 6
//import com.sun.xml.internal.ws.util.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
@ -21,6 +19,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
// Will use when we can compile with JDK 6
//import com.sun.xml.internal.ws.util.StringUtils;
public class InfoCommand extends MultiverseCommand {
private WorldManager worldManager;
@ -50,8 +51,7 @@ public class InfoCommand extends MultiverseCommand {
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
return;
}
}
else if (args.size() == 1) {
} else if (args.size() == 1) {
if (this.worldManager.getMVWorld(args.get(0)) != null) {
// then we have a world!
worldName = args.get(0);
@ -69,8 +69,7 @@ public class InfoCommand extends MultiverseCommand {
return;
}
}
}
else if (args.size() == 2) {
} else if (args.size() == 2) {
worldName = args.get(0);
try {
pageNum = Integer.parseInt(args.get(1)) - 1;

View File

@ -8,7 +8,6 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MVTeleport;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
import com.onarandombox.utils.*;
@ -82,7 +81,6 @@ public class TeleportCommand extends MultiverseCommand {
MVDestination d = df.getDestination(destinationName);
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter);
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
if (teleportEvent.isCancelled()) {
@ -95,7 +93,7 @@ public class TeleportCommand extends MultiverseCommand {
return;
}
if(!this.checkSendPermissions(teleporter,teleportee,d)) {
if (!this.checkSendPermissions(teleporter, teleportee, d)) {
return;
}
@ -110,7 +108,7 @@ public class TeleportCommand extends MultiverseCommand {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + "THERE from " + ChatColor.GREEN + ((Player) teleporter).getWorld().getName());
} else {
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + ((Player)teleporter).getWorld().getName() + " can get to " + ChatColor.RED + "THERE from where they are...");
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + ((Player) teleporter).getWorld().getName() + " can get to " + ChatColor.RED + "THERE from where they are...");
}
return;
}
@ -118,17 +116,17 @@ public class TeleportCommand extends MultiverseCommand {
// Special check to verify if players are tryint to teleport to the same
// WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self
if(d instanceof WorldDestination) {
if (d instanceof WorldDestination) {
World w = d.getLocation(teleportee).getWorld();
if(teleportee.getWorld().equals(w)) {
if(teleporter.equals(teleportee)) {
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.core.spawn.self", true)){
if (teleportee.getWorld().equals(w)) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
teleporter.sendMessage("Sorry you don't have permission to go to the world spawn!");
teleporter.sendMessage(ChatColor.RED + " (multiverse.core.spawn.self)");
return;
}
} else {
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.core.spawn.other", true)){
if (!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
teleporter.sendMessage("Sorry you don't have permission to send " + teleportee.getDisplayName() + "to the world spawn!");
teleporter.sendMessage(ChatColor.RED + " (multiverse.core.spawn.other)");
return;
@ -144,7 +142,7 @@ public class TeleportCommand extends MultiverseCommand {
if (!this.playerTeleporter.safelyTeleport(teleportee, d)) {
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + LocationManipulation.strCoordsRaw(d.getLocation(teleportee)));
this.plugin.log(Level.FINE, "Queueing Command");
Class<?> paramTypes[] = { Player.class, Location.class };
Class<?> paramTypes[] = {Player.class, Location.class};
List<Object> items = new ArrayList<Object>();
items.add(teleportee);
items.add(d.getLocation(teleportee));
@ -160,13 +158,13 @@ public class TeleportCommand extends MultiverseCommand {
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
MVMessaging message = this.plugin.getMessaging();
if (teleporter.equals(teleportee)) {
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.self."+destination.getIdentifier(),true)) {
message.sendMessages(teleporter, new String[] {"You don't have permission to teleport yourself to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.self."+destination.getIdentifier()+")"});
if (!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
message.sendMessages(teleporter, new String[]{"You don't have permission to teleport yourself to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.self." + destination.getIdentifier() + ")"});
return false;
}
} else {
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.other."+destination.getIdentifier(),true)) {
message.sendMessages(teleporter, new String[] {"You don't have permission to teleport another player to a " + ChatColor.GREEN + destination.getType() + " Destination.",ChatColor.RED + " (multiverse.teleport.other."+destination.getIdentifier()+")"});
if (!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
message.sendMessages(teleporter, new String[]{"You don't have permission to teleport another player to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.other." + destination.getIdentifier() + ")"});
return false;
}
}

View File

@ -7,19 +7,19 @@
package com.onarandombox.MultiverseCore.configuration;
import com.onarandombox.MultiverseCore.LoggablePlugin;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.config.Configuration;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.config.Configuration;
import com.onarandombox.MultiverseCore.LoggablePlugin;
public abstract class MVConfigMigrator {
public List<String> createdDefaults = new ArrayList<String>();
public abstract boolean migrate(String name, File folder);
protected final void migrateListItem(Configuration newConfig, Configuration oldConfig, String key, String oldProperty, String newProperty) {

View File

@ -7,14 +7,13 @@
package com.onarandombox.MultiverseCore.configuration;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.util.config.Configuration;
import java.io.File;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.util.config.Configuration;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class MVCoreConfigMigrator extends MVConfigMigrator {
private MultiverseCore core;

View File

@ -7,10 +7,10 @@
package com.onarandombox.MultiverseCore.event;
import java.util.List;
import org.bukkit.event.Event;
import java.util.List;
public class MVConfigMigrateEvent extends Event {
private static final long serialVersionUID = 3647950355746345397L;
private List<String> configsLoaded;

View File

@ -7,10 +7,10 @@
package com.onarandombox.MultiverseCore.event;
import java.util.List;
import org.bukkit.event.Event;
import java.util.List;
public class MVConfigReloadEvent extends Event {
private static final long serialVersionUID = 3647950355746345397L;
private List<String> configsLoaded;

View File

@ -7,17 +7,17 @@
package com.onarandombox.MultiverseCore.event;
import com.onarandombox.utils.MVDestination;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import com.onarandombox.utils.MVDestination;
/**
* Event that gets called when a player use the /mvtp command
* @author fernferret
*
* @author fernferret
*/
public class MVTeleportEvent extends Event implements Cancellable {
private static final long serialVersionUID = 854826818438649269L;

View File

@ -12,6 +12,7 @@ import org.bukkit.event.Event;
public class MVVersionRequestEvent extends Event {
private String pasteBinBuffer;
public MVVersionRequestEvent(String pasteBinBuffer) {
super("MVVersion");
this.pasteBinBuffer = pasteBinBuffer;
@ -20,6 +21,7 @@ public class MVVersionRequestEvent extends Event {
public String getPasteBinBuffer() {
return this.pasteBinBuffer;
}
public void setPasteBinBuffer(String buffer) {
this.pasteBinBuffer = buffer;
}

View File

@ -7,25 +7,18 @@
package com.onarandombox.MultiverseCore.listeners;
import java.util.List;
import java.util.logging.Level;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Animals;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.entity.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.WorldManager;
import java.util.List;
import java.util.logging.Level;
//import org.bukkit.event.entity.ExplosionPrimedEvent;
@ -41,12 +34,12 @@ public class MVEntityListener extends EntityListener {
@Override
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if(event.getEntity() instanceof Player) {
if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
MVWorld w = this.plugin.getWorldManager().getMVWorld(p.getWorld().getName());
if(w != null && !w.getHunger()) {
if (w != null && !w.getHunger()) {
// If the world has hunger set to false, do not let the level go down
if(event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) {
if (event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) {
event.setCancelled(true);
}
}
@ -54,7 +47,9 @@ public class MVEntityListener extends EntityListener {
}
/**
* Event - When a Entity is Damaged, we first sort out whether it is of importance to us, such as EntityVSEntity or EntityVSProjectile. Then we grab the attacked and defender and check if its a player. Then deal with the PVP Aspect.
* Event - When a Entity is Damaged, we first sort out whether it is of importance to us, such as EntityVSEntity or
* EntityVSProjectile. Then we grab the attacked and defender and check if its a player. Then deal with the PVP
* Aspect.
*/
@Override
public void onEntityDamage(EntityDamageEvent event) {
@ -107,9 +102,7 @@ public class MVEntityListener extends EntityListener {
}
}
/**
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.
*/
/** Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit. */
@Override
public void onCreatureSpawn(CreatureSpawnEvent event) {
@ -133,7 +126,7 @@ public class MVEntityListener extends EntityListener {
/**
* Handle people with non-standard animals: ie a patched craftbukkit.
*/
if(creature == null) {
if (creature == null) {
this.plugin.log(Level.FINER, "Found a null typed creature.");
return;
}

View File

@ -7,16 +7,15 @@
package com.onarandombox.MultiverseCore.listeners;
import java.util.Arrays;
import java.util.logging.Level;
import com.fernferret.allpay.AllPay;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import com.fernferret.allpay.AllPay;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.onarandombox.MultiverseCore.MultiverseCore;
import java.util.Arrays;
import java.util.logging.Level;
public class MVPluginListener extends ServerListener {
@ -26,9 +25,7 @@ public class MVPluginListener extends ServerListener {
this.plugin = plugin;
}
/**
* Keep an eye out for Plugins which we can utilize.
*/
/** Keep an eye out for Plugins which we can utilize. */
@Override
public void onPluginEnable(PluginEnableEvent event) {
/**
@ -54,9 +51,7 @@ public class MVPluginListener extends ServerListener {
}
}
/**
* We'll check if any of the plugins we rely on decide to Disable themselves.
*/
/** We'll check if any of the plugins we rely on decide to Disable themselves. */
@Override
public void onPluginDisable(PluginDisableEvent event) {
/**

View File

@ -7,13 +7,12 @@
package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.weather.WeatherListener;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class MVWeatherListener extends WeatherListener {
private MultiverseCore plugin;