Compare commits
6 Commits
main
...
9ea0a5ec67
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ea0a5ec67 | |||
| 79fd24c12b | |||
| 6b601f8218 | |||
| 8ae8045729 | |||
| e7cf295207 | |||
| 0e69507c9b |
@@ -2,7 +2,7 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#Sat Mar 03 21:02:20 PST 2012
|
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|||||||
32
README.md
32
README.md
@@ -1,3 +1,4 @@
|
|||||||
|
# Description
|
||||||
Metropolis generates a home for each user connecting to your world with roads between them. As new users connect the city expands.
|
Metropolis generates a home for each user connecting to your world with roads between them. As new users connect the city expands.
|
||||||
|
|
||||||
WorldGuard regions are used for each home and for the city as a whole.
|
WorldGuard regions are used for each home and for the city as a whole.
|
||||||
@@ -8,40 +9,39 @@ Each user gets assigned a home region named "h_username" where username is repla
|
|||||||
|
|
||||||
After creation these regions can be modified as normal via WorldGuard commands.
|
After creation these regions can be modified as normal via WorldGuard commands.
|
||||||
|
|
||||||
INSTALL:
|
# Install
|
||||||
To install just drop the jar into your plugins folder. All necessarry data will be created on first launch.
|
To install just drop the jar into your plugins folder. All necessarry data will be created on first launch.
|
||||||
|
|
||||||
CONFIG:
|
# Config
|
||||||
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.
|
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:
|
# Changelog
|
||||||
v0.5
|
* v0.5
|
||||||
Added example docs
|
Added example docs
|
||||||
Added Commands to plugin.yml to move and evict homes
|
Added Commands to plugin.yml to move and evict homes
|
||||||
Added floor and road supports to config file and generation
|
Added floor and road supports to config file and generation
|
||||||
v0.4.6
|
* v0.4.6
|
||||||
Added optional generation of a sign identifying owner in plots on creation
|
Added optional generation of a sign identifying owner in plots on creation
|
||||||
Added a Cuboid constructor that takes a worldedit selection
|
Added a Cuboid constructor that takes a worldedit selection
|
||||||
Added a debug mode that enables extra logging. MetropolisPlugin.DEBUG should be true for snapshots and false for release builds.
|
Added a debug mode that enables extra logging. MetropolisPlugin.DEBUG should be true for snapshots and false for release builds.
|
||||||
Added an occupied Plots list to MetropolisPlugin to keep track of both player homes and reserved plots.
|
Added an occupied Plots list to MetropolisPlugin to keep track of both player homes and reserved plots.
|
||||||
Added the Plot class as a parent of PlayerHome and moved relevant code to it.
|
Added the Plot class as a parent of PlayerHome and moved relevant code to it.
|
||||||
Added a command to reserve plots that aren't tied to a player. This can be used to setup a larger protected area around spawn
|
Added a command to reserve plots that aren't tied to a player. This can be used to setup a larger protected area around spawn
|
||||||
v0.4.5
|
* v0.4.5
|
||||||
v0.4.4
|
* v0.4.4
|
||||||
Added a welcome message telling players where their home is.
|
Added a welcome message telling players where their home is.
|
||||||
Switched from PlayerLoginEvent to PlayerJoinEvent
|
Switched from PlayerLoginEvent to PlayerJoinEvent
|
||||||
v0.4.3
|
* v0.4.3
|
||||||
Removed call to saveconfig on plugin unload.
|
Removed call to saveconfig on plugin unload.
|
||||||
v0.4.2
|
* v0.4.2
|
||||||
Made city region refresh on server restart.
|
Made city region refresh on server restart.
|
||||||
v0.4.1
|
* v0.4.1
|
||||||
v0.4
|
* v0.4
|
||||||
v0.3
|
* v0.3
|
||||||
Added command to generate a home for a user that is not currently logged in.
|
Added command to generate a home for a user that is not currently logged in.
|
||||||
v0.2.1
|
* v0.2.1
|
||||||
Made config file save on load and disable.
|
Made config file save on load and disable.
|
||||||
v0.2
|
* v0.2
|
||||||
Added configuration options.
|
Added configuration options.
|
||||||
|
* v0.1
|
||||||
v0.1
|
|
||||||
Initial Release
|
Initial Release
|
||||||
16
pom.xml
16
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.majinnaibu.bukkitplugins</groupId>
|
<groupId>com.majinnaibu.bukkitplugins</groupId>
|
||||||
<artifactId>Metropolis</artifactId>
|
<artifactId>Metropolis</artifactId>
|
||||||
<version>0.5-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>Metropolis</name>
|
<name>Metropolis</name>
|
||||||
<description>Metropolis generates homes and streets for players as they connect to your server.</description>
|
<description>Metropolis generates homes and streets for players as they connect to your server.</description>
|
||||||
<url>http://www.github.com/headhunter45/Metropolis</url>
|
<url>http://www.github.com/headhunter45/Metropolis</url>
|
||||||
@@ -28,20 +28,24 @@
|
|||||||
<url>http://files.zachsthings.com/repo</url>
|
<url>http://files.zachsthings.com/repo</url>
|
||||||
</repository>
|
</repository>
|
||||||
-->
|
-->
|
||||||
|
<!-- WorldEdit/WorldGuard/CommandBook -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>sk89q</id>
|
<id>sk89q</id>
|
||||||
<url>http://mvn2.sk89q.com/repo</url>
|
<url>http://mvn2.sk89q.com/repo</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!-- Bukkit -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>bukkit-repo</id>
|
<id>bukkit-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!-- Spout -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype-nexus-releases</id>
|
<id>sonatype-nexus-releases</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/releases</url>
|
<url>https://oss.sonatype.org/content/repositories/releases</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype-nexus-snapshots</id>
|
<id>sonatype-nexus-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
@@ -90,5 +94,15 @@
|
|||||||
<version>1.0-beta-6</version>
|
<version>1.0-beta-6</version>
|
||||||
</extension>
|
</extension>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@@ -29,6 +28,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisCommand;
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisCommand;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugGenerateTestHomesCommand;
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugGenerateTestHomesCommand;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugGetMaterialCommand;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugMatchMaterialCommand;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisFlagResetCommand;
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisFlagResetCommand;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeEvictCommand;
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeEvictCommand;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeGenerateCommand;
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeGenerateCommand;
|
||||||
@@ -38,7 +39,6 @@ import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeMoveComman
|
|||||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotGoCommand;
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotGoCommand;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotReserveCommand;
|
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotReserveCommand;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.eventlisteners.PlayerJoinListener;
|
import com.majinnaibu.bukkitplugins.metropolis.eventlisteners.PlayerJoinListener;
|
||||||
import com.sk89q.util.yaml.YAMLProcessor;
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
@@ -66,9 +66,9 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
public RegionManager regionManager = null;
|
public RegionManager regionManager = null;
|
||||||
|
|
||||||
private List<Plot> _occupiedPlots;
|
private List<Plot> _occupiedPlots;
|
||||||
private HashMap<String, List<Plot>> _ownedPlots;
|
private HashMap<UUID, List<Plot>> _ownedPlots;
|
||||||
private HashMap<String, UserOverride> _userOverrides;
|
private HashMap<String, UserOverride> _userOverrides;
|
||||||
private HashMap<String, Integer> _currentHomes;
|
private HashMap<UUID, Integer> _currentHomes;
|
||||||
|
|
||||||
private PlayerJoinListener _playerJoinListener = null;
|
private PlayerJoinListener _playerJoinListener = null;
|
||||||
|
|
||||||
@@ -117,16 +117,17 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
pdf = getDescription();
|
pdf = getDescription();
|
||||||
|
|
||||||
_ownedPlots = new HashMap<String, List<Plot>>();
|
_ownedPlots = new HashMap<UUID, List<Plot>>();
|
||||||
_userOverrides = new HashMap<String, UserOverride>();
|
_userOverrides = new HashMap<String, UserOverride>();
|
||||||
_currentHomes = new HashMap<String, Integer>();
|
_currentHomes = new HashMap<UUID, Integer>();
|
||||||
loadCurrentHomes();
|
loadCurrentHomes();
|
||||||
|
|
||||||
if(DEBUG){log.info("Checking config");}
|
if(DEBUG){log.info("Checking config");}
|
||||||
Configuration config = getConfig();
|
Configuration config = getConfig();
|
||||||
if(!config.contains("version")){
|
if(!config.contains("version")){
|
||||||
//new
|
|
||||||
if(DEBUG){log.info("No config exists. Assuming new installation.");}
|
if(DEBUG){log.info("No config exists. Assuming new installation.");}
|
||||||
|
config.set("version", version);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
int configVersion = safeGetIntFromConfig(config, "version");
|
int configVersion = safeGetIntFromConfig(config, "version");
|
||||||
if(configVersion < version){
|
if(configVersion < version){
|
||||||
@@ -135,14 +136,10 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
//upgrade config
|
//upgrade config
|
||||||
config.set("version", version);
|
config.set("version", version);
|
||||||
}
|
}
|
||||||
saveConfig();
|
|
||||||
if(DEBUG){log.info("Config updated");}
|
if(DEBUG){log.info("Config updated");}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.set("version", version);
|
|
||||||
saveConfig();
|
|
||||||
|
|
||||||
config.options().copyDefaults(true);
|
config.options().copyDefaults(true);
|
||||||
|
|
||||||
if(DEBUG){log.info("Reading configuration from file.");}
|
if(DEBUG){log.info("Reading configuration from file.");}
|
||||||
@@ -165,7 +162,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
spawnFloorMaterial = safeGetMaterialFromConfig(config, "spawn.material");
|
spawnFloorMaterial = safeGetMaterialFromConfig(config, "spawn.material");
|
||||||
generateWall = safeGetBooleanFromConfig(config, "wall.generate");
|
generateWall = safeGetBooleanFromConfig(config, "wall.generate");
|
||||||
wallMaterial = safeGetMaterialFromConfig(config, "wall.material");
|
wallMaterial = safeGetMaterialFromConfig(config, "wall.material");
|
||||||
wallHeight = safeGetIntFromConfig(config, "wall.material");
|
wallHeight = safeGetIntFromConfig(config, "wall.height");
|
||||||
worldName = safeGetStringFromConfig(config, "worldname");
|
worldName = safeGetStringFromConfig(config, "worldname");
|
||||||
_maxPlots = safeGetIntFromConfig(config, "plot.multiplier");
|
_maxPlots = safeGetIntFromConfig(config, "plot.multiplier");
|
||||||
_plotMultiplier = safeGetIntFromConfig(config, "plot.maxPerPlayer");
|
_plotMultiplier = safeGetIntFromConfig(config, "plot.maxPerPlayer");
|
||||||
@@ -284,6 +281,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
RegisterCommandHandler("metropolis", new MetropolisCommand(this));
|
RegisterCommandHandler("metropolis", new MetropolisCommand(this));
|
||||||
|
|
||||||
RegisterCommandHandler("metropolis-debug-generatetesthomes", new MetropolisDebugGenerateTestHomesCommand(this));
|
RegisterCommandHandler("metropolis-debug-generatetesthomes", new MetropolisDebugGenerateTestHomesCommand(this));
|
||||||
|
RegisterCommandHandler("metropolis-debug-getmaterial", new MetropolisDebugGetMaterialCommand(this));
|
||||||
|
RegisterCommandHandler("metropolis-debug-matchmaterial", new MetropolisDebugMatchMaterialCommand(this));
|
||||||
|
|
||||||
RegisterCommandHandler("metropolis-flag-reset", new MetropolisFlagResetCommand(this));
|
RegisterCommandHandler("metropolis-flag-reset", new MetropolisFlagResetCommand(this));
|
||||||
|
|
||||||
@@ -298,20 +297,20 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadCurrentHomes() {
|
private void loadCurrentHomes() {
|
||||||
YAMLProcessor processor = new YAMLProcessor(new File(getDataFolder(), "currentHomes.yml"), true);
|
// YAMLProcessor processor = new YAMLProcessor(new File(getDataFolder(), "currentHomes.yml"), true);
|
||||||
try {
|
// try {
|
||||||
processor.load();
|
// processor.load();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.info(e.toString());
|
// log.info(e.toString());
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Set<String> keys = processor.getMap().keySet();
|
// Set<String> keys = processor.getMap().keySet();
|
||||||
|
//
|
||||||
_currentHomes.clear();
|
// _currentHomes.clear();
|
||||||
for(String username : keys){
|
// for(String username : keys){
|
||||||
_currentHomes.put(username, processor.getInt(username, 0));
|
// _currentHomes.put(username, processor.getInt(username, 0));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildUserOverrides() {
|
private void buildUserOverrides() {
|
||||||
@@ -352,6 +351,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private Cuboid getCuboid(int row, int col) {
|
private Cuboid getCuboid(int row, int col) {
|
||||||
//This is only used for debug info
|
//This is only used for debug info
|
||||||
BlockVector min = getPlotMin(row, col, 1);
|
BlockVector min = getPlotMin(row, col, 1);
|
||||||
@@ -396,12 +396,10 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Material safeGetMaterialFromConfig(Configuration config, String name){
|
private Material safeGetMaterialFromConfig(Configuration config, String name){
|
||||||
Material material = null;
|
Material material = Material.AIR;
|
||||||
if(config.isInt(name)){
|
if(config.isString(name)){
|
||||||
material = Material.getMaterial(config.getInt(name));
|
material = Material.matchMaterial(config.getString(name));
|
||||||
}else if(config.isString(name)){
|
if(material == null){
|
||||||
material = Material.getMaterial(config.getString(name));
|
|
||||||
if(material== null){
|
|
||||||
material = Material.matchMaterial(config.getString(name));
|
material = Material.matchMaterial(config.getString(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -410,7 +408,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void throwInvalidConfigException() {
|
private void throwInvalidConfigException() {
|
||||||
log.info("Metropolis: ERROR config file is invalid. Please correct Metropolis/config.yml and restart the server.");
|
log.info("Metropolis: ERROR config file is invalid. Please correct or delete plugins/Metropolis/config.yml and restart the server.");
|
||||||
throw new RuntimeException("Config file is invalid.");
|
throw new RuntimeException("Config file is invalid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,12 +452,12 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
ProtectedCuboidRegion cuboidRegion = (ProtectedCuboidRegion) region;
|
ProtectedCuboidRegion cuboidRegion = (ProtectedCuboidRegion) region;
|
||||||
if(cuboidRegion.getId().startsWith("h_")){
|
if(cuboidRegion.getId().startsWith("h_")){
|
||||||
PlayerHome home = PlayerHome.get(region);
|
PlayerHome home = PlayerHome.get(region);
|
||||||
if(!_currentHomes.containsKey(home.getPlayerName()))
|
if(!_currentHomes.containsKey(home.getPlayerUUID()))
|
||||||
{
|
{
|
||||||
_currentHomes.put(home.getPlayerName(), home.getNumber());
|
_currentHomes.put(home.getPlayerUUID(), home.getNumber());
|
||||||
}
|
}
|
||||||
_occupiedPlots.add(home);
|
_occupiedPlots.add(home);
|
||||||
addOwnedPlot(home.getPlayerName(), home);
|
addOwnedPlot(home.getPlayerUUID(), home);
|
||||||
}else if(cuboidRegion.getId().startsWith("r_")){
|
}else if(cuboidRegion.getId().startsWith("r_")){
|
||||||
_occupiedPlots.add(Plot.get(cuboidRegion));
|
_occupiedPlots.add(Plot.get(cuboidRegion));
|
||||||
}
|
}
|
||||||
@@ -469,14 +467,14 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
size=calculateCitySize();
|
size=calculateCitySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOwnedPlot(String substring, Plot plot) {
|
private void addOwnedPlot(UUID playerUUID, Plot plot) {
|
||||||
if(_ownedPlots.containsKey(substring)){
|
if(_ownedPlots.containsKey(playerUUID)){
|
||||||
List<Plot> plots = _ownedPlots.get(substring);
|
List<Plot> plots = _ownedPlots.get(playerUUID);
|
||||||
plots.add(plot);
|
plots.add(plot);
|
||||||
}else{
|
}else{
|
||||||
List<Plot> plots = new ArrayList<Plot>();
|
List<Plot> plots = new ArrayList<Plot>();
|
||||||
plots.add(plot);
|
plots.add(plot);
|
||||||
_ownedPlots.put(substring, plots);
|
_ownedPlots.put(playerUUID, plots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,14 +486,14 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
public PlayerHome getPlayerHome(Player player) {
|
public PlayerHome getPlayerHome(Player player) {
|
||||||
PlayerHome home = null;
|
PlayerHome home = null;
|
||||||
|
|
||||||
String regionName = "h_" + player.getName();
|
String regionName = "h_1_" + player.getUniqueId().toString();
|
||||||
ProtectedRegion homeRegion = regionManager.getRegion(regionName);
|
ProtectedRegion homeRegion = regionManager.getRegion(regionName);
|
||||||
|
|
||||||
if(homeRegion == null){
|
if(homeRegion == null){
|
||||||
if(DEBUG){
|
if(DEBUG){
|
||||||
log.info(String.format("Creating home for player %s", player.getName()));
|
log.info(String.format("Creating home for player %s", player.getName()));
|
||||||
}
|
}
|
||||||
home = generateHome(player.getName());
|
home = generateHome(player);
|
||||||
}else{
|
}else{
|
||||||
home = new PlayerHome(homeRegion);
|
home = new PlayerHome(homeRegion);
|
||||||
}
|
}
|
||||||
@@ -830,7 +828,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
return (cuboid.minZ - roadWidth/2)/gridSizeZ;
|
return (cuboid.minZ - roadWidth/2)/gridSizeZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHomeOccupied(String owner, BlockVector minimumPoint, BlockVector maximumPoint) {
|
private void setHomeOccupied(OfflinePlayer owner, BlockVector minimumPoint, BlockVector maximumPoint) {
|
||||||
|
|
||||||
PlayerHome home = new PlayerHome(owner, minimumPoint, maximumPoint);
|
PlayerHome home = new PlayerHome(owner, minimumPoint, maximumPoint);
|
||||||
if(!_occupiedPlots.contains(home)){
|
if(!_occupiedPlots.contains(home)){
|
||||||
@@ -838,13 +836,13 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerHome generateHome(String playerName) {
|
public PlayerHome generateHome(OfflinePlayer playerName) {
|
||||||
int multiplier = getPlotMultiplier(playerName);
|
int multiplier = getPlotMultiplier(playerName.getName());
|
||||||
|
|
||||||
if(DEBUG){log.info(String.format("Generating home for %s", playerName));}
|
if(DEBUG){log.info(String.format("Generating home for %s", playerName.getName()));}
|
||||||
Cuboid homeCuboid = null;
|
Cuboid homeCuboid = null;
|
||||||
ProtectedRegion phomeRegion = null;
|
ProtectedRegion phomeRegion = null;
|
||||||
String regionName = "h_1_" + playerName;
|
String regionName = "h_1_" + playerName.getUniqueId();
|
||||||
phomeRegion = regionManager.getRegion(regionName);
|
phomeRegion = regionManager.getRegion(regionName);
|
||||||
if(phomeRegion != null){
|
if(phomeRegion != null){
|
||||||
return PlayerHome.get(phomeRegion);
|
return PlayerHome.get(phomeRegion);
|
||||||
@@ -864,7 +862,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
newHomeRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
newHomeRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||||
|
|
||||||
DefaultDomain d = newHomeRegion.getOwners();
|
DefaultDomain d = newHomeRegion.getOwners();
|
||||||
d.addPlayer(playerName);
|
d.addPlayer(playerName.getName());
|
||||||
newHomeRegion.setPriority(1);
|
newHomeRegion.setPriority(1);
|
||||||
|
|
||||||
regionManager.addRegion(newHomeRegion);
|
regionManager.addRegion(newHomeRegion);
|
||||||
@@ -901,10 +899,10 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
if(DEBUG){log.info(String.format("generateSign: %s", String.valueOf(generateSign)));}
|
if(DEBUG){log.info(String.format("generateSign: %s", String.valueOf(generateSign)));}
|
||||||
if(generateSign){
|
if(generateSign){
|
||||||
generateSign(homeCuboid, playerName);
|
generateSign(homeCuboid, playerName.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DEBUG){log.info(String.format("Done generating home for %s", playerName));}
|
if(DEBUG){log.info(String.format("Done generating home for %s", playerName.getName()));}
|
||||||
|
|
||||||
return new PlayerHome(newHomeRegion);
|
return new PlayerHome(newHomeRegion);
|
||||||
}
|
}
|
||||||
@@ -1018,7 +1016,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
public void assignPlot(OfflinePlayer player) {
|
public void assignPlot(OfflinePlayer player) {
|
||||||
//PlayerHome home = generateHome(player.getName());
|
//PlayerHome home = generateHome(player.getName());
|
||||||
generateHome(player.getName());
|
generateHome(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPlotMultiplier(String name) {
|
private int getPlotMultiplier(String name) {
|
||||||
@@ -1044,12 +1042,33 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public Player getPlayer(String name) {
|
public Player getPlayer(String name) {
|
||||||
return getServer().getPlayer(name);
|
Player player = null;
|
||||||
|
UUID playerUUID = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
playerUUID = UUID.fromString(name);
|
||||||
|
player = Bukkit.getPlayer(playerUUID);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
player = Bukkit.getPlayer(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return player; }
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public OfflinePlayer getOfflinePlayer(String name){
|
public OfflinePlayer getOfflinePlayer(String name){
|
||||||
return getServer().getOfflinePlayer(name);
|
OfflinePlayer player = null;
|
||||||
|
UUID playerUUID = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
playerUUID = UUID.fromString(name);
|
||||||
|
player = Bukkit.getOfflinePlayer(playerUUID);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
player = Bukkit.getOfflinePlayer(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String teleportPlayerToPlot(Player player, Plot plot) {
|
public String teleportPlayerToPlot(Player player, Plot plot) {
|
||||||
@@ -1062,9 +1081,9 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean homeExists(String playerName, int homeNumber) {
|
public boolean homeExists(UUID playerUUID, int homeNumber) {
|
||||||
for(Plot plot: _occupiedPlots){
|
for(Plot plot: _occupiedPlots){
|
||||||
if(plot.getRegionName().equalsIgnoreCase(String.format("h_%d_%s", homeNumber, playerName))){
|
if(plot.getRegionName().equalsIgnoreCase(String.format("h_%d_%s", homeNumber, playerUUID.toString()))){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1072,13 +1091,13 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHome(String name, int newHomeNumber) {
|
public void setHome(UUID playerUUID, int newHomeNumber) {
|
||||||
_currentHomes.put(name, newHomeNumber);
|
_currentHomes.put(playerUUID, newHomeNumber);
|
||||||
saveCurrentHomes();
|
saveCurrentHomes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCurrentHomes() {
|
private void saveCurrentHomes() {
|
||||||
File outFile = new File(getDataFolder(), "currentHomes.yml");
|
//File outFile = new File(getDataFolder(), "currentHomes.yml");
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import com.avaje.ebean.validation.NotNull;
|
import com.avaje.ebean.validation.NotNull;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
@@ -12,22 +16,30 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|||||||
@Table(name="Metropolis_PlayerHome")
|
@Table(name="Metropolis_PlayerHome")
|
||||||
public class PlayerHome extends Plot{
|
public class PlayerHome extends Plot{
|
||||||
@NotNull
|
@NotNull
|
||||||
private String playerName;
|
private UUID playerUUID = null;
|
||||||
public String getPlayerName(){return this.playerName;}
|
public UUID getPlayerUUID(){return this.playerUUID;}
|
||||||
public void setPlayerName(String playerName){this.playerName = playerName;}
|
public void setPlayerUUID(UUID playerUUID){this.playerUUID = playerUUID;}
|
||||||
|
|
||||||
private int number;
|
private int number;
|
||||||
|
|
||||||
public PlayerHome(String owner, BlockVector min, BlockVector max) {
|
public PlayerHome(UUID owner, BlockVector min, BlockVector max) {
|
||||||
super("h_" + owner, min, max);
|
super("h_1_" + owner, min, max);
|
||||||
this.playerName = owner;
|
this.playerUUID = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerHome(OfflinePlayer owner, BlockVector min, BlockVector max) {
|
||||||
|
super("h_1_" + owner.getUniqueId(), min, max);
|
||||||
|
this.playerUUID = owner.getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerHome() {
|
public PlayerHome() {
|
||||||
this.playerName = "";
|
this.playerUUID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerHome(ProtectedRegion homeRegion){
|
public PlayerHome(ProtectedRegion homeRegion){
|
||||||
|
this.playerUUID = null;
|
||||||
|
this.number = 0;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
String rname = homeRegion.getId();
|
String rname = homeRegion.getId();
|
||||||
|
|
||||||
@@ -36,13 +48,12 @@ public class PlayerHome extends Plot{
|
|||||||
if(secondUnderscore > 2){
|
if(secondUnderscore > 2){
|
||||||
try{
|
try{
|
||||||
this.number = Integer.parseInt(rname.substring(2, secondUnderscore));
|
this.number = Integer.parseInt(rname.substring(2, secondUnderscore));
|
||||||
this.playerName = rname.substring(secondUnderscore+1);
|
this.playerUUID = UUID.fromString(rname.substring(secondUnderscore+1));
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
this.number = 0;
|
this.number = 0;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
this.number = 0;
|
this.number = 0;
|
||||||
this.playerName = rname.substring(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setCuboid(new Cuboid(homeRegion.getMinimumPoint(), homeRegion.getMaximumPoint()));
|
setCuboid(new Cuboid(homeRegion.getMinimumPoint(), homeRegion.getMaximumPoint()));
|
||||||
@@ -63,7 +74,7 @@ public class PlayerHome extends Plot{
|
|||||||
|
|
||||||
PlayerHome otherPlayerHome = (PlayerHome)other;
|
PlayerHome otherPlayerHome = (PlayerHome)other;
|
||||||
|
|
||||||
if(!this.playerName.equals(otherPlayerHome.playerName)){
|
if(!this.playerUUID.equals(otherPlayerHome.playerUUID)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +88,7 @@ public class PlayerHome extends Plot{
|
|||||||
public String toFriendlyString() {
|
public String toFriendlyString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(String.format("Metropolis Home {Owner: %s min: (%d, %d, %d) max: (%d, %d, %d)}", getPlayerName(), getCuboid().getMinX(), getCuboid().getMinY(), getCuboid().getMinZ(), getCuboid().getMaxX(), getCuboid().getMaxY(), getCuboid().getMaxZ()));
|
sb.append(String.format("Metropolis Home {Owner: %s min: (%d, %d, %d) max: (%d, %d, %d)}", getPlayerUUID(), getCuboid().getMinX(), getCuboid().getMinY(), getCuboid().getMinZ(), getCuboid().getMaxX(), getCuboid().getMaxY(), getCuboid().getMaxZ()));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -20,7 +21,7 @@ public class MetropolisDebugGenerateTestHomesCommand implements CommandExecutor
|
|||||||
try{
|
try{
|
||||||
int numHomes = Integer.parseInt(args[0]);
|
int numHomes = Integer.parseInt(args[0]);
|
||||||
for(int i=1; i<= numHomes; i++){
|
for(int i=1; i<= numHomes; i++){
|
||||||
_plugin.generateHome(String.format("test%d", i));
|
_plugin.generateHome(Bukkit.getOfflinePlayer(String.format("test%d", i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
|
public class MetropolisDebugGetMaterialCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private MetropolisPlugin _plugin;
|
||||||
|
|
||||||
|
public MetropolisDebugGetMaterialCommand(MetropolisPlugin plugin) {
|
||||||
|
_plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
try {
|
||||||
|
sender.sendMessage(String.format("Material.getMaterial(\"%s\") returns \"%s\"", args[0], Material.getMaterial(args[0])));
|
||||||
|
return true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
_plugin.getLogger().log(Level.ALL, "Error", ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
|
public class MetropolisDebugMatchMaterialCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private MetropolisPlugin _plugin;
|
||||||
|
|
||||||
|
public MetropolisDebugMatchMaterialCommand(MetropolisPlugin plugin) {
|
||||||
|
_plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
try {
|
||||||
|
sender.sendMessage(String.format("Material.getMaterial(\"%s\") returns \"%s\"", String.join(" ", args), Material.matchMaterial(args[0])));
|
||||||
|
return true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
_plugin.getLogger().log(Level.ALL, "Error", ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,31 +18,33 @@ public class MetropolisHomeEvictCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
//get the player and region
|
//get the player and region
|
||||||
String playerName = "";
|
String targetUUIDString = null;
|
||||||
|
|
||||||
|
OfflinePlayer targetPlayer = null;
|
||||||
|
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length >= 1){
|
if(args.length >= 1){
|
||||||
playerName = args[0];
|
targetUUIDString = args[0];
|
||||||
|
targetPlayer = _plugin.getOfflinePlayer(targetUUIDString);
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer player = _plugin.getServer().getOfflinePlayer(playerName);
|
if(targetPlayer == null){
|
||||||
if(player == null){
|
sender.sendMessage(String.format("The requested player {%s}does not appear to exist.", targetUUIDString));
|
||||||
sender.sendMessage(String.format("The requested player {%s}does not appear to exist.", playerName));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion region = _plugin.getRegion(String.format("h_%s", player.getName()));
|
ProtectedRegion region = _plugin.getRegion(String.format("h_%s", targetPlayer.getUniqueId().toString()));
|
||||||
if(region == null){
|
if(region == null){
|
||||||
sender.sendMessage(String.format("The player {%s} has no home to be evicted from."));
|
sender.sendMessage(String.format("The player {%s} has no home to be evicted from."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove the player as owner and/or member of the region
|
//remove the player as owner and/or member of the region
|
||||||
region.getMembers().removePlayer(playerName);
|
region.getMembers().removePlayer(targetPlayer.getName());//playerName);
|
||||||
region.getOwners().removePlayer(playerName);
|
region.getOwners().removePlayer(targetPlayer.getName());
|
||||||
|
|
||||||
//if the region has no owners delete the region
|
//if the region has no owners delete the region
|
||||||
if(region.getMembers().size() == 0 && region.getOwners().size() == 0){
|
if(region.getMembers().size() == 0 && region.getOwners().size() == 0){
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -14,13 +15,14 @@ public class MetropolisHomeGenerateCommand implements CommandExecutor {
|
|||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(args.length < 1){
|
if(args.length < 1){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_plugin.generateHome(args[0]);
|
_plugin.generateHome(Bukkit.getOfflinePlayer(args[0]));
|
||||||
|
|
||||||
sender.sendMessage("[Metropolis] Home generated for " + args[0]);
|
sender.sendMessage("[Metropolis] Home generated for " + args[0]);
|
||||||
|
|
||||||
|
|||||||
@@ -21,33 +21,10 @@ public class MetropolisHomeGoCommand implements CommandExecutor {
|
|||||||
Player player = null;
|
Player player = null;
|
||||||
if(sender instanceof Player){
|
if(sender instanceof Player){
|
||||||
player = (Player)sender;
|
player = (Player)sender;
|
||||||
|
|
||||||
if(args.length >= 1){
|
|
||||||
if(player.hasPermission("")){
|
|
||||||
player = _plugin.getServer().getPlayer(args[0]);
|
|
||||||
|
|
||||||
if(player == null){
|
|
||||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
sender.sendMessage("Permission denied");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(args.length >= 1){
|
|
||||||
player = _plugin.getServer().getPlayer(args[0]);
|
|
||||||
|
|
||||||
if(player == null){
|
|
||||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
sender.sendMessage("You must be a player");
|
sender.sendMessage("You must be a player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PlayerHome home = _plugin.getPlayerHome(player);
|
PlayerHome home = _plugin.getPlayerHome(player);
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ public class MetropolisHomeMoveCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player == null || !_plugin.homeExists(player.getName(), newHomeNumber)){
|
if(player == null || !_plugin.homeExists(player.getUniqueId(), newHomeNumber)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_plugin.setHome(player.getName(), newHomeNumber);
|
_plugin.setHome(player.getUniqueId(), newHomeNumber);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis.util;
|
|
||||||
|
|
||||||
public class Material {
|
|
||||||
public static final int signTypeId = 63;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
//From evilmidget38 at https://gist.github.com/evilmidget38/a5c971d2f2b2c3b3fb37
|
||||||
|
package com.majinnaibu.bukkitplugins.metropolis.util;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
public class NameFetcher implements Callable<Map<UUID, String>> {
|
||||||
|
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||||
|
private final JSONParser jsonParser = new JSONParser();
|
||||||
|
private final List<UUID> uuids;
|
||||||
|
public NameFetcher(List<UUID> uuids) {
|
||||||
|
this.uuids = ImmutableList.copyOf(uuids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<UUID, String> call() throws Exception {
|
||||||
|
Map<UUID, String> uuidStringMap = new HashMap<UUID, String>();
|
||||||
|
for (UUID uuid: uuids) {
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL+uuid.toString().replace("-", "")).openConnection();
|
||||||
|
JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||||
|
String name = (String) response.get("name");
|
||||||
|
if (name == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String cause = (String) response.get("cause");
|
||||||
|
String errorMessage = (String) response.get("errorMessage");
|
||||||
|
if (cause != null && cause.length() > 0) {
|
||||||
|
throw new IllegalStateException(errorMessage);
|
||||||
|
}
|
||||||
|
uuidStringMap.put(uuid, name);
|
||||||
|
}
|
||||||
|
return uuidStringMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
//From evilmidget38 at https://gist.github.com/evilmidget38/26d70114b834f71fb3b4
|
||||||
|
package com.majinnaibu.bukkitplugins.metropolis.util;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||||
|
private static final double PROFILES_PER_REQUEST = 100;
|
||||||
|
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
||||||
|
private final JSONParser jsonParser = new JSONParser();
|
||||||
|
private final List<String> names;
|
||||||
|
private final boolean rateLimiting;
|
||||||
|
|
||||||
|
public UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||||
|
this.names = ImmutableList.copyOf(names);
|
||||||
|
this.rateLimiting = rateLimiting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUIDFetcher(List<String> names) {
|
||||||
|
this(names, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, UUID> call() throws Exception {
|
||||||
|
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||||
|
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
||||||
|
for (int i = 0; i < requests; i++) {
|
||||||
|
HttpURLConnection connection = createConnection();
|
||||||
|
String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
|
||||||
|
writeBody(connection, body);
|
||||||
|
JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||||
|
for (Object profile : array) {
|
||||||
|
JSONObject jsonProfile = (JSONObject) profile;
|
||||||
|
String id = (String) jsonProfile.get("id");
|
||||||
|
String name = (String) jsonProfile.get("name");
|
||||||
|
UUID uuid = UUIDFetcher.getUUID(id);
|
||||||
|
uuidMap.put(name, uuid);
|
||||||
|
}
|
||||||
|
if (rateLimiting && i != requests - 1) {
|
||||||
|
Thread.sleep(100L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uuidMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
|
||||||
|
OutputStream stream = connection.getOutputStream();
|
||||||
|
stream.write(body.getBytes());
|
||||||
|
stream.flush();
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpURLConnection createConnection() throws Exception {
|
||||||
|
URL url = new URL(PROFILE_URL);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UUID getUUID(String id) {
|
||||||
|
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" +id.substring(20, 32));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] toBytes(UUID uuid) {
|
||||||
|
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
|
||||||
|
byteBuffer.putLong(uuid.getMostSignificantBits());
|
||||||
|
byteBuffer.putLong(uuid.getLeastSignificantBits());
|
||||||
|
return byteBuffer.array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID fromBytes(byte[] array) {
|
||||||
|
if (array.length != 16) {
|
||||||
|
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
|
||||||
|
}
|
||||||
|
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
|
||||||
|
long mostSignificant = byteBuffer.getLong();
|
||||||
|
long leastSignificant = byteBuffer.getLong();
|
||||||
|
return new UUID(mostSignificant, leastSignificant);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID getUUIDOf(String name) throws Exception {
|
||||||
|
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,26 +4,27 @@ plot:
|
|||||||
sizeZ: 32
|
sizeZ: 32
|
||||||
offsetX: 0
|
offsetX: 0
|
||||||
offsetY: 0
|
offsetY: 0
|
||||||
offsetZ: 0
|
offsetZ: 0
|
||||||
multiplier: 1
|
multiplier: 1
|
||||||
maxPerPlayer: 1
|
maxPerPlayer: 1
|
||||||
initial: 1
|
initial: 1
|
||||||
floor:
|
floor:
|
||||||
generate: true
|
generate: true
|
||||||
|
clearSpaceAbove: 66
|
||||||
material: GRASS
|
material: GRASS
|
||||||
supports:
|
supports:
|
||||||
generate: true
|
generate: true
|
||||||
generate: true
|
material: STONE
|
||||||
sign:
|
sign:
|
||||||
generate: true
|
generate: true
|
||||||
generate: true
|
road:
|
||||||
width: 4
|
width: 4
|
||||||
clearSpaceAbove: 66
|
clearSpaceAbove: 66
|
||||||
level: 62
|
level: 62
|
||||||
level: 62
|
material: COBBLESTONE
|
||||||
supports:
|
supports:
|
||||||
generate: true
|
generate: true
|
||||||
generate: true
|
material: STONE
|
||||||
spawn:
|
spawn:
|
||||||
generate: true
|
generate: true
|
||||||
setAsWorldSpawn: true
|
setAsWorldSpawn: true
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
name: Metropolis
|
name: Metropolis
|
||||||
main: com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin
|
main: com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin
|
||||||
|
version: 1.0
|
||||||
depend: [WorldGuard]
|
depend: [WorldGuard]
|
||||||
softdepend: [WorldEdit,CommandBook]
|
softdepend: [WorldEdit,CommandBook]
|
||||||
version: 0.5
|
|
||||||
database: false
|
database: false
|
||||||
commands:
|
commands:
|
||||||
metropolis:
|
metropolis:
|
||||||
description: This command displays the current metropolis version.
|
description: This command displays the current metropolis version.
|
||||||
usage: /metropolis
|
usage: /metropolis
|
||||||
|
metropolis-home-generate:
|
||||||
|
description: This command generates a home for a user as if they'd just logged in.
|
||||||
|
permission: metropolis.home.generate
|
||||||
|
usage: /metropolis-home-generate <playername>
|
||||||
|
metropolis-home-list:
|
||||||
|
description: This lists the regions managed by Metropolis
|
||||||
|
permission: metropolis.home.list
|
||||||
|
usage: /metropolis-home-list
|
||||||
|
metropolis-home-evict:
|
||||||
Reference in New Issue
Block a user