mirror of
https://github.com/taoneill/war.git
synced 2024-11-10 20:50:04 +01:00
SpongeAPI 1.0
This commit is contained in:
parent
f6f7c91801
commit
99672561a1
@ -97,6 +97,10 @@
|
|||||||
<id>war-repo</id>
|
<id>war-repo</id>
|
||||||
<url>http://ci.tommytony.com/plugin/repository/everything/</url>
|
<url>http://ci.tommytony.com/plugin/repository/everything/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sponge-repo</id>
|
||||||
|
<url>http://repo.spongepowered.org/Sponge/maven/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -108,8 +112,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spongepowered</groupId>
|
<groupId>org.spongepowered</groupId>
|
||||||
<artifactId>SpongeAPI</artifactId>
|
<artifactId>spongeapi</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xerial</groupId>
|
<groupId>org.xerial</groupId>
|
||||||
|
@ -3,7 +3,7 @@ package com.tommytony.war;
|
|||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.tommytony.war.zone.ZoneConfig;
|
import com.tommytony.war.zone.ZoneConfig;
|
||||||
import org.spongepowered.api.entity.Player;
|
import org.spongepowered.api.entity.player.Player;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.tommytony.war;
|
package com.tommytony.war;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.api.Game;
|
import org.spongepowered.api.Game;
|
||||||
import org.spongepowered.api.event.SpongeEventHandler;
|
|
||||||
import org.spongepowered.api.event.state.PreInitializationEvent;
|
import org.spongepowered.api.event.state.PreInitializationEvent;
|
||||||
import org.spongepowered.api.event.state.ServerStartedEvent;
|
import org.spongepowered.api.event.state.ServerStartedEvent;
|
||||||
import org.spongepowered.api.event.state.ServerStartingEvent;
|
import org.spongepowered.api.event.state.ServerStartingEvent;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
|
import org.spongepowered.api.util.event.Subscribe;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -19,7 +19,7 @@ public class WarPlugin {
|
|||||||
private File dataDir;
|
private File dataDir;
|
||||||
private WarConfig config;
|
private WarConfig config;
|
||||||
|
|
||||||
@SpongeEventHandler
|
@Subscribe
|
||||||
public void onConstruction(PreInitializationEvent event) throws InstantiationException {
|
public void onConstruction(PreInitializationEvent event) throws InstantiationException {
|
||||||
game = event.getGame();
|
game = event.getGame();
|
||||||
logger = event.getPluginLog();
|
logger = event.getPluginLog();
|
||||||
@ -31,14 +31,14 @@ public class WarPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SpongeEventHandler
|
@Subscribe
|
||||||
public void onStartUp(ServerStartingEvent event) throws FileNotFoundException, SQLException {
|
public void onStartUp(ServerStartingEvent event) throws FileNotFoundException, SQLException {
|
||||||
if (!dataDir.exists() && !dataDir.mkdirs())
|
if (!dataDir.exists() && !dataDir.mkdirs())
|
||||||
throw new FileNotFoundException("Failed to make War data folder at " + dataDir.getPath());
|
throw new FileNotFoundException("Failed to make War data folder at " + dataDir.getPath());
|
||||||
config = new WarConfig(this, new File(dataDir, "war.sl3"));
|
config = new WarConfig(this, new File(dataDir, "war.sl3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SpongeEventHandler
|
@Subscribe
|
||||||
public void onStart(ServerStartedEvent event) {
|
public void onStart(ServerStartedEvent event) {
|
||||||
// register commands
|
// register commands
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package com.tommytony.war.command;
|
package com.tommytony.war.command;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.tommytony.war.WarConfig;
|
import com.tommytony.war.WarConfig;
|
||||||
import com.tommytony.war.WarPlugin;
|
import com.tommytony.war.WarPlugin;
|
||||||
import org.spongepowered.api.entity.Player;
|
import org.spongepowered.api.entity.player.Player;
|
||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
import org.spongepowered.api.util.command.CommandCallable;
|
import org.spongepowered.api.util.command.CommandCallable;
|
||||||
import org.spongepowered.api.util.command.CommandException;
|
import org.spongepowered.api.util.command.CommandException;
|
||||||
import org.spongepowered.api.util.command.CommandSource;
|
import org.spongepowered.api.util.command.CommandSource;
|
||||||
import org.spongepowered.api.util.command.Description;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -46,36 +43,6 @@ public class WarConfigCommand implements CommandCallable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a description of the command, detailing usage information.
|
|
||||||
*
|
|
||||||
* @return The command description
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Description getDescription() {
|
|
||||||
return new Description() {
|
|
||||||
@Override
|
|
||||||
public Optional<String> getShortDescription() {
|
|
||||||
return Optional.of("View/modify war config");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<String> getHelp() {
|
|
||||||
return Optional.of("Allows viewing of the war server config or changing various settings.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage() {
|
|
||||||
return "[-p] setting:value...";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getPermissions() {
|
|
||||||
return ImmutableList.of("war.admin", "war.admin.config");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether this command can probably be executed by the given source.
|
* Test whether this command can probably be executed by the given source.
|
||||||
* <p/>
|
* <p/>
|
||||||
@ -110,6 +77,39 @@ public class WarConfigCommand implements CommandCallable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a short one-line description of this command.
|
||||||
|
*
|
||||||
|
* @return A description, if available
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Optional<String> getShortDescription() {
|
||||||
|
return Optional.of("View/modify war config");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a longer help text about this command.
|
||||||
|
*
|
||||||
|
* @return A help text, if available
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Optional<String> getHelp() {
|
||||||
|
return Optional.of("Allows viewing of the war server config or changing various settings.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the usage string of this command.
|
||||||
|
* <p/>
|
||||||
|
* <p>A usage string may look like
|
||||||
|
* {@code [-w <world>] <var1> <var2>}.</p>
|
||||||
|
*
|
||||||
|
* @return A usage string
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "[-p] setting:value...";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of suggestions based on input.
|
* Get a list of suggestions based on input.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.tommytony.war.struct;
|
package com.tommytony.war.struct;
|
||||||
|
|
||||||
import org.spongepowered.api.block.Block;
|
import org.spongepowered.api.block.BlockLoc;
|
||||||
import org.spongepowered.api.math.Vector3d;
|
import org.spongepowered.api.math.Vector3d;
|
||||||
import org.spongepowered.api.world.Location;
|
import org.spongepowered.api.world.Location;
|
||||||
import org.spongepowered.api.world.extent.BlockVolume;
|
import org.spongepowered.api.world.extent.BlockVolume;
|
||||||
@ -84,7 +84,7 @@ public class Region implements BlockVolume {
|
|||||||
* @return The block
|
* @return The block
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Block getBlock(Vector3d position) {
|
public BlockLoc getBlock(Vector3d position) {
|
||||||
return first.getExtent().getBlock(position);
|
return first.getExtent().getBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class Region implements BlockVolume {
|
|||||||
* @return The block
|
* @return The block
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Block getBlock(int x, int y, int z) {
|
public BlockLoc getBlock(int x, int y, int z) {
|
||||||
return first.getExtent().getBlock(x, y, z);
|
return first.getExtent().getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user