Swap to Maven -- Hopefully

This commit is contained in:
Rigby 2011-07-20 15:48:46 +01:00
parent c678750c90
commit ab1c1be9b1
50 changed files with 3868 additions and 3721 deletions

View File

@ -1,8 +0,0 @@
wget -N http://ci.bukkit.org/job/dev-CraftBukkit/lastSuccessfulBuild/artifact/target/craftbukkit-0.0.1-SNAPSHOT.jar
wget -N http://mirror.onarandombox.com/Permissions.jar
wget -N http://mirror.onarandombox.com/Essentials.jar
wget -N http://mirror.onarandombox.com/iConomy.jar
#wget -N http://www.theyeticave.net/downloads/permissions/3.1.5/Permissions.jar
#wget -N http://earth2me.net:8001/artifactory/essentials-2.2/Essentials.jar
#wget -N http://mirror.nexua.org/iConomy/JARS/5.0/1/iConomy.jar

155
pom.xml Normal file
View File

@ -0,0 +1,155 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>MultiverseCore</artifactId>
<version>2.0</version>
<name>Multiverse-Core</name>
<description>World Management Plugin</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>UNKNOWN</project.build.number>
</properties>
<repositories>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/artifactory/repo</url>
</repository>
</repositories>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Build Helper - Additional Source Folders -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-wsdl-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/lib/allpay/src</source>
<source>${project.basedir}/lib/commandhandler/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.8</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-${project.build.number}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestEntries>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Bukkit Dependency -->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- Bukkit Dependency -->
<!-- Start of Economy Dependencies -->
<dependency>
<groupId>cosine.boseconomy</groupId>
<artifactId>BOSEconomy</artifactId>
<version>0.6.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>fr.crafter.tickleman.RealShop</groupId>
<artifactId>RealShop</artifactId>
<version>0.63</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.iConomy</groupId>
<artifactId>iConomy</artifactId>
<version>5.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nijiko.coelho.iConomy</groupId>
<artifactId>iConomy</artifactId>
<version>4.65</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.earth2me.essentials</groupId>
<artifactId>Essentials</artifactId>
<version>2.4.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Economy Dependencies -->
<!-- Start of Permissions Dependencies -->
<dependency>
<groupId>com.nijikokun.bukkit</groupId>
<artifactId>Permissions</artifactId>
<version>3.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Permissions Dependencies -->
</dependencies>
</project>

View File

@ -1,45 +1,45 @@
package com.onarandombox.MultiverseCore;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
//import org.bukkit.event.block.BlockRightClickEvent;
public class MVBlockListener extends BlockListener {
MultiverseCore plugin;
public MVBlockListener(MultiverseCore plugin) {
this.plugin = plugin;
}
// public void onBlockRightClicked(BlockRightClickEvent event){
// }
@Override
public void onBlockDamage(BlockDamageEvent event) {
}
@Override
public void onBlockPhysics(BlockPhysicsEvent event) {
if (event.isCancelled()) {
return;
}
int id = event.getChangedTypeId();
if (id == 90) { // && config.getBoolean("portalanywhere", false)
event.setCancelled(true);
return;
}
}
public void onBlockPlaced(BlockPlaceEvent event) {
}
}
package com.onarandombox.MultiverseCore;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
//import org.bukkit.event.block.BlockRightClickEvent;
public class MVBlockListener extends BlockListener {
MultiverseCore plugin;
public MVBlockListener(MultiverseCore plugin) {
this.plugin = plugin;
}
// public void onBlockRightClicked(BlockRightClickEvent event){
// }
@Override
public void onBlockDamage(BlockDamageEvent event) {
}
@Override
public void onBlockPhysics(BlockPhysicsEvent event) {
if (event.isCancelled()) {
return;
}
int id = event.getChangedTypeId();
if (id == 90) { // && config.getBoolean("portalanywhere", false)
event.setCancelled(true);
return;
}
}
public void onBlockPlaced(BlockPlaceEvent event) {
}
}

View File

@ -1,156 +1,156 @@
package com.onarandombox.MultiverseCore;
import java.util.List;
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.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
//import org.bukkit.event.entity.ExplosionPrimedEvent;
public class MVEntityListener extends EntityListener {
MultiverseCore plugin;
public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* 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) {
if (event.isCancelled()) {
return;
}
Entity attacker = null;
Entity defender = null;
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
attacker = sub.getDamager();
defender = sub.getEntity();
} else if (event instanceof EntityDamageByProjectileEvent) {
EntityDamageByProjectileEvent sub = (EntityDamageByProjectileEvent) event;
attacker = sub.getDamager();
defender = sub.getEntity();
} else {
return;
}
if (attacker == null || defender == null) {
return;
}
if (defender instanceof Player) {
Player player = (Player) defender;
World w = player.getWorld();
if (!this.plugin.isMVWorld(w.getName())) {
//if the world is not handled, we don't care
return;
}
MVWorld world = this.plugin.getMVWorld(w.getName());
if (attacker != null && attacker instanceof Player) {
Player pattacker = (Player) attacker;
if (!world.getPvp() && this.plugin.getConfig().getBoolean("fakepvp", false)) {
pattacker.sendMessage(ChatColor.RED + "PVP is disabled in this World.");
event.setCancelled(true);
return;
}
}
}
}
@Override
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (event.isCancelled()) {
return;
}
RegainReason reason = event.getRegainReason();
if (reason == RegainReason.REGEN && this.plugin.getConfig().getBoolean("disableautoheal", false)) {
event.setCancelled(true);
return;
}
}
/**
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.
*/
@Override
public void onCreatureSpawn(CreatureSpawnEvent event) {
// Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour.
if (event.getSpawnReason() == SpawnReason.CUSTOM) {
return;
}
World world = event.getEntity().getWorld();
if (event.isCancelled())
return;
// Check if it's a world which we are meant to be managing.
if (!(this.plugin.isMVWorld(world.getName())))
return;
CreatureType creature = event.getCreatureType();
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
/**
* Animal Handling
*/
if (event.getEntity() instanceof Animals) {
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getAnimalList(), mvworld.allowAnimalSpawning(), creature.toString().toUpperCase()));
}
/**
* Monster Handling
*/
if (event.getEntity() instanceof Monster || event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime) {
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.allowMonsterSpawning(), creature.toString().toUpperCase()));
}
}
private boolean shouldWeKillThisCreature(List<String> creatureList, boolean allowCreatureSpawning, String creature) {
if (creatureList.isEmpty() && allowCreatureSpawning) {
// 1. There are no exceptions and animals are allowd. Save it.
return false;
} else if (creatureList.isEmpty()) {
// 2. There are no exceptions and animals are NOT allowed. Kill it.
return true;
} else if (creatureList.contains(creature) && allowCreatureSpawning) {
// 3. There ARE exceptions and animals ARE allowed. Kill it.
return true;
} else if (!creatureList.contains(creature.toString().toUpperCase()) && allowCreatureSpawning) {
// 4. There ARE exceptions and animals ARE NOT allowed. SAVE it.
return false;
} else if (creatureList.contains(creature.toString().toUpperCase()) && !allowCreatureSpawning) {
// 5. No animals are allowed to be spawned, BUT this one can stay...
return false;
} else if (!creatureList.contains(creature.toString().toUpperCase()) && !allowCreatureSpawning) {
// 6. Animals are NOT allowd to spawn, and this creature is not in the save list... KILL IT
return true;
}
// This code should NEVER execute. I just left the verbose conditions in right now.
return false;
}
}
package com.onarandombox.MultiverseCore;
import java.util.List;
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.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
//import org.bukkit.event.entity.ExplosionPrimedEvent;
public class MVEntityListener extends EntityListener {
MultiverseCore plugin;
public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* 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) {
if (event.isCancelled()) {
return;
}
Entity attacker = null;
Entity defender = null;
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
attacker = sub.getDamager();
defender = sub.getEntity();
} else if (event instanceof EntityDamageByProjectileEvent) {
EntityDamageByProjectileEvent sub = (EntityDamageByProjectileEvent) event;
attacker = sub.getDamager();
defender = sub.getEntity();
} else {
return;
}
if (attacker == null || defender == null) {
return;
}
if (defender instanceof Player) {
Player player = (Player) defender;
World w = player.getWorld();
if (!this.plugin.isMVWorld(w.getName())) {
//if the world is not handled, we don't care
return;
}
MVWorld world = this.plugin.getMVWorld(w.getName());
if (attacker != null && attacker instanceof Player) {
Player pattacker = (Player) attacker;
if (!world.getPvp() && this.plugin.getConfig().getBoolean("fakepvp", false)) {
pattacker.sendMessage(ChatColor.RED + "PVP is disabled in this World.");
event.setCancelled(true);
return;
}
}
}
}
@Override
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (event.isCancelled()) {
return;
}
RegainReason reason = event.getRegainReason();
if (reason == RegainReason.REGEN && this.plugin.getConfig().getBoolean("disableautoheal", false)) {
event.setCancelled(true);
return;
}
}
/**
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.
*/
@Override
public void onCreatureSpawn(CreatureSpawnEvent event) {
// Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour.
if (event.getSpawnReason() == SpawnReason.CUSTOM) {
return;
}
World world = event.getEntity().getWorld();
if (event.isCancelled())
return;
// Check if it's a world which we are meant to be managing.
if (!(this.plugin.isMVWorld(world.getName())))
return;
CreatureType creature = event.getCreatureType();
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
/**
* Animal Handling
*/
if (event.getEntity() instanceof Animals) {
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getAnimalList(), mvworld.allowAnimalSpawning(), creature.toString().toUpperCase()));
}
/**
* Monster Handling
*/
if (event.getEntity() instanceof Monster || event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime) {
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.allowMonsterSpawning(), creature.toString().toUpperCase()));
}
}
private boolean shouldWeKillThisCreature(List<String> creatureList, boolean allowCreatureSpawning, String creature) {
if (creatureList.isEmpty() && allowCreatureSpawning) {
// 1. There are no exceptions and animals are allowd. Save it.
return false;
} else if (creatureList.isEmpty()) {
// 2. There are no exceptions and animals are NOT allowed. Kill it.
return true;
} else if (creatureList.contains(creature) && allowCreatureSpawning) {
// 3. There ARE exceptions and animals ARE allowed. Kill it.
return true;
} else if (!creatureList.contains(creature.toString().toUpperCase()) && allowCreatureSpawning) {
// 4. There ARE exceptions and animals ARE NOT allowed. SAVE it.
return false;
} else if (creatureList.contains(creature.toString().toUpperCase()) && !allowCreatureSpawning) {
// 5. No animals are allowed to be spawned, BUT this one can stay...
return false;
} else if (!creatureList.contains(creature.toString().toUpperCase()) && !allowCreatureSpawning) {
// 6. Animals are NOT allowd to spawn, and this creature is not in the save list... KILL IT
return true;
}
// This code should NEVER execute. I just left the verbose conditions in right now.
return false;
}
}

View File

@ -1,104 +1,104 @@
package com.onarandombox.MultiverseCore;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.pneumaticraft.commandhandler.PermissionsInterface;
public class MVPermissions implements PermissionsInterface {
private MultiverseCore plugin;
private PermissionHandler permissions = null;
/**
* Constructor FTW
*
* @param plugin Pass along the Core Plugin.
*/
public MVPermissions(MultiverseCore plugin) {
this.plugin = plugin;
// We have to see if permissions was loaded before MV was
if (this.plugin.getServer().getPluginManager().getPlugin("Permissions") != null) {
this.setPermissions(((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
this.plugin.log(Level.INFO, "- Attached to Permissions");
}
}
/**
* Check if a Player can teleport to the Destination world from there current world. This checks against the Worlds Blacklist
*
* @param p
* @param w
* @return
*/
public Boolean canTravelFromWorld(Player p, MVWorld w) {
List<String> blackList = w.getWorldBlacklist();
boolean returnValue = true;
for (String s : blackList) {
if (s.equalsIgnoreCase(p.getWorld().getName())) {
returnValue = false;
break;
}
}
return returnValue;
}
/**
* Check if the Player has the permissions to enter this world.
*
* @param p
* @param w
* @return
*/
public Boolean canEnterWorld(Player p, MVWorld w) {
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
}
public void setPermissions(PermissionHandler handler) {
this.permissions = handler;
}
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
if (this.permissions != null && this.permissions.has(player, node)) {
// If Permissions is enabled we check against them.
return true;
} else if (sender.hasPermission(node) && !opFallback) {
// If Now check the bukkit permissions
// OpFallback must be disabled for this to work
return true;
} else if (player.isOp() && opFallback) {
// If Player is Op we always let them use it if they have the fallback enabled!
return true;
}
// If the Player doesn't have Permissions and isn't an Op then
// we return true if OP is not required, otherwise we return false
// This allows us to act as a default permission guidance
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
return !isOpRequired && opFallback;
}
public String getType() {
if (this.permissions != null) {
return "Permissions " + this.plugin.getServer().getPluginManager().getPlugin("Permissions").getDescription().getVersion();
}
return "Bukkit Permissions/OPs.txt";
}
}
package com.onarandombox.MultiverseCore;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.pneumaticraft.commandhandler.PermissionsInterface;
public class MVPermissions implements PermissionsInterface {
private MultiverseCore plugin;
private PermissionHandler permissions = null;
/**
* Constructor FTW
*
* @param plugin Pass along the Core Plugin.
*/
public MVPermissions(MultiverseCore plugin) {
this.plugin = plugin;
// We have to see if permissions was loaded before MV was
if (this.plugin.getServer().getPluginManager().getPlugin("Permissions") != null) {
this.setPermissions(((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
this.plugin.log(Level.INFO, "- Attached to Permissions");
}
}
/**
* Check if a Player can teleport to the Destination world from there current world. This checks against the Worlds Blacklist
*
* @param p
* @param w
* @return
*/
public Boolean canTravelFromWorld(Player p, MVWorld w) {
List<String> blackList = w.getWorldBlacklist();
boolean returnValue = true;
for (String s : blackList) {
if (s.equalsIgnoreCase(p.getWorld().getName())) {
returnValue = false;
break;
}
}
return returnValue;
}
/**
* Check if the Player has the permissions to enter this world.
*
* @param p
* @param w
* @return
*/
public Boolean canEnterWorld(Player p, MVWorld w) {
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
}
public void setPermissions(PermissionHandler handler) {
this.permissions = handler;
}
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
if (this.permissions != null && this.permissions.has(player, node)) {
// If Permissions is enabled we check against them.
return true;
} else if (sender.hasPermission(node) && !opFallback) {
// If Now check the bukkit permissions
// OpFallback must be disabled for this to work
return true;
} else if (player.isOp() && opFallback) {
// If Player is Op we always let them use it if they have the fallback enabled!
return true;
}
// If the Player doesn't have Permissions and isn't an Op then
// we return true if OP is not required, otherwise we return false
// This allows us to act as a default permission guidance
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
return !isOpRequired && opFallback;
}
public String getType() {
if (this.permissions != null) {
return "Permissions " + this.plugin.getServer().getPluginManager().getPlugin("Permissions").getDescription().getVersion();
}
return "Bukkit Permissions/OPs.txt";
}
}

View File

@ -1,117 +1,117 @@
package com.onarandombox.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
public class MVPlayerListener extends PlayerListener {
MultiverseCore plugin;
MVTeleport mvteleporter;
public MVPlayerListener(MultiverseCore plugin) {
this.plugin = plugin;
}
// Taken out until we do persistance.
// @Override
// public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
// Location bedLoc = event.getBed().getLocation();
// bedLoc = this.plugin.getTeleporter().getSafeBedDestination(bedLoc);
// this.plugin.getPlayerSession(event.getPlayer()).setRespawnLocation(bedLoc);
// event.getPlayer().sendMessage("You should come back here when you type '/mv sleep'!");
// }
@Override
public void onPlayerChat(PlayerChatEvent event) {
if (event.isCancelled()) {
return;
}
// Check whether the Server is set to prefix the chat with the World name. If not we do nothing, if so we need to check if the World has an Alias.
if (this.plugin.getConfig().getBoolean("worldnameprefix", true)) {
String world = event.getPlayer().getWorld().getName();
String prefix = "";
// If we're not a MV world, don't do anything
if (!this.plugin.isMVWorld(world)) {
return;
}
MVWorld mvworld = this.plugin.getMVWorld(world);
prefix = mvworld.getColoredWorldString();
String format = event.getFormat();
event.setFormat("[" + prefix + "]" + format);
}
}
@Override
public void onPlayerRespawn(PlayerRespawnEvent event) {
// TODO: Reimplement bed respawning, needs to be a way to persist the bed location or something otherwise it's not very effective.
World world = event.getPlayer().getWorld();
// If it's not a World MV manages we stop.
if (!this.plugin.isMVWorld(world.getName())) {
return;
}
// Get the MVWorld
MVWorld mvWorld = this.plugin.getMVWorld(world.getName());
// Get the instance of the World the player should respawn at.
MVWorld respawnWorld = null;
if (this.plugin.isMVWorld(mvWorld.getRespawnToWorld())) {
respawnWorld = this.plugin.getMVWorld(mvWorld.getRespawnToWorld());
}
// If it's null then it either means the World doesn't exist or the value is blank, so we don't handle it.
if (respawnWorld == null) {
return;
}
Location respawnLocation = respawnWorld.getCBWorld().getSpawnLocation();
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
event.setRespawnLocation(respawnEvent.getPlayersRespawnLocation());
}
@Override
public void onPlayerJoin(PlayerJoinEvent event) {
if (this.plugin.getMVWorlds().size() == 0 && this.plugin.ph.hasPermission(event.getPlayer(), "multiverse.world.import", true)) {
event.getPlayer().sendMessage("You don't have any worlds imported into Multiverse!");
event.getPlayer().sendMessage("You can import your current worlds with " + ChatColor.AQUA + "/mvimport");
event.getPlayer().sendMessage("or you can create new ones with " + ChatColor.GOLD + "/mvcreate");
event.getPlayer().sendMessage("If you just wanna see all of the Multiverse Help, type: " + ChatColor.GREEN + "/mv");
}
}
@Override
public void onPlayerQuit(PlayerQuitEvent event) {
this.plugin.removePlayerSession(event.getPlayer());
}
@Override
public void onPlayerTeleport(PlayerTeleportEvent event) {
MVWorld fromWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
MVWorld toWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
if (toWorld != null) {
if (!this.plugin.getPermissions().canEnterWorld(event.getPlayer(), toWorld)) {
event.getPlayer().sendMessage("You don't have access to go here...");
event.setCancelled(true);
return;
}
}
if (fromWorld != null) {
if (fromWorld.getWorldBlacklist().contains(toWorld.getName())) {
event.getPlayer().sendMessage("You don't have access to go to " + toWorld.getColoredWorldString() + " from " + fromWorld.getColoredWorldString());
event.setCancelled(true);
return;
}
}
}
}
package com.onarandombox.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
public class MVPlayerListener extends PlayerListener {
MultiverseCore plugin;
MVTeleport mvteleporter;
public MVPlayerListener(MultiverseCore plugin) {
this.plugin = plugin;
}
// Taken out until we do persistance.
// @Override
// public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
// Location bedLoc = event.getBed().getLocation();
// bedLoc = this.plugin.getTeleporter().getSafeBedDestination(bedLoc);
// this.plugin.getPlayerSession(event.getPlayer()).setRespawnLocation(bedLoc);
// event.getPlayer().sendMessage("You should come back here when you type '/mv sleep'!");
// }
@Override
public void onPlayerChat(PlayerChatEvent event) {
if (event.isCancelled()) {
return;
}
// Check whether the Server is set to prefix the chat with the World name. If not we do nothing, if so we need to check if the World has an Alias.
if (this.plugin.getConfig().getBoolean("worldnameprefix", true)) {
String world = event.getPlayer().getWorld().getName();
String prefix = "";
// If we're not a MV world, don't do anything
if (!this.plugin.isMVWorld(world)) {
return;
}
MVWorld mvworld = this.plugin.getMVWorld(world);
prefix = mvworld.getColoredWorldString();
String format = event.getFormat();
event.setFormat("[" + prefix + "]" + format);
}
}
@Override
public void onPlayerRespawn(PlayerRespawnEvent event) {
// TODO: Reimplement bed respawning, needs to be a way to persist the bed location or something otherwise it's not very effective.
World world = event.getPlayer().getWorld();
// If it's not a World MV manages we stop.
if (!this.plugin.isMVWorld(world.getName())) {
return;
}
// Get the MVWorld
MVWorld mvWorld = this.plugin.getMVWorld(world.getName());
// Get the instance of the World the player should respawn at.
MVWorld respawnWorld = null;
if (this.plugin.isMVWorld(mvWorld.getRespawnToWorld())) {
respawnWorld = this.plugin.getMVWorld(mvWorld.getRespawnToWorld());
}
// If it's null then it either means the World doesn't exist or the value is blank, so we don't handle it.
if (respawnWorld == null) {
return;
}
Location respawnLocation = respawnWorld.getCBWorld().getSpawnLocation();
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
event.setRespawnLocation(respawnEvent.getPlayersRespawnLocation());
}
@Override
public void onPlayerJoin(PlayerJoinEvent event) {
if (this.plugin.getMVWorlds().size() == 0 && this.plugin.ph.hasPermission(event.getPlayer(), "multiverse.world.import", true)) {
event.getPlayer().sendMessage("You don't have any worlds imported into Multiverse!");
event.getPlayer().sendMessage("You can import your current worlds with " + ChatColor.AQUA + "/mvimport");
event.getPlayer().sendMessage("or you can create new ones with " + ChatColor.GOLD + "/mvcreate");
event.getPlayer().sendMessage("If you just wanna see all of the Multiverse Help, type: " + ChatColor.GREEN + "/mv");
}
}
@Override
public void onPlayerQuit(PlayerQuitEvent event) {
this.plugin.removePlayerSession(event.getPlayer());
}
@Override
public void onPlayerTeleport(PlayerTeleportEvent event) {
MVWorld fromWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
MVWorld toWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
if (toWorld != null) {
if (!this.plugin.getPermissions().canEnterWorld(event.getPlayer(), toWorld)) {
event.getPlayer().sendMessage("You don't have access to go here...");
event.setCancelled(true);
return;
}
}
if (fromWorld != null) {
if (fromWorld.getWorldBlacklist().contains(toWorld.getName())) {
event.getPlayer().sendMessage("You don't have access to go to " + toWorld.getColoredWorldString() + " from " + fromWorld.getColoredWorldString());
event.setCancelled(true);
return;
}
}
}
}

View File

@ -1,96 +1,96 @@
package com.onarandombox.MultiverseCore;
import java.util.Date;
import org.bukkit.entity.Player;
import org.bukkit.util.config.Configuration;
public class MVPlayerSession {
private Player player; // Player holder, may be unnecessary.
private Long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
private Long messageLast = 0L; // Timestamp for the Players last Alert Message.
// private Location bedSpawn;
//
// // Beds are 2 blocks, thus we need to store both places
// private Location bedA;
// private Location bedB;
private Configuration config; // Configuration file to find out Cooldown Timers.
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
this.player = player;
this.config = config;
// this.bedSpawn = null;
}
/**
* Update the Teleport time.
*/
public void teleport() {
this.teleportLast = (new Date()).getTime();
}
/**
* Grab whether the cooldown on Portal use has expired or not.
*
* @return
*/
public boolean getTeleportable() {
Long time = (new Date()).getTime();
if ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)) {
return true;
} else {
return false;
}
}
/**
* Send a Message to the Player as long as enough time has passed since the last message.
*
* @param msg
*/
public void message(String msg) {
Long time = (new Date()).getTime();
if ((time - this.messageLast) > this.config.getInt("messagecooldown", 2000)) {
this.player.sendMessage(msg);
this.messageLast = time;
}
}
// Commented out bed code, i'll get rid of it soon.
// --FF
// public void setRespawnLocation(Location location) {
// this.bedSpawn = location;
// }
// // This one simply spawns the player closer to the bed.
// public Location getBedRespawnLocation() {
// // There is a bedrespawn set
// if (this.bedSpawn != null) {
// if (!this.bs.playerCanSpawnHereSafely(this.bedSpawn) || !bedStillExists(this.bedSpawn)) {
// this.bedSpawn = null;
// return this.bedSpawn;
// }
// Location actualRespawn = this.bedSpawn;
// Location bedRespawn = new Location(actualRespawn.getWorld(), actualRespawn.getX(), actualRespawn.getY(), actualRespawn.getZ());
// bedRespawn.setY(bedRespawn.getY() - .25);
// return bedRespawn;
// }
// return null;
// }
//
// private boolean bedStillExists(Location bedSpawn) {
// //System.out.print("Dangers:");
// //this.bs.showDangers(bedSpawn);
// Location locationDown = new Location(bedSpawn.getWorld(), bedSpawn.getX(), bedSpawn.getY(), bedSpawn.getZ());
// locationDown.setY(locationDown.getY() - 1);
// if (locationDown.getBlock().getType() != Material.BED_BLOCK) {
// return false;
// }
// return true;
// }
}
package com.onarandombox.MultiverseCore;
import java.util.Date;
import org.bukkit.entity.Player;
import org.bukkit.util.config.Configuration;
public class MVPlayerSession {
private Player player; // Player holder, may be unnecessary.
private Long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
private Long messageLast = 0L; // Timestamp for the Players last Alert Message.
// private Location bedSpawn;
//
// // Beds are 2 blocks, thus we need to store both places
// private Location bedA;
// private Location bedB;
private Configuration config; // Configuration file to find out Cooldown Timers.
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
this.player = player;
this.config = config;
// this.bedSpawn = null;
}
/**
* Update the Teleport time.
*/
public void teleport() {
this.teleportLast = (new Date()).getTime();
}
/**
* Grab whether the cooldown on Portal use has expired or not.
*
* @return
*/
public boolean getTeleportable() {
Long time = (new Date()).getTime();
if ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)) {
return true;
} else {
return false;
}
}
/**
* Send a Message to the Player as long as enough time has passed since the last message.
*
* @param msg
*/
public void message(String msg) {
Long time = (new Date()).getTime();
if ((time - this.messageLast) > this.config.getInt("messagecooldown", 2000)) {
this.player.sendMessage(msg);
this.messageLast = time;
}
}
// Commented out bed code, i'll get rid of it soon.
// --FF
// public void setRespawnLocation(Location location) {
// this.bedSpawn = location;
// }
// // This one simply spawns the player closer to the bed.
// public Location getBedRespawnLocation() {
// // There is a bedrespawn set
// if (this.bedSpawn != null) {
// if (!this.bs.playerCanSpawnHereSafely(this.bedSpawn) || !bedStillExists(this.bedSpawn)) {
// this.bedSpawn = null;
// return this.bedSpawn;
// }
// Location actualRespawn = this.bedSpawn;
// Location bedRespawn = new Location(actualRespawn.getWorld(), actualRespawn.getX(), actualRespawn.getY(), actualRespawn.getZ());
// bedRespawn.setY(bedRespawn.getY() - .25);
// return bedRespawn;
// }
// return null;
// }
//
// private boolean bedStillExists(Location bedSpawn) {
// //System.out.print("Dangers:");
// //this.bs.showDangers(bedSpawn);
// Location locationDown = new Location(bedSpawn.getWorld(), bedSpawn.getX(), bedSpawn.getY(), bedSpawn.getZ());
// locationDown.setY(locationDown.getY() - 1);
// if (locationDown.getBlock().getType() != Material.BED_BLOCK) {
// return false;
// }
// return true;
// }
}

View File

@ -1,60 +1,60 @@
package com.onarandombox.MultiverseCore;
import java.util.Arrays;
import java.util.logging.Level;
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.configuration.DefaultConfiguration;
public class MVPluginListener extends ServerListener {
MultiverseCore plugin;
public MVPluginListener(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* Keep an eye out for Plugins which we can utilize.
*/
@Override
public void onPluginEnable(PluginEnableEvent event) {
/**
* Check to see if Permissions was just enabled
*/
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
this.plugin.ph.setPermissions(((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
this.plugin.log(Level.INFO, "- Attached to Permissions");
}
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) {
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
}
if (event.getPlugin().getDescription().getName().equals("MultiVerse")) {
this.plugin.getServer().getPluginManager().disablePlugin(event.getPlugin());
this.plugin.log(Level.WARNING, "I just disabled the old version of Multiverse for you. You should remove the JAR now, your configs have been migrated.");
new DefaultConfiguration(this.plugin.getDataFolder(), "config.yml", this.plugin.migrator);
}
}
/**
* 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.
*/
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
this.plugin.log(Level.INFO, "Permissions disabled");
this.plugin.ph.setPermissions(null);
}
// TODO: Disable econ when it disables.
}
}
package com.onarandombox.MultiverseCore;
import java.util.Arrays;
import java.util.logging.Level;
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.configuration.DefaultConfiguration;
public class MVPluginListener extends ServerListener {
MultiverseCore plugin;
public MVPluginListener(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* Keep an eye out for Plugins which we can utilize.
*/
@Override
public void onPluginEnable(PluginEnableEvent event) {
/**
* Check to see if Permissions was just enabled
*/
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
this.plugin.ph.setPermissions(((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
this.plugin.log(Level.INFO, "- Attached to Permissions");
}
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) {
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
}
if (event.getPlugin().getDescription().getName().equals("MultiVerse")) {
this.plugin.getServer().getPluginManager().disablePlugin(event.getPlugin());
this.plugin.log(Level.WARNING, "I just disabled the old version of Multiverse for you. You should remove the JAR now, your configs have been migrated.");
new DefaultConfiguration(this.plugin.getDataFolder(), "config.yml", this.plugin.migrator);
}
}
/**
* 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.
*/
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
this.plugin.log(Level.INFO, "Permissions disabled");
this.plugin.ph.setPermissions(null);
}
// TODO: Disable econ when it disables.
}
}

View File

@ -1,196 +1,196 @@
package com.onarandombox.MultiverseCore;
import java.util.ArrayList;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.onarandombox.utils.BlockSafety;
public class MVTeleport {
MultiverseCore plugin;
BlockSafety bs = new BlockSafety();
private static final Logger log = Logger.getLogger("Minecraft");
public MVTeleport(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* TODO: Sort out JavaDoc
*
* @param l
* @param w
* @return
*/
public Location getCompressedLocation(Player p, World w) {
Location l = p.getLocation();
// Check if they are the same world, might as well skip any calculations.
if (l.getWorld().getName().equalsIgnoreCase(w.getName())) {
return l;
}
double x, y, z;
// Grab the Scaling value for each world.
double srcComp = this.plugin.getMVWorld(l.getWorld().getName()).getScaling();
double trgComp = this.plugin.getMVWorld(w.getName()).getScaling();
// MultiverseCore.debugMsg(p.getName() + " -> " + p.getWorld().getName() + "(" + srcComp + ") -> " + w.getName() + "(" + trgComp + ")");
// If the Targets Compression is 0 then we teleport them to the Spawn of the World.
if (trgComp == 0.0) {
x = w.getSpawnLocation().getX();
y = w.getSpawnLocation().getY();
z = w.getSpawnLocation().getZ();
} else {
x = l.getX() / (srcComp != 0 ? srcComp : 1) * trgComp;
y = l.getY();
z = l.getZ() / (srcComp != 0 ? srcComp : 1) * trgComp;
}
return new Location(w, x, y, z);
}
/**
* This method will be specific to beds, and check on top of the bed then around it.
*
* @return
*/
public Location getSafeBedDestination(Location bedLocation) {
//System.out.print(bedLocation);
Location idealLocation = bedLocation;
idealLocation.setY(idealLocation.getY() + 1);
idealLocation.setX(idealLocation.getX() + .5);
idealLocation.setZ(idealLocation.getZ() + .5);
//System.out.print(idealLocation);
if (this.bs.playerCanSpawnHereSafely(idealLocation)) {
//System.out.print(idealLocation);
return bedLocation;
}
return null;
}
/**
* This function gets a safe place to teleport to.
*
* @param world
* @param player
* @return
*/
public Location getSafeDestination(Location l) {
double x = l.getX();
double y = l.getY();
double z = l.getZ();
World w = l.getWorld();
// To make things easier we'll start with the Y Coordinate on top of a Solid Block.
// while (bs.blockIsAboveAir(w, x, y, z)) {
// y--;
// }
double i = 0, r = 0, aux = -1;
for (r = 0; r < 32; r++) {
for (i = x - r; i <= x + r; i++) {
if ((aux = safeColumn(w, i, y, z - r)) > -1) {
z = z - r;
break;
}
if ((aux = safeColumn(w, i, y, z + r)) > -1) {
z = z + r;
break;
}
}
if (aux > -1) {
x = i;
break;
}
for (i = z - r + 1; i <= z + r - 1; i++) {
if ((aux = safeColumn(w, x - r, y, i)) > -1) {
x = x - r;
break;
}
if ((aux = safeColumn(w, x + r, y, i)) > -1) {
x = x + r;
break;
}
}
if (aux > -1) {
z = i;
break;
}
}
if (aux == -1) {
log.warning("Uh oh, no safe location.");
return null;
}
// log.info("Target location (safe): " + x + ", " + aux + ", " + z);
return new Location(w, x, aux, z);
}
/**
* Check the Column given to see if there is an available safe spot.
*
* @param world
* @param x
* @param y
* @param z
* @return
*/
private double safeColumn(World world, double x, double y, double z) {
for (double ny = 0; ny < 48; ny++) {
if ((y + ny < 120) && !this.bs.blockIsNotSafe(world, x, y + ny, z)) {
return y + ny;
}
if ((y - ny > 4) && !this.bs.blockIsNotSafe(world, x, y - ny, z)) {
return y - ny;
}
}
return -1;
}
/**
* Find a portal around the given location and return a new location.
*
* @param location
* @return
*/
public Location findPortal(Location location) {
World world = location.getWorld();
// Get list of columns in a circle around the block
ArrayList<Block> columns = new ArrayList<Block>();
for (int x = location.getBlockX() - 8; x <= location.getBlockX() + 8; ++x) {
for (int z = location.getBlockZ() - 8; z <= location.getBlockZ() + 8; ++z) {
int dx = location.getBlockX() - x, dz = location.getBlockZ() - z;
if (dx * dx + dz * dz <= 256) {
columns.add(world.getBlockAt(x, 0, z));
}
}
}
// For each column try to find a portal block
for (Block col : columns) {
for (int y = 0; y <= 127; y++) {
Block b = world.getBlockAt(col.getX(), y, col.getZ());
if (b.getType().equals(Material.PORTAL)) {
if (b.getWorld().getBlockAt(b.getX() + 1, b.getY(), b.getZ()).getType().equals(Material.PORTAL) || b.getWorld().getBlockAt(b.getX() - 1, b.getY(), b.getZ()).getType().equals(Material.PORTAL)) {
// portal is in X direction
return new Location(b.getWorld(), b.getX() + 0.5, b.getY(), b.getZ() + 1.5);
} else {
// portal is in Z direction
return new Location(b.getWorld(), b.getX() + 1.5, b.getY(), b.getZ() + 0.5);
}
}
}
}
return null;
}
}
package com.onarandombox.MultiverseCore;
import java.util.ArrayList;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.onarandombox.utils.BlockSafety;
public class MVTeleport {
MultiverseCore plugin;
BlockSafety bs = new BlockSafety();
private static final Logger log = Logger.getLogger("Minecraft");
public MVTeleport(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* TODO: Sort out JavaDoc
*
* @param l
* @param w
* @return
*/
public Location getCompressedLocation(Player p, World w) {
Location l = p.getLocation();
// Check if they are the same world, might as well skip any calculations.
if (l.getWorld().getName().equalsIgnoreCase(w.getName())) {
return l;
}
double x, y, z;
// Grab the Scaling value for each world.
double srcComp = this.plugin.getMVWorld(l.getWorld().getName()).getScaling();
double trgComp = this.plugin.getMVWorld(w.getName()).getScaling();
// MultiverseCore.debugMsg(p.getName() + " -> " + p.getWorld().getName() + "(" + srcComp + ") -> " + w.getName() + "(" + trgComp + ")");
// If the Targets Compression is 0 then we teleport them to the Spawn of the World.
if (trgComp == 0.0) {
x = w.getSpawnLocation().getX();
y = w.getSpawnLocation().getY();
z = w.getSpawnLocation().getZ();
} else {
x = l.getX() / (srcComp != 0 ? srcComp : 1) * trgComp;
y = l.getY();
z = l.getZ() / (srcComp != 0 ? srcComp : 1) * trgComp;
}
return new Location(w, x, y, z);
}
/**
* This method will be specific to beds, and check on top of the bed then around it.
*
* @return
*/
public Location getSafeBedDestination(Location bedLocation) {
//System.out.print(bedLocation);
Location idealLocation = bedLocation;
idealLocation.setY(idealLocation.getY() + 1);
idealLocation.setX(idealLocation.getX() + .5);
idealLocation.setZ(idealLocation.getZ() + .5);
//System.out.print(idealLocation);
if (this.bs.playerCanSpawnHereSafely(idealLocation)) {
//System.out.print(idealLocation);
return bedLocation;
}
return null;
}
/**
* This function gets a safe place to teleport to.
*
* @param world
* @param player
* @return
*/
public Location getSafeDestination(Location l) {
double x = l.getX();
double y = l.getY();
double z = l.getZ();
World w = l.getWorld();
// To make things easier we'll start with the Y Coordinate on top of a Solid Block.
// while (bs.blockIsAboveAir(w, x, y, z)) {
// y--;
// }
double i = 0, r = 0, aux = -1;
for (r = 0; r < 32; r++) {
for (i = x - r; i <= x + r; i++) {
if ((aux = safeColumn(w, i, y, z - r)) > -1) {
z = z - r;
break;
}
if ((aux = safeColumn(w, i, y, z + r)) > -1) {
z = z + r;
break;
}
}
if (aux > -1) {
x = i;
break;
}
for (i = z - r + 1; i <= z + r - 1; i++) {
if ((aux = safeColumn(w, x - r, y, i)) > -1) {
x = x - r;
break;
}
if ((aux = safeColumn(w, x + r, y, i)) > -1) {
x = x + r;
break;
}
}
if (aux > -1) {
z = i;
break;
}
}
if (aux == -1) {
log.warning("Uh oh, no safe location.");
return null;
}
// log.info("Target location (safe): " + x + ", " + aux + ", " + z);
return new Location(w, x, aux, z);
}
/**
* Check the Column given to see if there is an available safe spot.
*
* @param world
* @param x
* @param y
* @param z
* @return
*/
private double safeColumn(World world, double x, double y, double z) {
for (double ny = 0; ny < 48; ny++) {
if ((y + ny < 120) && !this.bs.blockIsNotSafe(world, x, y + ny, z)) {
return y + ny;
}
if ((y - ny > 4) && !this.bs.blockIsNotSafe(world, x, y - ny, z)) {
return y - ny;
}
}
return -1;
}
/**
* Find a portal around the given location and return a new location.
*
* @param location
* @return
*/
public Location findPortal(Location location) {
World world = location.getWorld();
// Get list of columns in a circle around the block
ArrayList<Block> columns = new ArrayList<Block>();
for (int x = location.getBlockX() - 8; x <= location.getBlockX() + 8; ++x) {
for (int z = location.getBlockZ() - 8; z <= location.getBlockZ() + 8; ++z) {
int dx = location.getBlockX() - x, dz = location.getBlockZ() - z;
if (dx * dx + dz * dz <= 256) {
columns.add(world.getBlockAt(x, 0, z));
}
}
}
// For each column try to find a portal block
for (Block col : columns) {
for (int y = 0; y <= 127; y++) {
Block b = world.getBlockAt(col.getX(), y, col.getZ());
if (b.getType().equals(Material.PORTAL)) {
if (b.getWorld().getBlockAt(b.getX() + 1, b.getY(), b.getZ()).getType().equals(Material.PORTAL) || b.getWorld().getBlockAt(b.getX() - 1, b.getY(), b.getZ()).getType().equals(Material.PORTAL)) {
// portal is in X direction
return new Location(b.getWorld(), b.getX() + 0.5, b.getY(), b.getZ() + 1.5);
} else {
// portal is in Z direction
return new Location(b.getWorld(), b.getX() + 1.5, b.getY(), b.getZ() + 0.5);
}
}
}
}
return null;
}
}

View File

@ -1,28 +1,28 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ConfirmCommand extends MultiverseCommand {
public ConfirmCommand(MultiverseCore plugin) {
super(plugin);
// Any command that is dangerous should require op
this.setName("Confirms a command that could destroy life, the universe and everything.");
this.setCommandUsage("/mvconfirm");
this.setArgRange(0, 0);
this.addKey("mvconfirm");
this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.getCommandHandler().confirmQueuedCommand(sender);
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ConfirmCommand extends MultiverseCommand {
public ConfirmCommand(MultiverseCore plugin) {
super(plugin);
// Any command that is dangerous should require op
this.setName("Confirms a command that could destroy life, the universe and everything.");
this.setCommandUsage("/mvconfirm");
this.setArgRange(0, 0);
this.addKey("mvconfirm");
this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.getCommandHandler().confirmQueuedCommand(sender);
}
}

View File

@ -1,58 +1,58 @@
package com.onarandombox.MultiverseCore.commands;
import java.io.File;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.pneumaticraft.commandhandler.CommandHandler;
public class CreateCommand extends MultiverseCommand {
public CreateCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create World");
this.setCommandUsage("/mvcreate" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]]");
this.setArgRange(2, 6);
this.addKey("mvcreate");
this.addKey("mvc");
this.addKey("mv create");
this.setPermission("multiverse.core.create", "Creates a new world and loads it.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() % 2 != 0) {
sender.sendMessage("You must preface your SEED with -s OR your GENERATOR with -g. Type /mv for help");
return;
}
String worldName = args.get(0);
String env = args.get(1);
String seed = CommandHandler.getFlag("-s", args);
String generator = CommandHandler.getFlag("-g", args);
if (new File(worldName).exists() || this.plugin.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
return;
}
Environment environment = this.plugin.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
sender.sendMessage(ChatColor.AQUA + "Starting world creation...");
if (this.plugin.addWorld(worldName, environment, seed, generator)) {
sender.sendMessage(ChatColor.GREEN + "Complete!");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
}
return;
}
}
package com.onarandombox.MultiverseCore.commands;
import java.io.File;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.pneumaticraft.commandhandler.CommandHandler;
public class CreateCommand extends MultiverseCommand {
public CreateCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create World");
this.setCommandUsage("/mvcreate" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]]");
this.setArgRange(2, 6);
this.addKey("mvcreate");
this.addKey("mvc");
this.addKey("mv create");
this.setPermission("multiverse.core.create", "Creates a new world and loads it.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() % 2 != 0) {
sender.sendMessage("You must preface your SEED with -s OR your GENERATOR with -g. Type /mv for help");
return;
}
String worldName = args.get(0);
String env = args.get(1);
String seed = CommandHandler.getFlag("-s", args);
String generator = CommandHandler.getFlag("-g", args);
if (new File(worldName).exists() || this.plugin.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
return;
}
Environment environment = this.plugin.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
sender.sendMessage(ChatColor.AQUA + "Starting world creation...");
if (this.plugin.addWorld(worldName, environment, seed, generator)) {
sender.sendMessage(ChatColor.GREEN + "Complete!");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
}
return;
}
}

View File

@ -1,28 +1,28 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class DeleteCommand extends MultiverseCommand {
public DeleteCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Delete World");
this.setCommandUsage("/mvdelete" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvdelete");
this.addKey("mv delete");
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Class<?> paramTypes[] = { String.class };
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", args, paramTypes, "World Deleted!", "World was not deleted!");
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class DeleteCommand extends MultiverseCommand {
public DeleteCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Delete World");
this.setCommandUsage("/mvdelete" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvdelete");
this.addKey("mv delete");
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Class<?> paramTypes[] = { String.class };
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", args, paramTypes, "World Deleted!", "World was not deleted!");
}
}

View File

@ -1,61 +1,61 @@
package com.onarandombox.MultiverseCore.commands;
import java.io.File;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ImportCommand extends MultiverseCommand {
public ImportCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Import World");
this.setCommandUsage("/mvimport" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + "[GENERATOR[:ID]]");
this.setArgRange(2, 3);
this.addKey("mvimport");
this.addKey("mvi");
this.addKey("mv import");
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
if (this.plugin.isMVWorld(worldName) && new File(worldName).exists()) {
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
return;
}
String generator = null;
if (args.size() == 3) {
generator = args.get(2);
}
String env = args.get(1);
Environment environment = this.plugin.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
if (new File(worldName).exists() && env != null) {
sender.sendMessage(ChatColor.AQUA + "Starting world import...");
this.plugin.addWorld(worldName, environment, null, generator);
sender.sendMessage(ChatColor.GREEN + "Complete!");
return;
} else if (env == null) {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world type did not exist.");
sender.sendMessage("For a list of available world types, type: /mvenv");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world folder does not exist...");
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.io.File;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ImportCommand extends MultiverseCommand {
public ImportCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Import World");
this.setCommandUsage("/mvimport" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + "[GENERATOR[:ID]]");
this.setArgRange(2, 3);
this.addKey("mvimport");
this.addKey("mvi");
this.addKey("mv import");
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
if (this.plugin.isMVWorld(worldName) && new File(worldName).exists()) {
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
return;
}
String generator = null;
if (args.size() == 3) {
generator = args.get(2);
}
String env = args.get(1);
Environment environment = this.plugin.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
if (new File(worldName).exists() && env != null) {
sender.sendMessage(ChatColor.AQUA + "Starting world import...");
this.plugin.addWorld(worldName, environment, null, generator);
sender.sendMessage(ChatColor.GREEN + "Complete!");
return;
} else if (env == null) {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world type did not exist.");
sender.sendMessage("For a list of available world types, type: /mvenv");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world folder does not exist...");
}
}
}

View File

@ -1,58 +1,58 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ListCommand extends MultiverseCommand {
public ListCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Listing");
this.setCommandUsage("/mvlist");
this.setArgRange(0, 0);
this.addKey("mvlist");
this.addKey("mvl");
this.addKey("mv list");
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
for (MVWorld world : this.plugin.getMVWorlds()) {
if (p != null && (!this.plugin.ph.canEnterWorld(p, world))) {
continue;
}
ChatColor color = ChatColor.GOLD;
Environment env = world.getEnvironment();
if (env == Environment.NETHER) {
color = ChatColor.RED;
} else if (env == Environment.NORMAL) {
color = ChatColor.GREEN;
} else if (env == Environment.SKYLANDS) {
color = ChatColor.AQUA;
}
output += world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment() + " \n";
}
String[] response = output.split("\n");
for (String msg : response) {
sender.sendMessage(msg);
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ListCommand extends MultiverseCommand {
public ListCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Listing");
this.setCommandUsage("/mvlist");
this.setArgRange(0, 0);
this.addKey("mvlist");
this.addKey("mvl");
this.addKey("mv list");
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
for (MVWorld world : this.plugin.getMVWorlds()) {
if (p != null && (!this.plugin.ph.canEnterWorld(p, world))) {
continue;
}
ChatColor color = ChatColor.GOLD;
Environment env = world.getEnvironment();
if (env == Environment.NETHER) {
color = ChatColor.RED;
} else if (env == Environment.NORMAL) {
color = ChatColor.GREEN;
} else if (env == Environment.SKYLANDS) {
color = ChatColor.AQUA;
}
output += world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment() + " \n";
}
String[] response = output.split("\n");
for (String msg : response) {
sender.sendMessage(msg);
}
}
}

View File

@ -1,73 +1,73 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
// This will contain all the properties that support the ADD/REMOVE
// Anything not in here will only support the SET action
public class ModifyAddCommand extends MultiverseCommand {
public ModifyAddCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Add a value)");
this.setCommandUsage("/mvmodify " + ChatColor.GREEN + "ADD {VALUE} {PROPERTY}" + ChatColor.GOLD + " [WORLD] ");
this.setArgRange(2, 3);
this.addKey("mvm add");
this.addKey("mvmadd");
this.addKey("mv modify add");
this.addKey("mvmodify add");
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Add, property)) {
sender.sendMessage("Sorry, you can't ADD to " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.addToList(property, value)) {
sender.sendMessage(value + " was added to " + property);
} else {
sender.sendMessage(value + " could not be added to " + property);
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
// This will contain all the properties that support the ADD/REMOVE
// Anything not in here will only support the SET action
public class ModifyAddCommand extends MultiverseCommand {
public ModifyAddCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Add a value)");
this.setCommandUsage("/mvmodify " + ChatColor.GREEN + "ADD {VALUE} {PROPERTY}" + ChatColor.GOLD + " [WORLD] ");
this.setArgRange(2, 3);
this.addKey("mvm add");
this.addKey("mvmadd");
this.addKey("mv modify add");
this.addKey("mvmodify add");
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Add, property)) {
sender.sendMessage("Sorry, you can't ADD to " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.addToList(property, value)) {
sender.sendMessage(value + " was added to " + property);
} else {
sender.sendMessage(value + " could not be added to " + property);
}
}
}

View File

@ -1,68 +1,68 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ModifyClearCommand extends MultiverseCommand {
public ModifyClearCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Clear a property)");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + " clear {PROPERTY}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(1, 2);
this.addKey("mvm clear");
this.addKey("mvmclear");
this.addKey("mv modify clear");
this.addKey("mvmodify clear");
this.setPermission("multiverse.core.modify.clear", "Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String property = args.get(0);
if (args.size() == 1) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(1));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Clear, property)) {
sender.sendMessage("Sorry, you can't use CLEAR with " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/cgB2B");
return;
}
if (world.clearList(property)) {
sender.sendMessage(property + " was cleared. It contains 0 values now.");
} else {
sender.sendMessage(property + " was NOT cleared.");
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ModifyClearCommand extends MultiverseCommand {
public ModifyClearCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Clear a property)");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + " clear {PROPERTY}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(1, 2);
this.addKey("mvm clear");
this.addKey("mvmclear");
this.addKey("mv modify clear");
this.addKey("mvmodify clear");
this.setPermission("multiverse.core.modify.clear", "Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String property = args.get(0);
if (args.size() == 1) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(1));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Clear, property)) {
sender.sendMessage("Sorry, you can't use CLEAR with " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/cgB2B");
return;
}
if (world.clearList(property)) {
sender.sendMessage(property + " was cleared. It contains 0 values now.");
} else {
sender.sendMessage(property + " was NOT cleared.");
}
}
}

View File

@ -1,71 +1,71 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
enum AddProperties {
blockblacklist, playerwhitelist, playerblacklist, worldblacklist, animals, monsters
}
enum Action {
Set, Add, Remove, Clear
}
// Color == Aliascolor
enum SetProperties {
alias, animals, monsters, pvp, scaling, aliascolor, color, respawn
}
public class ModifyCommand extends MultiverseCommand {
public ModifyCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + " {set|add|remove|clear} ...");
this.setArgRange(2, 3);
this.addKey("mvm");
this.addKey("mvmodify");
Map<String, Boolean> children = new HashMap<String, Boolean>();
children.put("multiverse.core.modify.add", true);
children.put("multiverse.core.modify.modify", true);
children.put("multiverse.core.modify.clear", true);
children.put("multiverse.core.modify.remove", true);
Permission modify = new Permission("multiverse.core.modify", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP, children);
this.setPermission(modify);
}
protected static boolean validateAction(Action action, String property) {
if (action == Action.Set) {
try {
SetProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
} else {
try {
AddProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// This is just a place holder. The real commands are in:
// ModifyAddCommand
// ModifyRemoveCommand
// ModifySetCommand
// ModifyClearCommand
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
enum AddProperties {
blockblacklist, playerwhitelist, playerblacklist, worldblacklist, animals, monsters
}
enum Action {
Set, Add, Remove, Clear
}
// Color == Aliascolor
enum SetProperties {
alias, animals, monsters, pvp, scaling, aliascolor, color, respawn
}
public class ModifyCommand extends MultiverseCommand {
public ModifyCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + " {set|add|remove|clear} ...");
this.setArgRange(2, 3);
this.addKey("mvm");
this.addKey("mvmodify");
Map<String, Boolean> children = new HashMap<String, Boolean>();
children.put("multiverse.core.modify.add", true);
children.put("multiverse.core.modify.modify", true);
children.put("multiverse.core.modify.clear", true);
children.put("multiverse.core.modify.remove", true);
Permission modify = new Permission("multiverse.core.modify", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP, children);
this.setPermission(modify);
}
protected static boolean validateAction(Action action, String property) {
if (action == Action.Set) {
try {
SetProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
} else {
try {
AddProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// This is just a place holder. The real commands are in:
// ModifyAddCommand
// ModifyRemoveCommand
// ModifySetCommand
// ModifyClearCommand
}
}

View File

@ -1,70 +1,70 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ModifyRemoveCommand extends MultiverseCommand {
public ModifyRemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Remove a value)");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + "REMOVE {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(2, 3);
this.addKey("mvm remove");
this.addKey("mvmremove");
this.addKey("mv modify remove");
this.addKey("mvmodify remove");
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Remove, property)) {
sender.sendMessage("Sorry, you can't REMOVE anything from" + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.removeFromList(property, value)) {
sender.sendMessage(value + " was removed from " + property);
} else {
sender.sendMessage(value + " could not be removed from " + property);
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ModifyRemoveCommand extends MultiverseCommand {
public ModifyRemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Remove a value)");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + "REMOVE {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(2, 3);
this.addKey("mvm remove");
this.addKey("mvmremove");
this.addKey("mv modify remove");
this.addKey("mvmodify remove");
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Remove, property)) {
sender.sendMessage("Sorry, you can't REMOVE anything from" + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.removeFromList(property, value)) {
sender.sendMessage(value + " was removed from " + property);
} else {
sender.sendMessage(value + " could not be removed from " + property);
}
}
}

View File

@ -1,71 +1,71 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ModifySetCommand extends MultiverseCommand {
public ModifySetCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Set a value)");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + " set {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(2, 3);
this.addKey("mvm set");
this.addKey("mvmset");
this.addKey("mv modify set");
this.addKey("mvmodify set");
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage("From the command line, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String value = args.get(1);
String property = args.get(0);
if (args.size() == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Set, property)) {
sender.sendMessage("Sorry, you can't SET " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/l54PH");
return;
}
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) {
sender.sendMessage(value + " is not a valid color. Please see our Github Wiki for the complete color list.");
} else if (world.setVariable(property, value)) {
sender.sendMessage("Property " + property + " was set to " + value);
} else {
sender.sendMessage("There was an error setting " + property);
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ModifySetCommand extends MultiverseCommand {
public ModifySetCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Set a value)");
this.setCommandUsage("/mvmodify" + ChatColor.GREEN + " set {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(2, 3);
this.addKey("mvm set");
this.addKey("mvmset");
this.addKey("mv modify set");
this.addKey("mvmodify set");
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage("From the command line, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MVWorld world;
String value = args.get(1);
String property = args.get(0);
if (args.size() == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName());
} else {
world = this.plugin.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Set, property)) {
sender.sendMessage("Sorry, you can't SET " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/l54PH");
return;
}
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) {
sender.sendMessage(value + " is not a valid color. Please see our Github Wiki for the complete color list.");
} else if (world.setVariable(property, value)) {
sender.sendMessage("Property " + property + " was set to " + value);
} else {
sender.sendMessage("There was an error setting " + property);
}
}
}

View File

@ -1,77 +1,77 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.PurgeWorlds;
public class PurgeCommand extends MultiverseCommand {
public PurgeCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Purge World of Creatures");
this.setCommandUsage("/mvpurge" + ChatColor.GOLD + " [WORLD|all] " + ChatColor.GREEN + "{all|animals|monsters|MOBNAME}");
this.setArgRange(1, 2);
this.addKey("mvpurge");
this.addKey("mv purge");
this.setPermission("multiverse.core.purge", "Removed the specified type of mob from the specified world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage("This command requires a WORLD when being run from the console!");
sender.sendMessage(this.getCommandUsage());
return;
}
String worldName = null;
String deathName = null;
if (args.size() == 1) {
worldName = p.getWorld().getName();
deathName = args.get(0);
} else {
worldName = args.get(0);
deathName = args.get(1);
}
if (!worldName.equalsIgnoreCase("all") && !this.plugin.isMVWorld(worldName)) {
((MultiverseCore)this.plugin).showNotMVWorldMessage(sender, worldName);
sender.sendMessage("It cannot be purged.");
return;
}
List<MVWorld> worldsToRemoveEntitiesFrom = new ArrayList<MVWorld>();
// Handle all case any user who names a world "all" should know better...
if (worldName.equalsIgnoreCase("all")) {
worldsToRemoveEntitiesFrom.addAll(this.plugin.getMVWorlds());
} else {
worldsToRemoveEntitiesFrom.add(this.plugin.getMVWorld(worldName));
}
PurgeWorlds purger = this.plugin.getWorldPurger();
ArrayList<String> thingsToKill = new ArrayList<String>();
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase());
} else {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
}
for (MVWorld w : worldsToRemoveEntitiesFrom) {
purger.purgeWorld(sender, w, thingsToKill, false, false);
}
return;
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.PurgeWorlds;
public class PurgeCommand extends MultiverseCommand {
public PurgeCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Purge World of Creatures");
this.setCommandUsage("/mvpurge" + ChatColor.GOLD + " [WORLD|all] " + ChatColor.GREEN + "{all|animals|monsters|MOBNAME}");
this.setArgRange(1, 2);
this.addKey("mvpurge");
this.addKey("mv purge");
this.setPermission("multiverse.core.purge", "Removed the specified type of mob from the specified world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage("This command requires a WORLD when being run from the console!");
sender.sendMessage(this.getCommandUsage());
return;
}
String worldName = null;
String deathName = null;
if (args.size() == 1) {
worldName = p.getWorld().getName();
deathName = args.get(0);
} else {
worldName = args.get(0);
deathName = args.get(1);
}
if (!worldName.equalsIgnoreCase("all") && !this.plugin.isMVWorld(worldName)) {
((MultiverseCore)this.plugin).showNotMVWorldMessage(sender, worldName);
sender.sendMessage("It cannot be purged.");
return;
}
List<MVWorld> worldsToRemoveEntitiesFrom = new ArrayList<MVWorld>();
// Handle all case any user who names a world "all" should know better...
if (worldName.equalsIgnoreCase("all")) {
worldsToRemoveEntitiesFrom.addAll(this.plugin.getMVWorlds());
} else {
worldsToRemoveEntitiesFrom.add(this.plugin.getMVWorld(worldName));
}
PurgeWorlds purger = this.plugin.getWorldPurger();
ArrayList<String> thingsToKill = new ArrayList<String>();
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase());
} else {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
}
for (MVWorld w : worldsToRemoveEntitiesFrom) {
purger.purgeWorld(sender, w, thingsToKill, false, false);
}
return;
}
}

View File

@ -1,30 +1,30 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ReloadCommand extends MultiverseCommand {
public ReloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Reload Configs");
this.setCommandUsage("/mvreload");
this.setArgRange(0, 0);
this.addKey("mvreload");
this.addKey("mv reload");
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage("Reloading Multiverse-Core config.yml and worlds.yml");
this.plugin.loadConfigs();
this.plugin.loadWorlds(true);
sender.sendMessage("Reload Complete!");
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class ReloadCommand extends MultiverseCommand {
public ReloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Reload Configs");
this.setCommandUsage("/mvreload");
this.setArgRange(0, 0);
this.addKey("mvreload");
this.addKey("mv reload");
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage("Reloading Multiverse-Core config.yml and worlds.yml");
this.plugin.loadConfigs();
this.plugin.loadWorlds(true);
sender.sendMessage("Reload Complete!");
}
}

View File

@ -1,30 +1,30 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class RemoveCommand extends MultiverseCommand {
public RemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Remove World");
this.setCommandUsage("/mvremove " + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvcoord");
this.setPermission("multiverse.core.remove", "Unloads a world from Multiverse and removes it from worlds.yml, this does NOT remove the world folder.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.removeWorld(args.get(0))) {
sender.sendMessage("World removed from config!");
} else {
sender.sendMessage("Error trying to remove world from config!");
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class RemoveCommand extends MultiverseCommand {
public RemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Remove World");
this.setCommandUsage("/mvremove " + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvcoord");
this.setPermission("multiverse.core.remove", "Unloads a world from Multiverse and removes it from worlds.yml, this does NOT remove the world folder.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.removeWorld(args.get(0))) {
sender.sendMessage("World removed from config!");
} else {
sender.sendMessage("Error trying to remove world from config!");
}
}
}

View File

@ -1,38 +1,38 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class SetSpawnCommand extends MultiverseCommand {
public SetSpawnCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Set World Spawn");
this.setCommandUsage("/mvsetspawn");
this.setArgRange(0, 0);
this.addKey("mvsetspawn");
this.addKey("mvss");
this.addKey("mv set spawn");
this.setPermission("multiverse.core.spawn.set", "Sets the spawn for the current world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location l = p.getLocation();
World w = p.getWorld();
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
p.sendMessage(w.getName() + " - Spawn set to X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ());
} else {
sender.sendMessage("You cannot use this command from the console.");
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class SetSpawnCommand extends MultiverseCommand {
public SetSpawnCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Set World Spawn");
this.setCommandUsage("/mvsetspawn");
this.setArgRange(0, 0);
this.addKey("mvsetspawn");
this.addKey("mvss");
this.addKey("mv set spawn");
this.setPermission("multiverse.core.spawn.set", "Sets the spawn for the current world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location l = p.getLocation();
World w = p.getWorld();
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
p.sendMessage(w.getName() + " - Spawn set to X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ());
} else {
sender.sendMessage("You cannot use this command from the console.");
}
}
}

View File

@ -1,41 +1,41 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class SleepCommand extends MultiverseCommand {
public SleepCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Go to Sleep");
this.setCommandUsage("/mv sleep");
this.setArgRange(0, 0);
this.addKey("mv sleep");
this.setPermission("multiverse.core.sleep", "Takes you the latest bed you've slept in (Currently BROKEN).", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (p == null) {
return;
}
// MVPlayerSession session = this.plugin.getPlayerSession(p);
// if (session.getBedRespawnLocation() != null) {
// p.teleport(session.getBedRespawnLocation());
// } else {
// sender.sendMessage("Hmm this is awkward...");
// sender.sendMessage("Something is wrong with your bed.");
// sender.sendMessage("It has either been destroyed or obstructed.");
// }
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class SleepCommand extends MultiverseCommand {
public SleepCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Go to Sleep");
this.setCommandUsage("/mv sleep");
this.setArgRange(0, 0);
this.addKey("mv sleep");
this.setPermission("multiverse.core.sleep", "Takes you the latest bed you've slept in (Currently BROKEN).", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (p == null) {
return;
}
// MVPlayerSession session = this.plugin.getPlayerSession(p);
// if (session.getBedRespawnLocation() != null) {
// p.teleport(session.getBedRespawnLocation());
// } else {
// sender.sendMessage("Hmm this is awkward...");
// sender.sendMessage("Something is wrong with your bed.");
// sender.sendMessage("It has either been destroyed or obstructed.");
// }
}
}

View File

@ -1,62 +1,62 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class SpawnCommand extends MultiverseCommand {
public SpawnCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Spawn");
this.setCommandUsage("/mvspawn" + ChatColor.GOLD + " [PLAYER]");
this.setArgRange(0, 1);
this.addKey("mvspawn");
this.addKey("mv spawn");
this.addKey("mvs");
this.setPermission("multiverse.core.spawn.use", "Teleports target player to the Spawn Point of the world they are in.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
// If a persons name was passed in, you must be A. the console, or B have permissions
if (args.size() == 1) {
if (player != null && !this.plugin.getPermissions().hasPermission(player, "multiverse.world.spawn.other", true)) {
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.world.spawn.other)");
return;
}
Player target = this.plugin.getServer().getPlayer(args.get(0));
if (target != null) {
target.sendMessage("Teleporting to this world's spawn...");
target.teleport(target.getWorld().getSpawnLocation());
if (player != null) {
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + player.getName());
} else {
target.sendMessage("You were teleported by: " + ChatColor.LIGHT_PURPLE + "the console");
}
} else {
sender.sendMessage(args.get(0) + " is not logged on right now!");
}
} else {
if (player != null && !this.plugin.getPermissions().hasPermission(player, "multiverse.world.spawn.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself to spawn. (multiverse.world.spawn.self)");
return;
}
if (player != null) {
player.sendMessage("Teleporting to this world's spawn...");
player.teleport(player.getWorld().getSpawnLocation());
} else {
sender.sendMessage("From the console, you must provide a PLAYER.");
}
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class SpawnCommand extends MultiverseCommand {
public SpawnCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Spawn");
this.setCommandUsage("/mvspawn" + ChatColor.GOLD + " [PLAYER]");
this.setArgRange(0, 1);
this.addKey("mvspawn");
this.addKey("mv spawn");
this.addKey("mvs");
this.setPermission("multiverse.core.spawn.use", "Teleports target player to the Spawn Point of the world they are in.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
// If a persons name was passed in, you must be A. the console, or B have permissions
if (args.size() == 1) {
if (player != null && !this.plugin.getPermissions().hasPermission(player, "multiverse.world.spawn.other", true)) {
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.world.spawn.other)");
return;
}
Player target = this.plugin.getServer().getPlayer(args.get(0));
if (target != null) {
target.sendMessage("Teleporting to this world's spawn...");
target.teleport(target.getWorld().getSpawnLocation());
if (player != null) {
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + player.getName());
} else {
target.sendMessage("You were teleported by: " + ChatColor.LIGHT_PURPLE + "the console");
}
} else {
sender.sendMessage(args.get(0) + " is not logged on right now!");
}
} else {
if (player != null && !this.plugin.getPermissions().hasPermission(player, "multiverse.world.spawn.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself to spawn. (multiverse.world.spawn.self)");
return;
}
if (player != null) {
player.sendMessage("Teleporting to this world's spawn...");
player.teleport(player.getWorld().getSpawnLocation());
} else {
sender.sendMessage("From the console, you must provide a PLAYER.");
}
}
}
}

View File

@ -1,113 +1,113 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
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.onarandombox.MultiverseCore.MVTeleport;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.Destination;
import com.onarandombox.utils.DestinationType;
public class TeleportCommand extends MultiverseCommand {
private MVTeleport playerTeleporter;
public TeleportCommand(MultiverseCore plugin) {
super(plugin);
Permission self = new Permission("multiverse.core.tp.self", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
Permission other = new Permission("multiverse.core.tp.other", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
this.plugin.getServer().getPluginManager().addPermission(self);
this.plugin.getServer().getPluginManager().addPermission(other);
Map<String, Boolean> children = new HashMap<String, Boolean>();
children.put(self.getName(), true);
children.put(other.getName(), true);
Permission tp = new Permission("multiverse.core.tp", "Allows teleportation to other worlds.", PermissionDefault.OP, children);
this.setName("Teleport");
this.setCommandUsage("/mvtp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 2);
this.addKey("mvtp");
this.addKey("mv tp");
this.setPermission(tp);
this.playerTeleporter = new MVTeleport(this.plugin);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
Player teleporter = null;
Player teleportee = null;
if (sender instanceof Player) {
teleporter = (Player) sender;
}
String worldName;
if (args.size() == 2) {
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.other", true)) {
sender.sendMessage("You don't have permission to teleport another player. (multiverse.core.tp.other)");
return;
}
teleportee = this.plugin.getServer().getPlayer(args.get(0));
if (teleportee == null) {
sender.sendMessage("Sorry, I couldn't find player: " + args.get(0));
return;
}
worldName = args.get(1);
} else {
worldName = args.get(0);
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself between worlds. (multiverse.core.tp.self)");
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage("From the console, you must specifiy a player to teleport");
return;
}
teleporter = (Player) sender;
teleportee = (Player) sender;
}
Destination d = Destination.parseDestination(worldName, (MultiverseCore) this.plugin);
if (!(d.getType() == DestinationType.World) || !this.plugin.isMVWorld(d.getName())) {
sender.sendMessage("Multiverse does not know about this world: " + worldName);
return;
}
MVWorld world = this.plugin.getMVWorld(d.getName());
if (teleporter != null && !this.plugin.getPermissions().canEnterWorld(teleporter, world)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD + teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
}
return;
} else if (teleporter != null && !this.plugin.getPermissions().canTravelFromWorld(teleporter, world)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + d.getName() + " from " + ChatColor.GREEN + teleporter.getWorld().getName());
} else {
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + teleporter.getWorld().getName() + " can get to " + ChatColor.RED + d.getName() + " from where they are...");
}
return;
}
Location l = this.playerTeleporter.getSafeDestination(this.plugin.getServer().getWorld(world.getName()).getSpawnLocation());
if(l == null) {
l = this.plugin.getServer().getWorld(world.getName()).getSpawnLocation();
}
if (l == null) {
teleporter.sendMessage("Sorry Boss, I tried everything, but just couldn't teleport ya there!");
return;
}
teleportee.teleport(l);
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
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.onarandombox.MultiverseCore.MVTeleport;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.Destination;
import com.onarandombox.utils.DestinationType;
public class TeleportCommand extends MultiverseCommand {
private MVTeleport playerTeleporter;
public TeleportCommand(MultiverseCore plugin) {
super(plugin);
Permission self = new Permission("multiverse.core.tp.self", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
Permission other = new Permission("multiverse.core.tp.other", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
this.plugin.getServer().getPluginManager().addPermission(self);
this.plugin.getServer().getPluginManager().addPermission(other);
Map<String, Boolean> children = new HashMap<String, Boolean>();
children.put(self.getName(), true);
children.put(other.getName(), true);
Permission tp = new Permission("multiverse.core.tp", "Allows teleportation to other worlds.", PermissionDefault.OP, children);
this.setName("Teleport");
this.setCommandUsage("/mvtp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 2);
this.addKey("mvtp");
this.addKey("mv tp");
this.setPermission(tp);
this.playerTeleporter = new MVTeleport(this.plugin);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
Player teleporter = null;
Player teleportee = null;
if (sender instanceof Player) {
teleporter = (Player) sender;
}
String worldName;
if (args.size() == 2) {
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.other", true)) {
sender.sendMessage("You don't have permission to teleport another player. (multiverse.core.tp.other)");
return;
}
teleportee = this.plugin.getServer().getPlayer(args.get(0));
if (teleportee == null) {
sender.sendMessage("Sorry, I couldn't find player: " + args.get(0));
return;
}
worldName = args.get(1);
} else {
worldName = args.get(0);
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself between worlds. (multiverse.core.tp.self)");
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage("From the console, you must specifiy a player to teleport");
return;
}
teleporter = (Player) sender;
teleportee = (Player) sender;
}
Destination d = Destination.parseDestination(worldName, (MultiverseCore) this.plugin);
if (!(d.getType() == DestinationType.World) || !this.plugin.isMVWorld(d.getName())) {
sender.sendMessage("Multiverse does not know about this world: " + worldName);
return;
}
MVWorld world = this.plugin.getMVWorld(d.getName());
if (teleporter != null && !this.plugin.getPermissions().canEnterWorld(teleporter, world)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD + teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
}
return;
} else if (teleporter != null && !this.plugin.getPermissions().canTravelFromWorld(teleporter, world)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + d.getName() + " from " + ChatColor.GREEN + teleporter.getWorld().getName());
} else {
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + teleporter.getWorld().getName() + " can get to " + ChatColor.RED + d.getName() + " from where they are...");
}
return;
}
Location l = this.playerTeleporter.getSafeDestination(this.plugin.getServer().getWorld(world.getName()).getSpawnLocation());
if(l == null) {
l = this.plugin.getServer().getWorld(world.getName()).getSpawnLocation();
}
if (l == null) {
teleporter.sendMessage("Sorry Boss, I tried everything, but just couldn't teleport ya there!");
return;
}
teleportee.teleport(l);
}
}

View File

@ -1,31 +1,31 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class UnloadCommand extends MultiverseCommand {
public UnloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Unload World");
this.setCommandUsage("/mvunload" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvunload");
this.addKey("mv unload");
this.setPermission("multiverse.core.unload", "Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.unloadWorld(args.get(0))) {
sender.sendMessage("World Unloaded!");
} else {
sender.sendMessage("Error trying to unload world!");
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class UnloadCommand extends MultiverseCommand {
public UnloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Unload World");
this.setCommandUsage("/mvunload" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvunload");
this.addKey("mv unload");
this.setPermission("multiverse.core.unload", "Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.unloadWorld(args.get(0))) {
sender.sendMessage("World Unloaded!");
} else {
sender.sendMessage("Error trying to unload world!");
}
}
}

View File

@ -1,68 +1,68 @@
package com.onarandombox.MultiverseCore.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class WhoCommand extends MultiverseCommand {
public WhoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Who?");
this.setCommandUsage("/mvwho" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(0, 1);
this.addKey("mvwho");
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// If this command was sent from a Player then we need to check Permissions
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
List<MVWorld> worlds = new ArrayList<MVWorld>();
if (args.size() > 0) {
if (this.plugin.isMVWorld(args.get(0))) {
worlds.add(this.plugin.getMVWorld(args.get(0)));
} else {
sender.sendMessage(ChatColor.RED + "World does not exist");
return;
}
} else {
worlds = new ArrayList<MVWorld>(this.plugin.getMVWorlds());
}
for (MVWorld world : worlds) {
if (!(this.plugin.isMVWorld(world.getName()))) {
continue;
}
if (p != null && (!this.plugin.getPermissions().canEnterWorld(p, world))) {
continue;
}
List<Player> players = world.getCBWorld().getPlayers();
String result = "";
if (players.size() <= 0) {
result = "Empty";
} else {
for (Player player : players) {
result += player.getName() + " ";
}
}
sender.sendMessage(world.getColoredWorldString() + ChatColor.WHITE + " - " + result);
}
}
}
package com.onarandombox.MultiverseCore.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class WhoCommand extends MultiverseCommand {
public WhoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Who?");
this.setCommandUsage("/mvwho" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(0, 1);
this.addKey("mvwho");
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// If this command was sent from a Player then we need to check Permissions
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
List<MVWorld> worlds = new ArrayList<MVWorld>();
if (args.size() > 0) {
if (this.plugin.isMVWorld(args.get(0))) {
worlds.add(this.plugin.getMVWorld(args.get(0)));
} else {
sender.sendMessage(ChatColor.RED + "World does not exist");
return;
}
} else {
worlds = new ArrayList<MVWorld>(this.plugin.getMVWorlds());
}
for (MVWorld world : worlds) {
if (!(this.plugin.isMVWorld(world.getName()))) {
continue;
}
if (p != null && (!this.plugin.getPermissions().canEnterWorld(p, world))) {
continue;
}
List<Player> players = world.getCBWorld().getPlayers();
String result = "";
if (players.size() <= 0) {
result = "Empty";
} else {
for (Player player : players) {
result += player.getName() + " ";
}
}
sender.sendMessage(world.getColoredWorldString() + ChatColor.WHITE + " - " + result);
}
}
}

View File

@ -1,57 +1,57 @@
package com.onarandombox.MultiverseCore.configuration;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import com.onarandombox.MultiverseCore.MVConfigMigrator;
import com.onarandombox.MultiverseCore.MultiverseCore;
/**
* https://github.com/Nijikokun/iConomy3/blob/master/com/nijiko/coelho/iConomy/iConomy.java
*
* @author Nijikokun & Coelho
*/
public class DefaultConfiguration {
public DefaultConfiguration(File folder, String name, MVConfigMigrator migrator) {
File actual = new File(folder, name);
// If defaults have been created, and we're being called again, we should try to migrate
if (MultiverseCore.defaultConfigsCreated) {
migrator.migrate(name, folder);
} else if (!actual.exists() && !migrator.migrate(name, folder)) {
InputStream input = this.getClass().getResourceAsStream("/defaults/" + name);
if (input != null) {
FileOutputStream output = null;
try {
output = new FileOutputStream(actual);
byte[] buf = new byte[8192];
int length = 0;
while ((length = input.read(buf)) > 0) {
output.write(buf, 0, length);
}
// MultiverseCore.log.info(MultiverseCore.logPrefix + "Default config file written: " + name);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (input != null)
input.close();
} catch (Exception e) {
}
try {
if (output != null)
output.close();
} catch (Exception e) {
}
}
}
}
}
}
package com.onarandombox.MultiverseCore.configuration;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import com.onarandombox.MultiverseCore.MVConfigMigrator;
import com.onarandombox.MultiverseCore.MultiverseCore;
/**
* https://github.com/Nijikokun/iConomy3/blob/master/com/nijiko/coelho/iConomy/iConomy.java
*
* @author Nijikokun & Coelho
*/
public class DefaultConfiguration {
public DefaultConfiguration(File folder, String name, MVConfigMigrator migrator) {
File actual = new File(folder, name);
// If defaults have been created, and we're being called again, we should try to migrate
if (MultiverseCore.defaultConfigsCreated) {
migrator.migrate(name, folder);
} else if (!actual.exists() && !migrator.migrate(name, folder)) {
InputStream input = this.getClass().getResourceAsStream("/defaults/" + name);
if (input != null) {
FileOutputStream output = null;
try {
output = new FileOutputStream(actual);
byte[] buf = new byte[8192];
int length = 0;
while ((length = input.read(buf)) > 0) {
output.write(buf, 0, length);
}
// MultiverseCore.log.info(MultiverseCore.logPrefix + "Default config file written: " + name);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (input != null)
input.close();
} catch (Exception e) {
}
try {
if (output != null)
output.close();
} catch (Exception e) {
}
}
}
}
}
}

View File

@ -1,80 +1,80 @@
package com.onarandombox.utils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
public class BlockSafety {
/**
* This function checks whether the block at the given coordinates are above air or not.
*
* @param world
* @param x
* @param y
* @param z
* @return
*/
private boolean blockIsAboveAir(Location l) {
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
downOne.setY(downOne.getY() - 1);
return (downOne.getBlock().getType() == Material.AIR);
}
public boolean blockIsNotSafe(World world, double x, double y, double z) {
Location l = new Location(world, x, y, z);
return !playerCanSpawnHereSafely(l);
}
/**
* This function checks whether the block at the coordinates given is safe or not by checking for Laval/Fire/Air etc. This also ensures there is enough space for a player to spawn!
*
* @param world
* @param x
* @param y
* @param z
* @return
*/
public boolean playerCanSpawnHereSafely(Location l) {
Location actual = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location upOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
upOne.setY(upOne.getY() + 1);
downOne.setY(downOne.getY() - 1);
if (actual.getBlock().getType() != Material.AIR || upOne.getBlock().getType() != Material.AIR)
return false;
if (downOne.getBlock().getType() == Material.LAVA)
return false;
if (downOne.getBlock().getType() == Material.STATIONARY_LAVA)
return false;
if (downOne.getBlock().getType() == Material.FIRE)
return false;
if (actual.getBlock().getType() == Material.FIRE)
return false;
if (blockIsAboveAir(actual))
return false;
return true;
}
public void showDangers(Location l) {
Location actual = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location upOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
upOne.setY(upOne.getY() + 1);
downOne.setY(downOne.getY() - 1);
System.out.print("Location Up: " + upOne.getBlock().getType());
System.out.print(" " + upOne);
System.out.print("Location: " + actual.getBlock().getType());
System.out.print(" " + actual);
System.out.print("Location Down: " + downOne.getBlock().getType());
System.out.print(" " + downOne);
}
}
package com.onarandombox.utils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
public class BlockSafety {
/**
* This function checks whether the block at the given coordinates are above air or not.
*
* @param world
* @param x
* @param y
* @param z
* @return
*/
private boolean blockIsAboveAir(Location l) {
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
downOne.setY(downOne.getY() - 1);
return (downOne.getBlock().getType() == Material.AIR);
}
public boolean blockIsNotSafe(World world, double x, double y, double z) {
Location l = new Location(world, x, y, z);
return !playerCanSpawnHereSafely(l);
}
/**
* This function checks whether the block at the coordinates given is safe or not by checking for Laval/Fire/Air etc. This also ensures there is enough space for a player to spawn!
*
* @param world
* @param x
* @param y
* @param z
* @return
*/
public boolean playerCanSpawnHereSafely(Location l) {
Location actual = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location upOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
upOne.setY(upOne.getY() + 1);
downOne.setY(downOne.getY() - 1);
if (actual.getBlock().getType() != Material.AIR || upOne.getBlock().getType() != Material.AIR)
return false;
if (downOne.getBlock().getType() == Material.LAVA)
return false;
if (downOne.getBlock().getType() == Material.STATIONARY_LAVA)
return false;
if (downOne.getBlock().getType() == Material.FIRE)
return false;
if (actual.getBlock().getType() == Material.FIRE)
return false;
if (blockIsAboveAir(actual))
return false;
return true;
}
public void showDangers(Location l) {
Location actual = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location upOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
upOne.setY(upOne.getY() + 1);
downOne.setY(downOne.getY() - 1);
System.out.print("Location Up: " + upOne.getBlock().getType());
System.out.print(" " + upOne);
System.out.print("Location: " + actual.getBlock().getType());
System.out.print(" " + actual);
System.out.print("Location Down: " + downOne.getBlock().getType());
System.out.print(" " + downOne);
}
}

View File

@ -1,89 +1,89 @@
package com.onarandombox.utils;
import org.bukkit.Location;
import org.bukkit.World;
public class LocationManipulation {
/**
* Convert a Location into a Colon separated string to allow us to store it in text.
*
* @param location
* @return
*/
public String locationToString(Location location) {
StringBuilder l = new StringBuilder();
l.append(location.getBlockX() + ":");
l.append(location.getBlockY() + ":");
l.append(location.getBlockZ() + ":");
l.append(location.getYaw() + ":");
l.append(location.getPitch());
return l.toString();
}
/**
* Convert a String to a Location.
*
* @param world
* @param xStr
* @param yStr
* @param zStr
* @param yawStr
* @param pitchStr
* @return
*/
public Location stringToLocation(World world, String xStr, String yStr, String zStr, String yawStr, String pitchStr) {
double x = Double.parseDouble(xStr);
double y = Double.parseDouble(yStr);
double z = Double.parseDouble(zStr);
float yaw = Float.valueOf(yawStr).floatValue();
float pitch = Float.valueOf(pitchStr).floatValue();
return new Location(world, x, y, z, yaw, pitch);
}
/**
* Convert a Location to XYZ Coordinates.
*
* @param l
* @return
*/
public String strCoords(Location l) {
String result = "";
result += "X: " + l.getBlockX() + " ";
result += "Y: " + l.getBlockY() + " ";
result += "Z: " + l.getBlockZ() + " ";
return result;
}
/**
* Return the NESW Direction a Location is facing.
*
* @param location
* @return
*/
public String getDirection(Location location) {
int r = (int) Math.abs((location.getYaw() - 90) % 360);
String dir;
if (r < 23)
dir = "N";
else if (r < 68)
dir = "NE";
else if (r < 113)
dir = "E";
else if (r < 158)
dir = "SE";
else if (r < 203)
dir = "S";
else if (r < 248)
dir = "SW";
else if (r < 293)
dir = "W";
else if (r < 338)
dir = "NW";
else
dir = "N";
return dir;
}
}
package com.onarandombox.utils;
import org.bukkit.Location;
import org.bukkit.World;
public class LocationManipulation {
/**
* Convert a Location into a Colon separated string to allow us to store it in text.
*
* @param location
* @return
*/
public String locationToString(Location location) {
StringBuilder l = new StringBuilder();
l.append(location.getBlockX() + ":");
l.append(location.getBlockY() + ":");
l.append(location.getBlockZ() + ":");
l.append(location.getYaw() + ":");
l.append(location.getPitch());
return l.toString();
}
/**
* Convert a String to a Location.
*
* @param world
* @param xStr
* @param yStr
* @param zStr
* @param yawStr
* @param pitchStr
* @return
*/
public Location stringToLocation(World world, String xStr, String yStr, String zStr, String yawStr, String pitchStr) {
double x = Double.parseDouble(xStr);
double y = Double.parseDouble(yStr);
double z = Double.parseDouble(zStr);
float yaw = Float.valueOf(yawStr).floatValue();
float pitch = Float.valueOf(pitchStr).floatValue();
return new Location(world, x, y, z, yaw, pitch);
}
/**
* Convert a Location to XYZ Coordinates.
*
* @param l
* @return
*/
public String strCoords(Location l) {
String result = "";
result += "X: " + l.getBlockX() + " ";
result += "Y: " + l.getBlockY() + " ";
result += "Z: " + l.getBlockZ() + " ";
return result;
}
/**
* Return the NESW Direction a Location is facing.
*
* @param location
* @return
*/
public String getDirection(Location location) {
int r = (int) Math.abs((location.getYaw() - 90) % 360);
String dir;
if (r < 23)
dir = "N";
else if (r < 68)
dir = "NE";
else if (r < 113)
dir = "E";
else if (r < 158)
dir = "SE";
else if (r < 203)
dir = "S";
else if (r < 248)
dir = "SW";
else if (r < 293)
dir = "W";
else if (r < 338)
dir = "NW";
else
dir = "N";
return dir;
}
}

View File

@ -1,122 +1,122 @@
package com.onarandombox.utils;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class PurgeWorlds {
MultiverseCore plugin;
public PurgeWorlds(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* Synchronizes the given world with it's settings
*/
public void purgeWorlds(CommandSender sender, List<MVWorld> worlds) {
if (worlds == null || worlds.isEmpty()) {
return;
}
for (MVWorld world : worlds) {
this.purgeWorld(sender, world);
}
}
/**
* Convince method for clearing all the animals that do not belong according to the config.
*
* @param sender
* @param world
*/
public void purgeWorld(CommandSender sender, MVWorld world) {
if (world == null) {
return;
}
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
allMobs.addAll(world.getMonsterList());
purgeWorld(sender, world, allMobs, !world.allowAnimalSpawning(), !world.allowMonsterSpawning());
}
public void purgeWorld(CommandSender sender, MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
if (mvworld == null) {
return;
}
World world = this.plugin.getServer().getWorld(mvworld.getName());
if (world == null) {
return;
}
int entitiesKilled = 0;
for (Entity e : world.getEntities()) {
// Check against Monsters
if (killMonster(mvworld, e, thingsToKill, negateMonsters)) {
entitiesKilled++;
continue;
}
// Check against Animals
if (this.killCreature(mvworld, e, thingsToKill, negateAnimals)) {
entitiesKilled++;
continue;
}
}
if (sender != null) {
sender.sendMessage(entitiesKilled + " entities purged from the world '" + world.getName() + "'");
}
}
private boolean killCreature(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Squid || e instanceof Animals) {
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("ANIMALS")) {
if (!negate) {
e.remove();
return true;
}
} else {
if (negate) {
e.remove();
return true;
}
}
}
return false;
}
/**
* Will kill the monster if it's in the list UNLESS the NEGATE boolean is set, then it will kill it if it's NOT
*
* @param mvworld
* @param e
* @param creaturesToKill
* @param negate
* @return
*/
private boolean killMonster(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast) {
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
if (!negate) {
e.remove();
return true;
}
} else {
if (negate) {
e.remove();
return true;
}
}
}
return false;
}
}
package com.onarandombox.utils;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class PurgeWorlds {
MultiverseCore plugin;
public PurgeWorlds(MultiverseCore plugin) {
this.plugin = plugin;
}
/**
* Synchronizes the given world with it's settings
*/
public void purgeWorlds(CommandSender sender, List<MVWorld> worlds) {
if (worlds == null || worlds.isEmpty()) {
return;
}
for (MVWorld world : worlds) {
this.purgeWorld(sender, world);
}
}
/**
* Convince method for clearing all the animals that do not belong according to the config.
*
* @param sender
* @param world
*/
public void purgeWorld(CommandSender sender, MVWorld world) {
if (world == null) {
return;
}
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
allMobs.addAll(world.getMonsterList());
purgeWorld(sender, world, allMobs, !world.allowAnimalSpawning(), !world.allowMonsterSpawning());
}
public void purgeWorld(CommandSender sender, MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
if (mvworld == null) {
return;
}
World world = this.plugin.getServer().getWorld(mvworld.getName());
if (world == null) {
return;
}
int entitiesKilled = 0;
for (Entity e : world.getEntities()) {
// Check against Monsters
if (killMonster(mvworld, e, thingsToKill, negateMonsters)) {
entitiesKilled++;
continue;
}
// Check against Animals
if (this.killCreature(mvworld, e, thingsToKill, negateAnimals)) {
entitiesKilled++;
continue;
}
}
if (sender != null) {
sender.sendMessage(entitiesKilled + " entities purged from the world '" + world.getName() + "'");
}
}
private boolean killCreature(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Squid || e instanceof Animals) {
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("ANIMALS")) {
if (!negate) {
e.remove();
return true;
}
} else {
if (negate) {
e.remove();
return true;
}
}
}
return false;
}
/**
* Will kill the monster if it's in the list UNLESS the NEGATE boolean is set, then it will kill it if it's NOT
*
* @param mvworld
* @param e
* @param creaturesToKill
* @param negate
* @return
*/
private boolean killMonster(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast) {
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
if (!negate) {
e.remove();
return true;
}
} else {
if (negate) {
e.remove();
return true;
}
}
}
return false;
}
}

View File

@ -1,99 +1,99 @@
package com.onarandombox.utils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import java.util.regex.Pattern;
public class UpdateChecker {
public static final Logger log = Logger.getLogger("Minecraft");
public Timer timer = new Timer(); // Create a new Timer.
private String name; // Hold the Plugins Name.
private String cversion; // Hold the Plugins Current Version.
public UpdateChecker(String name, String version) {
this.name = name;
this.cversion = version;
int delay = 0; // No Delay, fire the first check instantly.
int period = 1800; // Delay 30 Minutes
this.timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkUpdate();
}
}, delay * 1000, period * 1000);
}
public void checkUpdate() {
try {
URL url = new URL("http://bukkit.onarandombox.com/multiverse/version.php?n=" + URLEncoder.encode(this.name, "UTF-8") + "&v=" + this.cversion);
URLConnection conn = url.openConnection();
conn.setReadTimeout(2000); // 2000 = 2 Seconds.
int code = ((HttpURLConnection) conn).getResponseCode();
if (code != 200) {
return;
}
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String version = null;
while ((line = rd.readLine()) != null) {
if (version == null) {
version = line;
}
}
if (version == null) {
rd.close();
return;
}
String v1 = normalisedVersion(version);
String v2 = normalisedVersion(this.cversion);
int compare = v1.compareTo(v2);
if (compare > 0) {
log.info("[" + this.name + "]" + " - Update Available (" + version + ")");
}
rd.close();
} catch (Exception e) {
// No need to alert the user of any error here... it's not important.
}
}
/**
* Convert the given Version String to a Normalised Version String so we can compare it.
*
* @param version
* @return
*/
public static String normalisedVersion(String version) {
return normalisedVersion(version, ".", 4);
}
public static String normalisedVersion(String version, String sep, int maxWidth) {
String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
StringBuilder sb = new StringBuilder();
for (String s : split) {
sb.append(String.format("%" + maxWidth + 's', s));
}
return sb.toString();
}
}
package com.onarandombox.utils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import java.util.regex.Pattern;
public class UpdateChecker {
public static final Logger log = Logger.getLogger("Minecraft");
public Timer timer = new Timer(); // Create a new Timer.
private String name; // Hold the Plugins Name.
private String cversion; // Hold the Plugins Current Version.
public UpdateChecker(String name, String version) {
this.name = name;
this.cversion = version;
int delay = 0; // No Delay, fire the first check instantly.
int period = 1800; // Delay 30 Minutes
this.timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkUpdate();
}
}, delay * 1000, period * 1000);
}
public void checkUpdate() {
try {
URL url = new URL("http://bukkit.onarandombox.com/multiverse/version.php?n=" + URLEncoder.encode(this.name, "UTF-8") + "&v=" + this.cversion);
URLConnection conn = url.openConnection();
conn.setReadTimeout(2000); // 2000 = 2 Seconds.
int code = ((HttpURLConnection) conn).getResponseCode();
if (code != 200) {
return;
}
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String version = null;
while ((line = rd.readLine()) != null) {
if (version == null) {
version = line;
}
}
if (version == null) {
rd.close();
return;
}
String v1 = normalisedVersion(version);
String v2 = normalisedVersion(this.cversion);
int compare = v1.compareTo(v2);
if (compare > 0) {
log.info("[" + this.name + "]" + " - Update Available (" + version + ")");
}
rd.close();
} catch (Exception e) {
// No need to alert the user of any error here... it's not important.
}
}
/**
* Convert the given Version String to a Normalised Version String so we can compare it.
*
* @param version
* @return
*/
public static String normalisedVersion(String version) {
return normalisedVersion(version, ".", 4);
}
public static String normalisedVersion(String version, String sep, int maxWidth) {
String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
StringBuilder sb = new StringBuilder();
for (String s : split) {
sb.append(String.format("%" + maxWidth + 's', s));
}
return sb.toString();
}
}

View File

@ -1,35 +1,35 @@
# !!!This only applies to worlds being handled by Multiverse!!!
# If you don't see it using /mvlist this setting WILL HAVE NO EFFECT
# How long to leave in between sending a message to the player. (NOT YET IMPLEMENTED)
# In Milliseconds - Default is '5000' which is 5 Seconds.
messagecooldown: 5000
# How fast are people allowed to use /MVTP (NOT YET IMPLEMENTED)
# In Milliseconds - Default is '5000' which is 5 Seconds.
teleportcooldown: 5000
# If this is set to true, we will prefix the chat with
# a colorful world alias if it's present. If not, we simply
# show the world's name in white. If this is false Multiverse
# won't touch your chat
worldnameprefix: true
# If Multiverse does not find permissions should it automatically fall back to
# people defined in ops.txt? Remember, if you use ops based permissions
# the awesome Multiverse devs get to decide which commands require op!
# (Which is why we highly recommend a permissions plugin! You shouldn't trust us this much...)
opfallback: true
# If you have a world(s) that has monsters = false, and you want to disable the built
# in autohealing, set this to true. This will have NO EFFECT if monsters = true for a given world.
disableautoheal: false
# This will use the old style of PVP prevention so you can have zones of PVP
# Players will be notified when they punch/shoot and it's not allowed.
fakepvp: false
# This just signifies the version number so we can see what version of config you have.
# NEVER TOUCH THIS VALUE
# !!!This only applies to worlds being handled by Multiverse!!!
# If you don't see it using /mvlist this setting WILL HAVE NO EFFECT
# How long to leave in between sending a message to the player. (NOT YET IMPLEMENTED)
# In Milliseconds - Default is '5000' which is 5 Seconds.
messagecooldown: 5000
# How fast are people allowed to use /MVTP (NOT YET IMPLEMENTED)
# In Milliseconds - Default is '5000' which is 5 Seconds.
teleportcooldown: 5000
# If this is set to true, we will prefix the chat with
# a colorful world alias if it's present. If not, we simply
# show the world's name in white. If this is false Multiverse
# won't touch your chat
worldnameprefix: true
# If Multiverse does not find permissions should it automatically fall back to
# people defined in ops.txt? Remember, if you use ops based permissions
# the awesome Multiverse devs get to decide which commands require op!
# (Which is why we highly recommend a permissions plugin! You shouldn't trust us this much...)
opfallback: true
# If you have a world(s) that has monsters = false, and you want to disable the built
# in autohealing, set this to true. This will have NO EFFECT if monsters = true for a given world.
disableautoheal: false
# This will use the old style of PVP prevention so you can have zones of PVP
# Players will be notified when they punch/shoot and it's not allowed.
fakepvp: false
# This just signifies the version number so we can see what version of config you have.
# NEVER TOUCH THIS VALUE
version: 2.1

View File

@ -1,44 +1,44 @@
worlds:
#############################################
### - Examples & Explanation of Settings- ###
#############################################
##worlds:
## default: ## This world is called 'default'
## environment: NORMAL ## Created with a NORMAL environment.
## animals:
## spawn: true ## We want animals to Spawn.
## exceptions: ## We want all animals to spawn so we won't make any exceptions.
## monsters:
## spawn: true ## We want monsters to Spawn.
## exceptions: 'CREEPER' ## But we don't want Creepers to spawn as they destroy peoples homes and valuables.
## pvp: true ## We wan't PVP to be enabled so players can fight each other.
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
## playerBlacklist: '' ## We are not blacklisting any players or groups so anyone can enter this world.
## playerWhitelist: '' ## Because we have not blacklisted anyone we do not have to Whitelist someone.
##
## creative: ## This world is called 'creative'
## environment: NORMAL ## Created with a NORMAL environment.
## animals:
## spawn: true ## We want animals to spawn.
## exceptions: ## We want all animals to spawn so we won't make any exceptions.
## monsters:
## spawn: false ## We don't want monsters to Spawn because this is a Creative World.
## enforced: true ## We want to enforce this rule, this means any Monster that was alive during world load/creation will be removed. No monsters can inhabit this world.
## exceptions: ## We don't want to make any exceptions to this.
## pvp: false ## We want to disable PVP because this world is for creativeness only.
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
## playerBlacklist: 'g:Griefers' ## We don't want to allow the group 'Griefers' into the World.
## playerWhitelist: 'g:Artists' ## We want to allow the group 'Artists' to enter this World.
##
## nether: ## This world is called 'nether'
## environment: NETHER ## Created with a NETHER environment.
## animals:
## spawn: true ## We want animals to spawn.
## monsters:
## spawn: true ## We want monsters to spawn.
## pvp: true ## We want to enable PVP on this World.
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
## playerBlacklist: '' ## We are not blacklisting any players or groups so anyone can enter this world.
## playerWhitelist: '' ## Because we have not blacklisted anyone we do not have to Whitelist someone.
worlds:
#############################################
### - Examples & Explanation of Settings- ###
#############################################
##worlds:
## default: ## This world is called 'default'
## environment: NORMAL ## Created with a NORMAL environment.
## animals:
## spawn: true ## We want animals to Spawn.
## exceptions: ## We want all animals to spawn so we won't make any exceptions.
## monsters:
## spawn: true ## We want monsters to Spawn.
## exceptions: 'CREEPER' ## But we don't want Creepers to spawn as they destroy peoples homes and valuables.
## pvp: true ## We wan't PVP to be enabled so players can fight each other.
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
## playerBlacklist: '' ## We are not blacklisting any players or groups so anyone can enter this world.
## playerWhitelist: '' ## Because we have not blacklisted anyone we do not have to Whitelist someone.
##
## creative: ## This world is called 'creative'
## environment: NORMAL ## Created with a NORMAL environment.
## animals:
## spawn: true ## We want animals to spawn.
## exceptions: ## We want all animals to spawn so we won't make any exceptions.
## monsters:
## spawn: false ## We don't want monsters to Spawn because this is a Creative World.
## enforced: true ## We want to enforce this rule, this means any Monster that was alive during world load/creation will be removed. No monsters can inhabit this world.
## exceptions: ## We don't want to make any exceptions to this.
## pvp: false ## We want to disable PVP because this world is for creativeness only.
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
## playerBlacklist: 'g:Griefers' ## We don't want to allow the group 'Griefers' into the World.
## playerWhitelist: 'g:Artists' ## We want to allow the group 'Artists' to enter this World.
##
## nether: ## This world is called 'nether'
## environment: NETHER ## Created with a NETHER environment.
## animals:
## spawn: true ## We want animals to spawn.
## monsters:
## spawn: true ## We want monsters to spawn.
## pvp: true ## We want to enable PVP on this World.
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
## playerBlacklist: '' ## We are not blacklisting any players or groups so anyone can enter this world.
## playerWhitelist: '' ## Because we have not blacklisted anyone we do not have to Whitelist someone.

View File

@ -1,165 +1,165 @@
name: Multiverse-Core
main: com.onarandombox.MultiverseCore.MultiverseCore
authors: ['Rigby', 'fernferret']
version: 2.0
commands:
mv:
description: Generic Multiverse Command
usage: /<command>
mvcreate:
description: World create command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Creates a world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Creates a world called 'hellworld' with a NETHER environment.
mvc:
description: World create command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Creates a world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Creates a world called 'hellworld' with a NETHER environment.
mvimport:
description: World import command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
mvim:
description: World import command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
mvremove:
description: World remove command
usage: |
/<command> <world>
mvdelete:
description: World delete command
usage: |
/<command> <world>
mvunload:
description: World unload command
usage: |
/<command> <world>
mvmodify:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmset:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmadd:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmremove:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmclear:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvm:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvtp:
description: Command to teleport between Worlds
usage: |
/<command> <world>[:spawn]
Example: /<command> creative - Teleports you to the relevant location in the 'creative' world.
Example: /<command> creative:spawn - Teleports you to the spawn of the 'creative' world.
mvlist:
description: Print list of loaded Worlds
usage: |
/<command> [environment]
Example: /<command> NETHER - Shows all NETHER Worlds.
Example: /<command> NORMAL - Shows all NORMAL Worlds.
mvl:
description: Print list of loaded Worlds
usage: |
/<command> [environment]
Example: /<command> NETHER - Shows all NETHER Worlds.
Example: /<command> NORMAL - Shows all NORMAL Worlds.
mvsetspawn:
description: Set the spawn area for a particular world
usage: /<command> -- Sets the spawn area of the current world to your location.
mvss:
description: Set the spawn area for a particular world
usage: /<command> -- Sets the spawn area of the current world to your location.
mvspawn:
description: Teleport to the spawn area
usage: /<command> -- Teleports you to the spawn area of your current world.
mvs:
description: Teleport to the spawn area
usage: /<command> -- Teleports you to the spawn area of your current world.
mvcoord:
description: Display World, Coordinates, Direction & Compression for a world.
usage: |
/<command> [world]
/<command> -- Shows the relevant coordinates in your current world.
/<command> creative -- Shows the relevant coordinates if you were in the 'creative' world.
mvc:
description: Display World, Coordinates, Direction & Compression for a world.
usage: |
/<command> [world]
/<command> -- Shows the relevant coordinates in your current world.
/<command> creative -- Shows the relevant coordinates if you were in the 'creative' world.
mvwho:
description: Display online users per world.
usage: |
/<command> [world]
/<command> -- Shows who is online in each world.
/<command> creative -- Shows who is online in the 'creative' world.
mvw:
description: Display online users per world.
usage: |
/<command> [world]
/<command> -- Shows who is online in each world.
/<command> creative -- Shows who is online in the 'creative' world.
mvreload:
description: Reload Configuration files.
usage: /<command>
mvr:
description: Reload Configuration files.
usage: /<command>
mvpurge:
description: Purge the targetted world of creatures.
usage: |
/<command> [world] [creatures]
/<command> -- Purges the players world of all creatures.
/<command> creative * -- Purges the creative world of all Creatures.
/<command> creative creeper -- Purges the creative world of all CREEPERS.
mvconfirm:
description: Confirms sensitive decisions like deleting a world.
usage: |
/<command>
mvinfo:
description: Gets world info.
usage: |
/<command> [world]
mvi:
description: Gets world info.
usage: |
/<command> [world]
mvenv:
description: Tells the user all possible world types.
usage: |
/<command>
mvv:
description: Prints out version invo.
usage: |
/<command>
mvversion:
description: Prints out version invo.
usage: |
name: Multiverse-Core
main: com.onarandombox.MultiverseCore.MultiverseCore
authors: ['Rigby', 'fernferret']
version: maven-version-number
commands:
mv:
description: Generic Multiverse Command
usage: /<command>
mvcreate:
description: World create command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Creates a world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Creates a world called 'hellworld' with a NETHER environment.
mvc:
description: World create command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Creates a world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Creates a world called 'hellworld' with a NETHER environment.
mvimport:
description: World import command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
mvim:
description: World import command
usage: |
/<command> <world> <environment>
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
mvremove:
description: World remove command
usage: |
/<command> <world>
mvdelete:
description: World delete command
usage: |
/<command> <world>
mvunload:
description: World unload command
usage: |
/<command> <world>
mvmodify:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmset:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmadd:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmremove:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvmclear:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvm:
description: Modify the settings of an existing world
usage: |
/<command> <world> <option>:<value>
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
mvtp:
description: Command to teleport between Worlds
usage: |
/<command> <world>[:spawn]
Example: /<command> creative - Teleports you to the relevant location in the 'creative' world.
Example: /<command> creative:spawn - Teleports you to the spawn of the 'creative' world.
mvlist:
description: Print list of loaded Worlds
usage: |
/<command> [environment]
Example: /<command> NETHER - Shows all NETHER Worlds.
Example: /<command> NORMAL - Shows all NORMAL Worlds.
mvl:
description: Print list of loaded Worlds
usage: |
/<command> [environment]
Example: /<command> NETHER - Shows all NETHER Worlds.
Example: /<command> NORMAL - Shows all NORMAL Worlds.
mvsetspawn:
description: Set the spawn area for a particular world
usage: /<command> -- Sets the spawn area of the current world to your location.
mvss:
description: Set the spawn area for a particular world
usage: /<command> -- Sets the spawn area of the current world to your location.
mvspawn:
description: Teleport to the spawn area
usage: /<command> -- Teleports you to the spawn area of your current world.
mvs:
description: Teleport to the spawn area
usage: /<command> -- Teleports you to the spawn area of your current world.
mvcoord:
description: Display World, Coordinates, Direction & Compression for a world.
usage: |
/<command> [world]
/<command> -- Shows the relevant coordinates in your current world.
/<command> creative -- Shows the relevant coordinates if you were in the 'creative' world.
mvc:
description: Display World, Coordinates, Direction & Compression for a world.
usage: |
/<command> [world]
/<command> -- Shows the relevant coordinates in your current world.
/<command> creative -- Shows the relevant coordinates if you were in the 'creative' world.
mvwho:
description: Display online users per world.
usage: |
/<command> [world]
/<command> -- Shows who is online in each world.
/<command> creative -- Shows who is online in the 'creative' world.
mvw:
description: Display online users per world.
usage: |
/<command> [world]
/<command> -- Shows who is online in each world.
/<command> creative -- Shows who is online in the 'creative' world.
mvreload:
description: Reload Configuration files.
usage: /<command>
mvr:
description: Reload Configuration files.
usage: /<command>
mvpurge:
description: Purge the targetted world of creatures.
usage: |
/<command> [world] [creatures]
/<command> -- Purges the players world of all creatures.
/<command> creative * -- Purges the creative world of all Creatures.
/<command> creative creeper -- Purges the creative world of all CREEPERS.
mvconfirm:
description: Confirms sensitive decisions like deleting a world.
usage: |
/<command>
mvinfo:
description: Gets world info.
usage: |
/<command> [world]
mvi:
description: Gets world info.
usage: |
/<command> [world]
mvenv:
description: Tells the user all possible world types.
usage: |
/<command>
mvv:
description: Prints out version invo.
usage: |
/<command>
mvversion:
description: Prints out version invo.
usage: |
/<command>