mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-01-05 18:37:48 +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, ...
|
||||
# Valid types are 'NORMAL', 'VERSION_1_1', 'FLAT', 'AMPLIFIED', 'CUSTOMIZED' or 'LARGE_BIOMES'
|
||||
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
|
||||
spawn:
|
||||
|
@ -56,6 +56,9 @@ worldgeneration:
|
||||
# Type of the world eg. flat, amplified, ...
|
||||
# Valid types are 'NORMAL', 'VERSION_1_1', 'FLAT', 'AMPLIFIED', 'CUSTOMIZED' or 'LARGE_BIOMES'
|
||||
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
|
||||
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;
|
||||
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class WorldCreateEvent extends WorldEvent {
|
||||
|
||||
private final Player owner;
|
||||
private Environment env;
|
||||
private WorldType type;
|
||||
private long seed;
|
||||
private WorldCreator worldCreator;
|
||||
|
||||
public WorldCreateEvent(Player owner, Environment env, WorldType type, long seed) {
|
||||
public WorldCreateEvent(Player owner, WorldCreator creator) {
|
||||
this.owner = owner;
|
||||
this.env = env;
|
||||
this.type = type;
|
||||
this.setSeed(seed);
|
||||
this.setWorldCreator(creator);
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
@ -34,27 +29,15 @@ public class WorldCreateEvent extends WorldEvent {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public WorldType getType() {
|
||||
return type;
|
||||
/**
|
||||
* @return the worldcreator which will be used
|
||||
*/
|
||||
public WorldCreator getWorldCreator() {
|
||||
return worldCreator;
|
||||
}
|
||||
|
||||
public void setType(WorldType type) {
|
||||
this.type = type;
|
||||
public void setWorldCreator(WorldCreator worldCreator) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get the world which will be deleted
|
||||
*/
|
||||
public SystemWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get the executor of the command
|
||||
*/
|
||||
public CommandSender getExecutor() {
|
||||
return executor;
|
||||
}
|
||||
|
@ -6,29 +6,35 @@ import org.bukkit.event.HandlerList;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
|
||||
public class WorldLoadEvent extends WorldEvent {
|
||||
|
||||
|
||||
private final Player owner;
|
||||
private final SystemWorld world;
|
||||
|
||||
|
||||
public WorldLoadEvent(Player owner, SystemWorld systemWorld) {
|
||||
this.owner = owner;
|
||||
this.world = systemWorld;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return get the world which will be loaded
|
||||
*/
|
||||
public SystemWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return get person which intiziated the loading
|
||||
*/
|
||||
public Player getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
|
||||
public final static HandlerList handlers = new HandlerList();
|
||||
|
||||
|
||||
public final static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -238,10 +238,21 @@ public class SystemWorld {
|
||||
*/
|
||||
public static boolean create(Player 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();
|
||||
Environment env = PluginConfig.getEnvironment();
|
||||
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);
|
||||
if (event.isCancelled())
|
||||
return false;
|
||||
@ -252,15 +263,14 @@ public class SystemWorld {
|
||||
+ " worlds. If you want more, contact me");
|
||||
return false;
|
||||
}
|
||||
int id = dc.getHighestID();
|
||||
|
||||
String worlddir = PluginConfig.getWorlddir();
|
||||
File exampleworld = new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName());
|
||||
if (new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat")
|
||||
.exists()) {
|
||||
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);
|
||||
try {
|
||||
FileUtils.copyDirectory(exampleworld, newworld);
|
||||
@ -292,13 +302,7 @@ public class SystemWorld {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
WorldCreator wc = new WorldCreator(worldname);
|
||||
wc.environment(event.getEnv());
|
||||
wc.type(event.getType());
|
||||
if (event.getSeed() != 0)
|
||||
wc.seed(event.getSeed());
|
||||
|
||||
World worldinserver = Bukkit.createWorld(wc);
|
||||
World worldinserver = Bukkit.createWorld(event.getWorldCreator());
|
||||
Bukkit.getServer().getWorlds().add(worldinserver);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user