mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-01-21 21:01:53 +01:00
WorldAddmemberEvent added
This commit is contained in:
parent
eeab24d7b8
commit
3e9140be89
@ -56,6 +56,9 @@ worldgeneration:
|
|||||||
# Type of the world eg. flat, amplified, ...
|
# Type of the world eg. flat, amplified, ...
|
||||||
# Valid types are 'NORMAL', 'VERSION_1_1', 'FLAT', 'AMPLIFIED', 'CUSTOMIZED' or 'LARGE_BIOMES'
|
# Valid types are 'NORMAL', 'VERSION_1_1', 'FLAT', 'AMPLIFIED', 'CUSTOMIZED' or 'LARGE_BIOMES'
|
||||||
type: NORMAL
|
type: NORMAL
|
||||||
|
# Put in here the name of a generator
|
||||||
|
# If you have one from one plugin
|
||||||
|
generator: ''
|
||||||
|
|
||||||
# Location where you will be teleported when you leave you world
|
# Location where you will be teleported when you leave you world
|
||||||
spawn:
|
spawn:
|
||||||
|
@ -56,6 +56,9 @@ worldgeneration:
|
|||||||
# Type of the world eg. flat, amplified, ...
|
# Type of the world eg. flat, amplified, ...
|
||||||
# Valid types are 'NORMAL', 'VERSION_1_1', 'FLAT', 'AMPLIFIED', 'CUSTOMIZED' or 'LARGE_BIOMES'
|
# Valid types are 'NORMAL', 'VERSION_1_1', 'FLAT', 'AMPLIFIED', 'CUSTOMIZED' or 'LARGE_BIOMES'
|
||||||
type: NORMAL
|
type: NORMAL
|
||||||
|
# Put in here the name of a generator
|
||||||
|
# If you have one from one plugin
|
||||||
|
generator: ''
|
||||||
|
|
||||||
# Location where you will be teleported when you leave you world
|
# Location where you will be teleported when you leave you world
|
||||||
spawn:
|
spawn:
|
||||||
|
43
WorldSystem/src/de/butzlabben/event/WorldAddmemberEvent.java
Normal file
43
WorldSystem/src/de/butzlabben/event/WorldAddmemberEvent.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package de.butzlabben.event;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Butzlabben
|
||||||
|
* @since 09.05.2018
|
||||||
|
*/
|
||||||
|
public class WorldAddmemberEvent extends WorldEvent {
|
||||||
|
|
||||||
|
private final String worldname;
|
||||||
|
private final UUID uuid;
|
||||||
|
private Player adder;
|
||||||
|
|
||||||
|
public WorldAddmemberEvent(UUID uuid, String worldname, Player adder) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.worldname = worldname;
|
||||||
|
this.adder = adder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getAdding() {
|
||||||
|
return adder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorldname() {
|
||||||
|
return worldname;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public final static HandlerList handlers = new HandlerList();
|
||||||
|
}
|
@ -1,22 +1,17 @@
|
|||||||
package de.butzlabben.event;
|
package de.butzlabben.event;
|
||||||
|
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.WorldType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class WorldCreateEvent extends WorldEvent {
|
public class WorldCreateEvent extends WorldEvent {
|
||||||
|
|
||||||
private final Player owner;
|
private final Player owner;
|
||||||
private Environment env;
|
private WorldCreator worldCreator;
|
||||||
private WorldType type;
|
|
||||||
private long seed;
|
|
||||||
|
|
||||||
public WorldCreateEvent(Player owner, Environment env, WorldType type, long seed) {
|
public WorldCreateEvent(Player owner, WorldCreator creator) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.env = env;
|
this.setWorldCreator(creator);
|
||||||
this.type = type;
|
|
||||||
this.setSeed(seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getOwner() {
|
public Player getOwner() {
|
||||||
@ -34,27 +29,15 @@ public class WorldCreateEvent extends WorldEvent {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldType getType() {
|
/**
|
||||||
return type;
|
* @return the worldcreator which will be used
|
||||||
|
*/
|
||||||
|
public WorldCreator getWorldCreator() {
|
||||||
|
return worldCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(WorldType type) {
|
public void setWorldCreator(WorldCreator worldCreator) {
|
||||||
this.type = type;
|
this.worldCreator = worldCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Environment getEnv() {
|
|
||||||
return env;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnvironment(Environment env) {
|
|
||||||
this.env = env;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSeed() {
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSeed(long seed) {
|
|
||||||
this.seed = seed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,16 @@ public class WorldDeleteEvent extends WorldEvent {
|
|||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return get the world which will be deleted
|
||||||
|
*/
|
||||||
public SystemWorld getWorld() {
|
public SystemWorld getWorld() {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return get the executor of the command
|
||||||
|
*/
|
||||||
public CommandSender getExecutor() {
|
public CommandSender getExecutor() {
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
@ -6,29 +6,35 @@ import org.bukkit.event.HandlerList;
|
|||||||
import de.butzlabben.world.wrapper.SystemWorld;
|
import de.butzlabben.world.wrapper.SystemWorld;
|
||||||
|
|
||||||
public class WorldLoadEvent extends WorldEvent {
|
public class WorldLoadEvent extends WorldEvent {
|
||||||
|
|
||||||
private final Player owner;
|
private final Player owner;
|
||||||
private final SystemWorld world;
|
private final SystemWorld world;
|
||||||
|
|
||||||
public WorldLoadEvent(Player owner, SystemWorld systemWorld) {
|
public WorldLoadEvent(Player owner, SystemWorld systemWorld) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.world = systemWorld;
|
this.world = systemWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return get the world which will be loaded
|
||||||
|
*/
|
||||||
public SystemWorld getWorld() {
|
public SystemWorld getWorld() {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return get person which intiziated the loading
|
||||||
|
*/
|
||||||
public Player getOwner() {
|
public Player getOwner() {
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static HandlerList handlers = new HandlerList();
|
public final static HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public final static HandlerList getHandlerList() {
|
public final static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final HandlerList getHandlers() {
|
public final HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
@ -238,10 +238,21 @@ public class SystemWorld {
|
|||||||
*/
|
*/
|
||||||
public static boolean create(Player p) {
|
public static boolean create(Player p) {
|
||||||
DependenceConfig dc = new DependenceConfig(p);
|
DependenceConfig dc = new DependenceConfig(p);
|
||||||
|
|
||||||
|
String uuid = p.getUniqueId().toString();
|
||||||
|
int id = dc.getHighestID();
|
||||||
|
String worldname = "ID" + id + "-" + uuid;
|
||||||
|
|
||||||
|
WorldCreator creator = new WorldCreator(worldname);
|
||||||
long seed = PluginConfig.getSeed();
|
long seed = PluginConfig.getSeed();
|
||||||
Environment env = PluginConfig.getEnvironment();
|
Environment env = PluginConfig.getEnvironment();
|
||||||
WorldType type = PluginConfig.getWorldType();
|
WorldType type = PluginConfig.getWorldType();
|
||||||
WorldCreateEvent event = new WorldCreateEvent(p, env, type, seed);
|
if(seed != 0)
|
||||||
|
creator.seed(seed);
|
||||||
|
creator.type(type);
|
||||||
|
creator.environment(env);
|
||||||
|
|
||||||
|
WorldCreateEvent event = new WorldCreateEvent(p, creator);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
@ -252,15 +263,14 @@ public class SystemWorld {
|
|||||||
+ " worlds. If you want more, contact me");
|
+ " worlds. If you want more, contact me");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int id = dc.getHighestID();
|
|
||||||
String worlddir = PluginConfig.getWorlddir();
|
String worlddir = PluginConfig.getWorlddir();
|
||||||
File exampleworld = new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName());
|
File exampleworld = new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName());
|
||||||
if (new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat")
|
if (new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat")
|
||||||
.exists()) {
|
.exists()) {
|
||||||
new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat").delete();
|
new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat").delete();
|
||||||
}
|
}
|
||||||
String uuid = p.getUniqueId().toString();
|
|
||||||
String worldname = "ID" + id + "-" + uuid;
|
|
||||||
File newworld = new File(worlddir + "/" + worldname);
|
File newworld = new File(worlddir + "/" + worldname);
|
||||||
try {
|
try {
|
||||||
FileUtils.copyDirectory(exampleworld, newworld);
|
FileUtils.copyDirectory(exampleworld, newworld);
|
||||||
@ -292,13 +302,7 @@ public class SystemWorld {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorldCreator wc = new WorldCreator(worldname);
|
World worldinserver = Bukkit.createWorld(event.getWorldCreator());
|
||||||
wc.environment(event.getEnv());
|
|
||||||
wc.type(event.getType());
|
|
||||||
if (event.getSeed() != 0)
|
|
||||||
wc.seed(event.getSeed());
|
|
||||||
|
|
||||||
World worldinserver = Bukkit.createWorld(wc);
|
|
||||||
Bukkit.getServer().getWorlds().add(worldinserver);
|
Bukkit.getServer().getWorlds().add(worldinserver);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user