Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57b3370381 | ||
|
|
9d213fbc0a | ||
|
|
0c638035f2 | ||
|
|
63f8811b67 | ||
|
|
d01ce71343 | ||
|
|
fe00aae7e3 | ||
|
|
d4347d0cff | ||
|
|
b033d59b8a | ||
|
|
aedbfd7bab | ||
|
|
b93822502e | ||
|
|
f053f0546b | ||
|
|
af3b3d0fab | ||
|
|
b1fa677330 | ||
|
|
9691a0f978 | ||
|
|
0b1a387003 | ||
|
|
fb6a031860 | ||
|
|
703707a39b | ||
|
|
0b7b91a081 | ||
|
|
4ce503f55e | ||
|
|
74947a7efd | ||
|
|
85cd71cb8a | ||
|
|
3ad7d86f74 | ||
|
|
ac9194ec87 | ||
|
|
96e8208f3d | ||
|
|
895360ce8b | ||
|
|
21b997c1a2 | ||
|
|
7031e9e58b | ||
|
|
322acbc636 | ||
|
|
256d4b0abd | ||
|
|
88088548f8 | ||
|
|
affc96f2e2 | ||
|
|
f3830390f6 | ||
|
|
8b224349e6 | ||
|
|
b51e26bcf1 | ||
|
|
49ffb4dcec | ||
|
|
a66a5eaeb3 | ||
|
|
ba6f580fd8 | ||
|
|
e6c36be019 | ||
|
|
3e4b042de8 | ||
|
|
451955f858 | ||
|
|
8e5d96309f | ||
|
|
970692d228 | ||
|
|
91a5d6c1c5 | ||
|
|
7668d14613 | ||
|
|
38ce30f981 | ||
|
|
abb58b0563 | ||
|
|
22a7c5ae94 | ||
|
|
303bbc317b | ||
|
|
3531bd6432 |
No files matched your search
@@ -248,7 +248,7 @@
|
||||
<dependency>
|
||||
<groupId>me.main__.util</groupId>
|
||||
<artifactId>SerializationConfig</artifactId>
|
||||
<version>1.6b</version>
|
||||
<version>1.6c</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
@@ -300,7 +300,7 @@
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>Logging</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<version>1.0.9</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -7,19 +7,14 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVStaticDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.configuration.DestinationSerializor;
|
||||
import com.onarandombox.MultiverseCore.configuration.EntryFee;
|
||||
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
|
||||
import com.onarandombox.MultiverseCore.configuration.SpawnSettings;
|
||||
import com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator;
|
||||
import com.onarandombox.MultiverseCore.destination.BedDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatStyle;
|
||||
@@ -82,6 +77,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
PROPERTY_ALIASES.put("mode", "gameMode");
|
||||
PROPERTY_ALIASES.put("diff", "difficulty");
|
||||
PROPERTY_ALIASES.put("spawnlocation", "spawn");
|
||||
PROPERTY_ALIASES.put("limit", "playerLimit");
|
||||
PROPERTY_ALIASES.put("animals", "spawning.animals.spawn");
|
||||
PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn");
|
||||
PROPERTY_ALIASES.put("animalsrate", "spawning.animals.spawnrate");
|
||||
@@ -114,6 +110,19 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the respawnWorld-property.
|
||||
*/
|
||||
private final class RespawnWorldPropertyValidator extends WorldPropertyValidator<String> {
|
||||
@Override
|
||||
public String validateChange(String property, String newValue, String oldValue,
|
||||
MVWorld object) throws ChangeDeniedException {
|
||||
if (!plugin.getMVWorldManager().isMVWorld(newValue))
|
||||
throw new ChangeDeniedException();
|
||||
return super.validateChange(property, newValue, oldValue, object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the time-property.
|
||||
*/
|
||||
@@ -376,6 +385,8 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
};
|
||||
@Property(validator = ScalePropertyValidator.class, description = "Scale must be a positive double value. ex: 2.3")
|
||||
private volatile double scale;
|
||||
@Property(validator = RespawnWorldPropertyValidator.class, description = "You must set this to the NAME not alias of a world.")
|
||||
private volatile String respawnWorld;
|
||||
@Property(validator = AllowWeatherPropertyValidator.class, description = "Sorry, this must either be: true or false.")
|
||||
private volatile boolean allowWeather;
|
||||
@Property(serializor = DifficultyPropertySerializor.class, virtualType = Difficulty.class, persistVirtual = true,
|
||||
@@ -439,10 +450,10 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
return spawnLocation;
|
||||
}
|
||||
};
|
||||
@Property(serializor = DestinationSerializor.class)
|
||||
private volatile MVDestination respawnDestination;
|
||||
@Property(description = "Set this to false ONLY if you don't want this world to load itself on server restart.")
|
||||
private volatile boolean autoLoad;
|
||||
@Property(description = "If a player dies in this world, shoudld they go to their bed?")
|
||||
private volatile boolean bedRespawn;
|
||||
@Property
|
||||
private volatile List<String> worldBlacklist;
|
||||
@Property(serializor = TimePropertySerializor.class, virtualType = Long.class,
|
||||
@@ -464,12 +475,15 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
private volatile long seed;
|
||||
@Property
|
||||
private volatile String generator;
|
||||
@Property
|
||||
private volatile int playerLimit;
|
||||
// End of properties
|
||||
// --------------------------------------------------------------
|
||||
|
||||
private Permission permission;
|
||||
private Permission exempt;
|
||||
private Permission ignoreperm;
|
||||
private Permission limitbypassperm;
|
||||
|
||||
public MVWorld(boolean fixSpawn) {
|
||||
super();
|
||||
@@ -575,15 +589,21 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
|
||||
this.exempt = new Permission("multiverse.exempt." + this.getName(),
|
||||
"A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
|
||||
|
||||
this.limitbypassperm = new Permission("mv.bypass.playerlimit." + this.getName(),
|
||||
"A player who can enter this world regardless of wether its full", PermissionDefault.OP);
|
||||
try {
|
||||
this.plugin.getServer().getPluginManager().addPermission(this.permission);
|
||||
this.plugin.getServer().getPluginManager().addPermission(this.exempt);
|
||||
this.plugin.getServer().getPluginManager().addPermission(this.ignoreperm);
|
||||
this.plugin.getServer().getPluginManager().addPermission(this.limitbypassperm);
|
||||
// Add the permission and exempt to parents.
|
||||
this.addToUpperLists(this.permission);
|
||||
|
||||
// Add ignore to it's parent:
|
||||
this.ignoreperm.addParent("mv.bypass.gamemode.*", true);
|
||||
// Add limit bypass to it's parent
|
||||
this.limitbypassperm.addParent("mv.bypass.playerlimit.*", true);
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.plugin.log(Level.FINER, "Permissions nodes were already added for " + this.name);
|
||||
}
|
||||
@@ -612,16 +632,16 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
// Not sure how it will work in the nether...
|
||||
//Location newSpawn = this.spawnLocation.getWorld().getHighestBlockAt(this.spawnLocation).getLocation();
|
||||
if (newSpawn != null) {
|
||||
this.plugin.log(Level.INFO, String.format("New Spawn for '%s' is located at: %s",
|
||||
this.getName(), plugin.getLocationManipulation().locationToString(newSpawn)));
|
||||
Logging.info("New Spawn for '%s' is located at: %s",
|
||||
this.getName(), plugin.getLocationManipulation().locationToString(newSpawn));
|
||||
return newSpawn;
|
||||
} else {
|
||||
// If it's a standard end world, let's check in a better place:
|
||||
Location newerSpawn;
|
||||
newerSpawn = bs.getTopBlock(new Location(w, 0, 0, 0));
|
||||
if (newerSpawn != null) {
|
||||
this.plugin.log(Level.INFO, String.format("New Spawn for '%s' is located at: %s",
|
||||
this.getName(), plugin.getLocationManipulation().locationToString(newerSpawn)));
|
||||
Logging.info("New Spawn for '%s' is located at: %s",
|
||||
this.getName(), plugin.getLocationManipulation().locationToString(newerSpawn));
|
||||
return newerSpawn;
|
||||
} else {
|
||||
this.plugin.log(Level.SEVERE, "Safe spawn NOT found!!!");
|
||||
@@ -641,6 +661,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
this.color = EnglishChatColor.WHITE;
|
||||
this.style = EnglishChatStyle.NORMAL;
|
||||
this.scale = getDefaultScale(environment);
|
||||
this.respawnWorld = new String();
|
||||
this.allowWeather = true;
|
||||
this.spawning = new SpawnSettings();
|
||||
this.entryfee = new EntryFee();
|
||||
@@ -651,9 +672,10 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
this.gameMode = GameMode.SURVIVAL;
|
||||
this.spawnLocation = (world != null) ? new SpawnLocation(world.get().getSpawnLocation()) : new NullLocation();
|
||||
this.autoLoad = true;
|
||||
this.bedRespawn = true;
|
||||
this.worldBlacklist = new ArrayList<String>();
|
||||
this.generator = null;
|
||||
this.respawnDestination = new InvalidDestination();
|
||||
this.playerLimit = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -912,6 +934,22 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
public void setGenerator(String generator) {
|
||||
this.setPropertyValueUnchecked("generator", generator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getPlayerLimit() {
|
||||
return this.playerLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setPlayerLimit(int limit) {
|
||||
this.setPropertyValueUnchecked("playerLimit", limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -1098,11 +1136,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
*/
|
||||
@Override
|
||||
public World getRespawnToWorld() {
|
||||
if (this.getRespawnDestination() instanceof MVStaticDestination)
|
||||
return ((MVStaticDestination)this.getRespawnDestination()).getLocation().getWorld();
|
||||
else if (this.getRespawnDestination() instanceof WorldDestination)
|
||||
return ((WorldDestination)this.getRespawnDestination()).getWorld().getCBWorld();
|
||||
else throw new UnsupportedOperationException("The current respawnDestination doesn't support this!");
|
||||
return this.plugin.getServer().getWorld(respawnWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1110,10 +1144,8 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
*/
|
||||
@Override
|
||||
public boolean setRespawnToWorld(String respawnToWorld) {
|
||||
MultiverseWorld mvworld;
|
||||
if ((mvworld = this.plugin.getMVWorldManager().getMVWorld(respawnToWorld)) == null)
|
||||
return false;
|
||||
return this.setRespawnDestination(new WorldDestination(mvworld));
|
||||
if (!this.plugin.getMVWorldManager().isMVWorld(respawnToWorld)) return false;
|
||||
return this.setPropertyValueUnchecked("respawnWorld", respawnToWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1326,7 +1358,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
*/
|
||||
@Override
|
||||
public void setBedRespawn(boolean respawn) {
|
||||
this.setRespawnDestination(respawn ? this.plugin.getDestFactory().getDestination(BedDestination.STRING) : new InvalidDestination());
|
||||
this.setPropertyValueUnchecked("bedRespawn", respawn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1334,7 +1366,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
*/
|
||||
@Override
|
||||
public boolean getBedRespawn() {
|
||||
return this.getRespawnDestination() instanceof BedDestination;
|
||||
return this.bedRespawn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1400,22 +1432,6 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
|
||||
return this.setPropertyUnchecked("style", style);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MVDestination getRespawnDestination() {
|
||||
return this.respawnDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setRespawnDestination(MVDestination dest) {
|
||||
return this.setPropertyValueUnchecked("respawnDestination", dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final JSONObject jsonData = new JSONObject();
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.onarandombox.MultiverseCore.commands.ReloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ScriptCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SilentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
|
||||
@@ -67,8 +68,15 @@ import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
||||
import com.onarandombox.MultiverseCore.localization.LazyLocaleMessageProvider;
|
||||
import com.onarandombox.MultiverseCore.localization.LocalizationLoadingException;
|
||||
import com.onarandombox.MultiverseCore.localization.MessageProvider;
|
||||
import com.onarandombox.MultiverseCore.localization.MessageProviding;
|
||||
import com.onarandombox.MultiverseCore.localization.NoSuchLocalizationException;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import com.onarandombox.MultiverseCore.localization.SimpleMessageProvider;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
@@ -76,11 +84,10 @@ import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World.Environment;
|
||||
@@ -91,12 +98,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
@@ -109,6 +111,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
@@ -116,13 +119,14 @@ import java.util.logging.Level;
|
||||
/**
|
||||
* The implementation of the Multiverse-{@link Core}.
|
||||
*/
|
||||
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listener {
|
||||
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, MessageProviding {
|
||||
private static final int PROTOCOL = 18;
|
||||
// TODO: Investigate if this one is really needed to be static.
|
||||
// Doubt it. -- FernFerret
|
||||
private static Map<String, String> teleportQueue = new HashMap<String, String>();
|
||||
|
||||
private AnchorManager anchorManager = new AnchorManager(this);
|
||||
private MessageProvider messageProvider = new SimpleMessageProvider(this);
|
||||
// TODO please let's make this non-static
|
||||
private volatile MultiverseCoreConfiguration config;
|
||||
|
||||
@@ -147,7 +151,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
* @param teleportee The name of the player that was teleported.
|
||||
*/
|
||||
public static void addPlayerToTeleportQueue(String teleporter, String teleportee) {
|
||||
Logging.finest( "Adding mapping '%s' => '%s' to teleport queue", teleporter, teleportee);
|
||||
Logging.finest("Adding mapping '%s' => '%s' to teleport queue", teleporter, teleportee);
|
||||
teleportQueue.put(teleportee, teleporter);
|
||||
}
|
||||
|
||||
@@ -206,7 +210,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
|
||||
// HashMap to contain information relating to the Players.
|
||||
private HashMap<String, MVPlayerSession> playerSessions;
|
||||
private Economy vaultEco = null;
|
||||
private VaultHandler vaultHandler;
|
||||
private GenericBank bank = null;
|
||||
private AllPay banker;
|
||||
private Buscript buscript;
|
||||
@@ -251,6 +255,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Now using Vault.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
@@ -258,12 +263,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Economy getVaultEconomy() {
|
||||
return vaultEco;
|
||||
public VaultHandler getVaultHandler() {
|
||||
return vaultHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,10 +273,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.messaging = new MVMessaging();
|
||||
this.messaging = new MVMessaging(this);
|
||||
this.banker = new AllPay(this, LOG_TAG + " ");
|
||||
// Output a little snippet to show it's enabled.
|
||||
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " (API v" + PROTOCOL + ") Enabled - By " + getAuthors());
|
||||
this.vaultHandler = new VaultHandler(this);
|
||||
// Load the defaultWorldGenerators
|
||||
this.worldManager.getDefaultWorldGenerators();
|
||||
|
||||
@@ -302,10 +303,30 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
// this function will be called every time a plugin registers a new envtype with MV
|
||||
// Setup & Load our Configuration files.
|
||||
loadConfigs();
|
||||
try {
|
||||
Locale l = (this.config.getLocale() == null) ? Locale.getDefault() : this.config.getLocale();
|
||||
if (this.messageProvider instanceof LazyLocaleMessageProvider)
|
||||
((LazyLocaleMessageProvider)this.messageProvider).loadLocale(l);
|
||||
this.messageProvider.setLocale(l);
|
||||
} catch (NoSuchLocalizationException e) {
|
||||
if (this.config.getLocale() != null)
|
||||
this.log(Level.SEVERE, String.format(
|
||||
"Multiverse couldn't find any translations for the selected locale '%s'. '%s' will be used instead.",
|
||||
this.config.getLocale(), this.messageProvider.getLocale()));
|
||||
} catch (LocalizationLoadingException e) {
|
||||
this.log(Level.SEVERE, String.format("Failed to load the selected locale '%s'. '%s' will be used instead.",
|
||||
this.config.getLocale(), this.messageProvider.getLocale()));
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.log(Level.SEVERE, e.getMessage());
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
if (this.multiverseConfig != null) {
|
||||
Logging.setDebugLevel(getMVConfig().getGlobalDebug());
|
||||
Logging.setShowingConfig(!getMVConfig().getSilentStart());
|
||||
this.worldManager.loadDefaultWorlds();
|
||||
this.worldManager.loadWorlds(true);
|
||||
Logging.setDebugLevel(getMVConfig().getGlobalDebug());
|
||||
} else {
|
||||
this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse.");
|
||||
}
|
||||
@@ -341,43 +362,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
|
||||
this.initializeBuscript();
|
||||
this.setupMetrics();
|
||||
// Listen out for vault.
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
this.setupVaultEconomy();
|
||||
}
|
||||
|
||||
private boolean setupVaultEconomy() {
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
||||
final RegisteredServiceProvider<Economy> economyProvider
|
||||
= getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
Logging.fine("Vault economy enabled.");
|
||||
vaultEco = economyProvider.getProvider();
|
||||
} else {
|
||||
Logging.finer("Vault economy not detected.");
|
||||
vaultEco = null;
|
||||
}
|
||||
} else {
|
||||
Logging.finer("Vault was not found.");
|
||||
vaultEco = null;
|
||||
}
|
||||
|
||||
return (vaultEco != null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void vaultEnabled(PluginEnableEvent event) {
|
||||
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
|
||||
setupVaultEconomy();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void vaultDisabled(PluginDisableEvent event) {
|
||||
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
|
||||
Logging.fine("Vault economy disabled");
|
||||
setupVaultEconomy();
|
||||
}
|
||||
// Output a little snippet to show it's enabled.
|
||||
Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), PROTOCOL, getAuthors());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -544,47 +531,47 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
*/
|
||||
private void migrate22Values() {
|
||||
if (this.multiverseConfig.isSet("worldnameprefix")) {
|
||||
this.log(Level.INFO, "Migrating 'worldnameprefix'...");
|
||||
Logging.config("Migrating 'worldnameprefix'...");
|
||||
this.getMVConfig().setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
|
||||
this.multiverseConfig.set("worldnameprefix", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("firstspawnworld")) {
|
||||
this.log(Level.INFO, "Migrating 'firstspawnworld'...");
|
||||
Logging.config("Migrating 'firstspawnworld'...");
|
||||
this.getMVConfig().setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
|
||||
this.multiverseConfig.set("firstspawnworld", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("enforceaccess")) {
|
||||
this.log(Level.INFO, "Migrating 'enforceaccess'...");
|
||||
Logging.config("Migrating 'enforceaccess'...");
|
||||
this.getMVConfig().setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
|
||||
this.multiverseConfig.set("enforceaccess", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("displaypermerrors")) {
|
||||
this.log(Level.INFO, "Migrating 'displaypermerrors'...");
|
||||
Logging.config("Migrating 'displaypermerrors'...");
|
||||
this.getMVConfig().setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
|
||||
this.multiverseConfig.set("displaypermerrors", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("teleportintercept")) {
|
||||
this.log(Level.INFO, "Migrating 'teleportintercept'...");
|
||||
Logging.config("Migrating 'teleportintercept'...");
|
||||
this.getMVConfig().setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
|
||||
this.multiverseConfig.set("teleportintercept", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("firstspawnoverride")) {
|
||||
this.log(Level.INFO, "Migrating 'firstspawnoverride'...");
|
||||
Logging.config("Migrating 'firstspawnoverride'...");
|
||||
this.getMVConfig().setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
|
||||
this.multiverseConfig.set("firstspawnoverride", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("messagecooldown")) {
|
||||
this.log(Level.INFO, "Migrating 'messagecooldown'...");
|
||||
Logging.config("Migrating 'messagecooldown'...");
|
||||
this.getMVConfig().setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
|
||||
this.multiverseConfig.set("messagecooldown", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("debug")) {
|
||||
this.log(Level.INFO, "Migrating 'debug'...");
|
||||
Logging.config("Migrating 'debug'...");
|
||||
this.getMVConfig().setGlobalDebug(this.multiverseConfig.getInt("debug"));
|
||||
this.multiverseConfig.set("debug", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("version")) {
|
||||
this.log(Level.INFO, "Migrating 'version'...");
|
||||
Logging.config("Migrating 'version'...");
|
||||
this.multiverseConfig.set("version", null);
|
||||
}
|
||||
}
|
||||
@@ -844,6 +831,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
// Misc Commands
|
||||
this.commandHandler.registerCommand(new EnvironmentCommand(this));
|
||||
this.commandHandler.registerCommand(new DebugCommand(this));
|
||||
this.commandHandler.registerCommand(new SilentCommand(this));
|
||||
this.commandHandler.registerCommand(new GeneratorCommand(this));
|
||||
this.commandHandler.registerCommand(new CheckCommand(this));
|
||||
this.commandHandler.registerCommand(new ScriptCommand(this));
|
||||
@@ -857,7 +845,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
this.saveMVConfigs();
|
||||
this.banker = null;
|
||||
this.bank = null;
|
||||
log(Level.INFO, "- Disabled");
|
||||
Logging.shutdown();
|
||||
}
|
||||
|
||||
@@ -899,7 +886,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
||||
if (!this.isEnabled()) {
|
||||
sender.sendMessage("This plugin is Disabled!");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CH_PLUGIN_DISABLED);
|
||||
return true;
|
||||
}
|
||||
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
|
||||
@@ -908,11 +895,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
return this.commandHandler.locateAndRunCommand(sender, allArgs, getMVConfig().getDisplayPermErrors());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(ChatColor.RED + "An internal error occurred when attempting to perform this command.");
|
||||
if (sender.isOp())
|
||||
sender.sendMessage(ChatColor.RED + "Details were printed to the server console and logs, please add that to your bug report.");
|
||||
else
|
||||
sender.sendMessage(ChatColor.RED + "Try again and contact the server owner or an admin if this problem persists.");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CH_INTERNAL_ERROR);
|
||||
this.messaging.sendMessage(sender, sender.isOp() ? MultiverseMessage.CH_ADMIN_DEBUG : MultiverseMessage.CH_USER_DEBUG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -944,7 +928,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
* standard Server Console.
|
||||
*
|
||||
* @param level The Log-{@link Level}
|
||||
* @param msg The message
|
||||
* @param msg The message
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
|
||||
* messages will appear to originate from Multiverse-Core.
|
||||
@@ -1004,8 +988,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
* @param worldName The name of the invalid world
|
||||
*/
|
||||
public void showNotMVWorldMessage(CommandSender sender, String worldName) {
|
||||
sender.sendMessage("Multiverse doesn't know about " + ChatColor.DARK_AQUA + worldName + ChatColor.WHITE + " yet.");
|
||||
sender.sendMessage("Type " + ChatColor.DARK_AQUA + "/mv import ?" + ChatColor.WHITE + " for help!");
|
||||
// TODO remove this method because we can now send this message in one line
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.GENERIC_NOT_MV_WORLD, worldName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1045,6 +1029,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Now using Vault.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
@@ -1054,6 +1039,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Now using Vault.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
@@ -1240,6 +1226,25 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
|
||||
return this.anchorManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MessageProvider getMessageProvider() {
|
||||
return messageProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setMessageProvider(MessageProvider provider) {
|
||||
if (provider == null)
|
||||
throw new IllegalArgumentException("The new provider can't be null!");
|
||||
|
||||
messageProvider = provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.configuration.LocaleSerializor;
|
||||
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -54,6 +56,8 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
@Property
|
||||
private volatile int globaldebug;
|
||||
@Property
|
||||
private volatile boolean silentstart;
|
||||
@Property
|
||||
private volatile int messagecooldown;
|
||||
@Property
|
||||
private volatile double version;
|
||||
@@ -61,6 +65,8 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
private volatile String firstspawnworld;
|
||||
@Property
|
||||
private volatile int teleportcooldown;
|
||||
@Property(serializor = LocaleSerializor.class)
|
||||
private volatile Locale locale;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
@@ -88,6 +94,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
messagecooldown = 5000;
|
||||
teleportcooldown = 1000;
|
||||
this.version = 2.9;
|
||||
silentstart = false;
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
@@ -275,4 +282,25 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public boolean getUseAsyncChat() {
|
||||
return this.useasyncchat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSilentStart(boolean silentStart) {
|
||||
Logging.setShowingConfig(!silentStart);
|
||||
this.silentstart = silentStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSilentStart() {
|
||||
return silentstart;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -43,17 +43,18 @@ public interface Core {
|
||||
* Gets the Banking system that Multiverse-Core has hooked into.
|
||||
*
|
||||
* @return A {@link GenericBank} that can be used for payments.
|
||||
* @deprecated Now using vault, see {@link #getVaultEconomy}
|
||||
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
GenericBank getBank();
|
||||
|
||||
/**
|
||||
* Returns the Vault economy system if Vault is present and has an economy system enabled.
|
||||
* Returns the Vault handler used by Multiverse. The returned object will have all methods necessary for
|
||||
* interfacing with Vault.
|
||||
*
|
||||
* @return The vault economy system or null if not configured.
|
||||
* @return the Vault handler for Multiverse.
|
||||
*/
|
||||
Economy getVaultEconomy();
|
||||
VaultHandler getVaultHandler();
|
||||
|
||||
/**
|
||||
* Reloads the Multiverse Configuration files:
|
||||
@@ -155,7 +156,7 @@ public interface Core {
|
||||
* Sets the {@link GenericBank}-Bank AllPay is using.
|
||||
*
|
||||
* @param bank The new {@link GenericBank}
|
||||
* @deprecated Now using vault, see {@link #getVaultEconomy}
|
||||
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
void setBank(GenericBank bank);
|
||||
@@ -164,7 +165,7 @@ public interface Core {
|
||||
* Gets this plugin's {@link AllPay}-Banker.
|
||||
*
|
||||
* @return An {@link AllPay}-Banker
|
||||
* @deprecated Now using vault, see {@link #getVaultEconomy}
|
||||
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
AllPay getBanker();
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* A special {@link MVDestination} that can determine the target {@link Location} without a reference to the teleportee.
|
||||
*/
|
||||
public interface MVStaticDestination extends MVDestination {
|
||||
/**
|
||||
* Returns {@link MVDestination}'s target {@link Location}.
|
||||
* <p>
|
||||
* Although that shouldn't be necessary, it is recommended to implement
|
||||
* {@link #getLocation(org.bukkit.entity.Entity)} with a simple call to this method.
|
||||
* @return The target location.
|
||||
* @see #getLocation(org.bukkit.entity.Entity)
|
||||
*/
|
||||
Location getLocation();
|
||||
}
|
||||
@@ -90,6 +90,17 @@ public interface MVWorldManager {
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeConfig);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeFromConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @param deleteWorldFolder If true the world folder will be completely deleted. If false
|
||||
* only the contents of the world folder will be deleted
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
|
||||
/**
|
||||
@@ -145,4 +147,30 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
* @return useasyncchat.
|
||||
*/
|
||||
boolean getUseAsyncChat();
|
||||
|
||||
/**
|
||||
* Sets the locale.
|
||||
* @param locale The new value.
|
||||
*/
|
||||
void setLocale(Locale locale);
|
||||
|
||||
/**
|
||||
* Gets the locale.
|
||||
* @return locale
|
||||
*/
|
||||
Locale getLocale();
|
||||
|
||||
/**
|
||||
* Sets whether to suppress startup messages.
|
||||
*
|
||||
* @param silentStart true to suppress messages.
|
||||
*/
|
||||
void setSilentStart(boolean silentStart);
|
||||
|
||||
/**
|
||||
* Whether we are suppressing startup messages.
|
||||
*
|
||||
* @return true if we are suppressing startup messages.
|
||||
*/
|
||||
boolean getSilentStart();
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import java.util.Collection;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
|
||||
/**
|
||||
* Multiverse-messaging.
|
||||
*/
|
||||
@@ -14,6 +16,27 @@ public interface MultiverseMessaging {
|
||||
*/
|
||||
void setCooldown(int milliseconds);
|
||||
|
||||
/**
|
||||
* Sends a message to the specified sender if the cooldown has passed.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param message The message to send.
|
||||
* @param formatArgs Format arguments for the message.
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessage(CommandSender sender, MultiverseMessage message, Object...formatArgs);
|
||||
|
||||
/**
|
||||
* Sends a message to the specified sender if the cooldown has passed.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param message The message to send.
|
||||
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
|
||||
* @param formatArgs Format arguments for the message.
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessage(CommandSender sender, MultiverseMessage message, boolean ignoreCooldown, Object... formatArgs);
|
||||
|
||||
/**
|
||||
* Sends a message to the specified sender if the cooldown has passed.
|
||||
*
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import com.onarandombox.MultiverseCore.utils.DebugLog;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
|
||||
@@ -105,7 +106,7 @@ public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!this.isEnabled()) {
|
||||
sender.sendMessage("This plugin is Disabled!");
|
||||
this.core.getMessaging().sendMessage(sender, MultiverseMessage.CH_PLUGIN_DISABLED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -530,9 +530,7 @@ public interface MultiverseWorld {
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
*
|
||||
* @return A world that exists on the server.
|
||||
* @deprecated This is now deprecated. Use {@link #getRespawnDestination()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
World getRespawnToWorld();
|
||||
|
||||
/**
|
||||
@@ -541,9 +539,7 @@ public interface MultiverseWorld {
|
||||
*
|
||||
* @param respawnWorld The name of a world that exists on the server.
|
||||
* @return True if respawnWorld existed, false if not.
|
||||
* @deprecated This is now deprecated. Use {@link #setRespawnDestination(MVDestination)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setRespawnToWorld(String respawnWorld);
|
||||
|
||||
/**
|
||||
@@ -612,9 +608,7 @@ public interface MultiverseWorld {
|
||||
* bed or follow the normal respawn pattern.
|
||||
*
|
||||
* @return True if players dying in this world should respawn at their bed.
|
||||
* @deprecated This is now deprecated. Use {@link #getRespawnDestination()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean getBedRespawn();
|
||||
|
||||
/**
|
||||
@@ -624,10 +618,24 @@ public interface MultiverseWorld {
|
||||
* True is default.
|
||||
*
|
||||
* @param autoLoad True if players dying in this world respawn at their bed.
|
||||
* @deprecated This is now deprecated. Use {@link #setRespawnDestination(MVDestination)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setBedRespawn(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Sets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @param limit The new limit
|
||||
*/
|
||||
void setPlayerLimit(int limit);
|
||||
|
||||
/**
|
||||
* Gets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @return The player limit
|
||||
*/
|
||||
int getPlayerLimit();
|
||||
|
||||
/**
|
||||
* Same as {@link #getTime()}, but returns a string.
|
||||
@@ -662,19 +670,6 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
AllowedPortalType getAllowedPortals();
|
||||
|
||||
/**
|
||||
* Gets the {@link MVDestination} where players are sent if they die and respawn in this world.
|
||||
* @return The respawn destination.
|
||||
*/
|
||||
MVDestination getRespawnDestination();
|
||||
|
||||
/**
|
||||
* Sets the {@link MVDestination} where players are sent if they die and respawn in this world.
|
||||
* @param dest The new respawn destination.
|
||||
* @return True if the destination was set, false if not.
|
||||
*/
|
||||
boolean setRespawnDestination(MVDestination dest);
|
||||
|
||||
// properties that are not "getter+setter" style
|
||||
/**
|
||||
* Gets a list of all the worlds that players CANNOT travel to from this world,
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -55,11 +57,11 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
|
||||
private void showList(CommandSender sender, List<String> args) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.list", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to list anchors!");
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_NOLISTPERM);
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_LISTHEADER);
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
@@ -72,13 +74,12 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
if (filterObject.getFilter().length() > 0) {
|
||||
availableAnchors = this.getFilteredItems(availableAnchors, filterObject.getFilter());
|
||||
if (availableAnchors.size() == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
|
||||
+ "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_NOMATCH, filterObject.getFilter());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (availableAnchors.size() == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No anchors were defined.");
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_NODEF);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +100,7 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
filterObject.setPage(1);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_PAGEHEADER, filterObject.getPage(), totalPages);
|
||||
|
||||
this.showPage(filterObject.getPage(), sender, availableAnchors);
|
||||
}
|
||||
@@ -115,33 +116,24 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
return;
|
||||
}
|
||||
if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to delete anchors!");
|
||||
} else {
|
||||
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
|
||||
} else {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
|
||||
}
|
||||
}
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true))
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_NODELPERM);
|
||||
else
|
||||
this.plugin.getMessaging().sendMessage(sender, this.plugin.getAnchorManager().deleteAnchor(args.get(0))
|
||||
? MultiverseMessage.CMD_ANCHOR_DELSUCCESS : MultiverseMessage.CMD_ANCHOR_DELFAIL, args.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You must be a player to create Anchors.");
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_CONSOLECREATE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to create anchors!");
|
||||
} else {
|
||||
Player player = (Player) sender;
|
||||
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
|
||||
} else {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
|
||||
}
|
||||
}
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true))
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.CMD_ANCHOR_NOCREATEPERM);
|
||||
else
|
||||
this.plugin.getMessaging().sendMessage(sender, this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), ((Player) sender).getLocation())
|
||||
? MultiverseMessage.CMD_ANCHOR_CREATESUCCESS : MultiverseMessage.CMD_ANCHOR_CREATEFAIL, args.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -39,15 +40,12 @@ public class CheckCommand extends MultiverseCommand {
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Player p = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (p == null) {
|
||||
sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
|
||||
sender.sendMessage("Are they online?");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CHECK_NOSUCHPLAYER, args.get(0));
|
||||
return;
|
||||
}
|
||||
MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
|
||||
if (dest instanceof InvalidDestination) {
|
||||
sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,",
|
||||
args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE));
|
||||
sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CHECK_NOSUCHDEST);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -50,8 +51,7 @@ public class CloneCommand extends MultiverseCommand {
|
||||
objectArgs.add(CommandHandler.getFlag("-g", args));
|
||||
if (!this.worldManager.isMVWorld(args.get(0))) {
|
||||
// If no world was found, we can't clone.
|
||||
sender.sendMessage("Sorry, Multiverse doesn't know about world " + args.get(0) + ", so we can't clone it!");
|
||||
sender.sendMessage("Check the " + ChatColor.GREEN + "/mv list" + ChatColor.WHITE + " command to verify it is listed.");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CLONE_NOSUCHWORLD, args.get(0));
|
||||
return;
|
||||
}
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvclone", "cloneWorld", objectArgs,
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@@ -52,7 +54,7 @@ public class ConfigCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
if (!this.plugin.getMVConfig().setConfigProperty(args.get(0).toLowerCase(), args.get(1))) {
|
||||
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1)));
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CONFIG_SETFAIL, args.get(0), args.get(1));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,10 +65,10 @@ public class ConfigCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
if (this.plugin.saveMVConfigs()) {
|
||||
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CLONE_SUCCESS);
|
||||
this.plugin.loadConfigs();
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAIL!" + ChatColor.WHITE + " Check your console for details!");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CONFIG_FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
@@ -68,19 +69,18 @@ public class CreateCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "Multiverse cannot create " + ChatColor.GOLD +ChatColor.UNDERLINE + "another" + ChatColor.RESET + ChatColor.RED + " world named " + worldName);
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CREATE_WORLDEXISTS, worldName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldFile.exists()) {
|
||||
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");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CREATE_FILEEXISTS);
|
||||
return;
|
||||
}
|
||||
|
||||
Environment environment = EnvironmentCommand.getEnvFromString(env);
|
||||
if (environment == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CREATE_INVALIDENV);
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
}
|
||||
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CREATE_INVALIDTYPE);
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
return;
|
||||
}
|
||||
@@ -104,16 +104,16 @@ public class CreateCommand extends MultiverseCommand {
|
||||
}
|
||||
if (this.worldManager.getChunkGenerator(genarray.get(0), genarray.get(1), "test") == null) {
|
||||
// We have an invalid generator.
|
||||
sender.sendMessage("Invalid generator! '" + generator + "'. " + ChatColor.RED + "Aborting world creation.");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_CREATE_INVALIDGEN, generator);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
|
||||
Command.broadcastCommandMessage(sender, this.plugin.getMessageProvider().getMessage(MultiverseMessage.CMD_CREATE_START, worldName));
|
||||
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
|
||||
Command.broadcastCommandMessage(sender, "Complete!");
|
||||
Command.broadcastCommandMessage(sender, this.plugin.getMessageProvider().getMessage(MultiverseMessage.CMD_CREATE_COMPLETE));
|
||||
} else {
|
||||
Command.broadcastCommandMessage(sender, "FAILED.");
|
||||
Command.broadcastCommandMessage(sender, this.plugin.getMessageProvider().getMessage(MultiverseMessage.CMD_CREATE_FAILED));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class DebugCommand extends MultiverseCommand {
|
||||
public DebugCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn Debug on/off?");
|
||||
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off]");
|
||||
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|silent]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv debug");
|
||||
this.addKey("mv d");
|
||||
@@ -55,10 +55,11 @@ public class DebugCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
private void displayDebugMode(CommandSender sender) {
|
||||
if (plugin.getMVConfig().getGlobalDebug() == 0) {
|
||||
final int debugLevel = plugin.getMVConfig().getGlobalDebug();
|
||||
if (debugLevel == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
|
||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@@ -15,7 +18,6 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Returns a list of loaded generator plugins.
|
||||
@@ -24,7 +26,7 @@ public class GeneratorCommand extends MultiverseCommand {
|
||||
|
||||
public GeneratorCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Information");
|
||||
this.setName("Generator Information");
|
||||
this.setCommandUsage("/mv generators");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv generators");
|
||||
@@ -37,7 +39,7 @@ public class GeneratorCommand extends MultiverseCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
this.plugin.log(Level.INFO, "PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
|
||||
Logging.info("PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
|
||||
Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins();
|
||||
List<String> generators = new ArrayList<String>();
|
||||
for (Plugin p : plugins) {
|
||||
@@ -45,16 +47,16 @@ public class GeneratorCommand extends MultiverseCommand {
|
||||
generators.add(p.getDescription().getName());
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Loaded Generator Plugins ---");
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_GENERATOR_LISTHEADER);
|
||||
String loadedGens = "";
|
||||
boolean altColor = false;
|
||||
for (String s : generators) {
|
||||
loadedGens += (altColor ? ChatColor.YELLOW : ChatColor.WHITE) + s + " ";
|
||||
altColor = !altColor;
|
||||
}
|
||||
if (loadedGens.length() == 0) {
|
||||
loadedGens = ChatColor.RED + "No Generator Plugins found.";
|
||||
}
|
||||
sender.sendMessage(loadedGens);
|
||||
if (loadedGens.length() == 0)
|
||||
this.messaging.sendMessage(sender, MultiverseMessage.CMD_GENERATOR_NOGENSFOUND);
|
||||
else
|
||||
this.messaging.sendMessage(sender, loadedGens, false);
|
||||
}
|
||||
}
|
||||
@@ -125,8 +125,8 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
|
||||
if (world.getPrice() > 0) {
|
||||
final String formattedAmount;
|
||||
if (world.getCurrency() <= 0 && plugin.getVaultEconomy() != null) {
|
||||
formattedAmount = plugin.getVaultEconomy().format(world.getPrice());
|
||||
if (world.getCurrency() <= 0 && plugin.getVaultHandler().getEconomy() != null) {
|
||||
formattedAmount = plugin.getVaultHandler().getEconomy().format(world.getPrice());
|
||||
} else {
|
||||
formattedAmount = this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency());
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.localization.MessageProvider;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -22,16 +24,18 @@ import java.util.List;
|
||||
* Displays a listing of all worlds that a player can enter.
|
||||
*/
|
||||
public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
private MessageProvider provider;
|
||||
|
||||
public ListCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Listing");
|
||||
provider = plugin.getMessageProvider();
|
||||
this.setName(provider.getMessage(MultiverseMessage.CMD_LIST_NAME));
|
||||
this.setCommandUsage("/mv list");
|
||||
this.setArgRange(0, 2);
|
||||
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);
|
||||
this.setPermission("multiverse.core.list.worlds", provider.getMessage(MultiverseMessage.CMD_LIST_DESC), PermissionDefault.OP);
|
||||
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
@@ -66,7 +70,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
}
|
||||
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
||||
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
|
||||
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
|
||||
worldList.add(ChatColor.GRAY + name + " - " + "UNLOADED");
|
||||
}
|
||||
}
|
||||
return worldList;
|
||||
@@ -91,7 +95,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse World List ]====");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ " + this.provider.getMessage(MultiverseMessage.CMD_LIST_TITLE) + " ]====");
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
@@ -104,8 +108,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
if (filterObject.getFilter().length() > 0) {
|
||||
availableWorlds = this.getFilteredItems(availableWorlds, filterObject.getFilter());
|
||||
if (availableWorlds.size() == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
|
||||
+ "No worlds matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + provider.getMessage(MultiverseMessage.CMD_LIST_NO_MATCH) + " " + ChatColor.AQUA + filterObject.getFilter());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Enables debug-information.
|
||||
*/
|
||||
public class SilentCommand extends MultiverseCommand {
|
||||
|
||||
public SilentCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn silent mode on/off?");
|
||||
this.setCommandUsage("/mv silent" + ChatColor.GOLD + " [true|false|on|off]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv silent");
|
||||
this.addKey("mvsilent");
|
||||
this.addCommandExample("/mv silent " + ChatColor.GOLD + "true");
|
||||
this.setPermission("multiverse.core.silent", "Reduces the amount of startup messages.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("on")) {
|
||||
args.set(0, "true");
|
||||
}
|
||||
plugin.getMVConfig().setSilentStart(Boolean.valueOf(args.get(0)));
|
||||
plugin.saveMVConfigs();
|
||||
}
|
||||
this.displaySilentMode(sender);
|
||||
}
|
||||
|
||||
private void displaySilentMode(CommandSender sender) {
|
||||
if (plugin.getMVConfig().getSilentStart()) {
|
||||
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.GREEN + "ON");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.RED + "OFF");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.BitlyURLShortener;
|
||||
@@ -21,7 +22,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Dumps version info to the console.
|
||||
@@ -53,10 +53,10 @@ public class VersionCommand extends MultiverseCommand {
|
||||
buffer.append("[Multiverse-Core] Bukkit Version: ").append(this.plugin.getServer().getVersion()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Multiverse Plugins Loaded: ").append(this.plugin.getPluginCount()).append('\n');
|
||||
final boolean usingVault = this.plugin.getVaultEconomy() != null;
|
||||
final boolean usingVault = plugin.getVaultHandler().getEconomy() != null;
|
||||
buffer.append("[Multiverse-Core] Using Vault: ").append(usingVault).append('\n');
|
||||
if (usingVault) {
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getVaultEconomy().getName()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(plugin.getVaultHandler().getEconomy().getName()).append('\n');
|
||||
} else {
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class VersionCommand extends MultiverseCommand {
|
||||
final String data = versionEvent.getVersionInfo();
|
||||
String[] lines = data.split("\n");
|
||||
for (String line : lines) {
|
||||
this.plugin.log(Level.INFO, line);
|
||||
Logging.info(line);
|
||||
}
|
||||
|
||||
this.plugin.getServer().getScheduler().scheduleAsyncDelayedTask(this.plugin, new Runnable() {
|
||||
@@ -98,7 +98,7 @@ public class VersionCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
|
||||
plugin.log(Level.INFO, "Version info dumped here: " + pasteUrl);
|
||||
Logging.info("Version info dumped here: %s", pasteUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
|
||||
import me.main__.util.SerializationConfig.IllegalPropertyValueException;
|
||||
import me.main__.util.SerializationConfig.Serializor;
|
||||
|
||||
public class DestinationSerializor implements Serializor<MVDestination, String> {
|
||||
private static Core getCore() {
|
||||
Core c = (Core) Bukkit.getPluginManager().getPlugin("Multiverse-Core");
|
||||
if (c == null)
|
||||
throw new IllegalStateException("We need our MVCore-plugin!");
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MVDestination deserialize(String arg0, Class<MVDestination> arg1)
|
||||
throws IllegalPropertyValueException {
|
||||
return getCore().getDestFactory().getDestination(arg0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String serialize(MVDestination arg0) {
|
||||
return arg0.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import me.main__.util.SerializationConfig.IllegalPropertyValueException;
|
||||
import me.main__.util.SerializationConfig.Serializor;
|
||||
|
||||
public class LocaleSerializor implements Serializor<Locale, String> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Locale deserialize(String arg0, Class<Locale> arg1) throws IllegalPropertyValueException {
|
||||
return new Locale(arg0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String serialize(Locale arg0) {
|
||||
return arg0.getLanguage();
|
||||
}
|
||||
}
|
||||
@@ -82,24 +82,6 @@ public class SpawnLocation extends Location implements ConfigurationSerializable
|
||||
return serialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Location other = (Location) obj;
|
||||
|
||||
return /* (this.getWorld() == other.getWorld() || (this.getWorld() != null && this.getWorld().equals(other.getWorld())))
|
||||
&& */ (Double.doubleToLongBits(this.getX()) == Double.doubleToLongBits(other.getX()))
|
||||
&& (Double.doubleToLongBits(this.getY()) == Double.doubleToLongBits(other.getY()))
|
||||
&& (Double.doubleToLongBits(this.getZ()) == Double.doubleToLongBits(other.getZ()))
|
||||
&& (Float.floatToIntBits(this.getPitch()) == Float.floatToIntBits(other.getPitch()))
|
||||
&& (Float.floatToIntBits(this.getYaw()) == Float.floatToIntBits(other.getYaw()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Let Bukkit be able to deserialize this.
|
||||
* @param args The map.
|
||||
|
||||
@@ -59,15 +59,14 @@ public class SubSpawnSettings extends SerializationConfig {
|
||||
public List<String> getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param The new spawn rate
|
||||
* @param rate The new spawn rate
|
||||
*/
|
||||
public void setSpawnRate(int rate) {
|
||||
this.spawnrate = rate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The spawn rate
|
||||
*/
|
||||
|
||||
@@ -9,8 +9,6 @@ package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVStaticDestination;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -22,7 +20,7 @@ import java.util.List;
|
||||
/**
|
||||
* An anchor-{@link MVDestination}.
|
||||
*/
|
||||
public class AnchorDestination implements MVStaticDestination {
|
||||
public class AnchorDestination implements MVDestination {
|
||||
private boolean isValid;
|
||||
private Location location;
|
||||
private MultiverseCore plugin;
|
||||
@@ -62,20 +60,12 @@ public class AnchorDestination implements MVStaticDestination {
|
||||
return parsed.get(0).equalsIgnoreCase("a");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
return this.getLocation();
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.bukkit.util.Vector;
|
||||
* A bed-{@link MVDestination}.
|
||||
*/
|
||||
public class BedDestination implements MVDestination {
|
||||
public static final String STRING = "b:playerbed";
|
||||
|
||||
private boolean isValid;
|
||||
private Location knownBedLoc;
|
||||
@@ -121,6 +120,6 @@ public class BedDestination implements MVDestination {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return STRING;
|
||||
return "b:playerbed";
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,6 @@ package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVStaticDestination;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -22,7 +20,7 @@ import java.util.List;
|
||||
/**
|
||||
* A cannon-{@link MVDestination}.
|
||||
*/
|
||||
public class CannonDestination implements MVStaticDestination {
|
||||
public class CannonDestination implements MVDestination {
|
||||
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
|
||||
private boolean isValid;
|
||||
private Location location;
|
||||
@@ -94,20 +92,12 @@ public class CannonDestination implements MVStaticDestination {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
return this.getLocation();
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,8 +9,6 @@ package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVStaticDestination;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -22,7 +20,7 @@ import java.util.List;
|
||||
/**
|
||||
* An exact {@link MVDestination}.
|
||||
*/
|
||||
public class ExactDestination implements MVStaticDestination {
|
||||
public class ExactDestination implements MVDestination {
|
||||
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
|
||||
private boolean isValid;
|
||||
private Location location;
|
||||
@@ -85,20 +83,12 @@ public class ExactDestination implements MVStaticDestination {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
return this.getLocation();
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,11 +25,6 @@ public class WorldDestination implements MVDestination {
|
||||
private float yaw = -1;
|
||||
private String direction = "";
|
||||
|
||||
public WorldDestination() {} // for DestinationFactory
|
||||
public WorldDestination(MultiverseWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -175,10 +170,4 @@ public class WorldDestination implements MVDestination {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The world.
|
||||
*/
|
||||
public MultiverseWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,10 @@ package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -66,16 +65,31 @@ public class MVPlayerListener implements Listener {
|
||||
World world = event.getPlayer().getWorld();
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
|
||||
// If it's not a World MV manages we stop.
|
||||
if (mvWorld == null)
|
||||
if (mvWorld == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
MVDestination redest = mvWorld.getRespawnDestination();
|
||||
if (!(redest instanceof InvalidDestination))
|
||||
event.setRespawnLocation(redest.getLocation(event.getPlayer()));
|
||||
else
|
||||
event.setRespawnLocation(world.getSpawnLocation());
|
||||
|
||||
MVRespawnEvent respawnEvent = new MVRespawnEvent(event.getRespawnLocation(), event.getPlayer(), "compatability");
|
||||
if (mvWorld.getBedRespawn() && event.isBedSpawn()) {
|
||||
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the instance of the World the player should respawn at.
|
||||
MultiverseWorld respawnWorld = null;
|
||||
if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) {
|
||||
respawnWorld = this.worldManager.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.
|
||||
// NOW: We'll always handle it to get more accurate spawns
|
||||
if (respawnWorld != null) {
|
||||
world = respawnWorld.getCBWorld();
|
||||
}
|
||||
// World has been set to the appropriate world
|
||||
Location respawnLocation = getMostAccurateRespawnLocation(world);
|
||||
|
||||
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
|
||||
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
|
||||
event.setRespawnLocation(respawnEvent.getPlayersRespawnLocation());
|
||||
}
|
||||
@@ -107,7 +121,7 @@ public class MVPlayerListener implements Listener {
|
||||
this.plugin.log(Level.FINER, "Player joined AGAIN!");
|
||||
if (this.plugin.getMVConfig().getEnforceAccess() // check this only if we're enforcing access!
|
||||
&& !this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + p.getWorld().getName(), false)) {
|
||||
p.sendMessage("[MV] - Sorry you can't be in this world anymore!");
|
||||
this.plugin.getMessaging().sendMessage(p, MultiverseMessage.LISTENER_PLAYER_LOSTACCESSPERM);
|
||||
this.sendPlayerToDefaultWorld(p);
|
||||
}
|
||||
}
|
||||
@@ -180,6 +194,8 @@ public class MVPlayerListener implements Listener {
|
||||
+ "' don't have the FUNDS required to enter it.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if player is allowed to enter the world if we're enforcing permissions
|
||||
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
||||
if (event.isCancelled() && teleporter != null) {
|
||||
@@ -187,13 +203,31 @@ public class MVPlayerListener implements Listener {
|
||||
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
|
||||
+ "' because '" + teleporter.getName()
|
||||
+ "' don't have: multiverse.access." + event.getTo().getWorld().getName());
|
||||
} else {
|
||||
this.stateSuccess(teleportee.getName(), toWorld.getAlias());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was allowed to go to '" + toWorld.getAlias() + "' because enforceaccess is off.");
|
||||
}
|
||||
|
||||
// Does a limit actually exist?
|
||||
if (toWorld.getPlayerLimit() > -1) {
|
||||
// Are there equal or more people on the world than the limit?
|
||||
if (toWorld.getCBWorld().getPlayers().size() >= toWorld.getPlayerLimit()) {
|
||||
// Ouch the world is full, lets see if the player can bypass that limitation
|
||||
if (!pt.playerCanBypassPlayerLimit(toWorld, teleporter, teleportee)) {
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
|
||||
+ "' because the world is full and '" + teleporter.getName()
|
||||
+ "' doesn't have: mv.bypass.playerlimit." + event.getTo().getWorld().getName());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// By this point anything cancelling the event has returned on the method, meaning the teleport is a success \o/
|
||||
this.stateSuccess(teleportee.getName(), toWorld.getAlias());
|
||||
}
|
||||
|
||||
private void stateSuccess(String playerName, String worldName) {
|
||||
@@ -311,7 +345,8 @@ public class MVPlayerListener implements Listener {
|
||||
Logging.finest("To World: %s", world);
|
||||
player.setGameMode(world.getGameMode());
|
||||
} else {
|
||||
Logging.fine("The gamemode was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'", player.getName(), player.getWorld().getName(), world.getName());
|
||||
Logging.fine("The gamemode was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'",
|
||||
player.getName(), player.getWorld().getName(), world.getName());
|
||||
}
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MVPluginListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void pluginEnable(PluginEnableEvent event) {
|
||||
if (plugin.getVaultEconomy() != null) {
|
||||
if (plugin.getVaultHandler().getEconomy() != null) {
|
||||
// Don't hook 2 economy plugins.
|
||||
return;
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Multiverse 2 LazyMessageProvider
|
||||
* <p>
|
||||
* This interface describes a Multiverse-MessageProvider that only loads locales when they're needed.
|
||||
*/
|
||||
public interface LazyLocaleMessageProvider extends MessageProvider {
|
||||
|
||||
/**
|
||||
* Loads a localization for a specified {@link Locale}.
|
||||
* <p>
|
||||
* If that localization is already loaded, this method will reload it.
|
||||
*
|
||||
* @param locale The desired {@link Locale}.
|
||||
* @throws LocalizationLoadingException When an error occurs while trying to load the specified localization.
|
||||
*/
|
||||
void loadLocale(Locale locale) throws LocalizationLoadingException;
|
||||
|
||||
/**
|
||||
* Retrieves all loaded localizations.
|
||||
*
|
||||
* @return A {@link Set} of {@link Locale}s whose localizations are currently loaded.
|
||||
*/
|
||||
Set<Locale> getLoadedLocales();
|
||||
|
||||
/**
|
||||
* Detects if a localization is loaded for the specified {@link Locale}.
|
||||
*
|
||||
* @param locale The {@link Locale}.
|
||||
* @return Whether a localization is loaded for the specified {@link Locale}.
|
||||
*/
|
||||
boolean isLocaleLoaded(Locale locale);
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Thrown when an error occurs while a localization is loaded.
|
||||
*/
|
||||
public class LocalizationLoadingException extends IOException {
|
||||
private final Locale locale;
|
||||
|
||||
public LocalizationLoadingException(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public LocalizationLoadingException(String message, Locale locale) {
|
||||
super(message);
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public LocalizationLoadingException(Throwable cause, Locale locale) {
|
||||
super(cause);
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public LocalizationLoadingException(String message, Throwable cause, Locale locale) {
|
||||
super(message, cause);
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The locale we were trying to load.
|
||||
*/
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return super.getMessage() + " (While trying to load localization for locale " + getLocale() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Multiverse 2 MessageProvider
|
||||
* <p>
|
||||
* This interface describes a Multiverse-MessageProvider.
|
||||
*/
|
||||
public interface MessageProvider {
|
||||
/**
|
||||
* The default locale.
|
||||
*/
|
||||
Locale DEFAULT_LOCALE = Locale.ENGLISH;
|
||||
|
||||
/**
|
||||
* Returns a message (as {@link String}) for the specified key (as {@link MultiverseMessage}).
|
||||
*
|
||||
* @param key The key
|
||||
* @param args Args for String.format()
|
||||
* @return The message
|
||||
*/
|
||||
String getMessage(MultiverseMessage key, Object... args);
|
||||
|
||||
/**
|
||||
* Returns a message (as {@link String}) in a specified {@link Locale} for the specified key (as {@link MultiverseMessage}).
|
||||
*
|
||||
* @param key The Key
|
||||
* @param locale The {@link Locale}
|
||||
* @param args Args for String.format()
|
||||
* @return The message
|
||||
*/
|
||||
String getMessage(MultiverseMessage key, Locale locale, Object... args);
|
||||
|
||||
/**
|
||||
* @return the Locale this MessageProvider is currently using.
|
||||
*/
|
||||
Locale getLocale();
|
||||
|
||||
/**
|
||||
* Sets the locale for this MessageProvider.
|
||||
*
|
||||
* @param locale The new {@link Locale}.
|
||||
*/
|
||||
void setLocale(Locale locale);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
|
||||
/**
|
||||
* Multiverse 2 MessageProviding
|
||||
* <p>
|
||||
* This interface is implemented by classes that use a {@link MessageProvider}.
|
||||
*/
|
||||
public interface MessageProviding {
|
||||
/**
|
||||
* @return The {@link MessageProvider} used by the Core.
|
||||
*/
|
||||
MessageProvider getMessageProvider();
|
||||
|
||||
/**
|
||||
* Sets the {@link MessageProvider} used by the core.
|
||||
*
|
||||
* @param provider The new {@link MessageProvider}. Must not be null!
|
||||
*/
|
||||
void setMessageProvider(MessageProvider provider);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
|
||||
|
||||
/**
|
||||
* An enum containing all messages/strings used by Multiverse.
|
||||
*/
|
||||
public enum MultiverseMessage {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: JavadocVariable
|
||||
TEST_STRING("a test-string from the enum"),
|
||||
|
||||
//// Command handling error messages
|
||||
CH_PLUGIN_DISABLED("This plugin is disabled!"),
|
||||
CH_INTERNAL_ERROR("&cAn internal error occurred when attempting to perform this command."),
|
||||
CH_ADMIN_DEBUG("&cDetails were printed to the server console and logs, please add that to your bug report."),
|
||||
CH_USER_DEBUG("&cTry again and contact the server owner or an admin if this problem persists."),
|
||||
|
||||
//// Not MV world message
|
||||
GENERIC_NOT_MV_WORLD("Multiverse doesn't know about &3%s&f yet.\nType &3/mv import ?&f for help!"),
|
||||
|
||||
//// Commands
|
||||
// Anchor Command
|
||||
CMD_ANCHOR_NOLISTPERM("&cYou don't have the permission to list anchors!"),
|
||||
CMD_ANCHOR_LISTHEADER("&d====[ Multiverse Anchor List ]===="),
|
||||
CMD_ANCHOR_NOMATCH("&cSorry... &fNo anchors matched your filter: &b%s"),
|
||||
CMD_ANCHOR_NODEF("&cSorry... &fNo anchors were defined."),
|
||||
CMD_ANCHOR_PAGEHEADER("&b Page %d of %d"),
|
||||
CMD_ANCHOR_NODELPERM("&cYou don't have the permission to delete anchors!"),
|
||||
CMD_ANCHOR_NOCREATEPERM("&cYou don't have the permission to create anchors!"),
|
||||
CMD_ANCHOR_DELSUCCESS("Anchor '%s' was successfully &cdeleted!"),
|
||||
CMD_ANCHOR_DELFAIL("Anchor '%s' was &cNOT&f deleted!"),
|
||||
CMD_ANCHOR_CREATESUCCESS("Anchor '%s' was &asuccessfully&f created!"),
|
||||
CMD_ANCHOR_CREATEFAIL("Anchor '%s' was &cNOT&f created!"),
|
||||
CMD_ANCHOR_CONSOLECREATE("You must be a player to create Anchors!"),
|
||||
// Check Command
|
||||
CMD_CHECK_NOSUCHPLAYER("Could not find player &d%s&f\nAre they online?"),
|
||||
CMD_CHECK_NOSUCHDEST("You asked if '%s' could go to '&d%s&f', but I couldn't find a Destination of that name? Did you type it correctly?"),
|
||||
// Clone Command
|
||||
CMD_CLONE_NOSUCHWORLD("Sorry, Multiverse doesn't know about world '%s', so we can't clone it!\nCheck the &a/mv list&f command to verify it is listed."),
|
||||
CMD_CLONE_SUCCESS("&aWorld Cloned!"),
|
||||
CMD_CLONE_FAIL("&cWorld could NOT be cloned!"),
|
||||
// Config Command
|
||||
CMD_CONFIG_SETFAIL("&cSetting '%s' to '%s' failed!"),
|
||||
CMD_CONFIG_SUCCESS("&aSUCCESS!&f Values were updated successfully!"),
|
||||
CMD_CONFIG_FAIL("&cFAIL!&f Check your console for details!"),
|
||||
// Create Command
|
||||
CMD_CREATE_WORLDEXISTS("&cMultiverse cannot create &n&6another&r&c world named '%s'."),
|
||||
CMD_CREATE_FILEEXISTS("&cA Folder/World already exists with this name!\n&cIf you are confident it is a world you can import it with &a/mv import"),
|
||||
CMD_CREATE_INVALIDENV("&cThat is not a valid environment."),
|
||||
CMD_CREATE_INVALIDTYPE("&cThat is not a valid World Type."),
|
||||
CMD_CREATE_INVALIDGEN("Invalid generator '%s'! &cAborting world creation."),
|
||||
CMD_CREATE_START("Starting creation of world '%s'..."),
|
||||
CMD_CREATE_COMPLETE("Complete!"),
|
||||
CMD_CREATE_FAILED("FAILED."),
|
||||
// Generator Command
|
||||
CMD_GENERATOR_LISTHEADER("&b--- Loaded Generator Plugins ---"),
|
||||
CMD_GENERATOR_NOGENSFOUND("&cNo Generator Plugins found."),
|
||||
// List Command
|
||||
CMD_LIST_NAME("World Listing"),
|
||||
CMD_LIST_DESC("Displays a listing of all worlds that you can enter."),
|
||||
CMD_LIST_TITLE("Multiverse World List"),
|
||||
CMD_LIST_NO_MATCH("No worlds matched your filter:"),
|
||||
|
||||
//// Listeners
|
||||
// PlayerListener
|
||||
LISTENER_PLAYER_LOSTACCESSPERM("[MV] - Sorry you can't be in this world anymore!"),
|
||||
|
||||
//// Permissions
|
||||
PERMS_NOACCESS_SELF("You don't have access to go here..."),
|
||||
PERMS_NOACCESS_OTHER("You can't send %s here..."),
|
||||
PERMS_NOACCESS_BLACKLIST_SELF("You don't have access to go to %s from %s"),
|
||||
PERMS_NOACCESS_BLACKLIST_OTHER("You don't have access to send %s from %s to %s"),
|
||||
|
||||
//// World purger
|
||||
PURGER_ENTITIESKILLED("%d entities purged from the world '%s'"),
|
||||
// END CHECKSTYLE-SUPPRESSION: JavadocVariable
|
||||
; // SUPPRESS CHECKSTYLE: Whitespace
|
||||
|
||||
private final String def;
|
||||
|
||||
MultiverseMessage(String def) {
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return This {@link MultiverseMessage}'s default-message
|
||||
*/
|
||||
public String getDefault() {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Thrown when the requested localization is not found.
|
||||
*/
|
||||
public class NoSuchLocalizationException extends LocalizationLoadingException {
|
||||
|
||||
public NoSuchLocalizationException(Locale locale) {
|
||||
super(locale);
|
||||
}
|
||||
|
||||
public NoSuchLocalizationException(String message, Locale locale) {
|
||||
super(message, locale);
|
||||
}
|
||||
|
||||
public NoSuchLocalizationException(String message, Throwable cause, Locale locale) {
|
||||
super(message, cause, locale);
|
||||
}
|
||||
|
||||
public NoSuchLocalizationException(Throwable cause, Locale locale) {
|
||||
super(cause, locale);
|
||||
}
|
||||
}
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
/**
|
||||
* The normal {@link MessageProvider}-implementation.
|
||||
*/
|
||||
public class SimpleMessageProvider implements LazyLocaleMessageProvider {
|
||||
private static final String LOCALIZATION_FOLDER_NAME = "localization";
|
||||
|
||||
// Regex 1: replace all single & with the section char
|
||||
private static final String FORMAT_PATTERN_1;
|
||||
private static final String FORMAT_REPL_1;
|
||||
static {
|
||||
StringBuilder formatBuilder = new StringBuilder("([^&])&([");
|
||||
for (ChatColor c : ChatColor.values())
|
||||
formatBuilder.append(c.getChar());
|
||||
FORMAT_PATTERN_1 = formatBuilder.append("])").toString();
|
||||
|
||||
FORMAT_REPL_1 = new StringBuilder().append("$1").append(ChatColor.COLOR_CHAR).append("$2").toString();
|
||||
}
|
||||
|
||||
// Regex 2: replace all double & with single &
|
||||
private static final String FORMAT_PATTERN_2 = "&&";
|
||||
private static final String FORMAT_REPL_2 = "&";
|
||||
|
||||
private final Map<Locale, Map<MultiverseMessage, String>> messages;
|
||||
private final MultiverseCore core;
|
||||
|
||||
private Locale locale = DEFAULT_LOCALE;
|
||||
|
||||
public SimpleMessageProvider(MultiverseCore core) {
|
||||
this.core = core;
|
||||
messages = new ConcurrentHashMap<Locale, Map<MultiverseMessage, String>>();
|
||||
|
||||
try {
|
||||
loadLocale(locale);
|
||||
} catch (NoSuchLocalizationException e) {
|
||||
// let's take the defaults from the enum!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a given {@link Locale} if and only if it wasn't already loaded.
|
||||
* @param locale The locale
|
||||
* @throws LocalizationLoadingException If the locale wasn't loaded successfully.
|
||||
*/
|
||||
public void maybeLoadLocale(Locale locale) throws LocalizationLoadingException {
|
||||
if (!isLocaleLoaded(locale)) {
|
||||
try {
|
||||
loadLocale(locale);
|
||||
} catch (NoSuchLocalizationException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (!isLocaleLoaded(locale))
|
||||
throw new LocalizationLoadingException("Couldn't load the localization: "
|
||||
+ locale.toString(), locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the specified string.
|
||||
* <p>
|
||||
* You can use {@code &} to get colors. To get an {@code &} in the output, you have to write {@code &&}.
|
||||
*
|
||||
* @param string The {@link String}.
|
||||
* @param args Args for {@link String#format(String, Object...)}.
|
||||
* @return The formatted string.
|
||||
*/
|
||||
public static String format(String string, Object... args) {
|
||||
// Replaces & with the Section character
|
||||
string = string.replaceAll(FORMAT_PATTERN_1, FORMAT_REPL_1).replaceAll(FORMAT_PATTERN_2, FORMAT_REPL_2);
|
||||
|
||||
return String.format(string, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void loadLocale(Locale l) throws NoSuchLocalizationException {
|
||||
messages.remove(l);
|
||||
|
||||
InputStream resstream = null;
|
||||
InputStream filestream = null;
|
||||
|
||||
try {
|
||||
try {
|
||||
filestream = new FileInputStream(new File(core.getDataFolder(), l.getLanguage() + ".yml"));
|
||||
} catch (FileNotFoundException e) {
|
||||
}
|
||||
try {
|
||||
resstream = core.getResource(new StringBuilder(LOCALIZATION_FOLDER_NAME)
|
||||
.append("/").append(l.getLanguage()).append(".yml").toString());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if ((resstream == null) && (filestream == null))
|
||||
throw new NoSuchLocalizationException(l);
|
||||
|
||||
Map<MultiverseMessage, String> stringsMap = new HashMap<MultiverseMessage, String>();
|
||||
FileConfiguration resconfig = (resstream == null) ? null : YamlConfiguration.loadConfiguration(resstream);
|
||||
FileConfiguration fileconfig = (filestream == null) ? null : YamlConfiguration.loadConfiguration(filestream);
|
||||
for (MultiverseMessage m : MultiverseMessage.values()) {
|
||||
String value = m.getDefault();
|
||||
|
||||
if (resconfig != null)
|
||||
value = resconfig.getString(m.toString(), value);
|
||||
if (fileconfig != null)
|
||||
value = fileconfig.getString(m.toString(), value);
|
||||
|
||||
stringsMap.put(m, value);
|
||||
}
|
||||
|
||||
messages.put(l, Collections.unmodifiableMap(stringsMap));
|
||||
} finally {
|
||||
if (filestream != null)
|
||||
try {
|
||||
filestream.close();
|
||||
} catch (IOException e) {
|
||||
// silently discard
|
||||
}
|
||||
if (resstream != null)
|
||||
try {
|
||||
resstream.close();
|
||||
} catch (IOException e) {
|
||||
// silently discard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<Locale> getLoadedLocales() {
|
||||
return messages.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isLocaleLoaded(Locale l) {
|
||||
return messages.containsKey(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getMessage(MultiverseMessage key, Object... args) {
|
||||
if (!isLocaleLoaded(locale))
|
||||
return format(key.getDefault(), args);
|
||||
else
|
||||
return format(messages.get(locale).get(key), args);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getMessage(MultiverseMessage key, Locale locale, Object... args) {
|
||||
try {
|
||||
maybeLoadLocale(locale);
|
||||
} catch (LocalizationLoadingException e) {
|
||||
e.printStackTrace();
|
||||
return getMessage(key);
|
||||
}
|
||||
return format(messages.get(locale).get(key), args);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
if (locale == null)
|
||||
throw new IllegalArgumentException("Can't set locale to null!");
|
||||
try {
|
||||
maybeLoadLocale(locale);
|
||||
} catch (LocalizationLoadingException e) {
|
||||
if (!locale.equals(DEFAULT_LOCALE))
|
||||
throw new IllegalArgumentException("Error while trying to load localization for the given Locale!", e);
|
||||
}
|
||||
|
||||
this.locale = locale;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Contains localization.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.localization;
|
||||
@@ -50,7 +50,7 @@ public class AnchorManager {
|
||||
//world:x,y,z:pitch:yaw
|
||||
Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, ""));
|
||||
if (anchorLocation != null) {
|
||||
Logging.info("Loading anchor: '%s'...", key);
|
||||
Logging.config("Loading anchor: '%s'...", key);
|
||||
this.anchors.put(key, anchorLocation);
|
||||
} else {
|
||||
Logging.warning("The location for anchor '%s' is INVALID.", key);
|
||||
|
||||
@@ -24,7 +24,9 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* The Multiverse debug-logger.
|
||||
* @deprecated Deprecated in favor of new Logging lib. See {@link com.dumptruckman.minecraft.util.Logging}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DebugLog extends Logger {
|
||||
private FileHandler fh;
|
||||
private Logger standardLog = null;
|
||||
|
||||
@@ -45,6 +45,27 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to delete the contents of a folder, without deleting the folder itself.
|
||||
*
|
||||
* @param file The folder whose contents to delete.
|
||||
* @return true if the contents were successfully deleted
|
||||
*/
|
||||
public static boolean deleteFolderContents(File file) {
|
||||
if (file.exists()) {
|
||||
boolean ret = true;
|
||||
// If the file exists, and it has more than one file in it.
|
||||
if (file.isDirectory()) {
|
||||
for (File f : file.listFiles()) {
|
||||
ret = ret && deleteFolder(f);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final int COPY_BLOCK_SIZE = 1024;
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
import com.onarandombox.MultiverseCore.localization.MessageProviding;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -20,10 +22,12 @@ import java.util.Map;
|
||||
* The default-implementation of {@link MultiverseMessaging}.
|
||||
*/
|
||||
public class MVMessaging implements MultiverseMessaging {
|
||||
private final MessageProviding msgProviding;
|
||||
private Map<String, Long> sentList;
|
||||
private int cooldown;
|
||||
|
||||
public MVMessaging() {
|
||||
public MVMessaging(MessageProviding msgProviding) {
|
||||
this.msgProviding = msgProviding;
|
||||
this.sentList = new HashMap<String, Long>();
|
||||
this.cooldown = 5000; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
@@ -50,7 +54,6 @@ public class MVMessaging implements MultiverseMessaging {
|
||||
@Override
|
||||
public boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown) {
|
||||
if (!(sender instanceof Player) || ignoreCooldown) {
|
||||
|
||||
sendMessages(sender, messages);
|
||||
return true;
|
||||
}
|
||||
@@ -90,4 +93,20 @@ public class MVMessaging implements MultiverseMessaging {
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean sendMessage(CommandSender sender, MultiverseMessage message, Object... args) {
|
||||
return this.sendMessage(sender, message, true, args); // TODO what is a good default value?
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean sendMessage(CommandSender sender, MultiverseMessage message, boolean ignoreCooldown, Object...args) {
|
||||
return this.sendMessage(sender, this.msgProviding.getMessageProvider().getMessage(message, args), ignoreCooldown);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ package com.onarandombox.MultiverseCore.utils;
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -145,9 +147,9 @@ public class PermissionTools {
|
||||
}
|
||||
final boolean usingVault;
|
||||
final String formattedAmount;
|
||||
if (toWorld.getCurrency() <= 0 && plugin.getVaultEconomy() != null) {
|
||||
if (toWorld.getCurrency() <= 0 && plugin.getVaultHandler().getEconomy() != null) {
|
||||
usingVault = true;
|
||||
formattedAmount = plugin.getVaultEconomy().format(toWorld.getPrice());
|
||||
formattedAmount = plugin.getVaultHandler().getEconomy().format(toWorld.getPrice());
|
||||
} else {
|
||||
usingVault = false;
|
||||
formattedAmount = this.plugin.getBank().getFormattedAmount(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency());
|
||||
@@ -157,13 +159,13 @@ public class PermissionTools {
|
||||
errString = "You need " + formattedAmount + " to enter " + toWorld.getColoredWorldString();
|
||||
}
|
||||
if (usingVault) {
|
||||
if (!plugin.getVaultEconomy().has(teleporterPlayer.getName(), toWorld.getPrice())) {
|
||||
if (!plugin.getVaultHandler().getEconomy().has(teleporterPlayer.getName(), toWorld.getPrice())) {
|
||||
return false;
|
||||
} else if (pay) {
|
||||
if (toWorld.getPrice() < 0D) {
|
||||
plugin.getVaultEconomy().depositPlayer(teleporterPlayer.getName(), toWorld.getPrice() * -1D);
|
||||
plugin.getVaultHandler().getEconomy().depositPlayer(teleporterPlayer.getName(), toWorld.getPrice() * -1D);
|
||||
} else {
|
||||
plugin.getVaultEconomy().withdrawPlayer(teleporterPlayer.getName(), toWorld.getPrice());
|
||||
plugin.getVaultHandler().getEconomy().withdrawPlayer(teleporterPlayer.getName(), toWorld.getPrice());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -231,11 +233,10 @@ public class PermissionTools {
|
||||
// Actual checks
|
||||
if (toWorld != null) {
|
||||
if (!this.plugin.getMVPerms().canEnterWorld(teleporterPlayer, toWorld)) {
|
||||
if (teleportee.equals(teleporter)) {
|
||||
teleporter.sendMessage("You don't have access to go here...");
|
||||
} else {
|
||||
teleporter.sendMessage("You can't send " + teleportee.getName() + " here...");
|
||||
}
|
||||
if (teleportee.equals(teleporter))
|
||||
this.plugin.getMessaging().sendMessage(teleporter, MultiverseMessage.PERMS_NOACCESS_SELF);
|
||||
else
|
||||
this.plugin.getMessaging().sendMessage(teleporter, MultiverseMessage.PERMS_NOACCESS_OTHER, teleportee.getName());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -246,17 +247,34 @@ public class PermissionTools {
|
||||
}
|
||||
if (fromWorld != null) {
|
||||
if (fromWorld.getWorldBlacklist().contains(toWorld.getName())) {
|
||||
if (teleportee.equals(teleporter)) {
|
||||
teleporter.sendMessage("You don't have access to go to " + toWorld.getColoredWorldString() + " from " + fromWorld.getColoredWorldString());
|
||||
} else {
|
||||
teleporter.sendMessage("You don't have access to send " + teleportee.getName() + " from "
|
||||
+ fromWorld.getColoredWorldString() + " to " + toWorld.getColoredWorldString());
|
||||
}
|
||||
if (teleportee.equals(teleporter))
|
||||
this.plugin.getMessaging().sendMessage(teleporter, MultiverseMessage.PERMS_NOACCESS_BLACKLIST_SELF, toWorld.getColoredWorldString(), fromWorld.getColoredWorldString());
|
||||
else
|
||||
this.plugin.getMessaging().sendMessage(teleporter, MultiverseMessage.PERMS_NOACCESS_BLACKLIST_OTHER, teleportee.getName(), fromWorld.getColoredWorldString(), toWorld.getColoredWorldString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean playerCanBypassPlayerLimit(MultiverseWorld toWorld, CommandSender teleporter, Player teleportee) {
|
||||
|
||||
if (teleporter == null) {
|
||||
teleporter = teleportee;
|
||||
}
|
||||
|
||||
if (!(teleporter instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MVPermissions perms = plugin.getMVPerms();
|
||||
if (perms.hasPermission(teleportee, "mv.bypass.playerlimit." + toWorld.getName(), false)) {
|
||||
return true;
|
||||
} else {
|
||||
teleporter.sendMessage("The world " + toWorld.getColoredWorldString() + " is full");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a player should bypass game mode restrictions.
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.material.Bed;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -27,10 +27,18 @@ import java.util.Set;
|
||||
*/
|
||||
public class SimpleBlockSafety implements BlockSafety {
|
||||
private final Core plugin;
|
||||
private final static Set<BlockFace> AROUND_BLOCK = new HashSet<BlockFace>(){{ add(BlockFace.NORTH); add(BlockFace.NORTH_EAST);
|
||||
add(BlockFace.EAST); add(BlockFace.SOUTH_EAST);
|
||||
add(BlockFace.SOUTH); add(BlockFace.SOUTH_WEST);
|
||||
add(BlockFace.WEST); add(BlockFace.NORTH_WEST); }};
|
||||
private static final Set<BlockFace> AROUND_BLOCK = EnumSet.noneOf(BlockFace.class);
|
||||
|
||||
static {
|
||||
AROUND_BLOCK.add(BlockFace.NORTH);
|
||||
AROUND_BLOCK.add(BlockFace.NORTH_EAST);
|
||||
AROUND_BLOCK.add(BlockFace.EAST);
|
||||
AROUND_BLOCK.add(BlockFace.SOUTH_EAST);
|
||||
AROUND_BLOCK.add(BlockFace.SOUTH);
|
||||
AROUND_BLOCK.add(BlockFace.SOUTH_WEST);
|
||||
AROUND_BLOCK.add(BlockFace.WEST);
|
||||
AROUND_BLOCK.add(BlockFace.NORTH_WEST);
|
||||
}
|
||||
|
||||
public SimpleBlockSafety(Core plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -127,7 +135,7 @@ public class SimpleBlockSafety implements BlockSafety {
|
||||
*/
|
||||
private Location getSafeSpawnAroundABlock(Location l) {
|
||||
Iterator<BlockFace> checkblock = AROUND_BLOCK.iterator();
|
||||
while(checkblock.hasNext()) {
|
||||
while (checkblock.hasNext()) {
|
||||
final BlockFace face = checkblock.next();
|
||||
if (this.playerCanSpawnHereSafely(l.getBlock().getRelative(face).getLocation())) {
|
||||
// Don't forget to center the player.
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.utils;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -96,9 +97,8 @@ public class SimpleWorldPurger implements WorldPurger {
|
||||
entitiesKilled++;
|
||||
}
|
||||
}
|
||||
if (sender != null) {
|
||||
sender.sendMessage(entitiesKilled + " entities purged from the world '" + world.getName() + "'");
|
||||
}
|
||||
if (sender != null)
|
||||
this.plugin.getMessaging().sendMessage(sender, MultiverseMessage.PURGER_ENTITIESKILLED, entitiesKilled, world.getName());
|
||||
}
|
||||
|
||||
private boolean killDecision(Entity e, List<String> thingsToKill, boolean negateAnimals,
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -87,7 +89,7 @@ public class UpdateChecker {
|
||||
int compare = v1.compareTo(v2);
|
||||
|
||||
if (compare > 0) {
|
||||
log.info("[" + this.name + "]" + " - Update Available (" + version + ")");
|
||||
Logging.info("[%s] - Update Available (%s)", this.name, version);
|
||||
}
|
||||
|
||||
rd.close();
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
/**
|
||||
* A class we use to interface with Vault when it is present.
|
||||
*/
|
||||
public class VaultHandler implements Listener {
|
||||
|
||||
private Economy economy;
|
||||
|
||||
public VaultHandler(final Plugin plugin) {
|
||||
Bukkit.getPluginManager().registerEvents(new VaultListener(), plugin);
|
||||
setupVaultEconomy();
|
||||
}
|
||||
|
||||
private boolean setupVaultEconomy() {
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
||||
final RegisteredServiceProvider<Economy> economyProvider
|
||||
= Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
Logging.fine("Vault economy enabled.");
|
||||
economy = economyProvider.getProvider();
|
||||
} else {
|
||||
Logging.finer("Vault economy not detected.");
|
||||
economy = null;
|
||||
}
|
||||
} else {
|
||||
Logging.finer("Vault was not found.");
|
||||
economy = null;
|
||||
}
|
||||
|
||||
return (economy != null);
|
||||
}
|
||||
|
||||
private class VaultListener implements Listener {
|
||||
@EventHandler
|
||||
private void vaultEnabled(PluginEnableEvent event) {
|
||||
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
|
||||
setupVaultEconomy();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void vaultDisabled(PluginDisableEvent event) {
|
||||
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
|
||||
Logging.fine("Vault economy disabled");
|
||||
setupVaultEconomy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Vault economy system if Vault is present and has an economy system enabled.
|
||||
*
|
||||
* @return The vault economy system or null if not configured.
|
||||
*/
|
||||
public Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
@@ -114,9 +115,7 @@ public class WorldManager implements MVWorldManager {
|
||||
|
||||
removePlayersFromWorld(oldName);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Copying data for world '").append(oldName).append("'...");
|
||||
this.plugin.log(Level.INFO, builder.toString());
|
||||
Logging.config("Copying data for world '%s'", oldName);
|
||||
try {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
@@ -136,23 +135,23 @@ public class WorldManager implements MVWorldManager {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
this.plugin.log(Level.INFO, "Kind of copied stuff");
|
||||
Logging.fine("Kind of copied stuff");
|
||||
|
||||
WorldCreator worldCreator = new WorldCreator(newName);
|
||||
this.plugin.log(Level.INFO, "Started to copy settings");
|
||||
Logging.fine("Started to copy settings");
|
||||
worldCreator.copy(this.getMVWorld(oldName).getCBWorld());
|
||||
this.plugin.log(Level.INFO, "Copied lots of settings");
|
||||
Logging.fine("Copied lots of settings");
|
||||
|
||||
boolean useSpawnAdjust = this.getMVWorld(oldName).getAdjustSpawn();
|
||||
this.plugin.log(Level.INFO, "Copied more settings");
|
||||
Logging.fine("Copied more settings");
|
||||
|
||||
Environment environment = worldCreator.environment();
|
||||
this.plugin.log(Level.INFO, "Copied most settings");
|
||||
Logging.fine("Copied most settings");
|
||||
if (newWorldFile.exists()) {
|
||||
this.plugin.log(Level.INFO, "Succeeded at copying stuff");
|
||||
Logging.fine("Succeeded at copying stuff");
|
||||
if (this.addWorld(newName, environment, null, null, null, generator, useSpawnAdjust)) {
|
||||
// getMVWorld() doesn't actually return an MVWorld
|
||||
this.plugin.log(Level.INFO, "Succeeded at importing stuff");
|
||||
Logging.fine("Succeeded at importing stuff");
|
||||
MVWorld newWorld = (MVWorld) this.getMVWorld(newName);
|
||||
MVWorld oldWorld = (MVWorld) this.getMVWorld(oldName);
|
||||
newWorld.copyValues(oldWorld);
|
||||
@@ -221,7 +220,7 @@ public class WorldManager implements MVWorldManager {
|
||||
if (generator != null) {
|
||||
builder.append(" & generator: ").append(generator);
|
||||
}
|
||||
this.plugin.log(Level.INFO, builder.toString());
|
||||
Logging.info(builder.toString());
|
||||
|
||||
if (!doLoad(c, true)) {
|
||||
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'");
|
||||
@@ -262,12 +261,12 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
if (this.worldsFromTheConfig.containsKey(name)) {
|
||||
this.worldsFromTheConfig.remove(name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
|
||||
Logging.info("World '%s' was removed from config.yml", name);
|
||||
|
||||
this.saveWorldsConfig();
|
||||
return true;
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
|
||||
Logging.info("World '%s' was already removed from config.yml", name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -311,22 +310,22 @@ public class WorldManager implements MVWorldManager {
|
||||
if (this.worlds.containsKey(name)) {
|
||||
if (this.unloadWorldFromBukkit(name, true)) {
|
||||
this.worlds.remove(name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was unloaded from memory.");
|
||||
Logging.info("World '%s' was unloaded from memory.", name);
|
||||
|
||||
this.worldsFromTheConfig.get(name).tearDown();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
this.plugin.log(Level.WARNING, "World '" + name + "' could not be unloaded. Is it a default world?");
|
||||
Logging.warning("World '%s' could not be unloaded. Is it a default world?", name);
|
||||
}
|
||||
} else if (this.plugin.getServer().getWorld(name) != null) {
|
||||
this.plugin.log(Level.WARNING, "Hmm Multiverse does not know about this world but it's loaded in memory.");
|
||||
this.plugin.log(Level.WARNING, "To let Multiverse know about it, use:");
|
||||
this.plugin.log(Level.WARNING, String.format("/mv import %s %s", name, this.plugin.getServer().getWorld(name).getEnvironment().toString()));
|
||||
Logging.warning("Hmm Multiverse does not know about this world but it's loaded in memory.");
|
||||
Logging.warning("To let Multiverse know about it, use:");
|
||||
Logging.warning("/mv import %s %s", name, this.plugin.getServer().getWorld(name).getEnvironment().toString());
|
||||
} else if (this.worldsFromTheConfig.containsKey(name)) {
|
||||
return true; // it's already unloaded
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "Multiverse does not know about " + name + " and it's not loaded by Bukkit.");
|
||||
Logging.info("Multiverse does not know about '%s' and it's not loaded by Bukkit.", name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -405,7 +404,7 @@ public class WorldManager implements MVWorldManager {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteWorld(String name, boolean removeFromConfig) {
|
||||
public boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder) {
|
||||
World world = this.plugin.getServer().getWorld(name);
|
||||
if (world == null) {
|
||||
// We can only delete loaded worlds
|
||||
@@ -433,25 +432,33 @@ public class WorldManager implements MVWorldManager {
|
||||
try {
|
||||
File worldFile = world.getWorldFolder();
|
||||
plugin.log(Level.FINER, "deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
|
||||
boolean deletedWorld = FileUtils.deleteFolder(worldFile);
|
||||
if (deletedWorld) {
|
||||
this.plugin.log(Level.INFO, "World " + name + " was DELETED.");
|
||||
if (deleteWorldFolder ? FileUtils.deleteFolder(worldFile) : FileUtils.deleteFolderContents(worldFile)) {
|
||||
Logging.info("World '%s' was DELETED.", name);
|
||||
return true;
|
||||
} else {
|
||||
this.plugin.log(Level.SEVERE, "World " + name + " was NOT deleted.");
|
||||
this.plugin.log(Level.SEVERE, "Are you sure the folder " + name + " exists?");
|
||||
this.plugin.log(Level.SEVERE, "Please check your file permissions on " + name);
|
||||
Logging.severe("World '%s' was NOT deleted.", name);
|
||||
Logging.severe("Are you sure the folder %s exists?", name);
|
||||
Logging.severe("Please check your file permissions on '%s'", name);
|
||||
return false;
|
||||
}
|
||||
return deletedWorld;
|
||||
} catch (Throwable e) {
|
||||
this.plugin.log(Level.SEVERE, "Hrm, something didn't go as planned. Here's an exception for ya.");
|
||||
this.plugin.log(Level.SEVERE, "You can go politely explain your situation in #multiverse on esper.net");
|
||||
this.plugin.log(Level.SEVERE, "But from here, it looks like your folder is oddly named.");
|
||||
this.plugin.log(Level.SEVERE, "This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry.");
|
||||
this.plugin.log(Level.SEVERE, e.getMessage());
|
||||
Logging.severe("Hrm, something didn't go as planned. Here's an exception for ya.");
|
||||
Logging.severe("You can go politely explain your situation in #multiverse on esper.net");
|
||||
Logging.severe("But from here, it looks like your folder is oddly named.");
|
||||
Logging.severe("This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry.");
|
||||
Logging.severe(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteWorld(String name, boolean removeFromConfig) {
|
||||
return this.deleteWorld(name, removeFromConfig, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -641,7 +648,7 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
|
||||
// Simple Output to the Console to show how many Worlds were loaded.
|
||||
this.plugin.log(Level.INFO, count + " - World(s) loaded.");
|
||||
Logging.config("%s - World(s) loaded.", count);
|
||||
this.saveWorldsConfig();
|
||||
}
|
||||
|
||||
@@ -791,7 +798,7 @@ public class WorldManager implements MVWorldManager {
|
||||
world.setSeed(theSeed);
|
||||
}
|
||||
|
||||
if (this.deleteWorld(name, false)) {
|
||||
if (this.deleteWorld(name, false, false)) {
|
||||
this.doLoad(name, true);
|
||||
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
|
||||
Location newSpawn = world.getSpawnLocation();
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
TEST_STRING: 'a test-string from the resource'
|
||||
|
||||
# Generic Strings
|
||||
GENERIC_SORRY: 'Sorry...'
|
||||
GENERIC_PAGE: 'Page'
|
||||
GENERIC_OF: 'of'
|
||||
GENERIC_UNLOADED: 'UNLOADED'
|
||||
GENERIC_PLUGIN_DISABLED: 'This plugin is Disabled!'
|
||||
|
||||
# Errors
|
||||
ERROR_LOAD: 'Your configs were not loaded. Very little will function in Multiverse.'
|
||||
|
||||
|
||||
## Commands
|
||||
# List Command
|
||||
LIST_NAME: 'World Listing'
|
||||
LIST_DESC: 'Displays a listing of all worlds that you can enter.'
|
||||
LIST_TITLE: 'Multiverse World List'
|
||||
LIST_NO_MATCH: 'No worlds matched your filter:'
|
||||
|
||||
@@ -211,3 +211,7 @@ commands:
|
||||
usage: |
|
||||
/<command> <world> <environment>
|
||||
/<command> creative grieftastic -- Creates a world called 'grieftastic' exactly identical to the world 'creative'.
|
||||
mvsilent:
|
||||
description: Reduces startup messages
|
||||
usage: |
|
||||
/<command> [true|false]
|
||||
@@ -0,0 +1,204 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.localization.LazyLocaleMessageProvider;
|
||||
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||
import com.onarandombox.MultiverseCore.localization.SimpleMessageProvider;
|
||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
||||
public class TestLocalization {
|
||||
TestInstanceCreator creator;
|
||||
Server mockServer;
|
||||
CommandSender mockCommandSender;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertTrue(creator.setUp());
|
||||
mockServer = creator.getServer();
|
||||
mockCommandSender = creator.getCommandSender();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumDefaults() throws Exception {
|
||||
// Pull a core instance from the server.
|
||||
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||
|
||||
// Make sure Core is not null
|
||||
assertNotNull(plugin);
|
||||
|
||||
// Make sure Core is enabled
|
||||
assertTrue(plugin.isEnabled());
|
||||
|
||||
// Make sure Core is a MultiverseCore
|
||||
assertTrue(plugin instanceof MultiverseCore);
|
||||
|
||||
MultiverseCore core = (MultiverseCore) plugin;
|
||||
|
||||
// This should be the same core as creator.getCore()
|
||||
assertEquals(core, creator.getCore());
|
||||
|
||||
// Make sure there is neither the file nor the resource
|
||||
assertNull(core.getResource("localization/en.yml"));
|
||||
assertFalse(new File(TestInstanceCreator.pluginDirectory, "en.yml").exists());
|
||||
|
||||
// And now test it
|
||||
String actual = core.getMessageProvider().getMessage(MultiverseMessage.TEST_STRING);
|
||||
String expected = "a test-string from the enum";
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResourceDefaults() throws Exception {
|
||||
// Pull a core instance from the server.
|
||||
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||
|
||||
// Make sure Core is not null
|
||||
assertNotNull(plugin);
|
||||
|
||||
// Make sure Core is enabled
|
||||
assertTrue(plugin.isEnabled());
|
||||
|
||||
// Make sure Core is a MultiverseCore
|
||||
assertTrue(plugin instanceof MultiverseCore);
|
||||
|
||||
MultiverseCore core = (MultiverseCore) plugin;
|
||||
|
||||
// This should be the same core as creator.getCore()
|
||||
assertEquals(core, creator.getCore());
|
||||
|
||||
// Make sure there is no file, only the resource
|
||||
assertFalse(new File(TestInstanceCreator.pluginDirectory, "en.yml").exists());
|
||||
assertTrue(new File("src/main/resources/localization/en.yml").exists());
|
||||
doAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock invocation) throws Throwable {
|
||||
try {
|
||||
return new FileInputStream("src/main/resources/" + (String) invocation.getArguments()[0]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}).when(core).getResource(anyString());
|
||||
assertNotNull(core.getResource("localization/en.yml"));
|
||||
|
||||
// this only works for a LazyLocaleMessageProvider
|
||||
assertTrue(core.getMessageProvider() instanceof LazyLocaleMessageProvider);
|
||||
|
||||
LazyLocaleMessageProvider messageProvider = (LazyLocaleMessageProvider) core.getMessageProvider();
|
||||
|
||||
// We have to reload it
|
||||
messageProvider.loadLocale(Locale.ENGLISH);
|
||||
|
||||
// And now test it
|
||||
String actual = core.getMessageProvider().getMessage(MultiverseMessage.TEST_STRING);
|
||||
String expected = "a test-string from the resource";
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserFile() throws Exception {
|
||||
// Pull a core instance from the server.
|
||||
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||
|
||||
// Make sure Core is not null
|
||||
assertNotNull(plugin);
|
||||
|
||||
// Make sure Core is enabled
|
||||
assertTrue(plugin.isEnabled());
|
||||
|
||||
// Make sure Core is a MultiverseCore
|
||||
assertTrue(plugin instanceof MultiverseCore);
|
||||
|
||||
MultiverseCore core = (MultiverseCore) plugin;
|
||||
|
||||
// This should be the same core as creator.getCore()
|
||||
assertEquals(core, creator.getCore());
|
||||
|
||||
// Create the file
|
||||
File file = new File(TestInstanceCreator.pluginDirectory, "en.yml");
|
||||
BufferedWriter bwriter = new BufferedWriter(new FileWriter(file));
|
||||
String expected = "a test-string from the user-file";
|
||||
bwriter.write("TEST_STRING: " + expected);
|
||||
bwriter.close();
|
||||
|
||||
// Make sure there is the file and the resource
|
||||
assertTrue(file.exists());
|
||||
assertTrue(new File("src/main/resources/localization/en.yml").exists());
|
||||
doAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock invocation) throws Throwable {
|
||||
try {
|
||||
return new FileInputStream("src/main/resources/" + (String) invocation.getArguments()[0]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}).when(core).getResource(anyString());
|
||||
assertNotNull(core.getResource("localization/en.yml"));
|
||||
|
||||
// this only works for a LazyLocaleMessageProvider
|
||||
assertTrue(core.getMessageProvider() instanceof LazyLocaleMessageProvider);
|
||||
|
||||
LazyLocaleMessageProvider messageProvider = (LazyLocaleMessageProvider) core.getMessageProvider();
|
||||
|
||||
// We have to reload it
|
||||
messageProvider.loadLocale(Locale.ENGLISH);
|
||||
|
||||
// And now test it
|
||||
String actual = core.getMessageProvider().getMessage(MultiverseMessage.TEST_STRING);
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
// Clean up afterwards:
|
||||
assertTrue(file.delete());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormat() {
|
||||
String testString = "%sthisisasimpletest&moretesting&&thatsit.";
|
||||
String result = SimpleMessageProvider.format(testString, "arg");
|
||||
assertEquals("argthisisasimpletest\u00A7moretesting&thatsit.", result);
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ public class TestWorldProperties {
|
||||
private Player mockNewPlayer;
|
||||
private PlayerJoinEvent playerNewJoinEvent;
|
||||
private PlayerJoinEvent playerJoinEvent;
|
||||
private PlayerRespawnEvent playerRespawnBed;
|
||||
private PlayerRespawnEvent playerRespawnNormal;
|
||||
private HumanEntity mockHumanEntity;
|
||||
private EntityRegainHealthEvent entityRegainHealthEvent;
|
||||
@@ -101,8 +102,8 @@ public class TestWorldProperties {
|
||||
// Import the first world
|
||||
String[] normalArgs = new String[] { "import", "world", "normal" };
|
||||
core.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
||||
//verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
||||
//verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Complete!");
|
||||
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
||||
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Complete!");
|
||||
|
||||
// Import a second world
|
||||
String[] netherArgs = new String[] { "import", "world_nether", "nether" };
|
||||
@@ -132,6 +133,7 @@ public class TestWorldProperties {
|
||||
assertEquals(ChatColor.WHITE, mvWorld.getColor());
|
||||
assertTrue(mvWorld.isPVPEnabled());
|
||||
assertEquals(1D, mvWorld.getScaling(), 0);
|
||||
assertNull(mvWorld.getRespawnToWorld());
|
||||
assertTrue(mvWorld.isWeatherEnabled());
|
||||
assertEquals(Difficulty.NORMAL, mvWorld.getDifficulty());
|
||||
assertTrue(mvWorld.canAnimalsSpawn());
|
||||
@@ -143,6 +145,7 @@ public class TestWorldProperties {
|
||||
assertTrue(mvWorld.getAdjustSpawn());
|
||||
assertEquals(GameMode.SURVIVAL, mvWorld.getGameMode());
|
||||
assertTrue(mvWorld.isKeepingSpawnInMemory());
|
||||
assertTrue(mvWorld.getBedRespawn());
|
||||
assertTrue(mvWorld.getAutoLoad());
|
||||
assertEquals(new SpawnLocation(0, 64, 0), mvWorld.getSpawnLocation());
|
||||
|
||||
@@ -165,6 +168,7 @@ public class TestWorldProperties {
|
||||
|
||||
// call player chat event
|
||||
core.getMVConfig().setPrefixChat(true);
|
||||
com.onarandombox.MultiverseCore.listeners.MVChatListener mvcl = core.getChatListener();
|
||||
((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
|
||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||
core.getMVConfig().setPrefixChat(false);
|
||||
@@ -177,9 +181,12 @@ public class TestWorldProperties {
|
||||
core.getPlayerListener().playerJoin(playerNewJoinEvent);
|
||||
verify(mockNewPlayer).teleport(worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||
|
||||
// call player respawn event
|
||||
//core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
//verify(playerRespawnNormal).setRespawnLocation(mvWorld.getSpawnLocation());
|
||||
// call player respawn events
|
||||
core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||
// bedrespawn is on so nothing should happen
|
||||
verify(playerRespawnBed, never()).setRespawnLocation(any(Location.class));
|
||||
core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
verify(playerRespawnNormal).setRespawnLocation(mvWorld.getSpawnLocation());
|
||||
|
||||
// call entity regain health event
|
||||
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
||||
@@ -202,6 +209,10 @@ public class TestWorldProperties {
|
||||
assertEquals(false, mvWorld.isPVPEnabled());
|
||||
assertTrue(mvWorld.setScaling(2D));
|
||||
assertEquals(2D, mvWorld.getScaling(), 0);
|
||||
assertFalse(mvWorld.setRespawnToWorld("INVALID WORLD"));
|
||||
assertTrue(mvWorld.setRespawnToWorld("world_nether"));
|
||||
assertSame(worldManager.getMVWorld("world_nether").getCBWorld(),
|
||||
mvWorld.getRespawnToWorld());
|
||||
mvWorld.setEnableWeather(false);
|
||||
assertEquals(false, mvWorld.isWeatherEnabled());
|
||||
assertTrue(mvWorld.setDifficulty(Difficulty.PEACEFUL));
|
||||
@@ -224,6 +235,8 @@ public class TestWorldProperties {
|
||||
assertEquals(GameMode.CREATIVE, mvWorld.getGameMode());
|
||||
mvWorld.setKeepSpawnInMemory(false);
|
||||
assertEquals(false, mvWorld.isKeepingSpawnInMemory());
|
||||
mvWorld.setBedRespawn(false);
|
||||
assertEquals(false, mvWorld.getBedRespawn());
|
||||
mvWorld.setAutoLoad(false);
|
||||
assertEquals(false, mvWorld.getAutoLoad());
|
||||
mvWorld.setSpawnLocation(new Location(mvWorld.getCBWorld(), 1, 1, 1));
|
||||
@@ -268,9 +281,12 @@ public class TestWorldProperties {
|
||||
core.getPlayerListener().playerJoin(playerNewJoinEvent);
|
||||
verify(mockNewPlayer).teleport(new SpawnLocation(1, 1, 1));
|
||||
|
||||
// call player respawn event
|
||||
//core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
//verify(playerRespawnNormal).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||
// call player respawn events
|
||||
core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||
// bedrespawn is off so something should happen (and we've set respawn to nether...)
|
||||
verify(playerRespawnBed).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||
core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
verify(playerRespawnNormal).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||
|
||||
// call entity regain health event
|
||||
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
||||
@@ -298,6 +314,8 @@ public class TestWorldProperties {
|
||||
assertEquals(ChatColor.GREEN.toString() + "alias" + ChatColor.WHITE.toString(), mvWorld.getColoredWorldString());
|
||||
assertEquals(false, mvWorld.isPVPEnabled());
|
||||
assertEquals(2D, mvWorld.getScaling(), 0);
|
||||
assertSame(worldManager.getMVWorld("world_nether").getCBWorld(),
|
||||
mvWorld.getRespawnToWorld());
|
||||
assertEquals(false, mvWorld.isWeatherEnabled());
|
||||
assertEquals(Difficulty.PEACEFUL, mvWorld.getDifficulty());
|
||||
assertEquals(false, mvWorld.canAnimalsSpawn());
|
||||
@@ -309,6 +327,7 @@ public class TestWorldProperties {
|
||||
assertEquals(false, mvWorld.getAdjustSpawn());
|
||||
assertEquals(GameMode.CREATIVE, mvWorld.getGameMode());
|
||||
assertEquals(false, mvWorld.isKeepingSpawnInMemory());
|
||||
assertEquals(false, mvWorld.getBedRespawn());
|
||||
assertEquals(false, mvWorld.getAutoLoad());
|
||||
assertEquals(new SpawnLocation(1, 1, 1), mvWorld.getSpawnLocation());
|
||||
}
|
||||
@@ -339,6 +358,9 @@ public class TestWorldProperties {
|
||||
playerNewJoinEvent = PowerMockito.mock(PlayerJoinEvent.class);
|
||||
when(playerNewJoinEvent.getPlayer()).thenReturn(mockNewPlayer);
|
||||
// player respawn
|
||||
playerRespawnBed = PowerMockito.mock(PlayerRespawnEvent.class);
|
||||
when(playerRespawnBed.getPlayer()).thenReturn(mockPlayer);
|
||||
when(playerRespawnBed.isBedSpawn()).thenReturn(true);
|
||||
playerRespawnNormal = PowerMockito.mock(PlayerRespawnEvent.class);
|
||||
when(playerRespawnNormal.getPlayer()).thenReturn(mockPlayer);
|
||||
when(playerRespawnNormal.isBedSpawn()).thenReturn(false);
|
||||
|
||||
@@ -194,7 +194,7 @@ public class TestWorldStuff {
|
||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||
|
||||
// Verify
|
||||
verify(mockCommandSender).sendMessage("Invalid generator! 'BogusGen'. " + ChatColor.RED + "Aborting world creation.");
|
||||
verify(mockCommandSender).sendMessage("Invalid generator 'BogusGen'! " + ChatColor.RED + "Aborting world creation.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.logging.LogRecord;
|
||||
public class MVTestLogFormatter extends Formatter {
|
||||
private static final DateFormat df = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.powermock.core.MockGateway;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import com.onarandombox.MultiverseCore.localization.MessageProvider;
|
||||
import com.onarandombox.MultiverseCore.localization.SimpleMessageProvider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -77,6 +79,7 @@ public class TestInstanceCreator {
|
||||
when(pdf.getAuthors()).thenReturn(new ArrayList<String>());
|
||||
doReturn(pdf).when(core).getDescription();
|
||||
doReturn(true).when(core).isEnabled();
|
||||
doReturn(null).when(core).getResource(anyString());
|
||||
core.setServerFolder(serverDirectory);
|
||||
|
||||
// Add Core to the list of loaded plugins
|
||||
@@ -200,6 +203,10 @@ public class TestInstanceCreator {
|
||||
worldmanagerfield.setAccessible(true);
|
||||
worldmanagerfield.set(core, wm);
|
||||
|
||||
// Set messageProvider
|
||||
MessageProvider messageProvider = PowerMockito.spy(new SimpleMessageProvider(core));
|
||||
core.setMessageProvider(messageProvider);
|
||||
|
||||
// Set playerListener
|
||||
MVPlayerListener pl = PowerMockito.spy(new MVPlayerListener(core));
|
||||
Field playerlistenerfield = MultiverseCore.class.getDeclaredField("playerListener");
|
||||
|
||||
@@ -28,6 +28,7 @@ public class WorldCreatorMatcher extends ArgumentMatcher<WorldCreator> {
|
||||
this.careAboutGenerators = doICare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object creator) {
|
||||
Util.log("Checking world creators.");
|
||||
if (creator == null) {
|
||||
|
||||
Reference in new issue
Block a user