second commit, adding missing files
This commit is contained in:
parent
caa4cd8ecb
commit
cbf9c92398
35
TeamVento.iml
Normal file
35
TeamVento.iml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</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: 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" 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" />
|
||||
</component>
|
||||
</module>
|
87
pom.xml
Normal file
87
pom.xml
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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>
|
||||
|
||||
<name>Univento.eu TeamVento</name>
|
||||
<url>http://univento.eu</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2-beta-5</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>eu.univento.teamvento.TeamVento</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.univento</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
69
src/main/java/eu/univento/teamvento/commands/Prebuild.java
Normal file
69
src/main/java/eu/univento/teamvento/commands/Prebuild.java
Normal file
@ -0,0 +1,69 @@
|
||||
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;
|
||||
}
|
||||
}
|
75
src/main/java/eu/univento/teamvento/commands/Set.java
Normal file
75
src/main/java/eu/univento/teamvento/commands/Set.java
Normal file
@ -0,0 +1,75 @@
|
||||
package eu.univento.teamvento.commands;
|
||||
|
||||
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.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.WorldEdit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Set extends AutoCommand<TeamVento>{
|
||||
|
||||
public Set(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.Builder)) {
|
||||
Material material;
|
||||
if(args.length == 0) {
|
||||
material = p.getInventory().getItemInMainHand().getType();
|
||||
setBlocks(material, p);
|
||||
}
|
||||
if(args.length == 1) {
|
||||
if(Material.getMaterial(args[0]) != null) {
|
||||
material = Material.getMaterial(args[0]);
|
||||
setBlocks(material, p);
|
||||
}else{
|
||||
int id = Integer.parseInt(args[0]);
|
||||
material = Material.getMaterial(id);
|
||||
setBlocks(material, p);
|
||||
}
|
||||
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cYou need to give me some kind of stuff");
|
||||
}
|
||||
}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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
59
src/main/java/eu/univento/teamvento/commands/Setloc.java
Normal file
59
src/main/java/eu/univento/teamvento/commands/Setloc.java
Normal file
@ -0,0 +1,59 @@
|
||||
package eu.univento.teamvento.commands;
|
||||
|
||||
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.teamvento.TeamVento;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.2
|
||||
*/
|
||||
public class Setloc extends AutoCommand<TeamVento>{
|
||||
|
||||
/**
|
||||
* @param plugin main class
|
||||
* @param command command to execute
|
||||
* @param description describes the command
|
||||
* @param aliases aliases of command
|
||||
*/
|
||||
public Setloc(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());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
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>");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(msgs.NO_PERMS());
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Spawn");
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
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.teamvento.TeamVento;
|
||||
import eu.univento.teamvento.utils.VoidGenerator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class WorldCreate extends AutoCommand<TeamVento>{
|
||||
|
||||
public WorldCreate(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 == 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]);
|
||||
if(args[1].equalsIgnoreCase("normal")) {
|
||||
creator.environment(World.Environment.NORMAL);
|
||||
creator.type(WorldType.NORMAL);
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("flat")) {
|
||||
creator.environment(World.Environment.NORMAL);
|
||||
creator.type(WorldType.FLAT);
|
||||
creator.generateStructures(false);
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("void")) {
|
||||
creator.generator(new VoidGenerator());
|
||||
creator.type(WorldType.CUSTOMIZED);
|
||||
creator.generateStructures(false);
|
||||
}
|
||||
Bukkit.createWorld(creator);
|
||||
TeamVento.getCfg().set("worlds", TeamVento.getCfg().getStringList("worlds").add(args[0]));
|
||||
try {
|
||||
TeamVento.getCfg().save(TeamVento.getConfigFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§aYour world has been created");
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cPlease use /worldcreate <name> <normal, flat, void>");
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cPlease use /worldcreate <name> <normal, flat, void>");
|
||||
}
|
||||
}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;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
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.teamvento.TeamVento;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class WorldImport extends AutoCommand<TeamVento>{
|
||||
|
||||
public WorldImport(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.getWorld(args[0]) == null) {
|
||||
Bukkit.createWorld(new WorldCreator(args[0]));
|
||||
TeamVento.getCfg().set("worlds", TeamVento.getCfg().getStringList("worlds").add(args[0]));
|
||||
try {
|
||||
TeamVento.getCfg().save(TeamVento.getConfigFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§ayour world has been imported");
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cthe chosen world already exists");
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cplease use /worldimport <name>");
|
||||
}
|
||||
}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;
|
||||
}
|
||||
}
|
45
src/main/java/eu/univento/teamvento/commands/WorldList.java
Normal file
45
src/main/java/eu/univento/teamvento/commands/WorldList.java
Normal file
@ -0,0 +1,45 @@
|
||||
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.teamvento.TeamVento;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class WorldList extends AutoCommand<TeamVento> {
|
||||
|
||||
public WorldList(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.Supporter)) {
|
||||
p.sendMessage("§cAll worlds");
|
||||
for(String world : TeamVento.getCfg().getStringList("worlds")) {
|
||||
p.sendMessage("§a- " + world);
|
||||
}
|
||||
}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;
|
||||
}
|
||||
}
|
52
src/main/java/eu/univento/teamvento/commands/WorldTP.java
Normal file
52
src/main/java/eu/univento/teamvento/commands/WorldTP.java
Normal file
@ -0,0 +1,52 @@
|
||||
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.teamvento.TeamVento;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class WorldTP extends AutoCommand<TeamVento>{
|
||||
|
||||
public WorldTP(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.Supporter)) {
|
||||
if(args.length == 1) {
|
||||
if(Bukkit.getWorld(args[0]) != null) {
|
||||
p.teleport(Bukkit.getWorld(args[0]).getSpawnLocation());
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§aDu hast die Welt gewechselt");
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cDie Welt " + args[0] + " exsistiert nicht");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§cDie Anzahl der Argumente stimmt nicht");
|
||||
}
|
||||
}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;
|
||||
}
|
||||
}
|
65
src/main/java/eu/univento/teamvento/listener/Events.java
Normal file
65
src/main/java/eu/univento/teamvento/listener/Events.java
Normal file
@ -0,0 +1,65 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.teamvento.utils.PlotManager;
|
||||
import org.bukkit.Material;
|
||||
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.weather.WeatherChangeEvent;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.2
|
||||
*/
|
||||
public class Events implements Listener{
|
||||
|
||||
@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) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent e) {
|
||||
e.blockList().clear();
|
||||
}
|
||||
|
||||
@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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if(!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
39
src/main/java/eu/univento/teamvento/listener/JoinQuit.java
Normal file
39
src/main/java/eu/univento/teamvento/listener/JoinQuit.java
Normal file
@ -0,0 +1,39 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class JoinQuit implements Listener {
|
||||
|
||||
@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.setCollidable(false);
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.teamvento.utils.WorldEdit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PositionSetter implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
Block b = e.getClickedBlock();
|
||||
ItemStack item = p.getInventory().getItemInMainHand();
|
||||
if (p.isAllowed(Ranks.Builder)) {
|
||||
if(e.getAction() == Action.LEFT_CLICK_BLOCK && item.getType() == Material.WOOD_AXE) {
|
||||
WorldEdit.setPos1(p, b);
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§aset pos1");
|
||||
}
|
||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK && item.getType() == Material.WOOD_AXE) {
|
||||
WorldEdit.setPos2(p, b);
|
||||
p.sendMessage(p.getMessages().PREFIX() + "§aset pos2");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package eu.univento.teamvento.listener;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.teamvento.utils.PlotManager;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
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{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
45
src/main/java/eu/univento/teamvento/utils/Plot.java
Normal file
45
src/main/java/eu/univento/teamvento/utils/Plot.java
Normal file
@ -0,0 +1,45 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
import eu.univento.core.api.map.Cuboid;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Plot {
|
||||
|
||||
private Cuboid area;
|
||||
private UUID owner;
|
||||
private Location spawn;
|
||||
|
||||
public Plot(Cuboid area, UUID owner, Location spawn) {
|
||||
this.area = area;
|
||||
this.owner = owner;
|
||||
this.spawn = spawn;
|
||||
}
|
||||
|
||||
public boolean isInPlot(Location location) {
|
||||
return area.containsLocation(location);
|
||||
}
|
||||
|
||||
public boolean isInPlot(CustomPlayer player) {
|
||||
return area.containsLocation(player.getLocation());
|
||||
}
|
||||
|
||||
public boolean isOwner(CustomPlayer p) {
|
||||
return p.getUniqueId().equals(owner);
|
||||
}
|
||||
|
||||
public Cuboid getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public Location getSpawn() {
|
||||
return spawn;
|
||||
}
|
||||
|
||||
}
|
112
src/main/java/eu/univento/teamvento/utils/PlotManager.java
Normal file
112
src/main/java/eu/univento/teamvento/utils/PlotManager.java
Normal file
@ -0,0 +1,112 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
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 eu.univento.teamvento.TeamVento;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlotManager {
|
||||
|
||||
private static ArrayList<Plot> plots = new ArrayList<>();
|
||||
|
||||
public static void update() {
|
||||
FindIterable<Document> cursor = Core.getMongoDB().getDatabase().getCollection("plots").find();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static Plot getPlotByPlayer(CustomPlayer p) {
|
||||
for(Plot plot : plots) {
|
||||
if(plot.isOwner(p)) return plot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasPlot(CustomPlayer p) {
|
||||
return getPlotByPlayer(p) != null;
|
||||
}
|
||||
|
||||
public static void generatePlot(Plot plot) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void createPlot(Plot plot) {
|
||||
Document doc = new Document("uuid", plot.getOwner().toString());
|
||||
|
||||
HashMap<String, Double> 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<>();
|
||||
minPos.put("X", plot.getArea().getLowerX());
|
||||
minPos.put("Y", plot.getArea().getLowerY());
|
||||
minPos.put("Z", plot.getArea().getLowerZ());
|
||||
|
||||
HashMap<String, Object> spawn = new HashMap<>();
|
||||
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());
|
||||
|
||||
doc.put("maxPos", new BasicDBObject(maxPos));
|
||||
doc.put("minPos", new BasicDBObject(minPos));
|
||||
doc.put("Spawn", new BasicDBObject(spawn));
|
||||
|
||||
Core.getMongoDB().getDatabase().getCollection("plots").insertOne(doc);
|
||||
}
|
||||
|
||||
public static Plot getPlotByLocation(Location location) {
|
||||
for(Plot plot : plots) {
|
||||
if(plot.isInPlot(location)) return plot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
private static Object getObjectFromDatbase(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.get(name);
|
||||
}
|
||||
|
||||
private static Map<String, Object> getMapFromDatabase(String uuid, String name) {
|
||||
return (Map<String, Object>) getObjectFromDatbase(uuid, name);
|
||||
}
|
||||
|
||||
}
|
30
src/main/java/eu/univento/teamvento/utils/VoidGenerator.java
Normal file
30
src/main/java/eu/univento/teamvento/utils/VoidGenerator.java
Normal file
@ -0,0 +1,30 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class VoidGenerator extends ChunkGenerator{
|
||||
|
||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||
return Arrays.asList(new BlockPopulator[0]);
|
||||
}
|
||||
|
||||
public boolean canSpawn(World world, int x, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public byte[] generate(World world, Random random, int chunkX, int chunkZ) {
|
||||
return new byte[32768];
|
||||
}
|
||||
|
||||
public Location getFixedSpawnLocation(World world, Random random) {
|
||||
return new Location(world, 0, 128, 0);
|
||||
}
|
||||
|
||||
}
|
42
src/main/java/eu/univento/teamvento/utils/WorldEdit.java
Normal file
42
src/main/java/eu/univento/teamvento/utils/WorldEdit.java
Normal file
@ -0,0 +1,42 @@
|
||||
package eu.univento.teamvento.utils;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class WorldEdit {
|
||||
|
||||
private static HashMap<CustomPlayer, Block> pos1 = new HashMap<>();
|
||||
private static HashMap<CustomPlayer, Block> pos2 = new HashMap<>();
|
||||
|
||||
public static Block getPos1(CustomPlayer p) {
|
||||
return pos1.containsKey(p) ? pos1.get(p) : null;
|
||||
}
|
||||
|
||||
public static Block getPos2(CustomPlayer p) {
|
||||
return pos2.containsKey(p) ? pos2.get(p) : null;
|
||||
}
|
||||
|
||||
public static void setPos1(CustomPlayer p, Block b) {
|
||||
if(pos1.containsKey(p)) {
|
||||
pos1.remove(p);
|
||||
}
|
||||
pos1.put(p, b);
|
||||
}
|
||||
|
||||
public static void setPos2(CustomPlayer p, Block b) {
|
||||
if(pos2.containsKey(p)) {
|
||||
pos2.remove(p);
|
||||
}
|
||||
pos2.put(p, b);
|
||||
}
|
||||
|
||||
public static boolean hasSetPos(CustomPlayer p) {
|
||||
return pos1.containsKey(p) && pos2.containsKey(p);
|
||||
}
|
||||
}
|
6
src/main/resources/plugin.yml
Normal file
6
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,6 @@
|
||||
main: eu.univento.teamvento.TeamVento
|
||||
name: TeamVento
|
||||
version: 0.1
|
||||
author: joethei
|
||||
website: http://univento.eu/team/TeamVento
|
||||
description: Plugin for univento build server
|
Loading…
Reference in New Issue
Block a user