verstaubt

This commit is contained in:
BuildTools 2018-01-15 12:27:22 +01:00
parent 78d6d7eaa4
commit 91a042abb5
19 changed files with 597 additions and 524 deletions

View File

@ -20,77 +20,73 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.11.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: eu.univento:commons:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.mojang:authlib:1.5.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-all:5.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.11.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
<orderEntry type="library" name="Maven: com.boydti:fawe-api:latest" level="project" />
<orderEntry type="library" name="Maven: com.sk89q:worldguard:6.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: net.fabiozumbi12:redprotect:1.9.6" level="project" />
<orderEntry type="library" name="Maven: org.primesoft:BlocksHub:2.0" level="project" />
<orderEntry type="library" name="Maven: com.sk89q.worldedit:worldedit-core:6.1.3-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.plotsquared:plotsquared-api:latest" level="project" />
<orderEntry type="library" name="Maven: com.github.luben:zstd-jni:1.1.1" level="project" />
<orderEntry type="library" name="Maven: co.aikar:fastutil-lite:1.0" level="project" />
<orderEntry type="module" module-name="Commons" />
<orderEntry type="library" name="Maven: io.vertx:vertx-core:3.4.1" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.8.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.7.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.7.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.7.0" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-redis-client:3.4.1" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-mysql-postgresql-client:3.4.1" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-sql-common:3.4.1" level="project" />
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.12.1" level="project" />
<orderEntry type="library" name="Maven: com.github.mauricio:postgresql-async_2.12:0.2.21" level="project" />
<orderEntry type="library" name="Maven: com.github.mauricio:db-async-common_2.12:0.2.21" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.7" level="project" />
<orderEntry type="library" name="Maven: org.joda:joda-convert:1.8.1" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" name="Maven: com.github.mauricio:mysql-async_2.12:0.2.21" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-mongo-client:3.4.1" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-async:3.4.1" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.4.1" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:bson:3.4.1" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-rabbitmq-client:3.4.1" level="project" />
<orderEntry type="library" name="Maven: com.rabbitmq:amqp-client:3.6.5" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-web-client:3.4.2" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-web-common:3.4.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: io.sentry:sentry:1.2.2" level="project" />
<orderEntry type="library" name="Maven: com.github.ben-manes.caffeine:caffeine:2.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: com.github.nsp:JSkills:master-0.9.0-g8b333ec-15" level="project" />
<orderEntry type="library" name="Maven: com.google.dagger:dagger:2.14.1" level="project" />
<orderEntry type="library" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="module" module-name="Core" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-bukkit:3.4.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-core:3.4.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.dmulloy2:PacketWrapper:master-2b4bfddd12-1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-bukkit:3.6.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: pl.kacperduras:tasket-core:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: pl.kacperduras:tasket-bukkit:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.github.lordakkarin:nbt:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-buffer:5.0.0.Alpha2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-common:5.0.0.Alpha2" level="project" />
<orderEntry type="module" module-name="Commons" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: ai.api:libai:1.4.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-core:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-handler:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-handler-proxy:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec-socks:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec-http:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec-http2:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-resolver:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-resolver-dns:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec-dns:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.7.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.7.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.7.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-redis-client:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-mysql-postgresql-client:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-sql-common:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:postgresql-async_2.12:0.2.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:db-async-common_2.12:0.2.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.joda:joda-convert:1.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:mysql-async_2.12:0.2.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-mongo-client:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:mongodb-driver-async:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:mongodb-driver-core:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:bson:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-rabbitmq-client:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.rabbitmq:amqp-client:3.6.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TheHolyWaffle:TeamSpeak-3-Java-API:v1.0.13" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.nsp:JSkills:master-0.9.0-g8b333ec-15" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:simple:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:core:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:dense64:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.gitlab:java-gitlab-api:1.2.7" level="project" />
</component>
</module>

24
pom.xml
View File

@ -55,27 +55,13 @@
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@ -91,6 +77,12 @@
<version>latest</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="target2" level="project" />
<orderEntry type="library" name="target" level="project" />
<orderEntry type="library" name="target1" level="project" />
<orderEntry type="library" name="Kartoffelsuppe" level="project" />
<orderEntry type="library" name="Core" level="project" />
<orderEntry type="library" name="FakeCore" level="project" />
<orderEntry type="library" name="test-1.0-SNAPSHOT-jar-with-dependencies" level="project" />
<orderEntry type="module" module-name="FakeCore" />
<orderEntry type="module" module-name="Core" />
</component>
</module>

View File

@ -1,32 +1,34 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento;
import eu.univento.commons.server.ServerType;
import eu.univento.core.Core;
import eu.univento.core.api.Config;
import eu.univento.core.api.command.CommandFramework;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.teamvento.commands.PlotInfo;
import eu.univento.teamvento.commands.WorldCommands;
import eu.univento.teamvento.generator.GeneratorManager;
import eu.univento.teamvento.listener.Events;
import eu.univento.teamvento.listener.JoinQuit;
import eu.univento.teamvento.listener.MenuEvents;
import eu.univento.teamvento.listener.SignInteract;
import eu.univento.teamvento.generator.GeneratorManager;
import eu.univento.teamvento.plot.PlotManager;
import org.bukkit.*;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Sheep;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.io.File;
import java.util.Random;
/**
* @author joethei
@ -35,53 +37,25 @@ import java.util.Random;
public class TeamVento extends JavaPlugin {
private static final File file = new File("plugins/Core", "worlds.yml");
private static final FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
@Getter private static final File configFile = new File("plugins/Core", "worlds.yml");
@Getter private static final FileConfiguration cfg = YamlConfiguration.loadConfiguration(configFile);
public static File getConfigFile() {
return file;
}
public static FileConfiguration getCfg() {
return cfg;
}
private static TeamVento instance;
public static TeamVento getInstance() {
return instance;
}
private Random random = new Random();
@Getter private static TeamVento instance;
@Override
public void onEnable() {
instance = this;
/*
if(Bukkit.getWorld("plots") == null) {
WorldCreator creator = new WorldCreator("plots");
creator.generator(new VoidGenerator());
creator.type(WorldType.CUSTOMIZED);
creator.generateStructures(false);
Bukkit.createWorld(creator);
getCfg().set("plots", "void");
try {
getCfg().save(getConfigFile());
} catch (IOException e) {
e.printStackTrace();
}
}
*/
CommandFramework commandFramework = new CommandFramework(this);
commandFramework.registerCommands(new WorldCommands());
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new JoinQuit(), getInstance());
pm.registerEvents(new SignInteract(), getInstance());
pm.registerEvents(new MenuEvents(), getInstance());
pm.registerEvents(new Events(), getInstance());
pm.registerEvents(new JoinQuit(), this);
pm.registerEvents(new SignInteract(), this);
pm.registerEvents(new MenuEvents(), this);
pm.registerEvents(new Events(), this);
//new PlotInfo(this, "plotinfo", "info about a plot", "pi");
new PlotInfo(this, "plotinfo", "info about a plot", "pi");
for(String world : getCfg().getKeys(true)) {
World loadedWorld = Bukkit.createWorld(GeneratorManager.getWorldCreator(world, getCfg().getString(world)));
@ -90,35 +64,10 @@ public class TeamVento extends JavaPlugin {
loadedWorld.setAnimalSpawnLimit(0);
}
ServerSettings.setServerType(ServerType.TEAM_BUILD);
ServerSettings.setGameMode(GameMode.CREATIVE);
//PlotManager.update();
//PlotManager.setLastPlot(PlotManager.getPlotByOwner(Config.readString("lastPlot")));
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Bukkit.getWorlds().stream().filter(world -> world.getTime() > 7698).forEach(world -> world.setTime(0)), 100 * 20L, 20L);
ServerSettings.setup(ServerType.TEAM_BUILD, GameMode.CREATIVE);
PlotManager.update();
//Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Bukkit.getWorlds().stream().filter(world -> world.getTime() > 7698).forEach(world -> world.setTime(0)), 100 * 20L, 20L);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Events.redstone = 0, 1L, 10 * 20L);
Bukkit.getScheduler().runTaskTimer(this, () -> {
for(CustomPlayer player : Core.getOnlinePlayers()) {
if(player.getItemInHand().getType() == Material.SHEARS) {
Sheep sheep = (Sheep) player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.SHEEP);
sheep.setColor(DyeColor.values()[random.nextInt(DyeColor.values().length)]);
sheep.setVelocity(new Vector(random.nextDouble() * (random.nextBoolean() ? 1 : -1), 2, random.nextDouble() * (random.nextBoolean() ? 1 : -1)));
sheep.setAI(true);
Bukkit.getScheduler().runTaskLater(this, () -> {
Location loc = sheep.getEyeLocation();
final Firework firework = (Firework) player.getWorld().spawnEntity(loc, EntityType.FIREWORK);
FireworkMeta meta = firework.getFireworkMeta();
FireworkEffect effect = FireworkEffect.builder().withColor(sheep.getColor().getColor()).with(FireworkEffect.Type.BALL).build();
meta.addEffect(effect);
firework.setFireworkMeta(meta);
Bukkit.getScheduler().runTaskLater(this, firework::detonate, 1L);
sheep.remove();
}, 20L);
}
}
}, 20L, 10L);
}
@Override

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.commands;
import eu.univento.commons.player.rank.Rank;
@ -7,7 +12,6 @@ import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.plot.Plot;
import eu.univento.teamvento.plot.PlotManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -24,17 +28,17 @@ public class PlotInfo extends AutoCommand<TeamVento>{
if(sender instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) sender);
if(p.getDatabasePlayer().isAllowed(Rank.SrBuilder)) {
if(PlotManager.getPlotByLocation(p.getLocation()) != null) {
if(PlotManager.isPlot(p.getLocation())) {
Plot plot = PlotManager.getPlotByLocation(p.getLocation());
assert plot != null;
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
PlotManager.getCreatedDate(plot.getOwner()).whenComplete((instant, throwable) -> {
p.sendMessage("§eName: " + plot.getName());
p.sendMessage("§eErsteller: " + NameFetcher.getRequest(plot.getOwner()));
p.sendMessage("§eErstellt am: " + PlotManager.getCreatedDate(plot.getOwner().toString()));
p.sendMessage("§eErstellt am: " + instant.toString());
p.sendMessage("§eKontakt: " + plot.getContact());
p.sendMessage("§eBiom: " + plot.getBiome().name());
p.sendMessage("§eZeit: " + plot.getTime().name());
p.sendMessage("§Wetter: " + plot.getWeather().name());
p.sendMessage("§eWetter: " + plot.getWeather().name());
});
}else{
p.sendMessage("§cHier ist leider kein Plot");

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.commands;
import eu.univento.commons.player.rank.Rank;
@ -21,7 +26,15 @@ import java.util.stream.Collectors;
*/
public class WorldCommands {
@Command(name = "world.teleport", aliases = {"wtp"}, description = "teleport through the worlds", usage = "/world teleport <World>", rank = Rank.JrSupporter, inGameOnly = true)
@Command(name ="world", description = "all world commands", usage = "/world", rank = Rank.Sound)
public void world(CommandArgs args) {
args.getSender().sendMessage("/world list");
args.getSender().sendMessage("/world teleport <world>");
args.getSender().sendMessage("/world create <name> <generator>");
args.getSender().sendMessage("/world import <name> <generator>");
}
@Command(name = "world.teleport", aliases = {"wtp"}, description = "teleport through the worlds", usage = "/world teleport <World>", rank = Rank.Sound, inGameOnly = true)
public void teleport(CommandArgs args) {
if(args.length() == 1) {
if(Bukkit.getWorld(args.getArg(0)) != null) {
@ -39,7 +52,7 @@ public class WorldCommands {
return Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toCollection(LinkedList::new));
}
@Command(name = "world.list", aliases = {"wl"}, description = "list all worlds", usage = "/world list", rank = Rank.JrSupporter)
@Command(name = "world.list", aliases = {"wl"}, description = "list all worlds", usage = "/world list", rank = Rank.Sound)
public void list(CommandArgs args) {
args.getSender().sendMessage("§cAll worlds");
for(String world : TeamVento.getCfg().getKeys(true)) {
@ -47,10 +60,10 @@ public class WorldCommands {
}
}
@Command(name = "world.import", aliases = "wi", description = "import already existing worlds", usage = "/world import <name> <generator>", rank = Rank.Admin)
@Command(name = "world.import", aliases = {"wi"} , description = "import already existing worlds", usage = "/world import <name> <generator>", rank = Rank.Admin)
public void importWorld(CommandArgs args) {
if(args.length() == 2) {
if(Bukkit.getWorld(args.getArg(0)) == null && !new File(args.getArg(0)).exists()) {
if(Bukkit.getWorld(args.getArg(0)) == null && new File(args.getArg(0)).exists()) {
Bukkit.createWorld(GeneratorManager.getWorldCreator(args.getArg(0), args.getArg(1)));
TeamVento.getCfg().set(args.getArg(0), args.getArg(1));
try {
@ -59,16 +72,16 @@ public class WorldCommands {
e.printStackTrace();
}
args.getSender().sendMessage("§ayour world has been imported");
}else args.getSender().sendMessage("3cthe chosen world already exists");
}else args.getSender().sendMessage("§cthe chosen world already exists");
}else {
args.getSender().sendMessage("§cplease use /world import <name> <generator>");
}
}
@Command(name = "world.create", aliases = "wc", description = "create new worlds", usage = "/world create <name> <generator>", rank = Rank.SrBuilder)
@Command(name = "world.create", aliases = {"wc"}, description = "create new worlds", usage = "/world create <name> <generator>", rank = Rank.SrBuilder)
public void create(CommandArgs args) {
if(args.length() == 2) {
if(Bukkit.getWorld(args.getArg(0)) == null && GeneratorManager.getWorldCreator(args.getArg(0), args.getArg(1)) != null) {
if(Bukkit.getWorld(args.getArg(0)) == null && GeneratorManager.getWorldCreator(args.getArg(1), args.getArg(1)) != null) {
Bukkit.createWorld(GeneratorManager.getWorldCreator(args.getArg(0), args.getArg(1)));
TeamVento.getCfg().set(args.getArg(0), args.getArg(1));
try {

View File

@ -0,0 +1,100 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.generator;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.util.noise.PerlinOctaveGenerator;
import org.bukkit.util.noise.SimplexOctaveGenerator;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* @author joethei
* @version 1.0
*/
public class CustomGenerator extends ChunkGenerator {
private double scale = 32.0; //how far apart the tops of the hills are
private double threshold = 0.0; // the cutoff point for terrain
private int middle = 70; // the "middle" of the road
public List<BlockPopulator> getDefaultPopulators(World world) {
ArrayList<BlockPopulator> populators = new ArrayList<>();
populators.add(new CustomPopulator());
return populators;
}
/*
* Sets a block in the chunk. If the Block section doesn't exist, it allocates it.
* [y>>4] the section id (y/16)
* the math for the second offset confuses me
*/
void setBlock(int x, int y, int z, byte[][] chunk, Material material) {
if (chunk[y >> 4] == null)
chunk[y >> 4] = new byte[16 * 16 * 16];
if (!(y <= 256 && y >= 0 && x <= 16 && x >= 0 && z <= 16 && z >= 0))
return; //Out of bounds
try {
chunk[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = (byte) material.getId();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
//Generates block sections. Each block section is 16*16*16 blocks, stacked above each other. //There are world height / 16 sections. section number is world height / 16 (>>4)
//returns a byte[world height / 16][], formatted [section id][Blocks]. If there are no blocks in a section, it need not be allocated.
public byte[][] generateBlockSections(World world, Random rand, int ChunkX, int ChunkZ, BiomeGrid biomes) {
Random random = new Random(world.getSeed());
SimplexOctaveGenerator gen = new SimplexOctaveGenerator(random, 8);
PerlinOctaveGenerator gen2 = new PerlinOctaveGenerator(world.getSeed(), 8);
byte[][] chunk = new byte[world.getMaxHeight() / 16][];
gen2.setScale(1 / scale);
gen.setScale(1 / scale); //The distance between peaks of the terrain. Scroll down more to see what happens when you play with this
double threshold = this.threshold; //scroll down to see what happens when you play with this.
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
int real_x = x + ChunkX * 16;
int real_z = z + ChunkZ * 16;
double height = middle + gen2.noise(real_x, real_z, 0.5, 0.5) * middle / 3; // generate some smoother terrain
for (int y = 1; y < height && y < 256; y++) {
if (y > middle - middle / 3) {
double noise = gen.noise(real_x, y, real_z, 0.5, 0.5);
if (noise > threshold) //explained above
setBlock(x, y, z, chunk, Material.STONE); //set the block solid
} else {
setBlock(x, y, z, chunk, Material.STONE);
}
}
}
}
return chunk;
}
}
class CustomPopulator extends BlockPopulator {
@Override
public void populate(World world, Random random, Chunk chunk) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
world.getBlockAt(x + chunk.getX() * 16, 64, z + chunk.getZ() * 16).setType(Material.GRASS);
}
}
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.generator;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* @author joethei
* @version 1.0
*/
public class DevGenerator extends ChunkGenerator{
@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
return Arrays.asList(new BlockPopulator[0]);
}
@Override
public boolean canSpawn(World world, int x, int z) {
return true;
}
private int xyzToByte(int x, int y, int z) {
return (x * 16 + z) * 128 + y;
}
@Override
public byte[] generate(World world, Random random, int chunkx, int chunkz) {
byte[] result = new byte[32768];
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 256; y++) {
if(y > 0 && y < 100) result[xyzToByte(x, y, z)] = (byte) Material.SANDSTONE.getId();
if(y == 0) result[xyzToByte(x, y, z)] = (byte) Material.BEDROCK.getId();
}
}
}
return result;
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.generator;
/**
@ -7,5 +12,8 @@ package eu.univento.teamvento.generator;
public enum Generator {
NORMAL,
FLAT,
VOID;
VOID,
WATER,
DEV,
CUSTOM
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.generator;
import org.bukkit.World;
@ -6,26 +11,46 @@ import org.bukkit.WorldType;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class GeneratorManager {
public static WorldCreator getWorldCreator(String name, String generator) {
WorldCreator creator = new WorldCreator(name);
if(generator.equals("normal")) {
creator.environment(World.Environment.NORMAL);
creator.type(WorldType.NORMAL);
switch (generator) {
case "normal":
creator.environment(World.Environment.NORMAL);
creator.type(WorldType.NORMAL);
break;
case "flat":
creator.environment(World.Environment.NORMAL);
creator.type(WorldType.FLAT);
creator.generateStructures(false);
break;
case "void":
creator.generator(new VoidGenerator());
creator.type(WorldType.CUSTOMIZED);
creator.generateStructures(false);
break;
case "water":
creator.generator(new WaterGenerator());
creator.type(WorldType.CUSTOMIZED);
creator.generateStructures(false);
break;
case "dev":
creator.generator(new DevGenerator());
creator.type(WorldType.CUSTOMIZED);
creator.generateStructures(false);
break;
case "custom":
creator.generator(new CustomGenerator());
creator.type(WorldType.CUSTOMIZED);
creator.generateStructures(false);
break;
default:
return null;
}
if(generator.equals("flat")) {
creator.environment(World.Environment.NORMAL);
creator.type(WorldType.FLAT);
creator.generateStructures(false);
}
if(generator.equals("void")) {
creator.generator(new VoidGenerator());
creator.type(WorldType.CUSTOMIZED);
creator.generateStructures(false);
}else return null;
return creator;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.generator;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* @author joethei
* @version 1.0
*/
public class WaterGenerator extends ChunkGenerator {
@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
return Arrays.asList(new BlockPopulator[0]);
}
@Override
public boolean canSpawn(World world, int x, int z) {
return true;
}
private int xyzToByte(int x, int y, int z) {
return (x * 16 + z) * 128 + y;
}
@Override
public byte[] generate(World world, Random random, int chunkx, int chunkz) {
byte[] result = new byte[32768];
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 256; y++) {
if(y > 1 && y < 22) result[xyzToByte(x, y, z)] = (byte) Material.STATIONARY_WATER.getId();
if(y == 1) result[xyzToByte(x, y, z)] = (byte) Material.SAND.getId();
if(y == 0) result[xyzToByte(x, y, z)] = (byte) Material.BEDROCK.getId();
}
}
}
return result;
}
}

View File

@ -1,7 +1,10 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.listener;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.Config;
import eu.univento.core.api.events.MoveEventFilter;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento;
@ -9,7 +12,10 @@ import eu.univento.teamvento.plot.Plot;
import eu.univento.teamvento.plot.PlotManager;
import eu.univento.teamvento.plot.Time;
import eu.univento.teamvento.plot.Weather;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.WeatherType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
@ -20,10 +26,12 @@ import org.bukkit.event.block.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
@ -38,7 +46,7 @@ import java.util.UUID;
/**
* @author joethei
* @version 0.3
* @version 1.0
*/
public class Events implements Listener {
@ -222,7 +230,6 @@ public class Events implements Listener {
e.setCancelled(true);
}
/*
@EventHandler
public void onPickup(PlayerPickupItemEvent e) {
e.setCancelled(true);
@ -248,7 +255,6 @@ public class Events implements Listener {
e.setCancelled(true);
}
}
*/
@EventHandler
public void onConsume(PlayerItemConsumeEvent e) {
@ -271,7 +277,7 @@ public class Events implements Listener {
public void onBlockMove(MoveEventFilter.PlayerBlockMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
//plot enter
if (PlotManager.getPlotByLocation(e.getFrom()) == null && PlotManager.getPlotByLocation(e.getTo()) != null) {
if (!PlotManager.isPlot(e.getFrom()) && PlotManager.isPlot(e.getTo())) {
Plot plot = PlotManager.getPlotByLocation(e.getTo());
assert plot != null;
p.setPlayerTime(plot.getTime().getValue(), false);
@ -290,7 +296,7 @@ public class Events implements Listener {
}
}
//plot leave
if (PlotManager.getPlotByLocation(e.getFrom()) != null && PlotManager.getPlotByLocation(e.getTo()) == null) {
if (PlotManager.isPlot(e.getFrom()) && !PlotManager.isPlot(e.getTo())) {
p.setPlayerTime(Time.DAY.getValue(), false);
p.setPlayerWeather(WeatherType.CLEAR);
p.clearPotionEffects();
@ -298,28 +304,13 @@ public class Events implements Listener {
lightningTasks.get(p).cancel();
lightningTasks.remove(p);
}
if (e.getTo().getY() <= -5) {
if (!PlotManager.hasPlot(p)) {
p.teleport(Config.readLocation("Build.Locs.Spawn"));
return;
}
Plot plot = PlotManager.getPlotByPlayer(p);
assert plot != null;
Location loc = plot.getSpawn();
p.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
}
Block up = p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
if (p.getLocation().getBlock().getType() == Material.GOLD_PLATE && up.getType() == Material.COAL_BLOCK && p.getDatabasePlayer().isAllowed(Rank.JrSupporter)) {
p.teleport(Bukkit.getWorld("Planning").getSpawnLocation());
p.setGameMode(GameMode.ADVENTURE);
}
}
@EventHandler
public void onTeleport(PlayerTeleportEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
//plot enter
if (PlotManager.getPlotByLocation(e.getFrom()) == null && PlotManager.getPlotByLocation(e.getTo()) != null) {
if (!PlotManager.isPlot(e.getFrom()) && PlotManager.isPlot(e.getTo())) {
Plot plot = PlotManager.getPlotByLocation(e.getTo());
assert plot != null;
p.setPlayerTime(plot.getTime().getValue(), false);
@ -338,7 +329,7 @@ public class Events implements Listener {
}
}
//plot leave
if (PlotManager.getPlotByLocation(e.getFrom()) != null && PlotManager.getPlotByLocation(e.getTo()) == null) {
if (PlotManager.isPlot(e.getFrom()) && !PlotManager.isPlot(e.getTo())) {
p.setPlayerTime(Time.DAY.getValue(), false);
p.setPlayerWeather(WeatherType.CLEAR);
p.clearPotionEffects();
@ -385,6 +376,7 @@ public class Events implements Listener {
public void onEntityShootBow(EntityShootBowEvent e) {
if (e.getEntityType() != EntityType.PLAYER) return;
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity().getName());
assert p != null;
if (p.getUniqueId().toString().equals("682ebd10-3661-49ec-ba4d-4f24b761b1a7")) {
Projectile projectile = (Projectile) e.getProjectile();
projectile.setCustomNameVisible(true);

View File

@ -1,9 +1,16 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.listener;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.plot.Plot;
import eu.univento.teamvento.plot.PlotManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -14,7 +21,7 @@ import org.bukkit.inventory.meta.ItemMeta;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class JoinQuit implements Listener {
@ -24,8 +31,7 @@ public class JoinQuit implements Listener {
public void onJoin(PlayerJoinEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
e.setJoinMessage(null);
p.getDatabasePlayer().getRankAsync().whenComplete((rank, throwable) -> Bukkit.broadcastMessage(p.getDatabasePlayer().getRank().getPrefix() + p.getName() + p.getDatabasePlayer().getRank().getSuffix() + "ist beigetreten"));
p.resetAttackSpeed();
p.getDatabasePlayer().getRankAsync().whenComplete((rank, throwable) -> Bukkit.broadcastMessage(p.getDatabasePlayer().getRank().getPrefix() + p.getName() + "§7ist beigetreten"));
if (PlotManager.hasPlot(p)) {
Plot plot = PlotManager.getPlotByPlayer(p);
assert plot != null;
@ -37,7 +43,10 @@ public class JoinQuit implements Listener {
p.getInventory().setItem(8, menu);
}
}
p.teleport(Bukkit.getWorld("world").getSpawnLocation());
p.getDatabasePlayer().getRankAsync().whenComplete((rank, throwable) -> {
if(rank == Rank.Player) p.teleport(new Location(Bukkit.getWorld("plots"), 11.4D, 24.0D, 25.5D, -90.5F, 1.5F));
});
/*
String[] text;
@ -52,13 +61,15 @@ public class JoinQuit implements Listener {
Hologram holo = new Hologram(new ItemStack(Material.GRASS), text, Config.readLocation("Build.Locs.Holo"));
holograms.put(p, holo);
holo.showPlayer(p);
*/
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
e.setQuitMessage(p.getDatabasePlayer().getRank().getPrefix() + p.getName() + p.getDatabasePlayer().getRank().getSuffix() + "ist von uns gegangen");
e.setQuitMessage(p.getDatabasePlayer().getRank().getPrefix() + p.getName() + "§7ist von uns gegangen");
//holograms.remove(p);
}
}

View File

@ -1,12 +1,17 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.listener;
import eu.univento.commons.player.rank.Rank;
import eu.univento.commons.player.uuid.NameFetcher;
import eu.univento.commons.player.uuid.UUIDFetcher;
import eu.univento.core.Core;
import eu.univento.core.api.gui.AnvilGUI;
import eu.univento.core.api.gui.inventory.InventoryGUI;
import eu.univento.core.api.gui.inventory.PagedInventoryGUI;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.items.PageInventory;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.plot.*;
@ -25,7 +30,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.Map;
/**
* @author joethei
@ -40,7 +45,27 @@ public class MenuEvents implements Listener{
InventoryManager inventoryManager = new InventoryManager(p);
if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
if(p.getItemInHand().getType() == Material.WATCH && p.getItemInHand().getItemMeta().getDisplayName().equals("§eErweiterungen")) {
p.openInventory(inventoryManager.getMainInventory());
if(p.getDatabasePlayer().getRank() == Rank.Player) p.openInventory(inventoryManager.getPlayerInventory());
else {
InventoryGUI gui = new InventoryGUI(p, 27, "§eErweiterungen");
gui.addItem(0, new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullOwner("MHF_Apple").name("§eKöpfe").build(), customPlayer -> {
customPlayer.closeInventory();
InventoryGUI headsMainGui = new InventoryGUI(customPlayer, 9, "§eKöpfe");
headsMainGui.addItem(0, new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullOwner("MHF_Chest").name("§eBlöcke").build(), player -> {
player.closeInventory();
PagedInventoryGUI pagedInventoryGUI = new PagedInventoryGUI(player, "§eBlöcke");
for(Map.Entry<String, String> entry : Core.getHeadDB().getBlocks().entrySet()) {
pagedInventoryGUI.addItem(new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullUrl(entry.getValue()).name(entry.getKey()).build(), clickedPlayer -> {
clickedPlayer.closeInventory();
clickedPlayer.getInventory().addItem(new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullUrl(entry.getValue()).name(entry.getKey()).build());
});
}
pagedInventoryGUI.open();
});
headsMainGui.open();
});
gui.open();
}
}
}
}
@ -56,23 +81,21 @@ public class MenuEvents implements Listener{
if(!e.getCurrentItem().getItemMeta().hasDisplayName()) return;
Plot plot = PlotManager.getPlotByPlayer(p);
assert plot != null;
if(e.getInventory().getName().equals(inventoryManager.getMainInventory().getName())) {
if(e.getInventory().getName().equals(inventoryManager.getPlayerInventory().getName())) {
e.setCancelled(true);
if(e.getCurrentItem().getType() == Material.BED) {
p.closeInventory();
Location loc = plot.getSpawn();
p.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§ePlot zurücksetzen")) {
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eGrundstück zurücksetzen")) {
p.setFlying(true);
PlotManager.resetPlot(plot);
p.closeInventory();
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eFertig")) {
p.closeInventory();
if(plot.hasName() && plot.hasContact())
p.openInventory(inventoryManager.getReadyInventory());
else
p.sendMessage("§cName und Kontaktinformationen müssen angegeben werden");
p.openInventory(inventoryManager.getReadyInventory());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eBiom ändern")) {
p.closeInventory();
@ -93,14 +116,16 @@ public class MenuEvents implements Listener{
if(e.getCurrentItem().getType() == Material.MINECART) {
p.closeInventory();
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
/*
PageInventory inventory = new PageInventory("§eTeleport", p, true);
ArrayList<ItemStack> items = new ArrayList<>();
for(Plot plots : PlotManager.getPlots()) {
String name = NameFetcher.getRequest(plot.getOwner());
items.add(new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullOwner(name).name("§e" + plots.getName()).lore("§evon " + name).make());
items.add(new ItemBuilder(p, Material.SKULL_ITEM).durability((short) 3).skullOwner(name).name("§e" + plots.getName()).lore("§evon " + name).build());
}
inventory.setPages(items);
inventory.openInventory();
*/
});
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.listener;
import eu.univento.core.api.player.CustomPlayer;
@ -11,9 +16,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import java.util.ArrayList;
import java.util.List;
public class SignInteract implements Listener {
@EventHandler
@ -30,59 +32,8 @@ public class SignInteract implements Listener {
p.setFlying(true);
} else {
PlotManager.createPlot(p);
}
}
if(e.getClickedBlock().getType() == Material.SPONGE) {
generateSpiral(0, 0, 10);
}
}
}
public void generateSpiral(int midX, int midZ, int radius) {
int x = midX;
int z = midZ;
int f = 1;
List<Point> points = new ArrayList<>();
while(f <= radius * 2) {
for(int e = z + f; z < e; z++) {
points.add(new Point(x, z));
}
for(int e = x + f; x < e; x++) {
points.add(new Point(x, z));
}
f++;
for(int e = z - f; z > e; z--) {
points.add(new Point(x, z));
}
for(int e = x - f; x > e; x--) {
points.add(new Point(x, z));
}
f++;
}
for(int e = z + f - 1; z < e; z++) {
points.add(new Point(x, z));
}
for(Point point : points)
new Location(Bukkit.getWorld("plots"), point.getX(), 100, point.getZ()).getBlock().setType(Material.BEDROCK);
}
public class Point{
private int x;
private int z;
public int getX() {
return this.x;
}
public int getZ() {
return this.z;
}
public Point(int x, int z) {
this.x = x;
this.z = z;
}
@Override
public String toString() {
return "{" + this.x + " | " + this.z + "}";
}
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.plot;
import eu.univento.core.api.items.ItemBuilder;
@ -24,22 +29,22 @@ public class InventoryManager {
this.player = player;
}
public Inventory getMainInventory() {
public Inventory getPlayerInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§eGrundstücksverwaltung");
inv.setItem(0, new ItemBuilder(Material.MINECART).name("§eZu anderen Plots teleportieren").make());
inv.setItem(2, new ItemBuilder(Material.DOUBLE_PLANT).data(4).name("§eBiom ändern").make());
inv.setItem(8, new ItemBuilder(Material.LADDER).name("§eEinstellungen").make());
inv.setItem(10, new ItemBuilder(Material.WATCH).name("§eZeit ändern").make());
inv.setItem(13, new ItemBuilder(Material.BED).name("§ezu deinem Plot").make());
inv.setItem(16, new ItemBuilder(Material.DOUBLE_PLANT).name("§eWetter ändern").make());
inv.setItem(20, new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullOwner("conorf1807").make());
//inv.setItem(0, new ItemBuilder(player, Material.MINECART).name("§eZu anderen Plots teleportieren").build());
//inv.setItem(8, new ItemBuilder(player, Material.LADDER).name("§eEinstellungen").build());
inv.setItem(1, new ItemBuilder(Material.WATCH).name("§eZeit ändern").build());
inv.setItem(7, new ItemBuilder(Material.DOUBLE_PLANT).durability((short) 4).name("§eBiom ändern").build());
inv.setItem(13, new ItemBuilder(Material.BED).durability((short) 8).name("§ezu deinem Grundstück").build());
inv.setItem(19, new ItemBuilder(Material.DOUBLE_PLANT).name("§eWetter ändern").build());
//inv.setItem(20, new ItemBuilder(player, Material.SKULL_ITEM).durability((short) 3).skullOwner("conorf1807").build());
Dye resetDye = new Dye();
resetDye.setColor(DyeColor.RED);
ItemStack reset = resetDye.toItemStack(1);
ItemMeta resetMeta = reset.getItemMeta();
resetMeta.setDisplayName("§ePlot zurücksetzen");
resetMeta.setDisplayName("§eGrundstück zurücksetzen");
reset.setItemMeta(resetMeta);
Dye readyDye = new Dye();
@ -49,8 +54,8 @@ public class InventoryManager {
readyMeta.setDisplayName("§eFertig");
ready.setItemMeta(readyMeta);
inv.setItem(18, reset);
inv.setItem(26, ready);
inv.setItem(25, reset);
//inv.setItem(26, ready);
return inv;
}
@ -58,8 +63,8 @@ public class InventoryManager {
public Inventory getReadyInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§ePlot fertig ?");
inv.setItem(5, new ItemBuilder(Material.WOOL).color(Color.LIME).name("Ja").make());
inv.setItem(10, new ItemBuilder(Material.WOOL).color(Color.RED).name("Nein").make());
inv.setItem(5, new ItemBuilder(Material.WOOL).color(Color.LIME).name("Ja").build());
inv.setItem(10, new ItemBuilder(Material.WOOL).color(Color.RED).name("Nein").build());
return inv;
}
@ -67,13 +72,14 @@ public class InventoryManager {
public Inventory getBiomeInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§eBiom ändern");
inv.setItem(0, new ItemBuilder(Material.STAINED_CLAY).durability((short) 1).name("§eMessa").make());
inv.setItem(4, new ItemBuilder(Material.SAPLING).durability((short) 3).name("§eDschungel").make());
inv.setItem(8, new ItemBuilder(Material.WATER_LILY).name("§eSumpfgebiet").make());
inv.setItem(11, new ItemBuilder(Material.SAPLING).name("Wald").make());
inv.setItem(15, new ItemBuilder(Material.LONG_GRASS).durability((short) 1).name("§eFlachland").make());
inv.setItem(18, new ItemBuilder(Material.DEAD_BUSH).name("§eWüste").make());
inv.setItem(22, new ItemBuilder(Material.SNOW_BALL).name("§eTundra").make());
inv.setItem(0, new ItemBuilder(Material.STAINED_CLAY).durability((short) 1).name("§eMesa").build());
inv.setItem(4, new ItemBuilder(Material.SAPLING).durability((short) 3).name("§eDschungel").build());
inv.setItem(8, new ItemBuilder(Material.WATER_LILY).name("§eSumpfgebiet").build());
inv.setItem(11, new ItemBuilder(Material.SAPLING).name("§eWald").build());
inv.setItem(15, new ItemBuilder(Material.LONG_GRASS).durability((short) 1).name("§eFlachland").build());
inv.setItem(18, new ItemBuilder(Material.DEAD_BUSH).name("§eWüste").build());
inv.setItem(22, new ItemBuilder(Material.SNOW_BALL).name("§eTundra").build());
inv.setItem(26, new ItemBuilder(Material.SAPLING).name("§eTaiga").durability((short) 1).build());
return inv;
}
@ -81,8 +87,8 @@ public class InventoryManager {
public Inventory getSettingsInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§eEinstellungen");
inv.setItem(10, new ItemBuilder(Material.SIGN).name("§eName ändern").make());
inv.setItem(16, new ItemBuilder(Material.NAME_TAG).name("§eKontaktmöglichkeiten").make());
inv.setItem(10, new ItemBuilder(Material.SIGN).name("§eName ändern").build());
inv.setItem(16, new ItemBuilder(Material.NAME_TAG).name("§eKontaktmöglichkeiten").build());
return inv;
}
@ -90,10 +96,10 @@ public class InventoryManager {
public Inventory getTimeInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§eZeit ändern");
inv.setItem(10, new ItemBuilder(Material.MILK_BUCKET).name("§eMorgen").make());
inv.setItem(12, new ItemBuilder(Material.DOUBLE_PLANT).name("§eTag").make());
inv.setItem(14, new ItemBuilder(Material.BEETROOT_SOUP).name("§eAbend").make());
inv.setItem(16, new ItemBuilder(Material.COAL).name("§eNacht").durability((short) 1).make());
inv.setItem(10, new ItemBuilder(Material.MILK_BUCKET).name("§eMorgen").build());
inv.setItem(12, new ItemBuilder(Material.DOUBLE_PLANT).name("§eTag").build());
inv.setItem(14, new ItemBuilder(Material.BEETROOT_SOUP).name("§eAbend").build());
inv.setItem(16, new ItemBuilder(Material.COAL).name("§eNacht").durability((short) 1).build());
return inv;
}
@ -101,9 +107,9 @@ public class InventoryManager {
public Inventory getWeatherInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§eWetter ändern");
inv.setItem(11, new ItemBuilder(Material.DOUBLE_PLANT).name("§eSonne").make());
inv.setItem(13, new ItemBuilder(Material.WATER_BUCKET).name("§eRegen").make());
inv.setItem(15, new ItemBuilder(Material.BLAZE_ROD).name("§eGewitter").make());
inv.setItem(11, new ItemBuilder(Material.DOUBLE_PLANT).name("§eSonne").build());
inv.setItem(13, new ItemBuilder(Material.WATER_BUCKET).name("§eRegen").build());
inv.setItem(15, new ItemBuilder(Material.BLAZE_ROD).name("§eGewitter").build());
return inv;
}

View File

@ -1,7 +1,14 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.plot;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.schematic.Cuboid;
import io.vertx.core.json.JsonObject;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@ -19,6 +26,7 @@ import java.util.UUID;
public class Plot {
private JsonObject json;
private final Cuboid area;
private final UUID owner;
private final Location spawn;
@ -29,6 +37,21 @@ public class Plot {
this.spawn = spawn;
}
public Plot(JsonObject json) {
this.json = json;
this.area = new Cuboid(getLocation("minPos"), getLocation("maxPos"));
this.owner = UUID.fromString(json.getString("uuid"));
this.spawn = getLocation("Spawn");
}
private void update() {
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("plots", new JsonObject().put("uuid", getOwner().toString()), null, res -> {
if(res.succeeded()) {
this.json = res.result();
}else res.cause().printStackTrace();
});
}
public boolean isInPlot(Location location) {
return area.containsLocation(location);
}
@ -60,11 +83,11 @@ public class Plot {
}
public Biome getBiome() {
return Biome.valueOf(getStringFromDatabase("biome"));
return Biome.valueOf(json.getString("biome"));
}
public String getName() {
return getStringFromDatabase("name");
return json.getString("name");
}
public void setName(String name) {
@ -80,7 +103,7 @@ public class Plot {
}
public Time getTime() {
return Time.valueOf(getStringFromDatabase("time"));
return Time.valueOf(json.getString("time"));
}
public void setWeather(Weather weather) {
@ -88,7 +111,7 @@ public class Plot {
}
public Weather getWeather() {
return Weather.valueOf(getStringFromDatabase("weather"));
return Weather.valueOf(json.getString("weather"));
}
public void setContact(String contact) {
@ -96,7 +119,7 @@ public class Plot {
}
public String getContact() {
return getStringFromDatabase("contact");
return json.getString("contact");
}
public boolean hasContact() {
@ -108,7 +131,7 @@ public class Plot {
}
public boolean isReady() {
return (boolean) getObjectFromDatbase("ready");
return json.getBoolean("ready");
}
public WeatherType getWeatherType() {
@ -116,15 +139,18 @@ public class Plot {
return WeatherType.valueOf(getWeather().name());
}
private Object getObjectFromDatbase(String name) {
return null;
private Location getLocation(String name) {
JsonObject location = json.getJsonObject(name);
return new Location(Bukkit.getWorld("plots"), location.getDouble("X"), location.getDouble("Y"), location.getDouble("Z"));
}
private String getStringFromDatabase(String name) {
return "";
}
private void setInDatabase(String name, Object obj) {
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOneAndUpdate("plots", new JsonObject().put("uuid", getOwner().toString()), new JsonObject().put("$set", new JsonObject().put(name, obj)), event -> {
if(event.failed()) {
event.cause().printStackTrace();
}
});
update();
}
}

View File

@ -1,13 +1,15 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.plot;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento;
import lombok.AllArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
/**
* @author joethei
@ -29,13 +31,19 @@ interface PlotAction {
@Override
public void execute() {
Plot plot = PlotManager.getPlotPosition(player);
PlotManager.addPlotToDatabase(plot);
PlotManager.generatePlot(plot);
assert plot != null;
Location loc = plot.getSpawn();
player.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
player.sendHologram(new ItemStack(Material.GRASS), Config.readLocation("Build.Locs.Holo"), "§eZu deinem Plot teleportieren", "|", "|", "");
if(PlotManager.hasPlot(player)) {
player.sendMessage("§cDu hast doch schon ein Grundstück");
}else {
player.sendMessage("§aDein Grundstück wird erstellt");
Plot plot = PlotManager.getPlotPosition(player);
PlotManager.addPlotToDatabase(plot);
PlotManager.generatePlot(plot);
assert plot != null;
Location loc = plot.getSpawn();
player.setFlying(true);
player.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
//player.sendHologram(new ItemStack(Material.GRASS), Config.readLocation("Build.Locs.Holo"), "§eZu deinem Plot teleportieren", "|", "|", "");
}
}
}
@ -50,7 +58,7 @@ interface PlotAction {
@Override
public void execute() {
PlotManager.clearPlot(plot);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> PlotManager.generatePlot(plot), 13 * 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> PlotManager.generatePlot(plot), 15 * 20L);
}
}

View File

@ -1,7 +1,13 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.teamvento.plot;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.Core;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.schematic.Cuboid;
import eu.univento.teamvento.TeamVento;
@ -13,9 +19,13 @@ import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.time.Instant;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.LinkedBlockingDeque;
@ -39,21 +49,17 @@ public class PlotManager {
return lastPlot;
}
public static void setLastPlot(Plot plot) {
lastPlot = plot;
}
public static void update() {
Core.getCommons().getDatabaseManager().getMongoDB().getClient().find("plots", null, res -> {
Core.getCommons().getDatabaseManager().getMongoDB().getClient().find("plots", new JsonObject(), res -> {
if(res.succeeded()) {
for(JsonObject json : res.result()) {
String uuid = json.getString("uuid");
Plot plot = new Plot(new Cuboid(getLocation(uuid, "minPos"), getLocation(uuid, "maxPos")), UUID.fromString(uuid), getLocation(uuid, "Spawn"));
Plot plot = new Plot(json);
plots.add(plot);
plot.setBiome(plot.getBiome());
}
}else res.cause().printStackTrace();
});
lastPlot = getPlotByOwner(Config.readString("lastPlot"));
}
public static Plot getPlotByPlayer(CustomPlayer p) {
@ -69,17 +75,20 @@ public class PlotManager {
public static void createPlot(CustomPlayer p) {
if(queue.isEmpty()) {
new PlotAction.Create(p).execute();
}else {
queue.offer(new PlotAction.Create(p));
p.sendMessage("Du wurdest zur Warteschlange hinzugefügt: (" + queue.size() + ")");
queue.peek().execute();
}else {
p.sendMessage("§7Du wurdest zur Warteschlange hinzugefügt, bitte habe einen Moment Geduld: (" + queue.size() + ")");
queue.offer(new PlotAction.Create(p));
}
}
public static void resetPlot(Plot plot) {
if(queue.isEmpty()) {
new PlotAction.Reset(plot).execute();
queue.offer(new PlotAction.Reset(plot));
queue.peek().execute();
}else {
CustomPlayer.getPlayer(plot.getOwner()).sendMessage("§7Du wurdest zur Warteschlange hinzugefügt, bitte habe einen Moment Geduld: (" + queue.size() + ")");
queue.offer(new PlotAction.Reset(plot));
}
}
@ -162,10 +171,7 @@ public class PlotManager {
long i = 0;
for (Block b : rand1.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
b.setType(Material.WOOD_STEP);
b.setData((byte) 1);
}, i);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.STEP), i);
}
});
Cuboid rand2 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getUpperY() + 1.0D, blocks.getUpperZ()), new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getUpperY() + 1.0D, blocks.getUpperZ() - 50.0D));
@ -173,10 +179,7 @@ public class PlotManager {
long i = 0;
for (Block b : rand2.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
b.setType(Material.WOOD_STEP);
b.setData((byte) 1);
}, i);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.STEP), i);
}
});
Cuboid rand3 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getLowerX(), blocks.getUpperY() + 1.0D, blocks.getLowerZ()), new Location(Bukkit.getWorld("plots"), blocks.getLowerX(), blocks.getUpperY() + 1.0D, blocks.getLowerZ() + 50.0D));
@ -184,10 +187,7 @@ public class PlotManager {
long i = 0;
for (Block b : rand3.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
b.setType(Material.WOOD_STEP);
b.setData((byte) 1);
}, i);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.STEP), i);
}
});
Cuboid rand4 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getLowerX(), blocks.getUpperY() + 1.0D, blocks.getLowerZ()), new Location(Bukkit.getWorld("plots"), blocks.getLowerX() + 50.D, blocks.getUpperY() + 1.0D, blocks.getLowerZ()));
@ -195,42 +195,39 @@ public class PlotManager {
long i = 0;
for (Block b : rand4.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
b.setType(Material.WOOD_STEP);
b.setData((byte) 1);
}, i);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.STEP), i);
}
});
Cuboid street1 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX() + 1.0D, blocks.getUpperY(), blocks.getUpperZ() + 4.0D), new Location(Bukkit.getWorld("plots"), blocks.getUpperX() + 4.0D, 0.0D, blocks.getUpperZ() - 54.0D));
Cuboid street1 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX() + 1.0D, blocks.getUpperY(), blocks.getUpperZ() + 4.0D), new Location(Bukkit.getWorld("plots"), blocks.getUpperX() + 4.0D, 0D, blocks.getUpperZ() - 54.0D));
Bukkit.getScheduler().runTaskLaterAsynchronously(TeamVento.getInstance(), () -> {
long i = 0;
for (Block b : street1.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.COAL_BLOCK), i / 16);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.CONCRETE), i / 16);
}
}, 35 * 20L);
Cuboid street2 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getLowerX() - 1.0D, blocks.getUpperY(), blocks.getLowerZ() - 4.0D), new Location(Bukkit.getWorld("plots"), blocks.getLowerX() - 4.0D, 0.0D, blocks.getLowerZ() + 54.0D));
Cuboid street2 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getLowerX() - 1.0D, blocks.getUpperY(), blocks.getLowerZ() - 4.0D), new Location(Bukkit.getWorld("plots"), blocks.getLowerX() - 4.0D, 0D, blocks.getLowerZ() + 54.0D));
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
long i = 0;
for (Block b : street2.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.COAL_BLOCK), i / 16);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.CONCRETE), i / 16);
}
});
Cuboid street3 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getUpperY(), blocks.getUpperZ() + 1.0D), new Location(Bukkit.getWorld("plots"), blocks.getLowerX(), 0.0D, blocks.getLowerZ() + 54.0D));
Cuboid street3 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getUpperY(), blocks.getUpperZ() + 1.0D), new Location(Bukkit.getWorld("plots"), blocks.getLowerX(), 0D, blocks.getLowerZ() + 54.0D));
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
long i = 0;
for (Block b : street3.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.COAL_BLOCK), i / 16);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.CONCRETE), i / 16);
}
});
Cuboid street4 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getUpperY(), blocks.getUpperZ() - 54.0D), new Location(Bukkit.getWorld("plots"), blocks.getLowerX(), 0.0D, blocks.getLowerZ() - 1.0D));
Cuboid street4 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getUpperY(), blocks.getUpperZ() - 54.0D), new Location(Bukkit.getWorld("plots"), blocks.getLowerX(), 0D, blocks.getLowerZ() - 1.0D));
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
long i = 0;
for (Block b : street4.getBlocks()) {
i++;
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.COAL_BLOCK), i / 16);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.CONCRETE), i / 16);
}
});
@ -241,135 +238,44 @@ public class PlotManager {
menu.setItemMeta(menuMeta);
Bukkit.getPlayer(plot.getOwner()).getInventory().setItem(8, menu);
}, 35 * 20L));
if(!queue.isEmpty()) queue.peek().execute();
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), new BukkitRunnable() {
@Override
public void run() {
queue.poll();
if(!queue.isEmpty()) {
queue.peek().execute();
}
}
}, 60 * 20L);
}
static Plot getPlotPosition(CustomPlayer p) {
if (lastPlot == null) {
Bukkit.broadcastMessage("Erstes Plot");
Location lower = new Location(Bukkit.getWorld("plots"), Bukkit.getWorld("plots").getSpawnLocation().getX(), Bukkit.getWorld("plots").getSpawnLocation().getY() - 20.0D, Bukkit.getWorld("plots").getSpawnLocation().getZ());
Location upper = new Location(Bukkit.getWorld("plots"), lower.getX() + 50.0D, lower.getY() + 250.0D, lower.getZ() + 50.0D);
Cuboid area = new Cuboid(upper, lower);
return new Plot(area, p.getUniqueId(), new Location(Bukkit.getWorld("plots"), upper.getX() + 1.0D, lower.getY() + 25.0D, lower.getZ() + 25.0D));
Plot plot = new Plot(area, p.getUniqueId(), new Location(Bukkit.getWorld("plots"), upper.getX() + 1.0D, lower.getY() + 25.0D, lower.getZ() + 25.0D));
plots.add(plot);
lastPlot = plot;
return plot;
}
Location upper = lastPlot.getArea().getUpperLocation();
Location lower = lastPlot.getArea().getLowerLocation();
Location west = new Location(Bukkit.getWorld("plots"), lower.getX() - 25.0D, lower.getY() + 25.0D, lower.getZ() + 25.0D);
Location east = new Location(Bukkit.getWorld("plots"), upper.getX() + 25.0D, lower.getY() + 25.0D, lower.getZ() + 25.0D);
Location north = new Location(Bukkit.getWorld("plots"), lower.getX() + 25.0D, lower.getY() + 25.0D, lower.getZ() - 25.0D);
Location south = new Location(Bukkit.getWorld("plots"), upper.getX() - 25.0D, lower.getY() + 25.0D, lower.getZ() + 75.0D);
upper.setX(upper.getX() + 70);
lower.setX(lower.getX() + 70);
west.getBlock().setType(Material.GLASS);
east.getBlock().setType(Material.GRASS_PATH);
north.getBlock().setType(Material.STONE);
south.getBlock().setType(Material.ACACIA_STAIRS);
boolean westPlot = isPlot(west);
boolean eastPlot = isPlot(east);
boolean northPlot = isPlot(north);
boolean southPlot = isPlot(south);
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Westen");
upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Norden");
upper.setZ(upper.getZ() - 55);
lower.setZ(lower.getZ() - 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Osten");
upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Osten 2");
upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Süden");
upper.setZ(upper.getZ() + 55);
lower.setZ(lower.getZ() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Süden 2");
upper.setZ(upper.getZ() + 55);
lower.setZ(upper.getZ() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Westen 2");
upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Norden 2");
upper.setZ(upper.getZ() - 55);
lower.setZ(lower.getZ() - 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Norden 3");
upper.setZ(upper.getZ() - 55);
lower.setZ(lower.getZ() - 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Osten 3");
upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Osten 4");
upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Süden 3");
upper.setZ(upper.getZ() + 55);
lower.setZ(lower.getZ() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Westen 3");
upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
if (westPlot && eastPlot && northPlot && southPlot) {
Bukkit.broadcastMessage("Plot im Westen 4");
upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
return null;
}
private static Plot getPlot(UUID uuid, Location upper, Location lower) {
Cuboid area = new Cuboid(upper, lower);
Location spawn = new Location(Bukkit.getWorld("plots"), lower.getX() + 52.0D, lower.getY() + 25.0D, lower.getZ() + 25.0D);
Plot plot = new Plot(area, uuid, spawn);
Plot plot = new Plot(area, p.getUniqueId(), spawn);
plots.add(plot);
lastPlot = plot;
return plot;
}
static void addPlotToDatabase(Plot plot) {
JsonObject json = new JsonObject().put("uuid", plot.getOwner().toString());
Date date = new Date();
HashMap<String, Object> maxPos = new HashMap<>();
maxPos.put("X", plot.getArea().getUpperX());
@ -386,16 +292,15 @@ public class PlotManager {
spawn.put("Y", plot.getSpawn().getY());
spawn.put("Z", plot.getSpawn().getZ());
json.put("created", date).put("maxPos", new JsonObject(maxPos)).put("minPos", new JsonObject(minPos)).put("Spawn", new JsonObject(spawn)).put("time", Time.DAY.name())
json.put("created", Instant.now()).put("maxPos", new JsonObject(maxPos)).put("minPos", new JsonObject(minPos)).put("Spawn", new JsonObject(spawn)).put("time", Time.DAY.name())
.put("weather", Weather.CLEAR.name()).put("biome", Biome.PLAINS.name()).put("name", "§cunbenanntes Plot").put("contact", "").put("ready", false);
Core.getCommons().getDatabaseManager().getMongoDB().getClient().insert("plots", json, res -> {
if(res.failed()) res.cause().printStackTrace();
});
}
private static boolean isPlot(Location location) {
public static boolean isPlot(Location location) {
return getPlotByLocation(location) != null;
}
@ -411,45 +316,24 @@ public class PlotManager {
return null;
}
public static CompletableFuture<Instant> getCreatedDate(String uuid) {
return getDateFromDatabase(uuid);
}
private static Location getLocation(String uuid, String name) {
Map<String, Object> map = getMapFromDatabase(uuid, name);
return new Location(Bukkit.getWorld("plots"), Double.valueOf(String.valueOf(map.get("X"))), Double.valueOf(String.valueOf(map.get("Y"))), Double.valueOf(String.valueOf(map.get("Z"))));
}
public static boolean isAllowedToBuild(CustomPlayer p, Location loc) {
if(loc.getWorld().getName().equalsIgnoreCase("plots")) {
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return true;
if (p.getDatabasePlayer().isAllowed(Rank.Admin)) return true;
if(getPlotByLocation(loc) == null) return false;
Plot plot = getPlotByLocation(loc);
return plot != null && plot.isOwner(p);
assert plot != null;
return plot.isOwner(p);
}else {
return true;
}
}
private static CompletableFuture<Instant> getDateFromDatabase(String uuid) {
public static CompletableFuture<Instant> getCreatedDate(UUID uuid) {
CompletableFuture<Instant> future = new CompletableFuture<>();
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("plots", new JsonObject().put("uuid", uuid), null, res -> {
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("plots", new JsonObject().put("uuid", uuid.toString()), null, res -> {
if(res.succeeded()) future.complete(res.result().getInstant("created"));
else res.cause().printStackTrace();
});
return future;
}
private static CompletableFuture<Object> getObjectFromDatbase(String uuid, String name) {
CompletableFuture<Object> future = new CompletableFuture<>();
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("plots", new JsonObject().put("uuid", uuid), null, res -> {
if(res.succeeded()) future.complete(res.result().getValue(name));
else res.cause().printStackTrace();
});
return future;
}
private static Map<String, Object> getMapFromDatabase(String uuid, String name) {
return (Map<String, Object>) getObjectFromDatbase(uuid, name);
}
}