added failing plot generation
This commit is contained in:
parent
cbf9c92398
commit
48147b61ca
@ -11,25 +11,26 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.10-R0.1-SNAPSHOT" 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" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" 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" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.9.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
|
||||
<orderEntry type="module" module-name="Core" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-async:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:bson:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.31.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" />
|
||||
<orderEntry type="module" module-name="Core" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
|
||||
</component>
|
||||
</module>
|
29
pom.xml
29
pom.xml
@ -4,14 +4,15 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>eu.univento</groupId>
|
||||
<artifactId>TeamVento</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<groupId>eu.univento</groupId>
|
||||
<name>Univento.eu TeamVento</name>
|
||||
<url>http://univento.eu</url>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -61,21 +62,41 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-async</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.0.36.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.univento</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
|
20
src/main/TeamVento.iml
Normal file
20
src/main/TeamVento.iml
Normal file
@ -0,0 +1,20 @@
|
||||
<?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>
|
@ -1,23 +1,21 @@
|
||||
package eu.univento.teamvento;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import eu.univento.teamvento.commands.*;
|
||||
import eu.univento.teamvento.listener.Events;
|
||||
import eu.univento.teamvento.listener.JoinQuit;
|
||||
import eu.univento.teamvento.listener.PositionSetter;
|
||||
import eu.univento.teamvento.listener.*;
|
||||
import eu.univento.teamvento.utils.PlotManager;
|
||||
import eu.univento.teamvento.utils.VoidGenerator;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
@ -28,7 +26,6 @@ public class TeamVento extends JavaPlugin {
|
||||
private static File file = new File("plugins/Core", "worlds.yml");
|
||||
private static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
|
||||
public static File getConfigFile() {
|
||||
return file;
|
||||
}
|
||||
@ -55,39 +52,58 @@ public class TeamVento extends JavaPlugin {
|
||||
pm.registerEvents(new JoinQuit(), this);
|
||||
pm.registerEvents(new Events(), this);
|
||||
pm.registerEvents(new PositionSetter(), this);
|
||||
pm.registerEvents(new SignInteract(), this);
|
||||
pm.registerEvents(new MenuEvents(), this);
|
||||
|
||||
new Setloc(this, "setloc" , "sets locations");
|
||||
new Prebuild(this, "prebuild", "sets players to prebuild mode");
|
||||
new WorldTP(this, "worldtp", "teleports players to other worlds", "wtp");
|
||||
new WorldCreate(this, "worldcreate", "creates new worlds", "wc");
|
||||
new WorldImport(this, "worldimport", "imports worlds", "wi");
|
||||
new Set(this, "set", "sets the material of selected blocks");
|
||||
new Sel(this, "sel", "removes block selection");
|
||||
new WorldList(this, "worldlist", "lists all worlds", "wl");
|
||||
new PlotInfo(this, "plotinfo", "info about a plot", "pi");
|
||||
new Pack(this, "pack", "sets resource pack");
|
||||
|
||||
for(String world : cfg.getStringList("worlds")) {
|
||||
Bukkit.createWorld(new WorldCreator(world));
|
||||
for(String world : getCfg().getKeys(true)) {
|
||||
String generator = getCfg().getString(world);
|
||||
WorldCreator creator = new WorldCreator(world);
|
||||
creator.generateStructures(false);
|
||||
if(generator.equals("normal")) {
|
||||
creator.environment(World.Environment.NORMAL);
|
||||
creator.type(WorldType.NORMAL);
|
||||
}
|
||||
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);
|
||||
}
|
||||
Bukkit.createWorld(creator);
|
||||
World loadedWorld = Bukkit.getWorld(world);
|
||||
loadedWorld.setDifficulty(Difficulty.PEACEFUL);
|
||||
loadedWorld.setPVP(false);
|
||||
loadedWorld.setAnimalSpawnLimit(0);
|
||||
}
|
||||
|
||||
|
||||
ServerSettings.setGameMode(GameMode.CREATIVE);
|
||||
ServerSettings.setBuild(true);
|
||||
PlotManager.update();
|
||||
PlotManager.setLastPlot(PlotManager.getPlotByOwner(Config.readString("lastPlot")));
|
||||
log(Level.INFO, "Plugin ver." + getDescription().getVersion() + " gestartet");
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
ArrayList<String> worlds = Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
cfg.set("worlds", worlds);
|
||||
|
||||
try {
|
||||
cfg.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Config.write("lastPlot", PlotManager.getLastPlot().getOwner().toString());
|
||||
Bukkit.getWorld("plots").getLivingEntities().forEach(Entity::remove);
|
||||
log(Level.INFO, "Plugin beendet");
|
||||
}
|
||||
}
|
50
src/main/java/eu/univento/teamvento/commands/Pack.java
Normal file
50
src/main/java/eu/univento/teamvento/commands/Pack.java
Normal file
@ -0,0 +1,50 @@
|
||||
package eu.univento.teamvento.commands;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.ResourcePack;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 01.07.2016
|
||||
*/
|
||||
public class Pack extends AutoCommand<TeamVento>{
|
||||
|
||||
public Pack(TeamVento plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) sender);
|
||||
if(args.length == 1) {
|
||||
if(ResourcePack.valueOf(args[0]) != null) {
|
||||
p.setResourcePack(ResourcePack.valueOf(args[0]).getUrl());
|
||||
}else p.sendMessage("§cDieses Pack ist nicht erhätlich");
|
||||
}else{
|
||||
p.sendMessage("§cDa stimmt was mit den Argumenten nicht");
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for(ResourcePack pack : ResourcePack.values()) {
|
||||
list.add(pack.name());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
55
src/main/java/eu/univento/teamvento/commands/PlotInfo.java
Normal file
55
src/main/java/eu/univento/teamvento/commands/PlotInfo.java
Normal file
@ -0,0 +1,55 @@
|
||||
package eu.univento.teamvento.commands;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.core.api.utils.UUIDFetcher;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.Plot;
|
||||
import eu.univento.teamvento.utils.PlotManager;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlotInfo extends AutoCommand<TeamVento>{
|
||||
|
||||
public PlotInfo(TeamVento plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) sender);
|
||||
if(p.isAllowed(Rank.SrBuilder)) {
|
||||
if(PlotManager.getPlotByLocation(p.getLocation()) != null) {
|
||||
Plot plot = PlotManager.getPlotByLocation(p.getLocation());
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
p.sendMessage("§eErsteller: " + UUIDFetcher.getName(plot.getOwner()));
|
||||
p.sendMessage("§eErstellt am: " + PlotManager.getCreatedDate(plot.getOwner().toString()));
|
||||
TextComponent pack = new TextComponent("§eResourcePack " + plot.getResourcePack().getName());
|
||||
pack.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/pack " + plot.getResourcePack().name()));
|
||||
//p.spigot().sendMessage(pack);
|
||||
});
|
||||
}else{
|
||||
p.sendMessage("§cHier ist leider kein Plot");
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().NO_PERMS());
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package eu.univento.teamvento.commands;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import eu.univento.core.commands.Build;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Prebuild extends AutoCommand<TeamVento> {
|
||||
|
||||
|
||||
public Prebuild(TeamVento plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if(p.isAllowed(Ranks.HeadBuilder)) {
|
||||
if(args.length == 1) {
|
||||
if(Bukkit.getPlayer(args[0]) != null) {
|
||||
CustomPlayer t = CustomPlayer.getPlayer(Bukkit.getPlayer(args[0]));
|
||||
if(Build.getPlayers().containsKey(t)) {
|
||||
ItemStack[] content = Build.getPlayers().get(t);
|
||||
t.getInventory().setContents(content);
|
||||
Build.getPlayers().remove(t);
|
||||
t.setGameMode(ServerSettings.getGameMode());
|
||||
t.sendMessage(t.getMessages().PREFIX() + t.getMessages().Core_BUILD_OFF());
|
||||
}else {
|
||||
Build.getPlayers().put(t, t.getInventory().getContents());
|
||||
t.sendMessage(t.getMessages().PREFIX() + t.getMessages().Core_BUILD_ON());
|
||||
t.getInventory().clear();
|
||||
t.setGameMode(GameMode.CREATIVE);
|
||||
t.teleport(Bukkit.getWorld("vorbauen").getSpawnLocation());
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().NOT_ONLINE(args[0]));
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cplease use /prebuild <Player>");
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().NO_PERMS());
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
41
src/main/java/eu/univento/teamvento/commands/Sel.java
Normal file
41
src/main/java/eu/univento/teamvento/commands/Sel.java
Normal file
@ -0,0 +1,41 @@
|
||||
package eu.univento.teamvento.commands;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.WorldEdit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Sel extends AutoCommand<TeamVento>{
|
||||
|
||||
public Sel(TeamVento plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if(p.isAllowed(Rank.Builder)) {
|
||||
WorldEdit.setPos1(p, null);
|
||||
WorldEdit.setPos2(p, null);
|
||||
p.sendMessage(p.getMessages().PREFIX() + "selection cleared");
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().NO_PERMS());
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -4,9 +4,10 @@ import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.map.Cuboid;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.WorldEdit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -28,7 +29,7 @@ public class Set extends AutoCommand<TeamVento>{
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if(p.isAllowed(Ranks.Builder)) {
|
||||
if(p.isAllowed(Rank.Builder)) {
|
||||
Material material;
|
||||
if(args.length == 0) {
|
||||
material = p.getInventory().getItemInMainHand().getType();
|
||||
@ -63,10 +64,18 @@ public class Set extends AutoCommand<TeamVento>{
|
||||
|
||||
void setBlocks(Material material, CustomPlayer p) {
|
||||
if(material.isBlock()) {
|
||||
Cuboid cb = new Cuboid(WorldEdit.getPos1(p).getLocation(), WorldEdit.getPos2(p).getLocation());
|
||||
for(Block b : cb.getBlocks()) {
|
||||
b.setType(material);
|
||||
if(WorldEdit.getPos1(p) == null || WorldEdit.getPos2(p) == null) {
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§ca location has not been set");
|
||||
return;
|
||||
}
|
||||
Cuboid cb = new Cuboid(WorldEdit.getPos1(p).getLocation(), WorldEdit.getPos2(p).getLocation());
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for(Block b : cb.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(material), i / 90);
|
||||
}
|
||||
});
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§ayou have changed the material of the blocks");
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cthe item needs to be a block");
|
||||
|
@ -4,7 +4,7 @@ import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -33,11 +33,10 @@ public class Setloc extends AutoCommand<TeamVento>{
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
if(p.isAllowed(Rank.SrDeveloper)) {
|
||||
if(args.length == 1) {
|
||||
Config.write("Build.Locs." + args[0], p.getLocation());
|
||||
p.sendMessage("§aLocation gesetzt");
|
||||
System.out.println("Location gesetzt " + args[0]);
|
||||
}else {
|
||||
p.sendMessage("§6Nutze /setloc <Ort>");
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package eu.univento.teamvento.commands;
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.VoidGenerator;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -30,7 +30,7 @@ public class WorldCreate extends AutoCommand<TeamVento>{
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if(p.isAllowed(Ranks.HeadBuilder)) {
|
||||
if(p.isAllowed(Rank.SrBuilder)) {
|
||||
if(args.length == 2) {
|
||||
if(Bukkit.getWorld(args[0]) == null && (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("flat") || args[1].equalsIgnoreCase("void"))) {
|
||||
WorldCreator creator = new WorldCreator(args[0]);
|
||||
@ -49,7 +49,7 @@ public class WorldCreate extends AutoCommand<TeamVento>{
|
||||
creator.generateStructures(false);
|
||||
}
|
||||
Bukkit.createWorld(creator);
|
||||
TeamVento.getCfg().set("worlds", TeamVento.getCfg().getStringList("worlds").add(args[0]));
|
||||
TeamVento.getCfg().set(args[0], args[1]);
|
||||
try {
|
||||
TeamVento.getCfg().save(TeamVento.getConfigFile());
|
||||
} catch (IOException e) {
|
||||
|
@ -3,7 +3,7 @@ package eu.univento.teamvento.commands;
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.WorldCreator;
|
||||
@ -27,11 +27,11 @@ public class WorldImport extends AutoCommand<TeamVento>{
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if (p.isAllowed(Ranks.HeadBuilder)) {
|
||||
if (p.isAllowed(Rank.SrBuilder)) {
|
||||
if(args.length == 1) {
|
||||
if(Bukkit.getWorld(args[0]) == null) {
|
||||
Bukkit.createWorld(new WorldCreator(args[0]));
|
||||
TeamVento.getCfg().set("worlds", TeamVento.getCfg().getStringList("worlds").add(args[0]));
|
||||
TeamVento.getCfg().set(args[0], args[1]);
|
||||
try {
|
||||
TeamVento.getCfg().save(TeamVento.getConfigFile());
|
||||
} catch (IOException e) {
|
||||
|
@ -3,7 +3,7 @@ package eu.univento.teamvento.commands;
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -24,9 +24,9 @@ public class WorldList extends AutoCommand<TeamVento> {
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if(p.isAllowed(Ranks.Supporter)) {
|
||||
if(p.isAllowed(Rank.Supporter)) {
|
||||
p.sendMessage("§cAll worlds");
|
||||
for(String world : TeamVento.getCfg().getStringList("worlds")) {
|
||||
for(String world : TeamVento.getCfg().getKeys(true)) {
|
||||
p.sendMessage("§a- " + world);
|
||||
}
|
||||
}else{
|
||||
|
@ -3,13 +3,16 @@ package eu.univento.teamvento.commands;
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
@ -25,7 +28,7 @@ public class WorldTP extends AutoCommand<TeamVento>{
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if(p.isAllowed(Ranks.Supporter)) {
|
||||
if(p.isAllowed(Rank.Supporter)) {
|
||||
if(args.length == 1) {
|
||||
if(Bukkit.getWorld(args[0]) != null) {
|
||||
p.teleport(Bukkit.getWorld(args[0]).getSpawnLocation());
|
||||
@ -47,6 +50,6 @@ public class WorldTP extends AutoCommand<TeamVento>{
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
return Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
}
|
@ -1,17 +1,41 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.events.MoveEventFilter;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.Plot;
|
||||
import eu.univento.teamvento.utils.PlotManager;
|
||||
import org.bukkit.Material;
|
||||
import eu.univento.teamvento.utils.Time;
|
||||
import eu.univento.teamvento.utils.Weather;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
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.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
@ -19,47 +43,387 @@ import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
*/
|
||||
public class Events implements Listener{
|
||||
|
||||
public static int redstone;
|
||||
|
||||
private HashMap<CustomPlayer, BukkitTask> lightningTasks = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onTramp(PlayerInteractEvent e) {
|
||||
if(e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.SOIL) {
|
||||
if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.SOIL)
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent e) {
|
||||
e.blockList().clear();
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
|
||||
if(!p.isAllowed(Ranks.Builder)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else if(!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) {
|
||||
if (p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
|
||||
if(!p.isAllowed(Ranks.Builder)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if(PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()) == null) e.setCancelled(true);
|
||||
if(!PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
if(!e.getBlockPlaced().getWorld().getName().equals("plots")) e.setCancelled(false);
|
||||
if(p.isAllowed(Rank.SrDeveloper)) e.setCancelled(false);
|
||||
/**
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (p.isAllowed(Ranks.SrDeveloper)) return;
|
||||
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else if(!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) {
|
||||
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||
e.setBuildable(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingPlace(HangingPlaceEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true);
|
||||
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent e) {
|
||||
if(e.getRemover() instanceof Projectile) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) ((Projectile) e.getRemover()).getShooter());
|
||||
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) e.setCancelled(true);
|
||||
if (!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
if(e.getRemover() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getRemover());
|
||||
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) e.setCancelled(true);
|
||||
if (!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}else{
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||
if (e.getDamager() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getDamager());
|
||||
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (PlotManager.getPlotByLocation(e.getDamager().getLocation()) == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
if(e.getDamager() instanceof Projectile) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) ((Projectile) e.getDamager()).getShooter());
|
||||
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if(p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (PlotManager.getPlotByLocation(e.getDamager().getLocation()) == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onBurn(BlockBurnEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockIgnite(BlockIgniteEvent e) {
|
||||
if (e.getCause() != BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true);
|
||||
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeaveDecay(LeavesDecayEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockRedstone(BlockRedstoneEvent e) {
|
||||
if(e.getBlock().getWorld().getName().equalsIgnoreCase("EinfachAFK")) return;
|
||||
redstone++;
|
||||
if (redstone > 100) {
|
||||
e.getBlock().setType(Material.SIGN_POST);
|
||||
Sign sign = (Sign) e.getBlock().getState();
|
||||
sign.setLine(0, "Redstone");
|
||||
sign.setLine(1, "Clocks");
|
||||
sign.setLine(2, "sind");
|
||||
sign.setLine(3, "verboten");
|
||||
sign.update();
|
||||
redstone = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCreatureSpawn(CreatureSpawnEvent e) {
|
||||
if(e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) return;
|
||||
if (e.getEntity().getType() != EntityType.ITEM_FRAME && e.getEntity().getType() != EntityType.ARMOR_STAND && e.getEntity().getType() != EntityType.PAINTING) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockFromTo(BlockFromToEvent e) {
|
||||
Material type = e.getBlock().getType();
|
||||
if (type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA)
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
||||
if (!e.getPlayer().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (block.getType() == Material.FIRE) {
|
||||
if(p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if(PlotManager.getPlotByLocation(block.getLocation()) == null) e.setCancelled(true);
|
||||
if(!PlotManager.getPlotByLocation(block.getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Plot plot = PlotManager.getPlotByLocation(p.getLocation());
|
||||
if(plot == null) return;
|
||||
if(!plot.isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (!e.getRightClicked().getWorld().getName().equalsIgnoreCase("plots"))
|
||||
return;
|
||||
if(e.getRightClicked().getType() == EntityType.ITEM_FRAME) {
|
||||
if(p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true);
|
||||
if(!PlotManager.getPlotByLocation(e.getRightClicked().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (!e.getRightClicked().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if(p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true);
|
||||
if(!PlotManager.getPlotByLocation(e.getRightClicked().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(!p.isAllowed(Rank.SrDeveloper))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPickup(PlayerPickupItemEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(!p.isAllowed(Rank.SrDeveloper))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onArrowPickup(PlayerPickupArrowEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(!p.isAllowed(Rank.SrDeveloper))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMove(InventoryMoveItemEvent e) {
|
||||
assert e.getItem() != null;
|
||||
assert e.getItem().hasItemMeta();
|
||||
assert e.getItem().getItemMeta().hasDisplayName();
|
||||
//if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true);
|
||||
if(e.getItem().getType() == Material.WATCH) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent e) {
|
||||
assert e.getCursor() != null;
|
||||
assert e.getCursor().hasItemMeta();
|
||||
assert e.getCursor().getItemMeta().hasDisplayName();
|
||||
//if(e.getCursor().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true);
|
||||
if(e.getCursor().getType() == Material.WATCH) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onConsume(PlayerItemConsumeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (!e.getPlayer().getWorld().getName().equalsIgnoreCase("plots"))
|
||||
return;
|
||||
if(p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if(PlotManager.getPlotByLocation(e.getPlayer().getLocation()) == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(!PlotManager.getPlotByLocation(e.getPlayer().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBucketFill(PlayerBucketFillEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (!e.getPlayer().getWorld().getName().equalsIgnoreCase("plots"))
|
||||
return;
|
||||
if(p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if(PlotManager.getPlotByLocation(e.getPlayer().getLocation()) == null) e.setCancelled(true);
|
||||
if(!PlotManager.getPlotByLocation(e.getPlayer().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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) {
|
||||
Plot plot = PlotManager.getPlotByLocation(e.getTo());
|
||||
assert plot != null;
|
||||
p.setPlayerTime(plot.getTime().getValue(), false);
|
||||
p.setPlayerWeather(plot.getWeatherType());
|
||||
if(!plot.isOwner(p) && !plot.getOwner().equals(UUID.fromString("83007140-8306-4791-b341-e6fef1a23e8a")))
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 2));
|
||||
if(plot.getWeather() == Weather.THUNDER) {
|
||||
BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(TeamVento.getInstance(), () -> {
|
||||
Random random = new Random();
|
||||
int r = random.nextInt(100);
|
||||
if(r < 30) {
|
||||
p.strikeLightning(plot.getArea().getRandomLocation());
|
||||
}
|
||||
}, 2L, 50L);
|
||||
lightningTasks.put(p, task);
|
||||
}
|
||||
}
|
||||
//plot leave
|
||||
if(PlotManager.getPlotByLocation(e.getFrom()) != null && PlotManager.getPlotByLocation(e.getTo()) == null) {
|
||||
p.setPlayerTime(Time.DAY.getValue(), false);
|
||||
p.setPlayerWeather(WeatherType.CLEAR);
|
||||
p.clearPotionEffects();
|
||||
if(lightningTasks.containsKey(p))
|
||||
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);
|
||||
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();
|
||||
Block down = p.getLocation().subtract(0.0D, 2.0D, 0.0D).getBlock();
|
||||
if(p.getLocation().getBlock().getType() == Material.GOLD_PLATE && up.getType() == Material.COAL_BLOCK) {
|
||||
Core.log(Level.INFO, "Platte und Coal");
|
||||
if(down.getType() == Material.COMMAND_CHAIN && p.isAllowed(Rank.Supporter)){
|
||||
p.teleport(Config.readLocation("Build.Locs.Planning"));
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
if(up.getType() == Material.COAL_BLOCK && down.getType() == Material.COMMAND_CHAIN) {
|
||||
Core.log(Level.INFO, "Coal und Chain");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPotionSplash(PotionSplashEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent e) {
|
||||
if(e.getBlock().getType() != Material.CROPS)
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onStructureGrow(StructureGrowEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMultiPlace(BlockMultiPlaceEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (!e.getBlockPlaced().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
if (p.isAllowed(Rank.SrDeveloper)) return;
|
||||
if (PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()) == null) e.setCancelled(true);
|
||||
if (!PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()).isOwner(p)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent e) {
|
||||
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return;
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeashEntity(PlayerLeashEntityEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent e) {
|
||||
if(e.getEntityType() != EntityType.PLAYER) return;
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity().getName());
|
||||
if(p.getUniqueId().toString().equals("682ebd10-3661-49ec-ba4d-4f24b761b1a7")) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage("§cNein " + p.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent e) {
|
||||
if(e.getEntityType() == EntityType.FISHING_HOOK || e.getEntityType() == EntityType.SNOWBALL) {
|
||||
if (e.getEntity().getShooter() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity().getShooter());
|
||||
if (p.getUniqueId().toString().equals("682ebd10-3661-49ec-ba4d-4f24b761b1a7")) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage("§cNein " + p.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,22 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.Hologram;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.PlotManager;
|
||||
import net.minecraft.server.v1_10_R1.EnumParticle;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
@ -15,25 +24,44 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
*/
|
||||
public class JoinQuit implements Listener {
|
||||
|
||||
static HashMap<CustomPlayer, Hologram> holograms = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
e.setJoinMessage(null);
|
||||
if(p.getRank() == Ranks.Builder || p.getRank() == Ranks.HeadBuilder) {
|
||||
Bukkit.broadcastMessage(p.getColor() + p.getDisplayName() + " §8hat den Server §bbetreten");
|
||||
}else {
|
||||
p.teleport(Config.readLocation("Build.Locs.Spawn"));
|
||||
p.resetAttackSpeed();
|
||||
if(PlotManager.hasPlot(p)) {
|
||||
ItemStack menu = new ItemStack(Material.WATCH);
|
||||
ItemMeta menuMeta = menu.getItemMeta();
|
||||
menuMeta.setDisplayName("§eErweiterungen");
|
||||
menu.setItemMeta(menuMeta);
|
||||
p.getInventory().setItem(8, menu);
|
||||
}
|
||||
p.setCollidable(false);
|
||||
if(p.getRank() == Rank.Builder || p.getRank() == Rank.SrBuilder)
|
||||
Bukkit.broadcastMessage(p.getColor() + p.getDisplayName() + " §8hat den Server §bbetreten");
|
||||
else
|
||||
p.teleport(Config.readLocation("Build.Locs.Spawn"));
|
||||
|
||||
String[] text;
|
||||
if(PlotManager.hasPlot(p))
|
||||
text = new String[]{"§eZu deinem Plot teleportieren", "|", "|", "▼"};
|
||||
else
|
||||
text = new String[]{"§eNeues Plot erstellen", "|", "|", "▼",};
|
||||
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(TeamVento.getInstance(), () -> p.playParticle(Config.readLocation("Build.Locs.Holo").add(0.0D, 1.0D, 0.0D), EnumParticle.SPELL_WITCH, 0.4F, 10), 20L, 5L);
|
||||
|
||||
Hologram holo = new Hologram(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());
|
||||
if(p.getRank() == Ranks.Builder || p.getRank() == Ranks.HeadBuilder)
|
||||
e.setQuitMessage(p.getColor() + p.getDisplayName() + " §8hat den Server §cverlassen");
|
||||
else
|
||||
e.setQuitMessage(null);
|
||||
|
||||
e.setQuitMessage(null);
|
||||
holograms.remove(p);
|
||||
if(p.getRank() == Rank.Builder || p.getRank() == Rank.SrBuilder)
|
||||
Bukkit.broadcastMessage(p.getColor() + p.getDisplayName() + " §8hat den Server §cverlassen");
|
||||
}
|
||||
}
|
260
src/main/java/eu/univento/teamvento/listener/MenuEvents.java
Normal file
260
src/main/java/eu/univento/teamvento/listener/MenuEvents.java
Normal file
@ -0,0 +1,260 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.gui.AnvilGUI;
|
||||
import eu.univento.core.api.items.ItemBuilder;
|
||||
import eu.univento.core.api.items.ScrollingInventory;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.utils.UUIDFetcher;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MenuEvents implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
Inventorys invs = new Inventorys(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(invs.getMainInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
|
||||
Inventorys invs = new Inventorys(p);
|
||||
if(e.isShiftClick() && e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true);
|
||||
if(!PlotManager.hasPlot(p)) return;
|
||||
if(e.getCurrentItem() == null) return;
|
||||
if(!e.getCurrentItem().hasItemMeta()) return;
|
||||
if(!e.getCurrentItem().getItemMeta().hasDisplayName()) return;
|
||||
Plot plot = PlotManager.getPlotByPlayer(p);
|
||||
if(e.getInventory().getName().equals(invs.getMainInventory().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().getType() == Material.LEASH) {
|
||||
p.closeInventory();
|
||||
p.openInventory(invs.getAnimalsInventory());
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§ePlot zurücksetzen")) {
|
||||
PlotManager.clearPlot(plot);
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(TeamVento.getInstance(), () -> PlotManager.generatePlot(plot), 13 * 20L);
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eBiom ändern")) {
|
||||
p.closeInventory();
|
||||
p.openInventory(invs.getBiomeInventory());
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eWetter ändern")) {
|
||||
p.closeInventory();
|
||||
p.openInventory(invs.getWeatherInventory());
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.WATCH) {
|
||||
p.closeInventory();
|
||||
p.openInventory(invs.getTimeInventory());
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.LADDER) {
|
||||
p.closeInventory();
|
||||
p.openInventory(invs.getSettingsInventory());
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.MINECART) {
|
||||
p.closeInventory();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
ScrollingInventory inventory = new ScrollingInventory(p, "§eTeleport", 27);
|
||||
for(Plot plots : PlotManager.getPlots()) {
|
||||
String name = UUIDFetcher.getName(plots.getOwner());
|
||||
inventory.addItem(new ItemBuilder(Material.SKULL_ITEM)
|
||||
.durability(3).skullOwner(name)
|
||||
.name(plot.getName().equals("") ? "§cunbenanntes Plot" : "§e" + plots.getName())
|
||||
.lore("§eby " + name)
|
||||
.make());
|
||||
}
|
||||
inventory.openInventory();
|
||||
});
|
||||
}
|
||||
}
|
||||
if(e.getInventory().getName().equals(invs.getBiomeInventory().getName())) {
|
||||
e.setCancelled(true);
|
||||
if(e.getCurrentItem().getType() == Material.WATER_LILY) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.SWAMPLAND);
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.DEAD_BUSH) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.DESERT);
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eWald")) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.FOREST);
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eFlachland")) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.PLAINS);
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eTaiga")) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.TAIGA);
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eTundra")) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.TAIGA_COLD);
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.STAINED_CLAY) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.MESA);
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eDschungel")) {
|
||||
p.closeInventory();
|
||||
plot.setBiome(Biome.JUNGLE);
|
||||
}
|
||||
}
|
||||
if(e.getInventory().getName().equals(invs.getTimeInventory().getName())) {
|
||||
e.setCancelled(true);
|
||||
if(e.getCurrentItem().getType() == Material.MILK_BUCKET) {
|
||||
p.closeInventory();
|
||||
plot.setTime(Time.MORNING);
|
||||
if(plot.isInPlot(p.getLocation())) p.setPlayerTime(Time.MORNING.getValue(), false);
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.DOUBLE_PLANT) {
|
||||
p.closeInventory();
|
||||
plot.setTime(Time.DAY);
|
||||
if(plot.isInPlot(p.getLocation()))p.setPlayerTime(Time.DAY.getValue(), false);
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.BEETROOT_SOUP) {
|
||||
p.closeInventory();
|
||||
plot.setTime(Time.EVENING);
|
||||
if(plot.isInPlot(p.getLocation()))p.setPlayerTime(Time.EVENING.getValue(), false);
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.COAL) {
|
||||
p.closeInventory();
|
||||
plot.setTime(Time.NIGHT);
|
||||
if(plot.isInPlot(p.getLocation()))p.setPlayerTime(Time.NIGHT.getValue(), false);
|
||||
}
|
||||
}
|
||||
if(e.getInventory().getName().equals(invs.getWeatherInventory().getName())) {
|
||||
e.setCancelled(true);
|
||||
if(e.getCurrentItem().getType() == Material.DOUBLE_PLANT) {
|
||||
p.closeInventory();
|
||||
plot.setWeather(Weather.CLEAR);
|
||||
if(plot.isInPlot(p.getLocation()))p.setPlayerWeather(WeatherType.CLEAR);
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.WATER_BUCKET) {
|
||||
p.closeInventory();
|
||||
plot.setWeather(Weather.DOWNFALL);
|
||||
if(plot.isInPlot(p.getLocation()))p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.BLAZE_ROD) {
|
||||
p.closeInventory();
|
||||
plot.setWeather(Weather.THUNDER);
|
||||
if(plot.isInPlot(p.getLocation()))p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
}
|
||||
}
|
||||
if(e.getInventory().getName().equals(invs.getSettingsInventory().getName())) {
|
||||
e.setCancelled(true);
|
||||
if(e.getCurrentItem().getType() == Material.SIGN) {
|
||||
AnvilGUI gui = new AnvilGUI(p, event -> {
|
||||
if(event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
event.setWillClose(true);
|
||||
event.setWillDestroy(true);
|
||||
plot.setName(event.getName());
|
||||
p.refreshExperience();
|
||||
}else{
|
||||
event.setWillDestroy(true);
|
||||
event.setWillClose(true);
|
||||
}
|
||||
});
|
||||
ItemStack name = new ItemStack(Material.SIGN);
|
||||
ItemMeta nameMeta = name.getItemMeta();
|
||||
nameMeta.setDisplayName(plot.getName() == null ? "§cunbennantes Plot" : plot.getName());
|
||||
name.setItemMeta(nameMeta);
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, name);
|
||||
|
||||
gui.open();
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.NAME_TAG) {
|
||||
AnvilGUI gui = new AnvilGUI(p, event -> {
|
||||
if(event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
event.setWillClose(true);
|
||||
event.setWillDestroy(true);
|
||||
plot.setContact(event.getName());
|
||||
p.refreshExperience();
|
||||
}else{
|
||||
event.setWillDestroy(true);
|
||||
event.setWillClose(true);
|
||||
}
|
||||
});
|
||||
ItemStack name = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta nameMeta = name.getItemMeta();
|
||||
nameMeta.setDisplayName(plot.getContact() == null ? "§cKontaktdaten hier angeben" : plot.getContact());
|
||||
name.setItemMeta(nameMeta);
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, name);
|
||||
|
||||
gui.open();
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.DIRT) {
|
||||
ScrollingInventory inventory = new ScrollingInventory(p, "§eResourcePack", 27);
|
||||
for(ResourcePack pack : ResourcePack.values()) {
|
||||
inventory.addItem(new ItemBuilder(pack.getMaterial()).name(pack.getName())
|
||||
.enchantment(pack.name().equals(plot.getResourcePack().name()) ? Enchantment.ARROW_DAMAGE : null).make());
|
||||
}
|
||||
inventory.openInventory();
|
||||
}
|
||||
}
|
||||
if(e.getInventory().getName().equals("§eTeleport")) {
|
||||
if(e.getCurrentItem().getType() == Material.SKULL_ITEM) {
|
||||
SkullMeta skull = (SkullMeta) e.getCurrentItem().getItemMeta();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
Plot tpPlot = PlotManager.getPlotByOwner(UUIDFetcher.getUUID(skull.getOwner()).toString());
|
||||
Location loc = tpPlot.getSpawn();
|
||||
Bukkit.getScheduler().runTask(TeamVento.getInstance(), () -> p.teleport(new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F)));
|
||||
});
|
||||
}
|
||||
}
|
||||
if(e.getInventory().getName().equals("§eResourcePack")) {
|
||||
if(e.getCurrentItem() != null)
|
||||
plot.setResourcePack(ResourcePack.valueOf(e.getCurrentItem().getType()));
|
||||
}
|
||||
if(e.getInventory().getName().equals(invs.getAnimalsInventory().getName())) {
|
||||
if(e.getCurrentItem().getType() == Material.COOKED_BEEF) {
|
||||
p.closeInventory();
|
||||
Entity animal = Bukkit.getWorld("plots").spawnEntity(p.getLocation(), EntityType.PIG);
|
||||
Pig pig = (Pig) animal;
|
||||
pig.setAI(false);
|
||||
pig.setInvulnerable(true);
|
||||
pig.setRemoveWhenFarAway(false);
|
||||
pig.setCollidable(false);
|
||||
pig.setGravity(false);
|
||||
plot.addAnimal(animal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.teamvento.utils.WorldEdit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -22,7 +22,7 @@ public class PositionSetter implements Listener{
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
Block b = e.getClickedBlock();
|
||||
ItemStack item = p.getInventory().getItemInMainHand();
|
||||
if (p.isAllowed(Ranks.Builder)) {
|
||||
if (p.isAllowed(Rank.Builder)) {
|
||||
if(e.getAction() == Action.LEFT_CLICK_BLOCK && item.getType() == Material.WOOD_AXE) {
|
||||
WorldEdit.setPos1(p, b);
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§aset pos1");
|
||||
|
@ -1,7 +1,14 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.Hologram;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.Plot;
|
||||
import eu.univento.teamvento.utils.PlotManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -13,15 +20,24 @@ public class SignInteract implements Listener {
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if(e.getClickedBlock() instanceof Sign) {
|
||||
Sign sign = (Sign) e.getClickedBlock();
|
||||
if(sign.getLine(0).equalsIgnoreCase("teleport")) {
|
||||
if(PlotManager.hasPlot(p)) {
|
||||
p.teleport(PlotManager.getPlotByPlayer(p).getSpawn());
|
||||
}else{
|
||||
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if(e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && e.getClickedBlock().getLocation().add(0.0D, -1.0D, 0.0D).getBlock().getType() == Material.COMMAND) {
|
||||
e.setCancelled(true);
|
||||
if (PlotManager.hasPlot(p)) {
|
||||
Location loc = PlotManager.getPlotByPlayer(p).getSpawn();
|
||||
p.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
|
||||
} else {
|
||||
p.sendTitle("§eBitte warten", "§aDein Grundstück wird generiert");
|
||||
JoinQuit.holograms.get(p).hidePlayer(p);
|
||||
Hologram holo = new Hologram(new String[]{"§eZu deinem Plot teleportieren", "|", "|", "▼"}, Config.readLocation("Build.Locs.Holo"));
|
||||
holo.showPlayer(p);
|
||||
Plot plot = PlotManager.createPlot(p);
|
||||
PlotManager.createPlot(plot);
|
||||
PlotManager.generatePlot(plot);
|
||||
p.setFlying(true);
|
||||
Location loc = plot.getSpawn();
|
||||
p.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
248
src/main/java/eu/univento/teamvento/utils/Inventorys.java
Normal file
248
src/main/java/eu/univento/teamvento/utils/Inventorys.java
Normal file
@ -0,0 +1,248 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.material.Dye;
|
||||
|
||||
public class Inventorys {
|
||||
|
||||
private CustomPlayer player;
|
||||
|
||||
public Inventorys(CustomPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Inventory getMainInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 27, "§eGrundstücksverwaltung");
|
||||
|
||||
ItemStack teleport = new ItemStack(Material.MINECART);
|
||||
ItemMeta teleportMeta = teleport.getItemMeta();
|
||||
teleportMeta.setDisplayName("§eZu anderen Plots teleportieren");
|
||||
teleport.setItemMeta(teleportMeta);
|
||||
|
||||
ItemStack biome = new ItemStack(Material.DOUBLE_PLANT, 1, (short) 4);
|
||||
ItemMeta biomeMeta = biome.getItemMeta();
|
||||
biomeMeta.setDisplayName("§eBiom ändern");
|
||||
biome.setItemMeta(biomeMeta);
|
||||
|
||||
ItemStack animals = new ItemStack(Material.LEASH);
|
||||
ItemMeta animalsMeta = animals.getItemMeta();
|
||||
animalsMeta.setDisplayName("§eTiere");
|
||||
animals.setItemMeta(animalsMeta);
|
||||
|
||||
ItemStack settings = new ItemStack(Material.LADDER);
|
||||
ItemMeta settingsMeta = settings.getItemMeta();
|
||||
settingsMeta.setDisplayName("§eEinstellungen");
|
||||
settings.setItemMeta(settingsMeta);
|
||||
|
||||
ItemStack time = new ItemStack(Material.WATCH);
|
||||
ItemMeta timeMeta = time.getItemMeta();
|
||||
timeMeta.setDisplayName("§eZeit ändern");
|
||||
time.setItemMeta(timeMeta);
|
||||
|
||||
ItemStack home = new ItemStack(Material.BED);
|
||||
ItemMeta homeMeta = home.getItemMeta();
|
||||
homeMeta.setDisplayName("§ezu deinem Plot");
|
||||
home.setItemMeta(homeMeta);
|
||||
|
||||
ItemStack weather = new ItemStack(Material.DOUBLE_PLANT);
|
||||
ItemMeta weatherMeta = weather.getItemMeta();
|
||||
weatherMeta.setDisplayName("§eWetter ändern");
|
||||
weather.setItemMeta(weatherMeta);
|
||||
|
||||
Dye resetDye = new Dye();
|
||||
resetDye.setColor(DyeColor.RED);
|
||||
ItemStack reset = resetDye.toItemStack(1);
|
||||
ItemMeta resetMeta = reset.getItemMeta();
|
||||
resetMeta.setDisplayName("§ePlot zurücksetzen");
|
||||
reset.setItemMeta(resetMeta);
|
||||
|
||||
ItemStack skulls = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
SkullMeta skullMeta = (SkullMeta) skulls.getItemMeta();
|
||||
skullMeta.setOwner("conorf1807");
|
||||
skullMeta.setDisplayName("§eKöpfe");
|
||||
skulls.setItemMeta(skullMeta);
|
||||
|
||||
ItemStack particle = new ItemStack(Material.BLAZE_POWDER);
|
||||
ItemMeta particleMeta = particle.getItemMeta();
|
||||
particleMeta.setDisplayName("§ePartikel");
|
||||
particle.setItemMeta(particleMeta);
|
||||
|
||||
Dye readyDye = new Dye();
|
||||
readyDye.setColor(DyeColor.LIME);
|
||||
ItemStack ready = readyDye.toItemStack(1);
|
||||
ItemMeta readyMeta = ready.getItemMeta();
|
||||
readyMeta.setDisplayName("§eFertig");
|
||||
ready.setItemMeta(readyMeta);
|
||||
|
||||
inv.setItem(0, teleport);
|
||||
inv.setItem(2, biome);
|
||||
//inv.setItem(6, animals);
|
||||
inv.setItem(8, settings);
|
||||
inv.setItem(10, time);
|
||||
inv.setItem(13, home);
|
||||
inv.setItem(16, weather);
|
||||
inv.setItem(18, reset);
|
||||
inv.setItem(20, skulls);
|
||||
//inv.setItem(24, particle);
|
||||
inv.setItem(26, ready);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getBiomeInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 27, "§eBiom ändern");
|
||||
|
||||
ItemStack mesa = new ItemStack(Material.STAINED_CLAY, 1, (short) 1);
|
||||
ItemMeta mesaMeta = mesa.getItemMeta();
|
||||
mesaMeta.setDisplayName("§eMesa");
|
||||
mesa.setItemMeta(mesaMeta);
|
||||
|
||||
ItemStack jungle = new ItemStack(Material.SAPLING, 1, (short) 3);
|
||||
ItemMeta jungleMeta = jungle.getItemMeta();
|
||||
jungleMeta.setDisplayName("§eDschungel");
|
||||
jungle.setItemMeta(jungleMeta);
|
||||
|
||||
ItemStack swamp = new ItemStack(Material.WATER_LILY);
|
||||
ItemMeta swampMeta = swamp.getItemMeta();
|
||||
swampMeta.setDisplayName("§eSumpfgebiet");
|
||||
swamp.setItemMeta(swampMeta);
|
||||
|
||||
ItemStack forest = new ItemStack(Material.SAPLING);
|
||||
ItemMeta forestMeta = forest.getItemMeta();
|
||||
forestMeta.setDisplayName("§eWald");
|
||||
forest.setItemMeta(forestMeta);
|
||||
|
||||
ItemStack flatland = new ItemStack(Material.LONG_GRASS, 1, (short) 1);
|
||||
ItemMeta flatlandMeta = flatland.getItemMeta();
|
||||
flatlandMeta.setDisplayName("§eFlachland");
|
||||
flatland.setItemMeta(flatlandMeta);
|
||||
|
||||
ItemStack desert = new ItemStack(Material.DEAD_BUSH);
|
||||
ItemMeta desertMeta = desert.getItemMeta();
|
||||
desertMeta.setDisplayName("§eWüste");
|
||||
desert.setItemMeta(desertMeta);
|
||||
|
||||
ItemStack taiga = new ItemStack(Material.LONG_GRASS, 1, (short) 2);
|
||||
ItemMeta taigaMeta = taiga.getItemMeta();
|
||||
taigaMeta.setDisplayName("§eTaiga");
|
||||
taiga.setItemMeta(taigaMeta);
|
||||
|
||||
ItemStack tundra = new ItemStack(Material.SNOW_BALL);
|
||||
ItemMeta tundraMeta = tundra.getItemMeta();
|
||||
tundraMeta.setDisplayName("§eTundra");
|
||||
tundra.setItemMeta(tundraMeta);
|
||||
|
||||
inv.setItem(0, mesa);
|
||||
inv.setItem(4, jungle);
|
||||
inv.setItem(8, swamp);
|
||||
inv.setItem(11, forest);
|
||||
inv.setItem(15, flatland);
|
||||
inv.setItem(18, desert);
|
||||
inv.setItem(22, taiga);
|
||||
inv.setItem(26, tundra);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getSettingsInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 27, "§eEinstellungen");
|
||||
|
||||
ItemStack name = new ItemStack(Material.SIGN);
|
||||
ItemMeta nameMeta = name.getItemMeta();
|
||||
nameMeta.setDisplayName("§eName ändern");
|
||||
name.setItemMeta(nameMeta);
|
||||
|
||||
ItemStack contact = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta contactMeta = contact.getItemMeta();
|
||||
contactMeta.setDisplayName("§eKontaktmöglichkeiten");
|
||||
contact.setItemMeta(contactMeta);
|
||||
|
||||
ItemStack texture = new ItemStack(Material.DIRT);
|
||||
ItemMeta textureMeta = texture.getItemMeta();
|
||||
textureMeta.setDisplayName("§eResourcePack");
|
||||
texture.setItemMeta(textureMeta);
|
||||
|
||||
inv.setItem(10, name);
|
||||
inv.setItem(13, contact);
|
||||
inv.setItem(16, texture);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getTimeInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 27, "§eZeit ändern");
|
||||
|
||||
ItemStack morning = new ItemStack(Material.MILK_BUCKET);
|
||||
ItemMeta morningMeta = morning.getItemMeta();
|
||||
morningMeta.setDisplayName("§eMorgen");
|
||||
morning.setItemMeta(morningMeta);
|
||||
|
||||
ItemStack day = new ItemStack(Material.DOUBLE_PLANT);
|
||||
ItemMeta dayMeta = day.getItemMeta();
|
||||
dayMeta.setDisplayName("§eTag");
|
||||
day.setItemMeta(dayMeta);
|
||||
|
||||
ItemStack evening = new ItemStack(Material.BEETROOT_SOUP);
|
||||
ItemMeta eveningMeta = evening.getItemMeta();
|
||||
eveningMeta.setDisplayName("§eAbend");
|
||||
evening.setItemMeta(eveningMeta);
|
||||
|
||||
ItemStack night = new ItemStack(Material.COAL, 1, (short) 1);
|
||||
ItemMeta nightMeta = night.getItemMeta();
|
||||
nightMeta.setDisplayName("§eNacht");
|
||||
night.setItemMeta(nightMeta);
|
||||
|
||||
inv.setItem(10, morning);
|
||||
inv.setItem(12, day);
|
||||
inv.setItem(14, evening);
|
||||
inv.setItem(16, night);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getWeatherInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 27, "§eWetter ändern");
|
||||
|
||||
ItemStack sun = new ItemStack(Material.DOUBLE_PLANT);
|
||||
ItemMeta sunMeta = sun.getItemMeta();
|
||||
sunMeta.setDisplayName("§eSonne");
|
||||
sun.setItemMeta(sunMeta);
|
||||
|
||||
ItemStack rain = new ItemStack(Material.WATER_BUCKET);
|
||||
ItemMeta rainMeta = rain.getItemMeta();
|
||||
rainMeta.setDisplayName("§eRegen");
|
||||
rain.setItemMeta(rainMeta);
|
||||
|
||||
ItemStack thunder = new ItemStack(Material.BLAZE_ROD);
|
||||
ItemMeta thunderMeta = thunder.getItemMeta();
|
||||
thunderMeta.setDisplayName("§eGewitter");
|
||||
thunder.setItemMeta(thunderMeta);
|
||||
|
||||
inv.setItem(11, sun);
|
||||
inv.setItem(13, rain);
|
||||
inv.setItem(15, thunder);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getAnimalsInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 27, "§eTiere spawnen");
|
||||
|
||||
ItemStack pig = new ItemStack(Material.COOKED_BEEF);
|
||||
ItemMeta pigMeta = pig.getItemMeta();
|
||||
pigMeta.setDisplayName("Schwein gehabt");
|
||||
pig.setItemMeta(pigMeta);
|
||||
|
||||
inv.setItem(0, pig);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,21 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
import com.mongodb.CursorType;
|
||||
import com.mongodb.client.FindIterable;
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.map.Cuboid;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.Location;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Plot {
|
||||
|
||||
@ -22,12 +33,8 @@ public class Plot {
|
||||
return area.containsLocation(location);
|
||||
}
|
||||
|
||||
public boolean isInPlot(CustomPlayer player) {
|
||||
return area.containsLocation(player.getLocation());
|
||||
}
|
||||
|
||||
public boolean isOwner(CustomPlayer p) {
|
||||
return p.getUniqueId().equals(owner);
|
||||
return p.getUniqueId().toString().equals(owner.toString());
|
||||
}
|
||||
|
||||
public Cuboid getArea() {
|
||||
@ -42,4 +49,155 @@ public class Plot {
|
||||
return spawn;
|
||||
}
|
||||
|
||||
public void setBiome(Biome biome) {
|
||||
setInDatabase("biome", biome.name());
|
||||
for(Block blocks : getArea())
|
||||
blocks.setBiome(biome);
|
||||
for(Chunk chunk : Bukkit.getWorld("plots").getLoadedChunks())
|
||||
Bukkit.getWorld("plots").refreshChunk(chunk.getX(), chunk.getZ());
|
||||
for(LivingEntity entity : Bukkit.getWorld("plots").getLivingEntities())
|
||||
entity.teleport(entity);
|
||||
}
|
||||
|
||||
public Biome getBiome() {
|
||||
return Biome.valueOf(getStringFromDatabase("biome"));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStringFromDatabase("name");
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
setInDatabase("name", name);
|
||||
}
|
||||
|
||||
public boolean hasName() {
|
||||
return !getName().equals("");
|
||||
}
|
||||
|
||||
public void setTime(Time time) {
|
||||
setInDatabase("time", time.name());
|
||||
}
|
||||
|
||||
public Time getTime() {
|
||||
return Time.valueOf(getStringFromDatabase("time"));
|
||||
}
|
||||
|
||||
public void setWeather(Weather weather) {
|
||||
setInDatabase("weather", weather.name());
|
||||
}
|
||||
|
||||
public Weather getWeather() {
|
||||
return Weather.valueOf(getStringFromDatabase("weather"));
|
||||
}
|
||||
|
||||
public void setContact(String contact) {
|
||||
setInDatabase("contact", contact);
|
||||
}
|
||||
|
||||
public String getContact() {
|
||||
return getStringFromDatabase("contact");
|
||||
}
|
||||
|
||||
public boolean hasContact() {
|
||||
return !getContact().equals("");
|
||||
}
|
||||
|
||||
public void setResourcePack(ResourcePack pack) {
|
||||
setInDatabase("pack", pack.name());
|
||||
}
|
||||
|
||||
public ResourcePack getResourcePack() {
|
||||
return ResourcePack.valueOf(getStringFromDatabase("pack"));
|
||||
}
|
||||
|
||||
public void addAnimal(Entity animal) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", animal.getType().name());
|
||||
map.put("X", String.valueOf(animal.getLocation().getX()));
|
||||
map.put("Y", String.valueOf(animal.getLocation().getY()));
|
||||
map.put("Z", String.valueOf(animal.getLocation().getZ()));
|
||||
ArrayList<Map<String, String>> animals = (ArrayList<Map<String, String>>) getObjectFromDatbase("animals");
|
||||
animals.add(map);
|
||||
setInDatabase("animals", animals);
|
||||
}
|
||||
|
||||
public void removeAnimal(Entity animal) {
|
||||
Map<Location, EntityType> animals = getAnimalsMap();
|
||||
|
||||
//ArrayList<HashMap<String, String>> animals = (ArrayList<HashMap<String, String>>) getObjectFromDatbase("animals");
|
||||
if(animals.containsKey(animal.getLocation())) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", animal.getType().name());
|
||||
map.put("X", String.valueOf(animal.getLocation().getX()));
|
||||
map.put("Y", String.valueOf(animal.getLocation().getY()));
|
||||
map.put("Z", String.valueOf(animal.getLocation().getZ()));
|
||||
ArrayList<Map<String, String>> list = (ArrayList<Map<String, String>>) getObjectFromDatbase("animals");
|
||||
list.remove(map);
|
||||
setInDatabase("animals", list);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Entity> getAnimals() {
|
||||
ArrayList<Entity> animals = new ArrayList<>();
|
||||
Map<Location, EntityType> map = getAnimalsMap();
|
||||
for(Map.Entry<Location, EntityType> entry : map.entrySet())
|
||||
animals.addAll(Bukkit.getWorld("plots").getLivingEntities().stream().filter(entity -> entity.getLocation().equals(entry.getKey())).collect(Collectors.toList()));
|
||||
return animals;
|
||||
}
|
||||
|
||||
private Map<Location, EntityType> getAnimalsMap() {
|
||||
Map<Location, EntityType> map = new HashMap<>();
|
||||
ArrayList<Map<String, String>> list = (ArrayList<Map<String, String>>) getObjectFromDatbase("animals");
|
||||
assert list != null;
|
||||
for(Map<String, String> stringlist : list) {
|
||||
double x = Double.parseDouble(stringlist.get("X"));
|
||||
double y = Double.parseDouble(stringlist.get("Y"));
|
||||
double z = Double.parseDouble(stringlist.get("Z"));
|
||||
Location loc = new Location(Bukkit.getWorld("plots"), x, y , z);
|
||||
map.put(loc, EntityType.valueOf(String.valueOf(stringlist.get("type"))));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public WeatherType getWeatherType() {
|
||||
if(getWeather() == Weather.THUNDER) return WeatherType.DOWNFALL;
|
||||
return WeatherType.valueOf(getWeather().name());
|
||||
}
|
||||
|
||||
private Map<String, Object> getMapFromDatabase(String name) {
|
||||
return (Map<String, Object>) getObjectFromDatbase(name);
|
||||
}
|
||||
|
||||
private ArrayList<Object> getArrayListFromDatabase(String name) {
|
||||
return (ArrayList<Object>) getObjectFromDatbase(name);
|
||||
}
|
||||
|
||||
private Object getObjectFromDatbase(String name) {
|
||||
FindIterable<Document> cursor = Core.getMongoDB().getDatabase().getCollection("plots").find(new Document("uuid", owner.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return null;
|
||||
|
||||
return doc.get(name);
|
||||
}
|
||||
|
||||
private String getStringFromDatabase(String name) {
|
||||
FindIterable<Document> cursor = Core.getMongoDB().getDatabase().getCollection("plots").find(new Document("uuid", owner.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return null;
|
||||
|
||||
return doc.getString(name);
|
||||
}
|
||||
|
||||
private void setInDatabase(String name, String obj) {
|
||||
Core.getMongoDB().getDatabase().getCollection("plots").updateOne(new Document("uuid", owner.toString()), new Document("$set", new Document(name, obj)));
|
||||
}
|
||||
|
||||
private void setInDatabase(String name, ArrayList<Map<String, String>> obj) {
|
||||
Core.getMongoDB().getDatabase().getCollection("plots").updateOne(new Document("uuid", owner.toString()), new Document("$set", new Document(name, obj)));
|
||||
}
|
||||
}
|
@ -6,34 +6,50 @@ import com.mongodb.client.FindIterable;
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.map.Cuboid;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.utils.UUIDFetcher;
|
||||
import eu.univento.teamvento.TeamVento;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class PlotManager {
|
||||
|
||||
private static boolean reset = false;
|
||||
|
||||
private static ArrayList<Plot> plots = new ArrayList<>();
|
||||
private static Plot lastPlot;
|
||||
|
||||
public static ArrayList<Plot> getPlots() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
public static Plot getLastPlot() {
|
||||
return lastPlot;
|
||||
}
|
||||
|
||||
public static void setLastPlot(Plot plot) {
|
||||
lastPlot = plot;
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
FindIterable<Document> cursor = Core.getMongoDB().getDatabase().getCollection("plots").find();
|
||||
for(Document doc : cursor) {
|
||||
for (Document doc : cursor) {
|
||||
String uuid = doc.getString("uuid");
|
||||
Plot plot = new Plot(new Cuboid(getLocation(uuid, "minPos"), getLocation(uuid, "maxPos")), UUID.fromString(uuid), getLocation(uuid, "Spawn"));
|
||||
plots.add(plot);
|
||||
plot.setBiome(plot.getBiome());
|
||||
}
|
||||
}
|
||||
|
||||
public static Plot getPlotByPlayer(CustomPlayer p) {
|
||||
for(Plot plot : plots) {
|
||||
if(plot.isOwner(p)) return plot;
|
||||
for (Plot plot : plots) {
|
||||
if (plot.isOwner(p)) return plot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -42,26 +58,239 @@ public class PlotManager {
|
||||
return getPlotByPlayer(p) != null;
|
||||
}
|
||||
|
||||
public static void generatePlot(Plot plot) {
|
||||
public static void clearPlot(Plot plot) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(plot.getOwner());
|
||||
if(reset) {
|
||||
p.sendMessage("§cEs wird bereits grade ein Plot bearbeitet.");
|
||||
p.sendMessage("§cBitte versuche es später noch einmal.");
|
||||
return;
|
||||
}
|
||||
reset = true;
|
||||
|
||||
plot.getAnimals().forEach(plot::removeAnimal);
|
||||
|
||||
Cuboid area = plot.getArea();
|
||||
area.getUpperLocation().setY(plot.getArea().getLowerY());
|
||||
int i = 0;
|
||||
for(Block b : area.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.GRASS), i * 20L);
|
||||
Location lower = new Location(Bukkit.getWorld("plots"), area.getLowerX(), area.getLowerY() + 17.0D, area.getLowerZ());
|
||||
Location upper = new Location(Bukkit.getWorld("plots"), area.getUpperX(), area.getLowerY() + 20.0D, area.getUpperZ());
|
||||
Cuboid blocks = new Cuboid(lower, upper);
|
||||
|
||||
Cuboid highest = new Cuboid(upper, new Location(Bukkit.getWorld("plots"), area.getLowerX(), 250.0D, area.getLowerZ()));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : highest.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.AIR), i / 3000);
|
||||
}
|
||||
});
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : blocks.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.AIR), i / 45);
|
||||
}
|
||||
});
|
||||
Cuboid bottom = new Cuboid(new Location(Bukkit.getWorld("plots"), area.getLowerX(), 0.0D, area.getLowerZ()), new Location(Bukkit.getWorld("plots"), area.getUpperX(), 0.0D, area.getUpperZ()));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : bottom.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.AIR), i / 90);
|
||||
}
|
||||
});
|
||||
Cuboid between = new Cuboid(new Location(Bukkit.getWorld("plots"), bottom.getLowerX(), bottom.getLowerY() + 1.0D, bottom.getLowerZ()), new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getLowerY() - 1.0D, blocks.getUpperZ()));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : between.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.AIR), i / 200);
|
||||
}
|
||||
});
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(TeamVento.getInstance(), () -> reset = false, 13 * 20L);
|
||||
}
|
||||
|
||||
public static void generatePlot(Plot plot) {
|
||||
lastPlot = plot;
|
||||
Cuboid area = plot.getArea();
|
||||
Location lower = new Location(Bukkit.getWorld("plots"), area.getLowerX(), area.getLowerY() + 17.0D, area.getLowerZ());
|
||||
Location upper = new Location(Bukkit.getWorld("plots"), area.getUpperX(), area.getLowerY() + 20.0D, area.getUpperZ());
|
||||
Cuboid blocks = new Cuboid(lower, upper);
|
||||
plots.add(plot);
|
||||
plot.setBiome(Biome.FOREST);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : blocks.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
|
||||
b.setType(Material.DIRT);
|
||||
Core.getOnlinePlayers().stream().filter(players -> players.hasEffects()).forEachOrdered(players -> players.playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1));
|
||||
}, i / 16);
|
||||
}
|
||||
});
|
||||
Cuboid bottom = new Cuboid(new Location(Bukkit.getWorld("plots"), area.getLowerX(), 0.0D, area.getLowerZ()), new Location(Bukkit.getWorld("plots"), area.getUpperX(), 0.0D, area.getUpperZ()));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : bottom.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.BEDROCK), i / 100);
|
||||
}
|
||||
});
|
||||
Cuboid between = new Cuboid(new Location(Bukkit.getWorld("plots"), bottom.getLowerX(), bottom.getLowerY() + 1.0D, bottom.getLowerZ()), new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getLowerY() - 1.0D, blocks.getUpperZ()));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : between.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.STONE), i / 90);
|
||||
}
|
||||
});
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> blocks.getUpperLocation().getBlock().setType(Material.GRASS), 35 * 20L));
|
||||
|
||||
Cuboid rand1 = new Cuboid(new Location(Bukkit.getWorld("plots"), blocks.getUpperX(), blocks.getUpperY() + 1.0D, blocks.getUpperZ()), new Location(Bukkit.getWorld("plots"), blocks.getUpperX() - 50.0D, blocks.getUpperY() + 1.0D, blocks.getUpperZ()));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : rand1.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
|
||||
b.setType(Material.WOOD_STEP);
|
||||
b.setData((byte) 1);
|
||||
}, 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));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : rand2.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
|
||||
b.setType(Material.WOOD_STEP);
|
||||
b.setData((byte) 1);
|
||||
}, 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));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : rand3.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
|
||||
b.setType(Material.WOOD_STEP);
|
||||
b.setData((byte) 1);
|
||||
}, 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()));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
|
||||
long i = 0;
|
||||
for (Block b : rand4.getBlocks()) {
|
||||
i++;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
|
||||
b.setType(Material.WOOD_STEP);
|
||||
b.setData((byte) 1);
|
||||
}, 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));
|
||||
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);
|
||||
}
|
||||
}, 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));
|
||||
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);
|
||||
}
|
||||
});
|
||||
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));
|
||||
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);
|
||||
}
|
||||
});
|
||||
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));
|
||||
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().runTaskAsynchronously(TeamVento.getInstance(), () -> Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> {
|
||||
ItemStack menu = new ItemStack(Material.WATCH);
|
||||
ItemMeta menuMeta = menu.getItemMeta();
|
||||
menuMeta.setDisplayName("§eErweiterungen");
|
||||
menu.setItemMeta(menuMeta);
|
||||
Bukkit.getPlayer(plot.getOwner()).getInventory().setItem(8, menu);
|
||||
}, 35 * 20L));
|
||||
}
|
||||
|
||||
public static Plot createPlot(CustomPlayer p) {
|
||||
if (lastPlot == null) {
|
||||
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));
|
||||
}
|
||||
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);
|
||||
|
||||
west.getBlock().setType(Material.GLASS);
|
||||
east.getBlock().setType(Material.GRASS_PATH);
|
||||
north.getBlock().setType(Material.STONE);
|
||||
south.getBlock().setType(Material.ACACIA_STAIRS);
|
||||
|
||||
if(PlotManager.getPlotByLocation(south) == null && PlotManager.getPlotByLocation(west) == null && PlotManager.getPlotByLocation(north) == null && PlotManager.getPlotByLocation(east) == null) {
|
||||
upper.setX(upper.getX() + 55);
|
||||
lower.setX(lower.getX() + 55);
|
||||
}
|
||||
else if(PlotManager.getPlotByLocation(south) == null && PlotManager.getPlotByLocation(west) != null) {
|
||||
Bukkit.broadcastMessage("Plot im Süden");
|
||||
upper.setZ(upper.getZ() + 55);
|
||||
lower.setZ(lower.getZ() + 55);
|
||||
}
|
||||
else if(PlotManager.getPlotByLocation(west) == null && PlotManager.getPlotByLocation(north) != null) {
|
||||
Bukkit.broadcastMessage("Plot im Westen");
|
||||
upper.setX(upper.getX() - 55);
|
||||
lower.setX(lower.getX() - 55);
|
||||
}
|
||||
else if(PlotManager.getPlotByLocation(east) == null && PlotManager.getPlotByLocation(south) != null && PlotManager.getPlotByLocation(west) != null) {
|
||||
Bukkit.broadcastMessage("Plot im Osten1");
|
||||
upper.setX(upper.getX() + 55);
|
||||
lower.setX(lower.getX() + 55);
|
||||
}
|
||||
else if(PlotManager.getPlotByLocation(east) != null && PlotManager.getPlotByLocation(south) != null && PlotManager.getPlotByLocation(north) == null) {
|
||||
Bukkit.broadcastMessage("Plot im Norden1");
|
||||
upper.setZ(upper.getZ() - 55);
|
||||
lower.setZ(lower.getZ() - 55);
|
||||
}
|
||||
|
||||
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);
|
||||
return new Plot(area, p.getUniqueId(), spawn);
|
||||
}
|
||||
|
||||
public static void createPlot(Plot plot) {
|
||||
Document doc = new Document("uuid", plot.getOwner().toString());
|
||||
Date date = new Date();
|
||||
|
||||
HashMap<String, Double> maxPos = new HashMap<>();
|
||||
HashMap<String, Object> maxPos = new HashMap<>();
|
||||
maxPos.put("X", plot.getArea().getUpperX());
|
||||
maxPos.put("Y", plot.getArea().getUpperY());
|
||||
maxPos.put("Z", plot.getArea().getUpperZ());
|
||||
|
||||
HashMap<String, Double> minPos = new HashMap<>();
|
||||
HashMap<String, Object> minPos = new HashMap<>();
|
||||
minPos.put("X", plot.getArea().getLowerX());
|
||||
minPos.put("Y", plot.getArea().getLowerY());
|
||||
minPos.put("Z", plot.getArea().getLowerZ());
|
||||
@ -70,29 +299,57 @@ public class PlotManager {
|
||||
spawn.put("X", plot.getSpawn().getX());
|
||||
spawn.put("Y", plot.getSpawn().getY());
|
||||
spawn.put("Z", plot.getSpawn().getZ());
|
||||
spawn.put("Yaw", plot.getSpawn().getYaw());
|
||||
spawn.put("Pitch", plot.getSpawn().getPitch());
|
||||
|
||||
ArrayList<Map<String, String>> animals = new ArrayList<>();
|
||||
|
||||
doc.put("created", date);
|
||||
doc.put("maxPos", new BasicDBObject(maxPos));
|
||||
doc.put("minPos", new BasicDBObject(minPos));
|
||||
doc.put("Spawn", new BasicDBObject(spawn));
|
||||
doc.put("time", "DAY");
|
||||
doc.put("weather", "CLEAR");
|
||||
doc.put("biome", "PLAINS");
|
||||
doc.put("pack", "Default");
|
||||
doc.put("name", "");
|
||||
doc.put("contact", "");
|
||||
doc.put("animals", animals);
|
||||
|
||||
|
||||
Core.getMongoDB().getDatabase().getCollection("plots").insertOne(doc);
|
||||
}
|
||||
|
||||
public static Plot getPlotByLocation(Location location) {
|
||||
for(Plot plot : plots) {
|
||||
if(plot.isInPlot(location)) return plot;
|
||||
for (Plot plot : plots) {
|
||||
if (plot.isInPlot(location)) return plot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Plot getPlotByOwner(String owner) {
|
||||
for (Plot plot : plots) {
|
||||
if (plot.getOwner().equals(UUID.fromString(owner))) return plot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Date getCreatedDate(String uuid) {
|
||||
return getDateFromDatabase(uuid, "created");
|
||||
}
|
||||
|
||||
private static Location getLocation(String uuid, String name) {
|
||||
Map<String, Object> map = getMapFromDatabase(uuid, "Pos");
|
||||
if(map.containsKey("Yaw"))
|
||||
return new Location(Bukkit.getWorld("plots"), (double)map.get("X"), (double)map.get("Y"), (double)map.get("Z"), (float)map.get("Yaw"), (float)map.get("Pitch"));
|
||||
else
|
||||
return new Location(Bukkit.getWorld("plots"), (double) map.get("X"), (double) map.get("Y"), (double) map.get("Z"));
|
||||
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"))));
|
||||
}
|
||||
|
||||
|
||||
private static Date getDateFromDatabase(String uuid, String name) {
|
||||
FindIterable<Document> cursor = Core.getMongoDB().getDatabase().getCollection("plots").find(new Document("uuid", uuid));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return null;
|
||||
|
||||
return doc.getDate(name);
|
||||
}
|
||||
|
||||
private static Object getObjectFromDatbase(String uuid, String name) {
|
||||
|
48
src/main/java/eu/univento/teamvento/utils/ResourcePack.java
Normal file
48
src/main/java/eu/univento/teamvento/utils/ResourcePack.java
Normal file
@ -0,0 +1,48 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 29.06.2016
|
||||
*/
|
||||
public enum ResourcePack {
|
||||
|
||||
DEFAULT("§eDefault", Material.DIRT, ""),
|
||||
PURE_BD_CRAFT("§ePureBDCraft", Material.GLOWSTONE, "http://bdcraft.net/download/?z=PureBDcraft%20%2016x%20MC110&dl=bdcee96e7a816b6eb3ebda4549acd222641"),
|
||||
FAITHFUL("§eFaithful", Material.WOOD, "http://mods.curse.com/texture-packs/minecraft/236821-faithful-1-10/2310424#"),
|
||||
CHROMA_HILLS("§eChroma Hills", Material.SAND, "http://chromahills.com/zipfiles/ChromaHills128x-1.9-v.1.zip"),
|
||||
DOKUCRAFT("§eDokucraft", Material.BRICK, "https://www.dokucraft.co.uk/dl/1.9-Dokucraft-TSC-Light.zip"),
|
||||
SOARTEX_FANVER("§eSoartex Fanver", Material.MOSSY_COBBLESTONE, "http://mods.curse.com/texture-packs/minecraft/soartex-fanver-vanilla/2311293#"),
|
||||
DANDELION("§eDandelion", Material.YELLOW_FLOWER, "http://www.mediafire.com/download/7mmk531lf41f7ex/Dandelion+v1.8.1.zip");
|
||||
|
||||
private String name;
|
||||
private Material material;
|
||||
private String url;
|
||||
|
||||
private ResourcePack(String name, Material material, String url) {
|
||||
this.name = name;
|
||||
this.material = material;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public static ResourcePack valueOf(Material material) {
|
||||
for(ResourcePack pack : values()) {
|
||||
if(material == pack.getMaterial()) return pack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
18
src/main/java/eu/univento/teamvento/utils/Time.java
Normal file
18
src/main/java/eu/univento/teamvento/utils/Time.java
Normal file
@ -0,0 +1,18 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
public enum Time {
|
||||
MORNING(0),
|
||||
DAY(6000),
|
||||
EVENING(12000),
|
||||
NIGHT(18000);
|
||||
|
||||
final long value;
|
||||
|
||||
Time(long n) {
|
||||
this.value = n;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
7
src/main/java/eu/univento/teamvento/utils/Weather.java
Normal file
7
src/main/java/eu/univento/teamvento/utils/Weather.java
Normal file
@ -0,0 +1,7 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
public enum Weather {
|
||||
CLEAR,
|
||||
DOWNFALL,
|
||||
THUNDER
|
||||
}
|
@ -3,4 +3,5 @@ name: TeamVento
|
||||
version: 0.1
|
||||
author: joethei
|
||||
website: http://univento.eu/team/TeamVento
|
||||
description: Plugin for univento build server
|
||||
description: Plugin for univento build server
|
||||
depend: [Core]
|
||||
|
Loading…
Reference in New Issue
Block a user