mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
WIP! Just doing this to test the GitBot... AGAIN
This commit is contained in:
parent
fae3d33a6c
commit
db64804e27
@ -4,6 +4,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -27,6 +28,10 @@ public class MVPlayerListener extends PlayerListener {
|
||||
// MultiVerseCore.log.info("2 - " + event.getPlayer().getLocation().toString());
|
||||
}
|
||||
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player p = event.getPlayer(); // Grab Player
|
||||
|
@ -4,7 +4,6 @@ import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.PluginEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -22,6 +21,7 @@ public class MVPluginListener extends ServerListener {
|
||||
/**
|
||||
* Keep an eye out for Plugins which we can utilize.
|
||||
*/
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
|
||||
/**
|
||||
@ -49,6 +49,7 @@ public class MVPluginListener extends ServerListener {
|
||||
/**
|
||||
* We'll check if any of the plugins we rely on decide to Disable themselves.
|
||||
*/
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
/**
|
||||
* Check to see if Permissions just disabled.
|
||||
|
@ -16,7 +16,7 @@ public class MVWorld {
|
||||
public World world; // The World Instance.
|
||||
public Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
|
||||
public Long seed;
|
||||
|
||||
|
||||
public String name; // The Worlds Name, EG its folder name.
|
||||
public String alias = ""; // Short Alias for the World, this will be used in Chat Prefixes.
|
||||
|
||||
@ -69,6 +69,7 @@ public class MVWorld {
|
||||
temp = config.getStringList("worlds." + name + ".monsters.exceptions", new ArrayList<String>());
|
||||
for (String s : temp) {
|
||||
this.monsterList.add(s.toUpperCase());
|
||||
System.out.print(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,23 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -25,6 +41,9 @@ import org.bukkit.util.config.Configuration;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.onarandombox.MultiverseCore.command.CommandManager;
|
||||
import com.onarandombox.MultiverseCore.command.commands.CoordCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.MVCoord;
|
||||
import com.onarandombox.MultiverseCore.commands.MVCreate;
|
||||
import com.onarandombox.MultiverseCore.commands.MVImport;
|
||||
@ -43,9 +62,6 @@ import com.onarandombox.utils.UpdateChecker;
|
||||
|
||||
public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
// Setup a variable to hold our DataFolder which will house everything to do with Multiverse
|
||||
public static final File dataFolder = new File("plugins" + File.separator + "Multiverse");
|
||||
|
||||
// Useless stuff to keep us going.
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static DebugLog debugLog;
|
||||
@ -55,6 +71,9 @@ public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
// Setup our Map for our Commands using the CommandHandler.
|
||||
private Map<String, MVCommandHandler> commands = new HashMap<String, MVCommandHandler>();
|
||||
private CommandManager commandManager = new CommandManager();
|
||||
|
||||
private final String tag = "[Multiverse-Core]";
|
||||
|
||||
// Messaging
|
||||
private Messaging messaging = new Messaging();
|
||||
@ -75,6 +94,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
// Setup the block/player/entity listener.
|
||||
private MVPlayerListener playerListener = new MVPlayerListener(this);;
|
||||
@SuppressWarnings("unused")
|
||||
private MVBlockListener blockListener = new MVBlockListener(this);
|
||||
private MVEntityListener entityListener = new MVEntityListener(this);
|
||||
private MVPluginListener pluginListener = new MVPluginListener(this);
|
||||
@ -89,8 +109,15 @@ public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
dataFolder.mkdirs();
|
||||
debugLog = new DebugLog("Multiverse", dataFolder + File.separator + "debug.log");
|
||||
// Create our DataFolder
|
||||
getDataFolder().mkdirs();
|
||||
// Setup our Debug Log
|
||||
debugLog = new DebugLog("Multiverse", getDataFolder() + File.separator + "debug.log");
|
||||
|
||||
// Setup & Load our Configuration files.
|
||||
loadConfigs();
|
||||
// Call the Function to load all the Worlds and setup the HashMap
|
||||
loadWorlds();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,24 +125,21 @@ public class MultiverseCore extends JavaPlugin {
|
||||
// Output a little snippet to show it's enabled.
|
||||
log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors());
|
||||
|
||||
// Setup & Load our Configuration files.
|
||||
loadConfigs();
|
||||
|
||||
// Setup all the Events the plugin needs to Monitor.
|
||||
registerEvents();
|
||||
// Call the Function to load all the Worlds and setup the HashMap
|
||||
loadWorlds();
|
||||
// Purge Worlds of old Monsters/Animals which don't adhere to the setup.
|
||||
purgeWorlds();
|
||||
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
|
||||
setupPermissions();
|
||||
// Setup iConomy.
|
||||
setupiConomy();
|
||||
setupEconomy();
|
||||
// Call the Function to assign all the Commands to their Class.
|
||||
setupCommands();
|
||||
registerCommands();
|
||||
|
||||
// Start the Update Checker
|
||||
// updateCheck = new UpdateChecker(this.getDescription().getName(), this.getDescription().getVersion());
|
||||
|
||||
// Purge Worlds of old Monsters/Animals which don't adhere to the setup.
|
||||
purgeWorlds();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,10 +147,11 @@ public class MultiverseCore extends JavaPlugin {
|
||||
*/
|
||||
private void registerEvents() {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this); // Low so it acts above any other.
|
||||
// pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this); // Low so it acts above any other.
|
||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.Highest, this); // Cancel Teleports if needed.
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); // To create the Player Session
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); // To remove Player Sessions
|
||||
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Highest, this);
|
||||
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth.
|
||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.
|
||||
@ -157,7 +182,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
/**
|
||||
* Check for the iConomy plugin and set it up accordingly.
|
||||
*/
|
||||
private void setupiConomy() {
|
||||
private void setupEconomy() {
|
||||
Plugin test = this.getServer().getPluginManager().getPlugin("iConomy");
|
||||
|
||||
if (MultiverseCore.iConomy == null) {
|
||||
@ -172,12 +197,12 @@ public class MultiverseCore extends JavaPlugin {
|
||||
*/
|
||||
public void loadConfigs() {
|
||||
// Call the defaultConfiguration class to create the config files if they don't already exist.
|
||||
new DefaultConfiguration(dataFolder, "config.yml");
|
||||
new DefaultConfiguration(dataFolder, "worlds.yml");
|
||||
new DefaultConfiguration(getDataFolder(), "config.yml");
|
||||
new DefaultConfiguration(getDataFolder(), "worlds.yml");
|
||||
|
||||
// Now grab the Configuration Files.
|
||||
configMV = new Configuration(new File(dataFolder, "config.yml"));
|
||||
configWorlds = new Configuration(new File(dataFolder, "worlds.yml"));
|
||||
configMV = new Configuration(new File(getDataFolder(), "config.yml"));
|
||||
configWorlds = new Configuration(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
// Now attempt to Load the configurations.
|
||||
try {
|
||||
@ -205,25 +230,70 @@ public class MultiverseCore extends JavaPlugin {
|
||||
if (worlds.size() <= 0)
|
||||
return;
|
||||
|
||||
// TODO: Need a better method than this... too messy and atm it's not complete.
|
||||
|
||||
Set<String> worldKeys = worlds.keySet();
|
||||
for (String key : worldKeys) {
|
||||
World world = getServer().getWorld(key);
|
||||
if (world == null)
|
||||
continue;
|
||||
|
||||
// TODO: Sort out the Entity Purge, only purge what is configured to be.
|
||||
|
||||
/*
|
||||
* List<LivingEntity> entities = world.getLivingEntities();
|
||||
*
|
||||
* MVWorld mvworld = worlds.get(key);
|
||||
* for (Entity entity: entities){
|
||||
*
|
||||
* }
|
||||
*/
|
||||
MVWorld mvworld = worlds.get(key);
|
||||
List<String> monsters = mvworld.monsterList;
|
||||
List<String> animals = mvworld.animalList;
|
||||
System.out.print(monsters.size() + " - " + animals.size());
|
||||
for (Entity e : world.getEntities()) {
|
||||
// Check against Monsters
|
||||
if (e instanceof Creeper || e instanceof Skeleton || e instanceof Spider || e instanceof Zombie || e instanceof Ghast || e instanceof PigZombie || e instanceof Giant || e instanceof Slime || e instanceof Monster) {
|
||||
// If Monsters are disabled and there's no exceptions we can simply remove them.
|
||||
if (mvworld.monsters == false && !(monsters.size() > 0)) {
|
||||
e.remove();
|
||||
continue;
|
||||
}
|
||||
// If monsters are enabled and there's no exceptions we can continue to the next set.
|
||||
if (mvworld.monsters == true && !(monsters.size() > 0)) {
|
||||
continue;
|
||||
}
|
||||
String creature = e.toString().replaceAll("Craft", "");
|
||||
if (monsters.contains(creature.toUpperCase())) {
|
||||
if (mvworld.monsters) {
|
||||
System.out.print(creature + " - Removed");
|
||||
e.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check against Animals
|
||||
if (e instanceof Chicken || e instanceof Cow || e instanceof Sheep || e instanceof Pig || e instanceof Squid || e instanceof Animals) {
|
||||
// If Monsters are disabled and there's no exceptions we can simply remove them.
|
||||
if (mvworld.animals == false && !(animals.size() > 0)) {
|
||||
e.remove();
|
||||
continue;
|
||||
}
|
||||
// If monsters are enabled and there's no exceptions we can continue to the next set.
|
||||
if (mvworld.animals == true && !(animals.size() > 0)) {
|
||||
continue;
|
||||
}
|
||||
String creature = e.toString().replaceAll("Craft", "");
|
||||
if (animals.contains(creature.toUpperCase())) {
|
||||
if (mvworld.animals) {
|
||||
e.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Heroes commands to DThielke's Command Manager.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
// Page 1
|
||||
commandManager.addCommand(new HelpCommand(this));
|
||||
commandManager.addCommand(new CoordCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup commands to the Command Handler
|
||||
*/
|
||||
@ -270,7 +340,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
}
|
||||
// Output to the Log that wea re loading a world, specify the name and environment type.
|
||||
log(Level.INFO, "Loading World & Settings - '" + worldKey + "' - " + environment);
|
||||
|
||||
|
||||
// If a seed was given we need to parse it to a Long Format.
|
||||
if (seedString.length() > 0) {
|
||||
try {
|
||||
@ -278,7 +348,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
} catch (NumberFormatException numberformatexception) {
|
||||
seed = (long) seedString.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we don't have a seed then add a standard World, else add the world with the Seed.
|
||||
if (seed == null) {
|
||||
addWorld(worldKey, env, null);
|
||||
@ -293,6 +363,15 @@ public class MultiverseCore extends JavaPlugin {
|
||||
log(Level.INFO, count + " - World(s) loaded.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the worlds Seed.
|
||||
* @param w World
|
||||
* @return Seed
|
||||
*/
|
||||
public long getSeed(World w) {
|
||||
return ((CraftWorld) w).getHandle().worldData.b();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
* @param name World Name
|
||||
@ -302,11 +381,11 @@ public class MultiverseCore extends JavaPlugin {
|
||||
if (seed != null) {
|
||||
World world = getServer().createWorld(name, environment, seed);
|
||||
worlds.put(name, new MVWorld(world, configWorlds, this, seed)); // Place the World into the HashMap.
|
||||
System.out.print("Seed - " + ((CraftWorld) world).getHandle().q.b());
|
||||
System.out.print("Seed - " + getSeed(world));
|
||||
} else {
|
||||
World world = getServer().createWorld(name, environment);
|
||||
worlds.put(name, new MVWorld(world, configWorlds, this, null)); // Place the World into the HashMap.
|
||||
System.out.print("Seed - " + ((CraftWorld) world).getHandle().q.b());
|
||||
System.out.print("Seed - " + getSeed(world));
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,6 +398,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
debugLog.close();
|
||||
MultiverseCore.Permissions = null;
|
||||
log(Level.INFO, "- Disabled");
|
||||
}
|
||||
@ -369,14 +449,15 @@ public class MultiverseCore extends JavaPlugin {
|
||||
sender.sendMessage("This plugin is Disabled!");
|
||||
return true;
|
||||
}
|
||||
return commandManager.dispatch(sender, command, commandLabel, args);
|
||||
|
||||
MVCommandHandler handler = commands.get(command.getName().toLowerCase());
|
||||
|
||||
if (handler != null) {
|
||||
return handler.perform(sender, args);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// MVCommandHandler handler = commands.get(command.getName().toLowerCase());
|
||||
//
|
||||
// if (handler != null) {
|
||||
// return handler.perform(sender, args);
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -428,4 +509,12 @@ public class MultiverseCore extends JavaPlugin {
|
||||
}
|
||||
return authors.substring(2);
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
84
src/com/onarandombox/MultiverseCore/command/BaseCommand.java
Normal file
84
src/com/onarandombox/MultiverseCore/command/BaseCommand.java
Normal file
@ -0,0 +1,84 @@
|
||||
package com.onarandombox.MultiverseCore.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public abstract class BaseCommand {
|
||||
|
||||
protected MultiverseCore plugin;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String usage;
|
||||
protected int minArgs;
|
||||
protected int maxArgs;
|
||||
protected List<String> identifiers;
|
||||
|
||||
public BaseCommand(MultiverseCore plugin) {
|
||||
this.identifiers = new ArrayList<String>();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public abstract void execute(CommandSender sender, String[] args);
|
||||
|
||||
public String[] validate(String input, StringBuilder identifier) {
|
||||
String match = matchIdentifier(input);
|
||||
|
||||
if (match != null) {
|
||||
identifier = identifier.append(match);
|
||||
int i = identifier.length();
|
||||
String[] args = input.substring(i).trim().split(" ");
|
||||
if (args[0].isEmpty()) {
|
||||
args = new String[0];
|
||||
}
|
||||
int l = args.length;
|
||||
if (l >= minArgs && l <= maxArgs) {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String matchIdentifier(String input) {
|
||||
String lower = input.toLowerCase();
|
||||
|
||||
int index = -1;
|
||||
int n = identifiers.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
String identifier = identifiers.get(i).toLowerCase();
|
||||
if (lower.matches(identifier + "(\\s+.*|\\s*)")) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1) {
|
||||
return identifiers.get(index);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getIdentifiers() {
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
public void setIdentifiers(List<String> identifiers) {
|
||||
this.identifiers = identifiers;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (C) 2011 DThielke <dave.thielke@gmail.com>
|
||||
*
|
||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to
|
||||
* Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
|
||||
**/
|
||||
|
||||
package com.onarandombox.MultiverseCore.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
protected List<BaseCommand> commands;
|
||||
|
||||
public CommandManager() {
|
||||
commands = new ArrayList<BaseCommand>();
|
||||
}
|
||||
|
||||
public boolean dispatch(CommandSender sender, Command command, String label, String[] args) {
|
||||
String input = label + " ";
|
||||
for (String s : args) {
|
||||
input += s + " ";
|
||||
}
|
||||
|
||||
BaseCommand match = null;
|
||||
String[] trimmedArgs = null;
|
||||
StringBuilder identifier = new StringBuilder();
|
||||
|
||||
for (BaseCommand cmd : commands) {
|
||||
StringBuilder tmpIdentifier = new StringBuilder();
|
||||
String[] tmpArgs = cmd.validate(input, tmpIdentifier);
|
||||
if (tmpIdentifier.length() > identifier.length()) {
|
||||
identifier = tmpIdentifier;
|
||||
match = cmd;
|
||||
trimmedArgs = tmpArgs;
|
||||
}
|
||||
}
|
||||
|
||||
if (match != null) {
|
||||
if (trimmedArgs != null) {
|
||||
match.execute(sender, trimmedArgs);
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage("§cCommand: " + ChatColor.WHITE + match.getName());
|
||||
sender.sendMessage("§cDescription: " + ChatColor.WHITE + match.getDescription());
|
||||
sender.sendMessage("§cUsage: " + ChatColor.WHITE + match.getUsage());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addCommand(BaseCommand command) {
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
public void removeCommand(BaseCommand command) {
|
||||
commands.remove(command);
|
||||
}
|
||||
|
||||
public List<BaseCommand> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
|
||||
public class CoordCommand extends BaseCommand {
|
||||
|
||||
private LocationManipulation locMan = new LocationManipulation();
|
||||
|
||||
public CoordCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Coordinates";
|
||||
description = "Returns detailed information on the Players where abouts.";
|
||||
usage = "/mvcoord";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("mvcoord");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// Check if the command was sent from a Player.
|
||||
if (sender instanceof Player) {
|
||||
// If this command was sent from a Player then we need to check Permissions
|
||||
if (!(plugin.ph.has(((Player) sender), "multiverse.coord"))) {
|
||||
sender.sendMessage("You do not have access to this command.");
|
||||
return;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
|
||||
p.sendMessage(ChatColor.RED + "World: " + ChatColor.WHITE + p.getWorld().getName());
|
||||
p.sendMessage(ChatColor.RED + "Compression: " + ChatColor.WHITE + plugin.worlds.get(p.getWorld().getName()).compression);
|
||||
p.sendMessage(ChatColor.RED + "Coordinates: " + ChatColor.WHITE + locMan.strCoords(p.getLocation()));
|
||||
p.sendMessage(ChatColor.RED + "Direction: " + ChatColor.WHITE + locMan.getDirection(p.getLocation()));
|
||||
p.sendMessage(ChatColor.RED + "Block: " + ChatColor.WHITE + Material.getMaterial(p.getWorld().getBlockTypeIdAt(p.getLocation())));
|
||||
} else {
|
||||
sender.sendMessage("This command needs to be used from a Player.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (C) 2011 DThielke <dave.thielke@gmail.com>
|
||||
*
|
||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to
|
||||
* Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
|
||||
**/
|
||||
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
public class HelpCommand extends BaseCommand {
|
||||
private static final int CMDS_PER_PAGE = 8;
|
||||
|
||||
public HelpCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Help";
|
||||
description = "Displays the help menu";
|
||||
usage = "§e/mv help §8[page#]";
|
||||
minArgs = 0;
|
||||
maxArgs = 1;
|
||||
identifiers.add("mv help");
|
||||
identifiers.add("mv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int page = 0;
|
||||
if (args.length != 0) {
|
||||
try {
|
||||
page = Integer.parseInt(args[0]) - 1;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
List<BaseCommand> commands = plugin.getCommandManager().getCommands();
|
||||
|
||||
int numPages = commands.size() / CMDS_PER_PAGE;
|
||||
if (commands.size() % CMDS_PER_PAGE != 0) {
|
||||
numPages++;
|
||||
}
|
||||
|
||||
if (page >= numPages || page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
sender.sendMessage("§c-----[ " + "§f" + plugin.getTag().replace("[", "").replace("]", "") + " Help <" + (page + 1) + "/" + numPages + ">§c ]-----");
|
||||
int start = page * CMDS_PER_PAGE;
|
||||
int end = start + CMDS_PER_PAGE;
|
||||
if (end > commands.size()) {
|
||||
end = commands.size();
|
||||
}
|
||||
for (int c = start; c < end; c++) {
|
||||
BaseCommand cmd = commands.get(c);
|
||||
sender.sendMessage(" §a" + cmd.getUsage());
|
||||
}
|
||||
|
||||
sender.sendMessage("§cFor more info on a particular command, type '/<command> ?'");
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,9 @@ main: com.onarandombox.MultiverseCore.MultiverseCore
|
||||
authors: ['Rigby', 'Herocraft Coding Team']
|
||||
version: 2.0
|
||||
commands:
|
||||
mv:
|
||||
description: Generic Multiverse Command
|
||||
usage: /<command>
|
||||
mvcreate:
|
||||
description: World create command
|
||||
usage: |
|
||||
|
Loading…
Reference in New Issue
Block a user