本文整理汇总了Java中cn.nukkit.event.level.LevelLoadEvent类的典型用法代码示例。如果您正苦于以下问题:Java LevelLoadEvent类的具体用法?Java LevelLoadEvent怎么用?Java LevelLoadEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LevelLoadEvent类属于cn.nukkit.event.level包,在下文中一共展示了LevelLoadEvent类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onLevelLoad
import cn.nukkit.event.level.LevelLoadEvent; //导入依赖的package包/类
@EventHandler()
public void onLevelLoad(LevelLoadEvent event){
FileUtils.loadData(event.getLevel().getFolderName());
}
开发者ID:if-Team,项目名称:Nukkit-Plugins,代码行数:5,代码来源:LevelLoadListener.java
示例2: loadLevel
import cn.nukkit.event.level.LevelLoadEvent; //导入依赖的package包/类
public boolean loadLevel(String name) {
if (Objects.equals(name.trim(), "")) {
throw new LevelException("Invalid empty level name");
}
if (this.isLevelLoaded(name)) {
return true;
} else if (!this.isLevelGenerated(name)) {
this.logger.notice(this.getLanguage().translateString("nukkit.level.notFound", name));
return false;
}
String path = this.getDataPath() + "worlds/" + name + "/";
Class<? extends LevelProvider> provider = LevelProviderManager.getProvider(path);
if (provider == null) {
this.logger.error(this.getLanguage().translateString("nukkit.level.loadError", new String[]{name, "Unknown provider"}));
return false;
}
Level level;
try {
level = new Level(this, name, path, provider);
} catch (Exception e) {
this.logger.error(this.getLanguage().translateString("nukkit.level.loadError", new String[]{name, e.getMessage()}));
this.logger.logException(e);
return false;
}
this.levels.put(level.getId(), level);
level.initLevel();
this.getPluginManager().callEvent(new LevelLoadEvent(level));
level.setTickRate(this.baseTickRate);
return true;
}
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:42,代码来源:Server.java
示例3: generateLevel
import cn.nukkit.event.level.LevelLoadEvent; //导入依赖的package包/类
public boolean generateLevel(String name, long seed, Class<? extends Generator> generator, Map<String, Object> options) {
if (Objects.equals(name.trim(), "") || this.isLevelGenerated(name)) {
return false;
}
if (!options.containsKey("preset")) {
options.put("preset", this.getPropertyString("generator-settings", ""));
}
if (generator == null) {
generator = Generator.getGenerator(this.getLevelType());
}
Class<? extends LevelProvider> provider;
String providerName;
if ((provider = LevelProviderManager.getProviderByName
(providerName = (String) this.getConfig("level-settings.default-format", "mcregion"))) == null) {
provider = LevelProviderManager.getProviderByName(providerName = "mcregion");
}
Level level;
try {
String path = this.getDataPath() + "worlds/" + name + "/";
provider.getMethod("generate", String.class, String.class, long.class, Class.class, Map.class).invoke(null, path, name, seed, generator, options);
level = new Level(this, name, path, provider);
this.levels.put(level.getId(), level);
level.initLevel();
level.setTickRate(this.baseTickRate);
} catch (Exception e) {
this.logger.error(this.getLanguage().translateString("nukkit.level.generationError", new String[]{name, e.getMessage()}));
this.logger.logException(e);
return false;
}
this.getPluginManager().callEvent(new LevelInitEvent(level));
this.getPluginManager().callEvent(new LevelLoadEvent(level));
/*this.getLogger().notice(this.getLanguage().translateString("nukkit.level.backgroundGeneration", name));
int centerX = (int) level.getSpawnLocation().getX() >> 4;
int centerZ = (int) level.getSpawnLocation().getZ() >> 4;
TreeMap<String, Integer> order = new TreeMap<>();
for (int X = -3; X <= 3; ++X) {
for (int Z = -3; Z <= 3; ++Z) {
int distance = X * X + Z * Z;
int chunkX = X + centerX;
int chunkZ = Z + centerZ;
order.put(Level.chunkHash(chunkX, chunkZ), distance);
}
}
List<Map.Entry<String, Integer>> sortList = new ArrayList<>(order.entrySet());
Collections.sort(sortList, new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
return o2.getValue() - o1.getValue();
}
});
for (String index : order.keySet()) {
Chunk.Entry entry = Level.getChunkXZ(index);
level.populateChunk(entry.chunkX, entry.chunkZ, true);
}*/
return true;
}
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:75,代码来源:Server.java
示例4: generateLevel
import cn.nukkit.event.level.LevelLoadEvent; //导入依赖的package包/类
public boolean generateLevel(String name, long seed, Class<? extends Generator> generator, Map<String, Object> options, Class<? extends LevelProvider> provider) {
if (Objects.equals(name.trim(), "") || this.isLevelGenerated(name)) {
return false;
}
if (!options.containsKey("preset")) {
options.put("preset", this.getPropertyString("generator-settings", ""));
}
if (generator == null) {
generator = Generator.getGenerator(this.getLevelType());
}
if (provider == null) {
if ((provider = LevelProviderManager.getProviderByName
((String) this.getConfig("level-settings.default-format", "anvil"))) == null) {
provider = LevelProviderManager.getProviderByName("anvil");
}
}
Level level;
try {
String path = this.getDataPath() + "worlds/" + name + "/";
provider.getMethod("generate", String.class, String.class, long.class, Class.class, Map.class).invoke(null, path, name, seed, generator, options);
level = new Level(this, name, path, provider);
this.levels.put(level.getId(), level);
level.initLevel();
level.setTickRate(this.baseTickRate);
} catch (Exception e) {
this.logger.error(this.getLanguage().translateString("nukkit.level.generationError", new String[]{name, e.getMessage()}));
this.logger.logException(e);
return false;
}
this.getPluginManager().callEvent(new LevelInitEvent(level));
this.getPluginManager().callEvent(new LevelLoadEvent(level));
/*this.getLogger().notice(this.getLanguage().translateString("nukkit.level.backgroundGeneration", name));
int centerX = (int) level.getSpawnLocation().getX() >> 4;
int centerZ = (int) level.getSpawnLocation().getZ() >> 4;
TreeMap<String, Integer> order = new TreeMap<>();
for (int X = -3; X <= 3; ++X) {
for (int Z = -3; Z <= 3; ++Z) {
int distance = X * X + Z * Z;
int chunkX = X + centerX;
int chunkZ = Z + centerZ;
order.put(Level.chunkHash(chunkX, chunkZ), distance);
}
}
List<Map.Entry<String, Integer>> sortList = new ArrayList<>(order.entrySet());
Collections.sort(sortList, new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
return o2.getValue() - o1.getValue();
}
});
for (String index : order.keySet()) {
Chunk.Entry entry = Level.getChunkXZ(index);
level.populateChunk(entry.chunkX, entry.chunkZ, true);
}*/
return true;
}
开发者ID:NycuRO,项目名称:Apollo-OLD,代码行数:75,代码来源:Server.java
示例5: loadLevel
import cn.nukkit.event.level.LevelLoadEvent; //导入依赖的package包/类
public boolean loadLevel(String name) {
if (Objects.equals(name.trim(), "")) {
throw new LevelException("Invalid empty level name");
}
if (this.isLevelLoaded(name)) {
return true;
} else if (!this.isLevelGenerated(name)) {
this.logger.notice(this.getLanguage().translateString("nukkit.level.notFound", name));
return false;
}
String path;
if (name.contains("/") || name.contains("\\")) {
path = name;
} else {
path = this.getDataPath() + "worlds/" + name + "/";
}
Class<? extends LevelProvider> provider = LevelProviderManager.getProvider(path);
if (provider == null) {
this.logger.error(this.getLanguage().translateString("nukkit.level.loadError", new String[]{name, "Unknown provider"}));
return false;
}
Level level;
try {
level = new Level(this, name, path, provider);
} catch (Exception e) {
this.logger.error(this.getLanguage().translateString("nukkit.level.loadError", new String[]{name, e.getMessage()}));
this.logger.logException(e);
return false;
}
this.levels.put(level.getId(), level);
level.initLevel();
this.getPluginManager().callEvent(new LevelLoadEvent(level));
level.setTickRate(this.baseTickRate);
return true;
}
开发者ID:Nukkit,项目名称:Nukkit,代码行数:48,代码来源:Server.java
示例6: generateLevel
import cn.nukkit.event.level.LevelLoadEvent; //导入依赖的package包/类
public boolean generateLevel(String name, long seed, Class<? extends Generator> generator, Map<String, Object> options, Class<? extends LevelProvider> provider) {
if (Objects.equals(name.trim(), "") || this.isLevelGenerated(name)) {
return false;
}
if (!options.containsKey("preset")) {
options.put("preset", this.getPropertyString("generator-settings", ""));
}
if (generator == null) {
generator = Generator.getGenerator(this.getLevelType());
}
if (provider == null) {
if ((provider = LevelProviderManager.getProviderByName
((String) this.getConfig("level-settings.default-format", "anvil"))) == null) {
provider = LevelProviderManager.getProviderByName("anvil");
}
}
String path;
if (name.contains("/") || name.contains("\\")) {
path = name;
} else {
path = this.getDataPath() + "worlds/" + name + "/";
}
Level level;
try {
provider.getMethod("generate", String.class, String.class, long.class, Class.class, Map.class).invoke(null, path, name, seed, generator, options);
level = new Level(this, name, path, provider);
this.levels.put(level.getId(), level);
level.initLevel();
level.getGameRules().setGameRule("spawnRadius", "" + this.getSpawnRadius());
level.setTickRate(this.baseTickRate);
} catch (Exception e) {
this.logger.error(this.getLanguage().translateString("nukkit.level.generationError", new String[]{name, e.getMessage()}));
this.logger.logException(e);
return false;
}
this.getPluginManager().callEvent(new LevelInitEvent(level));
this.getPluginManager().callEvent(new LevelLoadEvent(level));
/*this.getLogger().notice(this.getLanguage().translateString("nukkit.level.backgroundGeneration", name));
int centerX = (int) level.getSpawnLocation().getX() >> 4;
int centerZ = (int) level.getSpawnLocation().getZ() >> 4;
TreeMap<String, Integer> order = new TreeMap<>();
for (int X = -3; X <= 3; ++X) {
for (int Z = -3; Z <= 3; ++Z) {
int distance = X * X + Z * Z;
int chunkX = X + centerX;
int chunkZ = Z + centerZ;
order.put(Level.chunkHash(chunkX, chunkZ), distance);
}
}
List<Map.Entry<String, Integer>> sortList = new ArrayList<>(order.entrySet());
Collections.sort(sortList, new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
return o2.getValue() - o1.getValue();
}
});
for (String index : order.keySet()) {
Chunk.Entry entry = Level.getChunkXZ(index);
level.populateChunk(entry.chunkX, entry.chunkZ, true);
}*/
return true;
}
开发者ID:Nukkit,项目名称:Nukkit,代码行数:82,代码来源:Server.java
示例7: onWorldLoad
import cn.nukkit.event.level.LevelLoadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldLoad(LevelLoadEvent event) {
handle(event.getLevel());
}
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:5,代码来源:WorldEvents.java
注:本文中的cn.nukkit.event.level.LevelLoadEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论