changed plot positions again, still not working

This commit is contained in:
Johannes Theiner 2016-09-17 12:10:01 +02:00
parent aecd9f572a
commit 1488b48c38
14 changed files with 303 additions and 76 deletions

View File

@ -6,29 +6,42 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <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/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="craftbukkit-1.10.2" level="project" />
<orderEntry type="module" module-name="Core" /> <orderEntry type="module" module-name="Core" />
<orderEntry type="module" module-name="CloudCommons" />
<orderEntry type="module" module-name="Commons" /> <orderEntry type="module" module-name="Commons" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" /> <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-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: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: org.mongodb:bson:3.2.2" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" /> <orderEntry type="library" name="Maven: org.mongodb.morphia:morphia:1.2.1" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" /> <orderEntry type="library" name="Maven: cglib:cglib-nodep:2.2.2" level="project" />
<orderEntry type="library" name="Maven: com.thoughtworks.proxytoys:proxytoys:1.0" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.4.5" level="project" /> <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" /> <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" /> <orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" /> <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" /> <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" /> <orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.10-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
</component> </component>
</module> </module>

25
pom.xml
View File

@ -51,12 +51,37 @@
</plugins> </plugins>
</build> </build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>eu.univento</groupId> <groupId>eu.univento</groupId>
<artifactId>Core</artifactId> <artifactId>Core</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>

View File

@ -49,14 +49,14 @@ public class TeamVento extends JavaPlugin {
pm.registerEvents(new SignInteract(), this); pm.registerEvents(new SignInteract(), this);
pm.registerEvents(new MenuEvents(), this); pm.registerEvents(new MenuEvents(), this);
new Setloc(this, "setloc" , "sets locations"); new Setloc(this, "setloc", "sets locations");
new WorldTP(this, "teleports players to other worlds", "wtp"); new WorldTP(this, "worldteleport", "teleports players to other worlds", "wtp");
new WorldCreate(this, "creates new worlds", "wc"); new WorldCreate(this, "worldcreate", "creates new worlds", "wc");
new WorldImport(this, "worldimport", "imports worlds"); new WorldImport(this, "worldimport", "imports worlds", "wi");
new Set(this, "set", "sets the material of selected blocks"); new Set(this, "set", "sets the material of selected blocks");
new Sel(this, "sel", "removes block selection"); new Sel(this, "sel", "removes block selection");
new WorldList(this, "lists all worlds", "wl"); new WorldList(this, "worldlist", "lists all worlds", "wl");
new PlotInfo(this, "info about a plot", "pi"); new PlotInfo(this, "plotinfo", "info about a plot", "pi");
new Pack(this, "pack", "sets resource pack"); new Pack(this, "pack", "sets resource pack");
for(String world : getCfg().getKeys(true)) { for(String world : getCfg().getKeys(true)) {
@ -89,7 +89,6 @@ public class TeamVento extends JavaPlugin {
ServerSettings.setBuild(false); ServerSettings.setBuild(false);
PlotManager.update(); PlotManager.update();
PlotManager.setLastPlot(PlotManager.getPlotByOwner(Config.readString("lastPlot"))); PlotManager.setLastPlot(PlotManager.getPlotByOwner(Config.readString("lastPlot")));
Core.getCommons().getLoggingHandler().getTrashGames().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, () -> Bukkit.getWorlds().stream().filter(world -> world.getTime() > 7698).forEach(world -> world.setTime(0)), 100 * 20L, 20L);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Events.redstone = 0, 1L, 10 * 20L); Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Events.redstone = 0, 1L, 10 * 20L);
} }
@ -99,6 +98,5 @@ public class TeamVento extends JavaPlugin {
Config.write(PlotManager.getLastPlot().getOwner().toString()); Config.write(PlotManager.getLastPlot().getOwner().toString());
Bukkit.getWorld("plots").getLivingEntities().forEach(Entity::remove); Bukkit.getWorld("plots").getLivingEntities().forEach(Entity::remove);
Core.getInstance().unregisterPlugin(this); Core.getInstance().unregisterPlugin(this);
Core.getCommons().getLoggingHandler().getTrashGames().info("Plugin beendet");
} }
} }

View File

@ -8,6 +8,10 @@ import eu.univento.core.api.utils.UUIDFetcher;
import eu.univento.teamvento.TeamVento; import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.utils.Plot; import eu.univento.teamvento.utils.Plot;
import eu.univento.teamvento.utils.PlotManager; import eu.univento.teamvento.utils.PlotManager;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -27,10 +31,15 @@ public class PlotInfo extends AutoCommand<TeamVento>{
if(p.getDatabasePlayer().isAllowed(Rank.SrBuilder)) { if(p.getDatabasePlayer().isAllowed(Rank.SrBuilder)) {
if(PlotManager.getPlotByLocation(p.getLocation()) != null) { if(PlotManager.getPlotByLocation(p.getLocation()) != null) {
Plot plot = PlotManager.getPlotByLocation(p.getLocation()); Plot plot = PlotManager.getPlotByLocation(p.getLocation());
assert plot != null;
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> { Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
p.sendMessage("§eErsteller: " + UUIDFetcher.getName(plot.getOwner())); p.sendMessage("§eErsteller: " + UUIDFetcher.getName(plot.getOwner()));
p.sendMessage("§eErstellt am: " + PlotManager.getCreatedDate(plot.getOwner().toString())); p.sendMessage("§eErstellt am: " + PlotManager.getCreatedDate(plot.getOwner().toString()));
p.sendMessage("§eResourcePack " + plot.getResourcePack().getName()); p.sendMessage("§eResourcePack: " + plot.getResourcePack().getName());
TextComponent text = new TextComponent("§eResourcePack: " + plot.getResourcePack().getName());
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "pack " + plot.getResourcePack().getName()));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eLade ResourcePack").create()));
p.spigot().sendMessage(text);
}); });
}else{ }else{
p.sendMessage("§cHier ist leider kein Plot"); p.sendMessage("§cHier ist leider kein Plot");

View File

@ -3,7 +3,7 @@ package eu.univento.teamvento.commands;
import eu.univento.commons.player.Rank; import eu.univento.commons.player.Rank;
import eu.univento.core.api.AutoCommand; import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.languages.Messages; import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.map.Cuboid; import eu.univento.core.api.schematic.Cuboid;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento; import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.utils.WorldEdit; import eu.univento.teamvento.utils.WorldEdit;

View File

@ -5,6 +5,10 @@ import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.languages.Messages; import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento; import eu.univento.teamvento.TeamVento;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -27,7 +31,10 @@ public class WorldList extends AutoCommand<TeamVento> {
if(p.getDatabasePlayer().isAllowed(Rank.Supporter)) { if(p.getDatabasePlayer().isAllowed(Rank.Supporter)) {
p.sendMessage("§cAll worlds"); p.sendMessage("§cAll worlds");
for(String world : TeamVento.getCfg().getKeys(true)) { for(String world : TeamVento.getCfg().getKeys(true)) {
p.sendMessage("§a- " + world); TextComponent text = new TextComponent("§a- " + world);
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/wtp " + world));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("In die Welt").create()));
p.spigot().sendMessage(text);
} }
}else{ }else{
p.sendMessage(p.getMessages().NO_PERMS()); p.sendMessage(p.getMessages().NO_PERMS());

View File

@ -61,11 +61,16 @@ public class Events implements Listener{
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent e) { public void onBlockBreak(BlockBreakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true); if(PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
if(!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true); e.setCancelled(true);
return;
}
Plot plot = PlotManager.getPlotByLocation(e.getBlock().getLocation());
assert plot != null;
if(!plot.isOwner(p)) e.setCancelled(true);
if(!e.getBlock().getWorld().getName().equals("plots")) e.setCancelled(false); if(!e.getBlock().getWorld().getName().equals("plots")) e.setCancelled(false);
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) e.setCancelled(false); if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) e.setCancelled(false);
/** /*
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) { if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
@ -79,11 +84,16 @@ public class Events implements Listener{
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent e) { public void onBlockPlace(BlockPlaceEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()) == null) e.setCancelled(true); if(PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()) == null) {
if(!PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()).isOwner(p)) e.setCancelled(true); e.setCancelled(true);
return;
}
Plot plot = PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation());
assert plot != null;
if(!plot.isOwner(p)) e.setCancelled(true);
if(!e.getBlockPlaced().getWorld().getName().equals("plots")) e.setCancelled(false); if(!e.getBlockPlaced().getWorld().getName().equals("plots")) e.setCancelled(false);
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) e.setCancelled(false); if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) e.setCancelled(false);
/** /*
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (p.getDatabasePlayer().isAllowed(Ranks.SrDeveloper)) return; if (p.getDatabasePlayer().isAllowed(Ranks.SrDeveloper)) return;
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
@ -101,7 +111,9 @@ public class Events implements Listener{
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true); if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true);
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getBlock().getLocation());
assert plot != null;
if(!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -111,14 +123,18 @@ public class Events implements Listener{
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return;
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) e.setCancelled(true); if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) e.setCancelled(true);
if (!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getEntity().getLocation());
assert plot != null;
if(!plot.isOwner(p)) e.setCancelled(true);
} }
if(e.getRemover() instanceof Player) { if(e.getRemover() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getRemover()); CustomPlayer p = CustomPlayer.getPlayer((Player) e.getRemover());
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return;
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) e.setCancelled(true); if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) e.setCancelled(true);
if (!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getEntity().getLocation());
assert plot != null;
if(!plot.isOwner(p)) e.setCancelled(true);
}else{ }else{
e.setCancelled(true); e.setCancelled(true);
} }
@ -134,7 +150,9 @@ public class Events implements Listener{
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
if (!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getEntity().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
if(e.getDamager() instanceof Projectile) { if(e.getDamager() instanceof Projectile) {
CustomPlayer p = CustomPlayer.getPlayer((Player) ((Projectile) e.getDamager()).getShooter()); CustomPlayer p = CustomPlayer.getPlayer((Player) ((Projectile) e.getDamager()).getShooter());
@ -144,7 +162,9 @@ public class Events implements Listener{
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
if(!PlotManager.getPlotByLocation(e.getEntity().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getEntity().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
} }
@ -164,7 +184,9 @@ public class Events implements Listener{
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true); if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true);
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getBlock().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -191,6 +213,12 @@ public class Events implements Listener{
@EventHandler @EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e) { public void onCreatureSpawn(CreatureSpawnEvent e) {
if(e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) return; if(e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) return;
if(PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) {
e.setCancelled(true);
return;
}
Plot plot = PlotManager.getPlotByLocation(e.getEntity().getLocation());
assert plot != null;
if (e.getEntity().getType() != EntityType.ITEM_FRAME && e.getEntity().getType() != EntityType.ARMOR_STAND && e.getEntity().getType() != EntityType.PAINTING) { if (e.getEntity().getType() != EntityType.ITEM_FRAME && e.getEntity().getType() != EntityType.ARMOR_STAND && e.getEntity().getType() != EntityType.PAINTING) {
e.setCancelled(true); e.setCancelled(true);
} }
@ -214,7 +242,9 @@ public class Events implements Listener{
if (block.getType() == Material.FIRE) { if (block.getType() == Material.FIRE) {
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if(PlotManager.getPlotByLocation(block.getLocation()) == null) e.setCancelled(true); if(PlotManager.getPlotByLocation(block.getLocation()) == null) e.setCancelled(true);
if(!PlotManager.getPlotByLocation(block.getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getClickedBlock().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
} }
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) { if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
@ -232,7 +262,9 @@ public class Events implements Listener{
if(e.getRightClicked().getType() == EntityType.ITEM_FRAME) { if(e.getRightClicked().getType() == EntityType.ITEM_FRAME) {
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true); if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true);
if(!PlotManager.getPlotByLocation(e.getRightClicked().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getRightClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
} }
@ -242,27 +274,23 @@ public class Events implements Listener{
if (!e.getRightClicked().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getRightClicked().getWorld().getName().equalsIgnoreCase("plots")) return;
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true); if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true);
if(!PlotManager.getPlotByLocation(e.getRightClicked().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getRightClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onDrop(PlayerDropItemEvent e) { public void onDrop(PlayerDropItemEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.getDatabasePlayer().isAllowed(Rank.SrDeveloper))
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onPickup(PlayerPickupItemEvent e) { public void onPickup(PlayerPickupItemEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.getDatabasePlayer().isAllowed(Rank.SrDeveloper))
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e) { public void onArrowPickup(PlayerPickupArrowEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.getDatabasePlayer().isAllowed(Rank.SrDeveloper))
e.setCancelled(true); e.setCancelled(true);
} }
@ -272,7 +300,10 @@ public class Events implements Listener{
assert e.getItem().hasItemMeta(); assert e.getItem().hasItemMeta();
assert e.getItem().getItemMeta().hasDisplayName(); assert e.getItem().getItemMeta().hasDisplayName();
//if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true); //if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true);
if(e.getItem().getType() == Material.WATCH) e.setCancelled(true); if(e.getItem().getType() == Material.WATCH) {
e.setCancelled(true);
Core.getCommons().getLoggingHandler().getTeamVento().info("Item has been moved");
}
} }
@EventHandler @EventHandler
@ -281,13 +312,17 @@ public class Events implements Listener{
assert e.getCursor().hasItemMeta(); assert e.getCursor().hasItemMeta();
assert e.getCursor().getItemMeta().hasDisplayName(); assert e.getCursor().getItemMeta().hasDisplayName();
//if(e.getCursor().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true); //if(e.getCursor().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true);
if(e.getCursor().getType() == Material.WATCH) e.setCancelled(true); if(e.getCursor().getType() == Material.WATCH) {
e.setCancelled(true);
Core.getCommons().getLoggingHandler().getTeamVento().info("Item has been dragged");
}
} }
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent e) { public void onInventoryClick(InventoryClickEvent e) {
if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR) { if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR) {
Core.getCommons().getLoggingHandler().getTeamVento().info("Inventory clicked: Swap with cursor"); Core.getCommons().getLoggingHandler().getTeamVento().info("Inventory clicked: Swap with cursor");
e.setCancelled(true);
} }
} }
@ -306,7 +341,9 @@ public class Events implements Listener{
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
if(!PlotManager.getPlotByLocation(e.getPlayer().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getBlockClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -316,7 +353,9 @@ public class Events implements Listener{
return; return;
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if(PlotManager.getPlotByLocation(e.getPlayer().getLocation()) == null) e.setCancelled(true); if(PlotManager.getPlotByLocation(e.getPlayer().getLocation()) == null) e.setCancelled(true);
if(!PlotManager.getPlotByLocation(e.getPlayer().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getBlockClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -328,7 +367,8 @@ public class Events implements Listener{
assert plot != null; assert plot != null;
p.setPlayerTime(plot.getTime().getValue(), false); p.setPlayerTime(plot.getTime().getValue(), false);
p.setPlayerWeather(plot.getWeatherType()); p.setPlayerWeather(plot.getWeatherType());
if(!plot.isOwner(p) && !plot.getOwner().equals(UUID.fromString("83007140-8306-4791-b341-e6fef1a23e8a"))) p.setResourcePack(plot.getResourcePack().getUrl());
if(!plot.isOwner(p) && !plot.getOwner().equals(UUID.fromString("c35f6ece-c430-4fc0-b61e-18b55be19ee3")))
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 2)); p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 2));
if(plot.getWeather() == Weather.THUNDER) { if(plot.getWeather() == Weather.THUNDER) {
BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(TeamVento.getInstance(), () -> { BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(TeamVento.getInstance(), () -> {
@ -356,6 +396,7 @@ public class Events implements Listener{
return; return;
} }
Plot plot = PlotManager.getPlotByPlayer(p); Plot plot = PlotManager.getPlotByPlayer(p);
assert plot != null;
Location loc = plot.getSpawn(); Location loc = plot.getSpawn();
p.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F)); p.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
} }
@ -395,7 +436,9 @@ public class Events implements Listener{
if (!e.getBlockPlaced().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getBlockPlaced().getWorld().getName().equalsIgnoreCase("plots")) return;
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()) == null) e.setCancelled(true); if (PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()) == null) e.setCancelled(true);
if (!PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()).isOwner(p)) e.setCancelled(true); Plot plot = PlotManager.getPlotByLocation(e.getBlock().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -414,8 +457,18 @@ public class Events implements Listener{
if(e.getEntityType() != EntityType.PLAYER) return; if(e.getEntityType() != EntityType.PLAYER) return;
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity().getName()); CustomPlayer p = CustomPlayer.getPlayer(e.getEntity().getName());
if(p.getUniqueId().toString().equals("682ebd10-3661-49ec-ba4d-4f24b761b1a7")) { if(p.getUniqueId().toString().equals("682ebd10-3661-49ec-ba4d-4f24b761b1a7")) {
e.setCancelled(true); Projectile projectile = (Projectile) e.getProjectile();
p.sendMessage("§cNein " + p.getDisplayName()); projectile.setCustomNameVisible(true);
projectile.setCustomName("§cNope " + p.getDisplayName() + ", Nope");
projectile.setPassenger(projectile.getWorld().spawnEntity(projectile.getLocation(), EntityType.CHICKEN));
}
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
if(e.getEntity().getPassenger() != null) {
e.getEntity().getPassenger().remove();
e.getEntity().remove();
} }
} }

View File

@ -5,6 +5,7 @@ import eu.univento.core.api.Config;
import eu.univento.core.api.Hologram; import eu.univento.core.api.Hologram;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento; import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.utils.Plot;
import eu.univento.teamvento.utils.PlotManager; import eu.univento.teamvento.utils.PlotManager;
import net.minecraft.server.v1_10_R1.EnumParticle; import net.minecraft.server.v1_10_R1.EnumParticle;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -32,12 +33,16 @@ public class JoinQuit implements Listener {
e.setJoinMessage(null); e.setJoinMessage(null);
p.resetAttackSpeed(); p.resetAttackSpeed();
if(PlotManager.hasPlot(p)) { if(PlotManager.hasPlot(p)) {
Plot plot = PlotManager.getPlotByPlayer(p);
assert plot != null;
if(!plot.isReady()) {
ItemStack menu = new ItemStack(Material.WATCH); ItemStack menu = new ItemStack(Material.WATCH);
ItemMeta menuMeta = menu.getItemMeta(); ItemMeta menuMeta = menu.getItemMeta();
menuMeta.setDisplayName("§eErweiterungen"); menuMeta.setDisplayName("§eErweiterungen");
menu.setItemMeta(menuMeta); menu.setItemMeta(menuMeta);
p.getInventory().setItem(8, menu); p.getInventory().setItem(8, menu);
} }
}
if(p.getDatabasePlayer().getRank() == Rank.Builder || p.getDatabasePlayer().getRank() == Rank.SrBuilder) if(p.getDatabasePlayer().getRank() == Rank.Builder || p.getDatabasePlayer().getRank() == Rank.SrBuilder)
Bukkit.broadcastMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §8hat den Server §bbetreten"); Bukkit.broadcastMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §8hat den Server §bbetreten");
else else

View File

@ -1,7 +1,10 @@
package eu.univento.teamvento.listener; package eu.univento.teamvento.listener;
import eu.univento.commons.player.Rank;
import eu.univento.core.Core;
import eu.univento.core.api.gui.AnvilGUI; import eu.univento.core.api.gui.AnvilGUI;
import eu.univento.core.api.items.ItemBuilder; import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.items.PageInventory;
import eu.univento.core.api.items.ScrollingInventory; import eu.univento.core.api.items.ScrollingInventory;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.utils.UUIDFetcher; import eu.univento.core.api.utils.UUIDFetcher;
@ -12,8 +15,6 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.WeatherType; import org.bukkit.WeatherType;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Pig; import org.bukkit.entity.Pig;
@ -27,6 +28,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
public class MenuEvents implements Listener{ public class MenuEvents implements Listener{
@EventHandler @EventHandler
@ -50,6 +53,7 @@ public class MenuEvents implements Listener{
if(!e.getCurrentItem().hasItemMeta()) return; if(!e.getCurrentItem().hasItemMeta()) return;
if(!e.getCurrentItem().getItemMeta().hasDisplayName()) return; if(!e.getCurrentItem().getItemMeta().hasDisplayName()) return;
Plot plot = PlotManager.getPlotByPlayer(p); Plot plot = PlotManager.getPlotByPlayer(p);
assert plot != null;
if(e.getInventory().getName().equals(invs.getMainInventory().getName())) { if(e.getInventory().getName().equals(invs.getMainInventory().getName())) {
e.setCancelled(true); e.setCancelled(true);
if(e.getCurrentItem().getType() == Material.BED) { if(e.getCurrentItem().getType() == Material.BED) {
@ -66,6 +70,13 @@ public class MenuEvents implements Listener{
Bukkit.getScheduler().runTaskLaterAsynchronously(TeamVento.getInstance(), () -> PlotManager.generatePlot(plot), 13 * 20L); Bukkit.getScheduler().runTaskLaterAsynchronously(TeamVento.getInstance(), () -> PlotManager.generatePlot(plot), 13 * 20L);
p.closeInventory(); p.closeInventory();
} }
if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eFertig")) {
p.closeInventory();
if(plot.hasName() && plot.hasContact())
p.openInventory(invs.getReadyInventory());
else
p.sendMessage("§cName und Kontaktinformationen müssen angegeben werden");
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eBiom ändern")) { if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eBiom ändern")) {
p.closeInventory(); p.closeInventory();
p.openInventory(invs.getBiomeInventory()); p.openInventory(invs.getBiomeInventory());
@ -85,19 +96,27 @@ public class MenuEvents implements Listener{
if(e.getCurrentItem().getType() == Material.MINECART) { if(e.getCurrentItem().getType() == Material.MINECART) {
p.closeInventory(); p.closeInventory();
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> { Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
ScrollingInventory inventory = new ScrollingInventory(p, "§eTeleport"); PageInventory inventory = new PageInventory("§eTeleport", p, true);
ArrayList<ItemStack> items = new ArrayList<>();
for(Plot plots : PlotManager.getPlots()) { for(Plot plots : PlotManager.getPlots()) {
String name = UUIDFetcher.getName(plots.getOwner()); String name = UUIDFetcher.getName(plots.getOwner());
inventory.addItem(new ItemBuilder(Material.SKULL_ITEM) items.add(new ItemBuilder(Material.SKULL_ITEM).durability().skullOwner(name).name("§e" + plots.getName()).lore("§evon " + name).make());
.durability().skullOwner(name)
.name(plot.getName().equals("") ? "§cunbenanntes Plot" : "§e" + plots.getName())
.lore("§eby " + name)
.make());
} }
inventory.setPages(items);
inventory.openInventory(); inventory.openInventory();
}); });
} }
} }
if(e.getInventory().getName().equals(invs.getReadyInventory().getName())) {
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("Ja")) {
p.closeInventory();
plot.setReady();
p.getInventory().remove(p.getInventory().getItem(8));
Core.getOnlinePlayers().stream().filter(player -> player.getDatabasePlayer().isAllowed(Rank.Builder)).forEach(player -> player.sendMessage("§a[Plot]§e" + p.getName() + " ist fertig"));
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("Nein"))
p.closeInventory();
}
if(e.getInventory().getName().equals(invs.getBiomeInventory().getName())) { if(e.getInventory().getName().equals(invs.getBiomeInventory().getName())) {
e.setCancelled(true); e.setCancelled(true);
if(e.getCurrentItem().getType() == Material.WATER_LILY) { if(e.getCurrentItem().getType() == Material.WATER_LILY) {
@ -210,7 +229,7 @@ public class MenuEvents implements Listener{
}); });
ItemStack name = new ItemStack(Material.NAME_TAG); ItemStack name = new ItemStack(Material.NAME_TAG);
ItemMeta nameMeta = name.getItemMeta(); ItemMeta nameMeta = name.getItemMeta();
nameMeta.setDisplayName(plot.getContact() == null ? "§cKontaktdaten hier angeben" : plot.getContact()); nameMeta.setDisplayName(plot.getContact() == null ? "§cKontaktdaten" : plot.getContact());
name.setItemMeta(nameMeta); name.setItemMeta(nameMeta);
gui.setSlot(name); gui.setSlot(name);
@ -219,8 +238,10 @@ public class MenuEvents implements Listener{
if(e.getCurrentItem().getType() == Material.DIRT) { if(e.getCurrentItem().getType() == Material.DIRT) {
ScrollingInventory inventory = new ScrollingInventory(p, "§eResourcePack"); ScrollingInventory inventory = new ScrollingInventory(p, "§eResourcePack");
for(ResourcePack pack : ResourcePack.values()) { for(ResourcePack pack : ResourcePack.values()) {
inventory.addItem(new ItemBuilder(pack.getMaterial()).name(pack.getName()) if(pack.equals(plot.getResourcePack()))
.enchantment(pack.name().equals(plot.getResourcePack().name()) ? Enchantment.ARROW_DAMAGE : null).make()); inventory.addItem(new ItemBuilder(pack.getMaterial()).glow().name(pack.getName()).make());
else
inventory.addItem(new ItemBuilder(pack.getMaterial()).name(pack.getName()).make());
} }
inventory.openInventory(); inventory.openInventory();
} }
@ -230,14 +251,17 @@ public class MenuEvents implements Listener{
SkullMeta skull = (SkullMeta) e.getCurrentItem().getItemMeta(); SkullMeta skull = (SkullMeta) e.getCurrentItem().getItemMeta();
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> { Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
Plot tpPlot = PlotManager.getPlotByOwner(UUIDFetcher.getUUID(skull.getOwner()).toString()); Plot tpPlot = PlotManager.getPlotByOwner(UUIDFetcher.getUUID(skull.getOwner()).toString());
assert tpPlot != null;
Location loc = tpPlot.getSpawn(); 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))); 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.getInventory().getName().equals("§eResourcePack")) {
if(e.getCurrentItem() != null) if(e.getCurrentItem() != null) {
plot.setResourcePack(ResourcePack.valueOf(e.getCurrentItem().getType())); plot.setResourcePack(ResourcePack.valueOf(e.getCurrentItem().getType()));
p.closeInventory();
}
} }
if(e.getInventory().getName().equals(invs.getAnimalsInventory().getName())) { if(e.getInventory().getName().equals(invs.getAnimalsInventory().getName())) {
if(e.getCurrentItem().getType() == Material.COOKED_BEEF) { if(e.getCurrentItem().getType() == Material.COOKED_BEEF) {

View File

@ -13,6 +13,9 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import java.util.ArrayList;
import java.util.List;
public class SignInteract implements Listener { public class SignInteract implements Listener {
@EventHandler @EventHandler
@ -38,6 +41,56 @@ public class SignInteract implements Listener {
} }
} }
if(e.getClickedBlock().getType() == Material.SPONGE) {
generateSpiral(0, 0, 10);
}
}
}
public void generateSpiral(int midX, int midZ, int radius) {
int x = midX;
int z = midZ;
int f = 1;
List<Point> points = new ArrayList<>();
while(f <= radius * 2) { // der Radius ist Länge der Strecke zwischen dem Rand und dem Mittelpunkt ohne die Mitte selbst, in deinem Beispiel 2.
for(int e = z + f; z < e; z++) { // nach oben
points.add(new Point(x, z));
}
for(int e = x + f; x < e; x++) { // nach rechts
points.add(new Point(x, z));
}
f++; // die Linie muss ja eins länger sein, sonst würde es sich überschneiden
for(int e = z - f; z > e; z--) { // nach unten
points.add(new Point(x, z));
}
for(int e = x - f; x > e; x--) { // nach links
points.add(new Point(x, z));
}
f++; // dasselbe wie oben
} // dann alles von vorne, bis man in der unteren linken Ecke mit dem vorgegebenen Radius angelangt ist.
for(int e = z + f - 1; z < e; z++) { // nach oben damit die Spirale fertigestellt wird
points.add(new Point(x, z));
}
for(Point point : points)
new Location(Bukkit.getWorld("plots"), point.getX(), 100, point.getZ()).getBlock().setType(Material.BEDROCK);
}
public class Point{
private int x;
private int z;
public int getX() {
return this.x;
}
public int getZ() {
return this.z;
}
public Point(int x, int z) {
this.x = x;
this.z = z;
}
@Override
public String toString() {
return "{" + this.x + " | " + this.z + "}";
} }
} }
} }

View File

@ -1,7 +1,9 @@
package eu.univento.teamvento.utils; package eu.univento.teamvento.utils;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -96,6 +98,15 @@ public class Inventorys {
return inv; return inv;
} }
public Inventory getReadyInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§ePlot fertig ?");
inv.setItem(5, new ItemBuilder(Material.WOOL).color(Color.LIME).name("Ja").make());
inv.setItem(10, new ItemBuilder(Material.WOOL).color(Color.RED).name("Nein").make());
return inv;
}
public Inventory getBiomeInventory() { public Inventory getBiomeInventory() {
Inventory inv = Bukkit.createInventory(player, 27, "§eBiom ändern"); Inventory inv = Bukkit.createInventory(player, 27, "§eBiom ändern");

View File

@ -3,7 +3,7 @@ package eu.univento.teamvento.utils;
import com.mongodb.CursorType; import com.mongodb.CursorType;
import com.mongodb.client.FindIterable; import com.mongodb.client.FindIterable;
import eu.univento.core.Core; import eu.univento.core.Core;
import eu.univento.core.api.map.Cuboid; import eu.univento.core.api.schematic.Cuboid;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import org.bson.Document; import org.bson.Document;
import org.bukkit.*; import org.bukkit.*;
@ -110,6 +110,14 @@ public class Plot {
return ResourcePack.valueOf(getStringFromDatabase("pack")); return ResourcePack.valueOf(getStringFromDatabase("pack"));
} }
public void setReady() {
setInDatabase("ready", true);
}
public boolean isReady() {
return (boolean) getObjectFromDatbase("ready");
}
public void addAnimal(Entity animal) { public void addAnimal(Entity animal) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("type", animal.getType().name()); map.put("type", animal.getType().name());
@ -192,7 +200,7 @@ public class Plot {
return doc.getString(name); return doc.getString(name);
} }
private void setInDatabase(String name, String obj) { private void setInDatabase(String name, Object obj) {
Core.getCommons().getDatabaseManager().getMongoDB().getDatabase().getCollection("plots").updateOne(new Document("uuid", owner.toString()), new Document("$set", new Document(name, obj))); Core.getCommons().getDatabaseManager().getMongoDB().getDatabase().getCollection("plots").updateOne(new Document("uuid", owner.toString()), new Document("$set", new Document(name, obj)));
} }

View File

@ -4,7 +4,7 @@ import com.mongodb.BasicDBObject;
import com.mongodb.CursorType; import com.mongodb.CursorType;
import com.mongodb.client.FindIterable; import com.mongodb.client.FindIterable;
import eu.univento.core.Core; import eu.univento.core.Core;
import eu.univento.core.api.map.Cuboid; import eu.univento.core.api.schematic.Cuboid;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento; import eu.univento.teamvento.TeamVento;
import org.bson.Document; import org.bson.Document;
@ -58,6 +58,7 @@ public class PlotManager {
public static void clearPlot(Plot plot) { public static void clearPlot(Plot plot) {
CustomPlayer p = CustomPlayer.getPlayer(plot.getOwner()); CustomPlayer p = CustomPlayer.getPlayer(plot.getOwner());
assert p != null;
if (reset) { if (reset) {
p.sendMessage("§cEs wird bereits grade ein Plot bearbeitet."); p.sendMessage("§cEs wird bereits grade ein Plot bearbeitet.");
p.sendMessage("§cBitte versuche es später noch einmal."); p.sendMessage("§cBitte versuche es später noch einmal.");
@ -112,7 +113,6 @@ public class PlotManager {
Location lower = new Location(Bukkit.getWorld("plots"), area.getLowerX(), area.getLowerY() + 17.0D, area.getLowerZ()); 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()); Location upper = new Location(Bukkit.getWorld("plots"), area.getUpperX(), area.getLowerY() + 20.0D, area.getUpperZ());
Cuboid blocks = new Cuboid(lower, upper); Cuboid blocks = new Cuboid(lower, upper);
plots.add(plot);
plot.setBiome(Biome.FOREST); plot.setBiome(Biome.FOREST);
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> { Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
@ -256,76 +256,96 @@ public class PlotManager {
Bukkit.broadcastMessage("Plot im Westen"); Bukkit.broadcastMessage("Plot im Westen");
upper.setX(upper.getX() + 55); upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55); lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot == null && southPlot == null) { if (westPlot == null && eastPlot != null && northPlot == null && southPlot == null) {
Bukkit.broadcastMessage("Plot im Norden"); Bukkit.broadcastMessage("Plot im Norden");
upper.setZ(upper.getZ() - 55); upper.setZ(upper.getZ() - 55);
lower.setZ(lower.getZ() - 55); lower.setZ(lower.getZ() - 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot == null && eastPlot == null && northPlot == null && southPlot != null) {
Bukkit.broadcastMessage("Plot im Osten"); Bukkit.broadcastMessage("Plot im Osten");
upper.setX(upper.getX() - 55); upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55); lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) {
Bukkit.broadcastMessage("Plot im Osten 2"); Bukkit.broadcastMessage("Plot im Osten 2");
upper.setX(upper.getX() - 55); upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55); lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot == null) { if (westPlot != null && eastPlot == null && northPlot == null && southPlot == null) {
Bukkit.broadcastMessage("Plot im Süden"); Bukkit.broadcastMessage("Plot im Süden");
upper.setZ(upper.getZ() + 55); upper.setZ(upper.getZ() + 55);
lower.setZ(lower.getZ() + 55); lower.setZ(lower.getZ() + 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot != null && southPlot == null) { if (westPlot != null && eastPlot == null && northPlot != null && southPlot == null) {
Bukkit.broadcastMessage("Plot im Süden 2"); Bukkit.broadcastMessage("Plot im Süden 2");
upper.setZ(upper.getZ() + 55); upper.setZ(upper.getZ() + 55);
lower.setZ(upper.getZ() + 55); lower.setZ(upper.getZ() + 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot != null && southPlot == null) { if (westPlot == null && eastPlot == null && northPlot != null && southPlot == null) {
Bukkit.broadcastMessage("Plot im Westen 2"); Bukkit.broadcastMessage("Plot im Westen 2");
upper.setX(upper.getX() + 55); upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55); lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot == null && southPlot == null) { if (westPlot == null && eastPlot != null && northPlot == null && southPlot == null) {
Bukkit.broadcastMessage("Plot im Norden 2"); Bukkit.broadcastMessage("Plot im Norden 2");
upper.setZ(upper.getZ() - 55); upper.setZ(upper.getZ() - 55);
lower.setZ(lower.getZ() - 55); lower.setZ(lower.getZ() - 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot == null && southPlot != null) { if (westPlot == null && eastPlot != null && northPlot == null && southPlot != null) {
Bukkit.broadcastMessage("Plot im Norden 3"); Bukkit.broadcastMessage("Plot im Norden 3");
upper.setZ(upper.getZ() - 55); upper.setZ(upper.getZ() - 55);
lower.setZ(lower.getZ() - 55); lower.setZ(lower.getZ() - 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot == null && eastPlot == null && northPlot == null && southPlot != null) {
Bukkit.broadcastMessage("Plot im Osten 3"); Bukkit.broadcastMessage("Plot im Osten 3");
upper.setX(upper.getX() - 55); upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55); lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) {
Bukkit.broadcastMessage("Plot im Osten 4"); Bukkit.broadcastMessage("Plot im Osten 4");
upper.setX(upper.getX() - 55); upper.setX(upper.getX() - 55);
lower.setX(lower.getX() - 55); lower.setX(lower.getX() - 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) {
Bukkit.broadcastMessage("Plot im Süden 3"); Bukkit.broadcastMessage("Plot im Süden 3");
upper.setZ(upper.getZ() + 55); upper.setZ(upper.getZ() + 55);
lower.setZ(lower.getZ() + 55); lower.setZ(lower.getZ() + 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot != null && southPlot == null) { if (westPlot == null && eastPlot == null && northPlot != null && southPlot == null) {
Bukkit.broadcastMessage("Plot im Westen 3"); Bukkit.broadcastMessage("Plot im Westen 3");
upper.setX(upper.getX() + 55); upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55); lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot != null && southPlot == null) { if (westPlot == null && eastPlot != null && northPlot != null && southPlot == null) {
Bukkit.broadcastMessage("Plot im Westen 4"); Bukkit.broadcastMessage("Plot im Westen 4");
upper.setX(upper.getX() + 55); upper.setX(upper.getX() + 55);
lower.setX(lower.getX() + 55); lower.setX(lower.getX() + 55);
return getPlot(p.getUniqueId(), upper, lower);
}
return null;
} }
private static Plot getPlot(UUID uuid, Location upper, Location lower) {
Cuboid area = new Cuboid(upper, lower); 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); 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); Plot plot = new Plot(area, uuid, spawn);
plots.add(plot);
return plot;
} }
public static void createPlot(Plot plot) { public static void createPlot(Plot plot) {
@ -356,10 +376,10 @@ public class PlotManager {
doc.put("time", "DAY"); doc.put("time", "DAY");
doc.put("weather", "CLEAR"); doc.put("weather", "CLEAR");
doc.put("biome", "PLAINS"); doc.put("biome", "PLAINS");
doc.put("pack", "Default"); doc.put("pack", "DEFAULT");
doc.put("name", ""); doc.put("name", "§cunbenanntes Plot");
doc.put("contact", ""); doc.put("contact", "");
doc.put("animals", animals); doc.put("ready", false);
Core.getCommons().getDatabaseManager().getMongoDB().getDatabase().getCollection("plots").insertOne(doc); Core.getCommons().getDatabaseManager().getMongoDB().getDatabase().getCollection("plots").insertOne(doc);

View File

@ -8,6 +8,7 @@ import org.bukkit.Material;
*/ */
public enum ResourcePack { public enum ResourcePack {
//FIXME: sends empty resource packs
DEFAULT("§eDefault", Material.DIRT, ""), DEFAULT("§eDefault", Material.DIRT, ""),
PURE_BD_CRAFT("§ePureBDCraft", Material.GLOWSTONE, "http://bdcraft.net/download/?z=PureBDcraft%20%2016x%20MC110&dl=bdcee96e7a816b6eb3ebda4549acd222641"), 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#"), FAITHFUL("§eFaithful", Material.WOOD, "http://mods.curse.com/texture-packs/minecraft/236821-faithful-1-10/2310424#"),