released v0.3
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="C:/Users/Tom/Desktop/MC Servers/plugins/Metropolis-0.2.jar"/>
|
||||
<jar path="C:/Users/Tom/Desktop/MC Servers/plugins/Metropolis-0.3.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/Metropolis/Plugin.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
|
||||
@@ -12,9 +12,11 @@ INSTALL:
|
||||
To install just drop the jar into your plugins folder. All necessarry data will be created on first launch.
|
||||
|
||||
CONFIG:
|
||||
There are no configuration options currently, eventually block size, road width, road height and space above the road will be configurable.
|
||||
Edit the config.yml file. You can set the height to clear above roads, the road width, the plot size (incluing half the road width on either side), the road material, and the level at which the road is generated.
|
||||
|
||||
Changelog:
|
||||
v0.3
|
||||
Added command to generate a home for a user that is not currently logged in.
|
||||
v0.2.1
|
||||
Made config file save on load and disable.
|
||||
v0.2
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.majinnaibu.bukkit.plugins.metropolis.commands.MetropolisHomeGenerateCommand;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
@@ -112,6 +113,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
saveConfig();
|
||||
|
||||
getCommand("metropolis-home-generate").setExecutor(new MetropolisHomeGenerateCommand(this));
|
||||
|
||||
|
||||
/*
|
||||
Set<String>strings = config.getKeys(true);
|
||||
@@ -147,25 +150,13 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
PlayerHome getPlayerHome(Player player) {
|
||||
PlayerHome home = null;
|
||||
home = new PlayerHome();
|
||||
|
||||
String regionName = "h_" + player.getName();
|
||||
ProtectedRegion homeRegion = regionManager.getRegion(regionName);
|
||||
Cuboid plotCuboid = null;
|
||||
Cuboid homeCuboid = null;
|
||||
|
||||
log.info(homeRegion == null? "null" : homeRegion.toString());
|
||||
if(homeRegion == null){
|
||||
plotCuboid = findNextUnownedHomeRegion();
|
||||
homeCuboid = plotCuboid.inset(roadWidth/2, roadWidth/2);
|
||||
homeRegion = new ProtectedCuboidRegion(regionName, homeCuboid.getMin(), homeCuboid.getMax());
|
||||
DefaultDomain d = homeRegion.getOwners();
|
||||
d.addPlayer(player.getName());
|
||||
//TODO: set flags for chest protection
|
||||
homeRegion.setPriority(1);
|
||||
regionManager.addRegion(homeRegion);
|
||||
|
||||
createRoads(plotCuboid);
|
||||
home = generateHome(player.getName());
|
||||
}
|
||||
|
||||
return home;
|
||||
@@ -183,7 +174,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
/**/
|
||||
|
||||
private void createRoads(Cuboid plotCuboid) {
|
||||
log.info("createRoads");
|
||||
if(roadWidth>0){
|
||||
int x=0;
|
||||
int y= roadLevel;
|
||||
@@ -194,7 +184,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("road1");
|
||||
for(x=plotCuboid.minX; x<plotCuboid.minX + roadWidth/2; x++){
|
||||
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
@@ -206,7 +195,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
log.info("road2");
|
||||
for(x=plotCuboid.maxX - roadWidth/2+1; x<=plotCuboid.maxX; x++){
|
||||
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
@@ -218,7 +206,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
log.info("road3");
|
||||
for(z=plotCuboid.minZ; z<plotCuboid.minZ + roadWidth/2; z++){
|
||||
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
@@ -230,7 +217,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
log.info("road4");
|
||||
for(z=plotCuboid.maxZ - roadWidth/2+1; z<=plotCuboid.maxZ; z++){
|
||||
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
@@ -245,7 +231,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
private Cuboid findNextUnownedHomeRegion() {
|
||||
log.info("findNextUnownedHomeRegion");
|
||||
int homeIndex = 0;
|
||||
if(_occupiedHomes.size() == 0){
|
||||
if(size < 1){
|
||||
@@ -324,4 +309,23 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlayerHome generateHome(String string) {
|
||||
Cuboid plotCuboid = null;
|
||||
Cuboid homeCuboid = null;
|
||||
ProtectedRegion homeRegion = null;
|
||||
String regionName = "h_" + string;
|
||||
|
||||
plotCuboid = findNextUnownedHomeRegion();
|
||||
homeCuboid = plotCuboid.inset(roadWidth/2, roadWidth/2);
|
||||
homeRegion = new ProtectedCuboidRegion(regionName, homeCuboid.getMin(), homeCuboid.getMax());
|
||||
DefaultDomain d = homeRegion.getOwners();
|
||||
d.addPlayer(string);
|
||||
homeRegion.setPriority(1);
|
||||
regionManager.addRegion(homeRegion);
|
||||
|
||||
createRoads(plotCuboid);
|
||||
|
||||
return new PlayerHome(homeRegion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import javax.persistence.Table;
|
||||
import com.avaje.ebean.validation.NotNull;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
@Entity()
|
||||
@Table(name="met_home")
|
||||
@@ -29,14 +31,26 @@ public class PlayerHome implements Comparable<PlayerHome>{
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public PlayerHome(ProtectedCuboidRegion region){
|
||||
if(region.getId().startsWith("h_") && region.getId().length() > 2){
|
||||
this.playerName = region.getId().substring(2);
|
||||
public PlayerHome(ProtectedRegion homeRegion){
|
||||
if(homeRegion instanceof ProtectedCuboidRegion){
|
||||
ProtectedCuboidRegion cuboidRegion = (ProtectedCuboidRegion) homeRegion;
|
||||
if(cuboidRegion.getId().startsWith("h_") && cuboidRegion.getId().length() > 2){
|
||||
this.playerName = cuboidRegion.getId().substring(2);
|
||||
}else{
|
||||
this.playerName = region.getId();
|
||||
this.playerName = cuboidRegion.getId();
|
||||
}
|
||||
|
||||
this.cuboid = new Cuboid(region.getMinimumPoint(), region.getMaximumPoint());
|
||||
this.cuboid = new Cuboid(cuboidRegion.getMinimumPoint(), cuboidRegion.getMaximumPoint());
|
||||
}else if(homeRegion instanceof ProtectedPolygonalRegion){
|
||||
ProtectedPolygonalRegion polygonalRegion = (ProtectedPolygonalRegion)homeRegion;
|
||||
if(polygonalRegion.getId().startsWith("h_") && polygonalRegion.getId().length() > 2){
|
||||
this.playerName = polygonalRegion.getId().substring(2);
|
||||
}else{
|
||||
this.playerName = polygonalRegion.getId();
|
||||
}
|
||||
|
||||
this.cuboid = new Cuboid(polygonalRegion.getMinimumPoint(), polygonalRegion.getMaximumPoint());
|
||||
}
|
||||
}
|
||||
|
||||
public int getId(){return this.id;}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.majinnaibu.bukkit.plugins.metropolis.commands;
|
||||
|
||||
public class MetropolisCommand {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.majinnaibu.bukkit.plugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkit.plugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisHomeGenerateCommand implements CommandExecutor {
|
||||
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeGenerateCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
if(sender instanceof Player){
|
||||
player = (Player)sender;
|
||||
}
|
||||
|
||||
if(player != null){
|
||||
if(player.hasPermission("metropolis.generate")){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args.length < 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.generateHome(args[0]);
|
||||
|
||||
sender.sendMessage("[Metropolis] Home generated for " + args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Metropolis
|
||||
main: com.majinnaibu.bukkit.plugins.metropolis.MetropolisPlugin
|
||||
depend: [WorldEdit, WorldGuard]
|
||||
version: 0.2.1
|
||||
database: true
|
||||
|
||||
version: 0.3
|
||||
database: false
|
||||
commands:
|
||||
metropolis-home-generate:
|
||||
description: This command generates a home for a user as if they'd just logged in.
|
||||
permission: metropolis.generate
|
||||
usage: /metropolis-home-generate <playername>
|
||||
|
||||
Reference in New Issue
Block a user