Now all properties are settable ingame. (bugfix)

This commit is contained in:
main() 2012-05-02 16:25:40 +02:00
parent 96294c092c
commit 48768b5d6c
3 changed files with 69 additions and 6 deletions

View File

@ -198,7 +198,7 @@
<dependency>
<groupId>me.main__.util</groupId>
<artifactId>SerializationConfig</artifactId>
<version>1.5</version>
<version>1.6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

View File

@ -341,7 +341,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
private String alias;
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'color' must be a valid color-name.")
private EnglishChatColor color;
@Property(description = "Sorry, 'pvp' must either be: true or false.")
@Property(description = "Sorry, 'pvp' must either be: true or false.", virtualType = Boolean.class)
private VirtualProperty<Boolean> pvp = new VirtualProperty<Boolean>() {
@Override
public void set(Boolean newValue) {
@ -359,7 +359,8 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
private String respawnWorld;
@Property(validator = AllowWeatherPropertyValidator.class, description = "Sorry, this must either be: true or false.")
private boolean allowWeather;
@Property(serializor = DifficultyPropertySerializor.class, description = "Difficulty must be set as one of the following: peaceful easy normal hard")
@Property(serializor = DifficultyPropertySerializor.class, virtualType = Difficulty.class,
description = "Difficulty must be set as one of the following: peaceful easy normal hard")
private VirtualProperty<Difficulty> difficulty = new VirtualProperty<Difficulty>() {
@Override
public void set(Difficulty newValue) {
@ -388,7 +389,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
private GameMode gameMode;
@Property
private boolean keepSpawnLoaded;
@Property(description = "Sorry, this must either be: true or false.")
@Property(description = "Sorry, this must either be: true or false.", virtualType = Boolean.class)
private VirtualProperty<Boolean> keepSpawnInMemory = new VirtualProperty<Boolean>() {
@Override
public void set(Boolean newValue) {
@ -403,7 +404,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
};
@Property
private SpawnLocation spawnLocation;
@Property(validator = SpawnLocationPropertyValidator.class,
@Property(validator = SpawnLocationPropertyValidator.class, virtualType = Location.class,
description = "There is no help available for this variable. Go bug Rigby90 about it.")
private VirtualProperty<Location> spawn = new VirtualProperty<Location>() {
@Override
@ -429,7 +430,8 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
@Property
private List<String> worldBlacklist;
@SuppressWarnings("unused") // it IS used!
@Property(serializor = TimePropertySerializor.class, description = "Set the time to whatever you want! (Will NOT freeze time)")
@Property(serializor = TimePropertySerializor.class, virtualType = Long.class,
description = "Set the time to whatever you want! (Will NOT freeze time)")
private VirtualProperty<Long> time = new VirtualProperty<Long>() {
@Override
public void set(Long newValue) {

View File

@ -0,0 +1,61 @@
package com.onarandombox.MultiverseCore.test;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import org.bukkit.Server;
import org.bukkit.World.Environment;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
public class TestModifyCommand {
TestInstanceCreator creator;
Server mockServer;
MultiverseCore core;
CommandSender mockCommandSender;
@Before
public void setUp() throws Exception {
creator = new TestInstanceCreator();
assertTrue(creator.setUp());
mockServer = creator.getServer();
mockCommandSender = creator.getCommandSender();
core = creator.getCore();
// create world
assertTrue(core.getMVWorldManager().addWorld("world", Environment.NORMAL, null, null, null, null));
}
@After
public void tearDown() throws Exception {
creator.tearDown();
}
@Test
public void testSetHidden() {
Command cmd = mock(Command.class);
when(cmd.getName()).thenReturn("mv");
MultiverseWorld world = core.getMVWorldManager().getMVWorld("world");
assertNotNull(world);
assertFalse(world.isHidden()); // ensure it's not hidden now
assertTrue(core.onCommand(mockCommandSender, cmd, "", // run the command
new String[] { "modify", "set", "hidden", "true", "world" }));
assertTrue(world.isHidden()); // test if it worked
}
}