- got rid of teleport bug

- removed ResourcePacks
+ added queue to plot generation and reset
+ names in /worldlist are now clickable
This commit is contained in:
BuildTools 2016-10-10 13:14:01 +02:00
parent 1488b48c38
commit 140f8dc0d0
14 changed files with 287 additions and 455 deletions

View File

@ -11,25 +11,6 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Core" />
<orderEntry type="module" module-name="CloudCommons" />
<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: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: org.mongodb.morphia:morphia:1.2.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: org.slf4j:slf4j-api:1.7.16" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" 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.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: 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: 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" 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: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
@ -43,5 +24,29 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.10-SNAPSHOT" 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: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" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="CloudCommons" />
<orderEntry type="library" name="Maven: net.gpedro.integrations.slack:slack-webhook:1.2.1" level="project" />
<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: 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: io.netty:netty-all:4.0.36.Final" 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: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" name="Maven: com.github.theholywaffle:teamspeak3-api:1.0.14-SNAPSHOT" 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="module" module-name="Core" />
<orderEntry type="module-library">
<library name="Maven: eu.the5zig.mod:mod:1.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/../Core/local-maven-repo/The5zigMod.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component> </component>
</module> </module>

28
pom.xml
View File

@ -51,19 +51,7 @@
</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>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
@ -82,7 +70,21 @@
<version>1.10.2-R0.1-SNAPSHOT</version> <version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>CloudCommons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -57,7 +57,6 @@ public class TeamVento extends JavaPlugin {
new Sel(this, "sel", "removes block selection"); new Sel(this, "sel", "removes block selection");
new WorldList(this, "worldlist", "lists all worlds", "wl"); new WorldList(this, "worldlist", "lists all worlds", "wl");
new PlotInfo(this, "plotinfo", "info about a plot", "pi"); new PlotInfo(this, "plotinfo", "info about a plot", "pi");
new Pack(this, "pack", "sets resource pack");
for(String world : getCfg().getKeys(true)) { for(String world : getCfg().getKeys(true)) {
String generator = getCfg().getString(world); String generator = getCfg().getString(world);

View File

@ -1,47 +0,0 @@
package eu.univento.teamvento.commands;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.utils.ResourcePack;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
/**
* @author joethei
* @version 0.1
*/
public class Pack extends AutoCommand<TeamVento>{
public Pack(TeamVento plugin, String command, String description, String... aliases) {
super(plugin, command, description, aliases);
}
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if(sender instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) sender);
if(args.length == 1) {
p.setResourcePack(ResourcePack.valueOf(args[0]).getUrl());
}else{
p.sendMessage("§cDa stimmt was mit den Argumenten nicht");
}
}else{
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
}
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
ArrayList<String> list = new ArrayList<>();
for(ResourcePack pack : ResourcePack.values()) {
list.add(pack.name());
}
return list;
}
}

View File

@ -8,10 +8,6 @@ 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;
@ -33,13 +29,13 @@ public class PlotInfo extends AutoCommand<TeamVento>{
Plot plot = PlotManager.getPlotByLocation(p.getLocation()); Plot plot = PlotManager.getPlotByLocation(p.getLocation());
assert plot != null; assert plot != null;
Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> { Bukkit.getScheduler().runTaskAsynchronously(TeamVento.getInstance(), () -> {
p.sendMessage("§eName: " + plot.getName());
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("§eKontakt: " + plot.getContact());
TextComponent text = new TextComponent("§eResourcePack: " + plot.getResourcePack().getName()); p.sendMessage("§eBiom: " + plot.getBiome().name());
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "pack " + plot.getResourcePack().getName())); p.sendMessage("§eZeit: " + plot.getTime().name());
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eLade ResourcePack").create())); p.sendMessage("§Wetter: " + plot.getWeather().name());
p.spigot().sendMessage(text);
}); });
}else{ }else{
p.sendMessage("§cHier ist leider kein Plot"); p.sendMessage("§cHier ist leider kein Plot");

View File

@ -23,13 +23,11 @@ import org.bukkit.event.block.*;
import org.bukkit.event.entity.*; import org.bukkit.event.entity.*;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@ -61,80 +59,30 @@ 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) { if(!PlotManager.isAllowedToBuild(p, e.getBlock().getLocation())) 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(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) e.setCancelled(false);
/*
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
e.setCancelled(true);
return;
}
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true);
*/
} }
@EventHandler @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) { if(!PlotManager.isAllowedToBuild(p, e.getBlock().getLocation())) 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(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) e.setCancelled(false);
/*
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (p.getDatabasePlayer().isAllowed(Ranks.SrDeveloper)) return;
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return;
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) {
e.setCancelled(true);
return;
}
if (!PlotManager.getPlotByLocation(e.getBlock().getLocation()).isOwner(p)) e.setCancelled(true);
*/
} }
@EventHandler @EventHandler
public void onHangingPlace(HangingPlaceEvent e) { public void onHangingPlace(HangingPlaceEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return; if(!PlotManager.isAllowedToBuild(p, e.getEntity().getLocation())) e.setCancelled(true);
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true);
Plot plot = PlotManager.getPlotByLocation(e.getBlock().getLocation());
assert plot != null;
if(!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onHangingBreakByEntity(HangingBreakByEntityEvent e) { public void onHangingBreakByEntity(HangingBreakByEntityEvent e) {
if(e.getRemover() instanceof Projectile) { if(e.getRemover() instanceof Projectile) {
CustomPlayer p = CustomPlayer.getPlayer((Player) ((Projectile) e.getRemover()).getShooter()); CustomPlayer p = CustomPlayer.getPlayer((Player) ((Projectile) e.getRemover()).getShooter());
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return; if(!PlotManager.isAllowedToBuild(p, e.getEntity().getLocation())) e.setCancelled(true);
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) 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(!PlotManager.isAllowedToBuild(p, e.getEntity().getLocation())) e.setCancelled(true);
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getEntity().getLocation()) == null) 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);
} }
@ -144,27 +92,11 @@ public class Events implements Listener{
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) { public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Player) { if (e.getDamager() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getDamager()); CustomPlayer p = CustomPlayer.getPlayer((Player) e.getDamager());
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return; if(!PlotManager.isAllowedToBuild(p, e.getEntity().getLocation())) e.setCancelled(true);
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getDamager().getLocation()) == null) {
e.setCancelled(true);
return;
}
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());
if (!e.getEntity().getWorld().getName().equalsIgnoreCase("plots")) return; if(!PlotManager.isAllowedToBuild(p, e.getEntity().getLocation())) e.setCancelled(true);
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getDamager().getLocation()) == null) {
e.setCancelled(true);
return;
}
Plot plot = PlotManager.getPlotByLocation(e.getEntity().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
} }
@ -176,17 +108,12 @@ public class Events implements Listener{
@EventHandler @EventHandler
public void onBlockIgnite(BlockIgniteEvent e) { public void onBlockIgnite(BlockIgniteEvent e) {
if (e.getCause() != BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) { if (e.getCause() != BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && e.getCause() != BlockIgniteEvent.IgniteCause.FIREBALL) {
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (!e.getBlock().getWorld().getName().equalsIgnoreCase("plots")) return; if(!PlotManager.isAllowedToBuild(p, e.getBlock().getLocation())) e.setCancelled(true);
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getBlock().getLocation()) == null) e.setCancelled(true);
Plot plot = PlotManager.getPlotByLocation(e.getBlock().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -231,6 +158,11 @@ public class Events implements Listener{
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler
public void onPiston(BlockPistonEvent e) {
e.setCancelled(true);
}
@EventHandler @EventHandler
public void onInteract(PlayerInteractEvent e) { public void onInteract(PlayerInteractEvent e) {
if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.SOIL) if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.SOIL)
@ -240,43 +172,26 @@ public class Events implements Listener{
Block block = e.getClickedBlock().getRelative(BlockFace.UP); Block block = e.getClickedBlock().getRelative(BlockFace.UP);
if (!e.getPlayer().getWorld().getName().equalsIgnoreCase("plots")) return; if (!e.getPlayer().getWorld().getName().equalsIgnoreCase("plots")) return;
if (block.getType() == Material.FIRE) { if (block.getType() == Material.FIRE) {
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if(!PlotManager.isAllowedToBuild(p, e.getClickedBlock().getLocation())) e.setCancelled(true);
if(PlotManager.getPlotByLocation(block.getLocation()) == null) 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) {
Plot plot = PlotManager.getPlotByLocation(p.getLocation()); if(!PlotManager.isAllowedToBuild(p, e.getClickedBlock().getLocation())) e.setCancelled(true);
if(plot == null) return;
if(!plot.isOwner(p)) e.setCancelled(true);
} }
} }
@EventHandler @EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent e) { public void onPlayerInteractEntity(PlayerInteractEntityEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (!e.getRightClicked().getWorld().getName().equalsIgnoreCase("plots"))
return;
if(e.getRightClicked().getType() == EntityType.ITEM_FRAME) { if(e.getRightClicked().getType() == EntityType.ITEM_FRAME) {
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return; if(!PlotManager.isAllowedToBuild(p, e.getRightClicked().getLocation())) e.setCancelled(true);
if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true);
Plot plot = PlotManager.getPlotByLocation(e.getRightClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
} }
@EventHandler @EventHandler
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent e) { public void onArmorStandManipulate(PlayerArmorStandManipulateEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (!e.getRightClicked().getWorld().getName().equalsIgnoreCase("plots")) return; if(!PlotManager.isAllowedToBuild(p, e.getRightClicked().getLocation())) e.setCancelled(true);
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if(PlotManager.getPlotByLocation(e.getRightClicked().getLocation()) == null) e.setCancelled(true);
Plot plot = PlotManager.getPlotByLocation(e.getRightClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -294,34 +209,18 @@ public class Events implements Listener{
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler
public void onInventoryMove(InventoryMoveItemEvent e) {
assert e.getItem() != null;
assert e.getItem().hasItemMeta();
assert e.getItem().getItemMeta().hasDisplayName();
//if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true);
if(e.getItem().getType() == Material.WATCH) {
e.setCancelled(true);
Core.getCommons().getLoggingHandler().getTeamVento().info("Item has been moved");
}
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
assert e.getCursor() != null;
assert e.getCursor().hasItemMeta();
assert e.getCursor().getItemMeta().hasDisplayName();
//if(e.getCursor().getItemMeta().getDisplayName().equalsIgnoreCase("§eErweiterungen")) e.setCancelled(true);
if(e.getCursor().getType() == Material.WATCH) {
e.setCancelled(true);
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.getClickedInventory() instanceof PlayerInventory) {
Core.getCommons().getLoggingHandler().getTeamVento().info("Inventory clicked: Swap with cursor"); if(e.getSlot() == 8 || e.getHotbarButton() == 8) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onSwapHands(PlayerSwapHandItemsEvent e) {
if(e.getPlayer().getInventory().getHeldItemSlot() == 8) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -334,28 +233,13 @@ public class Events implements Listener{
@EventHandler @EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent e) { public void onBucketEmpty(PlayerBucketEmptyEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (!e.getPlayer().getWorld().getName().equalsIgnoreCase("plots")) if(!PlotManager.isAllowedToBuild(p, e.getBlockClicked().getLocation())) e.setCancelled(true);
return;
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if(PlotManager.getPlotByLocation(e.getPlayer().getLocation()) == null) {
e.setCancelled(true);
return;
}
Plot plot = PlotManager.getPlotByLocation(e.getBlockClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onBucketFill(PlayerBucketFillEvent e) { public void onBucketFill(PlayerBucketFillEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (!e.getPlayer().getWorld().getName().equalsIgnoreCase("plots")) if(!PlotManager.isAllowedToBuild(p, e.getBlockClicked().getLocation())) e.setCancelled(true);
return;
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if(PlotManager.getPlotByLocation(e.getPlayer().getLocation()) == null) e.setCancelled(true);
Plot plot = PlotManager.getPlotByLocation(e.getBlockClicked().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler
@ -367,7 +251,6 @@ 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());
p.setResourcePack(plot.getResourcePack().getUrl());
if(!plot.isOwner(p) && !plot.getOwner().equals(UUID.fromString("c35f6ece-c430-4fc0-b61e-18b55be19ee3"))) 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) {
@ -414,6 +297,39 @@ public class Events implements Listener{
} }
} }
@EventHandler
public void onTeleport(PlayerTeleportEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
//plot enter
if(PlotManager.getPlotByLocation(e.getFrom()) == null && PlotManager.getPlotByLocation(e.getTo()) != null) {
Plot plot = PlotManager.getPlotByLocation(e.getTo());
assert plot != null;
p.setPlayerTime(plot.getTime().getValue(), false);
p.setPlayerWeather(plot.getWeatherType());
if(!plot.isOwner(p) && !plot.getOwner().equals(UUID.fromString("c35f6ece-c430-4fc0-b61e-18b55be19ee3")))
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 2));
if(plot.getWeather() == Weather.THUNDER) {
BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(TeamVento.getInstance(), () -> {
Random random = new Random();
int r = random.nextInt(100);
if(r < 30) {
p.strikeLightning(plot.getArea().getRandomLocation());
}
}, 2L, 50L);
lightningTasks.put(p, task);
}
}
//plot leave
if(PlotManager.getPlotByLocation(e.getFrom()) != null && PlotManager.getPlotByLocation(e.getTo()) == null) {
p.setPlayerTime(Time.DAY.getValue(), false);
p.setPlayerWeather(WeatherType.CLEAR);
p.clearPotionEffects();
if(lightningTasks.containsKey(p))
lightningTasks.get(p).cancel();
lightningTasks.remove(p);
}
}
@EventHandler @EventHandler
public void onPotionSplash(PotionSplashEvent e) { public void onPotionSplash(PotionSplashEvent e) {
e.setCancelled(true); e.setCancelled(true);
@ -433,12 +349,7 @@ public class Events implements Listener{
@EventHandler @EventHandler
public void onMultiPlace(BlockMultiPlaceEvent e) { public void onMultiPlace(BlockMultiPlaceEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (!e.getBlockPlaced().getWorld().getName().equalsIgnoreCase("plots")) return; if(!PlotManager.isAllowedToBuild(p, e.getBlockPlaced().getLocation())) e.setCancelled(true);
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return;
if (PlotManager.getPlotByLocation(e.getBlockPlaced().getLocation()) == null) e.setCancelled(true);
Plot plot = PlotManager.getPlotByLocation(e.getBlock().getLocation());
assert plot != null;
if (!plot.isOwner(p)) e.setCancelled(true);
} }
@EventHandler @EventHandler

View File

@ -25,7 +25,7 @@ import java.util.HashMap;
*/ */
public class JoinQuit implements Listener { public class JoinQuit implements Listener {
static final HashMap<CustomPlayer, Hologram> holograms = new HashMap<>(); public static final HashMap<CustomPlayer, Hologram> holograms = new HashMap<>();
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {

View File

@ -5,19 +5,17 @@ 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.PageInventory;
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;
import eu.univento.teamvento.TeamVento; import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.utils.*; import eu.univento.teamvento.utils.*;
import net.gpedro.integrations.slack.SlackApi;
import net.gpedro.integrations.slack.SlackMessage;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; 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.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -66,8 +64,7 @@ public class MenuEvents implements Listener{
p.openInventory(invs.getAnimalsInventory()); p.openInventory(invs.getAnimalsInventory());
} }
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§ePlot zurücksetzen")) { if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§ePlot zurücksetzen")) {
PlotManager.clearPlot(plot); PlotManager.resetPlot(plot);
Bukkit.getScheduler().runTaskLaterAsynchronously(TeamVento.getInstance(), () -> PlotManager.generatePlot(plot), 13 * 20L);
p.closeInventory(); p.closeInventory();
} }
if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eFertig")) { if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eFertig")) {
@ -113,6 +110,10 @@ public class MenuEvents implements Listener{
plot.setReady(); plot.setReady();
p.getInventory().remove(p.getInventory().getItem(8)); 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")); Core.getOnlinePlayers().stream().filter(player -> player.getDatabasePlayer().isAllowed(Rank.Builder)).forEach(player -> player.sendMessage("§a[Plot]§e" + p.getName() + " ist fertig"));
SlackApi api = new SlackApi("https://hooks.slack.com/services/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");
SlackMessage message = new SlackMessage("#bauevent", p.getName(), " ist nun fertig mit bauen");
message.setIcon("http://cravatar.eu/head/" + p.getUniqueId().toString());
api.call(message);
} }
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("Nein")) if(e.getCurrentItem().getItemMeta().getDisplayName().equals("Nein"))
p.closeInventory(); p.closeInventory();
@ -235,16 +236,6 @@ public class MenuEvents implements Listener{
gui.open(); gui.open();
} }
if(e.getCurrentItem().getType() == Material.DIRT) {
ScrollingInventory inventory = new ScrollingInventory(p, "§eResourcePack");
for(ResourcePack pack : ResourcePack.values()) {
if(pack.equals(plot.getResourcePack()))
inventory.addItem(new ItemBuilder(pack.getMaterial()).glow().name(pack.getName()).make());
else
inventory.addItem(new ItemBuilder(pack.getMaterial()).name(pack.getName()).make());
}
inventory.openInventory();
}
} }
if(e.getInventory().getName().equals("§eTeleport")) { if(e.getInventory().getName().equals("§eTeleport")) {
if(e.getCurrentItem().getType() == Material.SKULL_ITEM) { if(e.getCurrentItem().getType() == Material.SKULL_ITEM) {
@ -257,24 +248,5 @@ public class MenuEvents implements Listener{
}); });
} }
} }
if(e.getInventory().getName().equals("§eResourcePack")) {
if(e.getCurrentItem() != null) {
plot.setResourcePack(ResourcePack.valueOf(e.getCurrentItem().getType()));
p.closeInventory();
}
}
if(e.getInventory().getName().equals(invs.getAnimalsInventory().getName())) {
if(e.getCurrentItem().getType() == Material.COOKED_BEEF) {
p.closeInventory();
Entity animal = Bukkit.getWorld("plots").spawnEntity(p.getLocation(), EntityType.PIG);
Pig pig = (Pig) animal;
pig.setAI(false);
pig.setInvulnerable(true);
pig.setRemoveWhenFarAway(false);
pig.setCollidable(false);
pig.setGravity(false);
plot.addAnimal(animal);
}
}
} }
} }

View File

@ -1,7 +1,5 @@
package eu.univento.teamvento.listener; package eu.univento.teamvento.listener;
import eu.univento.core.api.Config;
import eu.univento.core.api.Hologram;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.utils.Plot; import eu.univento.teamvento.utils.Plot;
import eu.univento.teamvento.utils.PlotManager; import eu.univento.teamvento.utils.PlotManager;
@ -25,19 +23,12 @@ public class SignInteract implements Listener {
if(e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && e.getClickedBlock().getLocation().add(0.0D, -1.0D, 0.0D).getBlock().getType() == Material.COMMAND) { if(e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && e.getClickedBlock().getLocation().add(0.0D, -1.0D, 0.0D).getBlock().getType() == Material.COMMAND) {
e.setCancelled(true); e.setCancelled(true);
if (PlotManager.hasPlot(p)) { if (PlotManager.hasPlot(p)) {
Location loc = PlotManager.getPlotByPlayer(p).getSpawn(); Plot plot = PlotManager.getPlotByPlayer(p);
p.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F)); assert plot != null;
} else {
p.sendTitle("§eBitte warten", "§aDein Grundstück wird generiert");
JoinQuit.holograms.get(p).hidePlayer(p);
Hologram holo = new Hologram(new String[]{"§eZu deinem Plot teleportieren", "|", "|", ""}, Config.readLocation("Build.Locs.Holo"));
holo.showPlayer(p);
Plot plot = PlotManager.createPlot(p);
PlotManager.createPlot(plot);
PlotManager.generatePlot(plot);
p.setFlying(true);
Location loc = plot.getSpawn(); 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));
} else {
PlotManager.createPlot(p);
} }
} }

View File

@ -175,14 +175,8 @@ public class Inventorys {
contactMeta.setDisplayName("§eKontaktmöglichkeiten"); contactMeta.setDisplayName("§eKontaktmöglichkeiten");
contact.setItemMeta(contactMeta); contact.setItemMeta(contactMeta);
ItemStack texture = new ItemStack(Material.DIRT);
ItemMeta textureMeta = texture.getItemMeta();
textureMeta.setDisplayName("§eResourcePack");
texture.setItemMeta(textureMeta);
inv.setItem(10, name); inv.setItem(10, name);
inv.setItem(13, contact); inv.setItem(16, contact);
inv.setItem(16, texture);
return inv; return inv;
} }

View File

@ -3,18 +3,20 @@ 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.schematic.Cuboid;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.schematic.Cuboid;
import org.bson.Document; import org.bson.Document;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.WeatherType;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import java.util.*; import java.util.ArrayList;
import java.util.stream.Collectors; import java.util.Map;
import java.util.UUID;
public class Plot { public class Plot {
@ -33,7 +35,7 @@ public class Plot {
} }
public boolean isOwner(CustomPlayer p) { public boolean isOwner(CustomPlayer p) {
return p.getUniqueId().toString().equals(owner.toString()); return p.getUniqueId().equals(owner);
} }
public Cuboid getArea() { public Cuboid getArea() {
@ -102,14 +104,6 @@ public class Plot {
return !getContact().equals(""); return !getContact().equals("");
} }
public void setResourcePack(ResourcePack pack) {
setInDatabase("pack", pack.name());
}
public ResourcePack getResourcePack() {
return ResourcePack.valueOf(getStringFromDatabase("pack"));
}
public void setReady() { public void setReady() {
setInDatabase("ready", true); setInDatabase("ready", true);
} }
@ -118,55 +112,6 @@ public class Plot {
return (boolean) getObjectFromDatbase("ready"); return (boolean) getObjectFromDatbase("ready");
} }
public void addAnimal(Entity animal) {
Map<String, String> map = new HashMap<>();
map.put("type", animal.getType().name());
map.put("X", String.valueOf(animal.getLocation().getX()));
map.put("Y", String.valueOf(animal.getLocation().getY()));
map.put("Z", String.valueOf(animal.getLocation().getZ()));
ArrayList<Map<String, String>> animals = (ArrayList<Map<String, String>>) getObjectFromDatbase("animals");
animals.add(map);
setInDatabase(animals);
}
public void removeAnimal(Entity animal) {
Map<Location, EntityType> animals = getAnimalsMap();
//ArrayList<HashMap<String, String>> animals = (ArrayList<HashMap<String, String>>) getObjectFromDatbase("animals");
if(animals.containsKey(animal.getLocation())) {
Map<String, String> map = new HashMap<>();
map.put("type", animal.getType().name());
map.put("X", String.valueOf(animal.getLocation().getX()));
map.put("Y", String.valueOf(animal.getLocation().getY()));
map.put("Z", String.valueOf(animal.getLocation().getZ()));
ArrayList<Map<String, String>> list = (ArrayList<Map<String, String>>) getObjectFromDatbase("animals");
list.remove(map);
setInDatabase(list);
}
}
public ArrayList<Entity> getAnimals() {
ArrayList<Entity> animals = new ArrayList<>();
Map<Location, EntityType> map = getAnimalsMap();
for(Map.Entry<Location, EntityType> entry : map.entrySet())
animals.addAll(Bukkit.getWorld("plots").getLivingEntities().stream().filter(entity -> entity.getLocation().equals(entry.getKey())).collect(Collectors.toList()));
return animals;
}
private Map<Location, EntityType> getAnimalsMap() {
Map<Location, EntityType> map = new HashMap<>();
ArrayList<Map<String, String>> list = (ArrayList<Map<String, String>>) getObjectFromDatbase("animals");
assert list != null;
for(Map<String, String> stringlist : list) {
double x = Double.parseDouble(stringlist.get("X"));
double y = Double.parseDouble(stringlist.get("Y"));
double z = Double.parseDouble(stringlist.get("Z"));
Location loc = new Location(Bukkit.getWorld("plots"), x, y , z);
map.put(loc, EntityType.valueOf(String.valueOf(stringlist.get("type"))));
}
return map;
}
public WeatherType getWeatherType() { public WeatherType getWeatherType() {
if(getWeather() == Weather.THUNDER) return WeatherType.DOWNFALL; if(getWeather() == Weather.THUNDER) return WeatherType.DOWNFALL;
return WeatherType.valueOf(getWeather().name()); return WeatherType.valueOf(getWeather().name());

View File

@ -0,0 +1,69 @@
package eu.univento.teamvento.utils;
import eu.univento.core.api.Config;
import eu.univento.core.api.Hologram;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.teamvento.TeamVento;
import eu.univento.teamvento.listener.JoinQuit;
import lombok.AllArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
/**
* @author joethei
* @version 0.1
*/
interface PlotAction {
void execute();
class Create implements PlotAction{
Create(CustomPlayer player) {
this.player = player;
}
CustomPlayer player;
@Override
public void execute() {
Plot plot = PlotManager.getPlotPosition(player);
PlotManager.addPlotToDatabase(plot);
PlotManager.generatePlot(plot);
assert plot != null;
Location loc = plot.getSpawn();
player.teleport(new Location(Bukkit.getWorld("plots"), loc.getX(), loc.getY(), loc.getZ(), 89.0F, 6.0F));
JoinQuit.holograms.get(player).hidePlayer(player);
Hologram holo = new Hologram(new String[]{"§eZu deinem Plot teleportieren", "|", "|", ""}, Config.readLocation("Build.Locs.Holo"));
holo.showPlayer(player);
}
}
class Reset implements PlotAction {
Reset(Plot plot) {
this.plot = plot;
}
Plot plot;
@Override
public void execute() {
PlotManager.clearPlot(plot);
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> PlotManager.generatePlot(plot), 13 * 20L);
}
}
@AllArgsConstructor
class SetFloor implements PlotAction{
Plot plot;
@Override
public void execute() {
}
}
}

View File

@ -3,22 +3,26 @@ package eu.univento.teamvento.utils;
import com.mongodb.BasicDBObject; 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.commons.player.Rank;
import eu.univento.core.Core; import eu.univento.core.Core;
import eu.univento.core.api.schematic.Cuboid;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.schematic.Cuboid;
import eu.univento.teamvento.TeamVento; import eu.univento.teamvento.TeamVento;
import org.bson.Document; import org.bson.Document;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.*; import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
public class PlotManager { public class PlotManager {
private static boolean reset = false; private static Queue<PlotAction> queue = new LinkedBlockingDeque<>();
private static final ArrayList<Plot> plots = new ArrayList<>(); private static final ArrayList<Plot> plots = new ArrayList<>();
private static Plot lastPlot; private static Plot lastPlot;
@ -56,17 +60,24 @@ public class PlotManager {
return getPlotByPlayer(p) != null; return getPlotByPlayer(p) != null;
} }
public static void clearPlot(Plot plot) { public static void createPlot(CustomPlayer p) {
CustomPlayer p = CustomPlayer.getPlayer(plot.getOwner()); if(queue.isEmpty()) {
assert p != null; new PlotAction.Create(p).execute();
if (reset) { }else {
p.sendMessage("§cEs wird bereits grade ein Plot bearbeitet."); queue.offer(new PlotAction.Create(p));
p.sendMessage("§cBitte versuche es später noch einmal."); p.sendMessage("Du wurdest zu Warteschlange hinzugefügt: " + queue.size());
return;
} }
reset = true; }
plot.getAnimals().forEach(plot::removeAnimal); public static void resetPlot(Plot plot) {
if(queue.isEmpty()) {
new PlotAction.Reset(plot).execute();
}else {
queue.offer(new PlotAction.Reset(plot));
}
}
static void clearPlot(Plot plot) {
Cuboid area = plot.getArea(); Cuboid area = plot.getArea();
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());
@ -104,10 +115,9 @@ public class PlotManager {
Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.AIR), i / 200); Bukkit.getScheduler().scheduleSyncDelayedTask(TeamVento.getInstance(), () -> b.setType(Material.AIR), i / 200);
} }
}); });
Bukkit.getScheduler().runTaskLaterAsynchronously(TeamVento.getInstance(), () -> reset = false, 13 * 20L);
} }
public static void generatePlot(Plot plot) { static void generatePlot(Plot plot) {
lastPlot = plot; lastPlot = plot;
Cuboid area = plot.getArea(); Cuboid area = plot.getArea();
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());
@ -224,9 +234,11 @@ public class PlotManager {
menu.setItemMeta(menuMeta); menu.setItemMeta(menuMeta);
Bukkit.getPlayer(plot.getOwner()).getInventory().setItem(8, menu); Bukkit.getPlayer(plot.getOwner()).getInventory().setItem(8, menu);
}, 35 * 20L)); }, 35 * 20L));
if(!queue.isEmpty()) queue.peek().execute();
} }
public static Plot createPlot(CustomPlayer p) { static Plot getPlotPosition(CustomPlayer p) {
if (lastPlot == null) { if (lastPlot == null) {
Bukkit.broadcastMessage("Erstes Plot"); Bukkit.broadcastMessage("Erstes Plot");
Location lower = new Location(Bukkit.getWorld("plots"), Bukkit.getWorld("plots").getSpawnLocation().getX(), Bukkit.getWorld("plots").getSpawnLocation().getY() - 20.0D, Bukkit.getWorld("plots").getSpawnLocation().getZ()); Location lower = new Location(Bukkit.getWorld("plots"), Bukkit.getWorld("plots").getSpawnLocation().getX(), Bukkit.getWorld("plots").getSpawnLocation().getY() - 20.0D, Bukkit.getWorld("plots").getSpawnLocation().getZ());
@ -247,90 +259,90 @@ public class PlotManager {
north.getBlock().setType(Material.STONE); north.getBlock().setType(Material.STONE);
south.getBlock().setType(Material.ACACIA_STAIRS); south.getBlock().setType(Material.ACACIA_STAIRS);
Plot westPlot = getPlotByLocation(west); boolean westPlot = getPlotByLocation(west) != null;
Plot eastPlot = getPlotByLocation(east); boolean eastPlot = getPlotByLocation(east) != null;
Plot northPlot = getPlotByLocation(north); boolean northPlot = getPlotByLocation(north) != null;
Plot southPlot = getPlotByLocation(south); boolean southPlot = getPlotByLocation(south) != null;
if (westPlot == null && eastPlot == null && northPlot == null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot == null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot != null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot != null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot == null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot == null && southPlot != null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot != null && eastPlot == null && northPlot == null && southPlot != null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot == null && northPlot != null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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); return getPlot(p.getUniqueId(), upper, lower);
} }
if (westPlot == null && eastPlot != null && northPlot != null && southPlot == null) { if (westPlot && eastPlot && northPlot && southPlot) {
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);
@ -348,7 +360,7 @@ public class PlotManager {
return plot; return plot;
} }
public static void createPlot(Plot plot) { static void addPlotToDatabase(Plot plot) {
Document doc = new Document("uuid", plot.getOwner().toString()); Document doc = new Document("uuid", plot.getOwner().toString());
Date date = new Date(); Date date = new Date();
@ -367,16 +379,13 @@ public class PlotManager {
spawn.put("Y", plot.getSpawn().getY()); spawn.put("Y", plot.getSpawn().getY());
spawn.put("Z", plot.getSpawn().getZ()); spawn.put("Z", plot.getSpawn().getZ());
ArrayList<Map<String, String>> animals = new ArrayList<>();
doc.put("created", date); doc.put("created", date);
doc.put("maxPos", new BasicDBObject(maxPos)); doc.put("maxPos", new BasicDBObject(maxPos));
doc.put("minPos", new BasicDBObject(minPos)); doc.put("minPos", new BasicDBObject(minPos));
doc.put("Spawn", new BasicDBObject(spawn)); doc.put("Spawn", new BasicDBObject(spawn));
doc.put("time", "DAY"); doc.put("time", Time.DAY.name());
doc.put("weather", "CLEAR"); doc.put("weather", Weather.CLEAR.name());
doc.put("biome", "PLAINS"); doc.put("biome", Biome.PLAINS.name());
doc.put("pack", "DEFAULT");
doc.put("name", "§cunbenanntes Plot"); doc.put("name", "§cunbenanntes Plot");
doc.put("contact", ""); doc.put("contact", "");
doc.put("ready", false); doc.put("ready", false);
@ -386,16 +395,14 @@ public class PlotManager {
} }
public static Plot getPlotByLocation(Location location) { public static Plot getPlotByLocation(Location location) {
for (Plot plot : plots) { for (Plot plot : plots)
if (plot.isInPlot(location)) return plot; if (plot.isInPlot(location)) return plot;
}
return null; return null;
} }
public static Plot getPlotByOwner(String owner) { public static Plot getPlotByOwner(String owner) {
for (Plot plot : plots) { for (Plot plot : plots)
if (plot.getOwner().equals(UUID.fromString(owner))) return plot; if (plot.getOwner().equals(UUID.fromString(owner))) return plot;
}
return null; return null;
} }
@ -408,6 +415,42 @@ public class PlotManager {
return new Location(Bukkit.getWorld("plots"), Double.valueOf(String.valueOf(map.get("X"))), Double.valueOf(String.valueOf(map.get("Y"))), Double.valueOf(String.valueOf(map.get("Z")))); return new Location(Bukkit.getWorld("plots"), Double.valueOf(String.valueOf(map.get("X"))), Double.valueOf(String.valueOf(map.get("Y"))), Double.valueOf(String.valueOf(map.get("Z"))));
} }
private static List<Location> spiral(int midX, int midZ, int radius) {
int x = midX;
int z = midZ;
int f = 1;
List<Location> locations = new ArrayList<>();
while(f <= radius * 2) {
for(int i = z + f; z < i; z++) {
locations.add(new Location(Bukkit.getWorld("plots"), x, 25, z));
}
for(int i = z + f; z > i; x++) {
locations.add(new Location(Bukkit.getWorld("plots"), x, 25, z));
}
f++;
for(int i = z -f; z > i; z--) {
locations.add(new Location(Bukkit.getWorld("plots"), x, 25, z));
}
for(int i = x - f; x > i; x--) {
locations.add(new Location(Bukkit.getWorld("plots"), x, 25, z));
}
f++;
}
for(int i = z + f - 1; z < i; z++) {
locations.add(new Location(Bukkit.getWorld("plots"), x, 25, z));
}
return locations;
}
public static boolean isAllowedToBuild(CustomPlayer p, Location loc) {
if(loc.getWorld().getName().equalsIgnoreCase("plots")) {
if (p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) return true;
Plot plot = getPlotByLocation(loc);
return plot != null && plot.isOwner(p);
}else {
return true;
}
}
private static Date getDateFromDatabase(String uuid) { private static Date getDateFromDatabase(String uuid) {
FindIterable<Document> cursor = Core.getCommons().getDatabaseManager().getMongoDB().getDatabase().getCollection("plots").find(new Document("uuid", uuid)); FindIterable<Document> cursor = Core.getCommons().getDatabaseManager().getMongoDB().getDatabase().getCollection("plots").find(new Document("uuid", uuid));

View File

@ -1,48 +0,0 @@
package eu.univento.teamvento.utils;
import org.bukkit.Material;
/**
* @author joethei
* @version 0.1
*/
public enum ResourcePack {
//FIXME: sends empty resource packs
DEFAULT("§eDefault", Material.DIRT, ""),
PURE_BD_CRAFT("§ePureBDCraft", Material.GLOWSTONE, "http://bdcraft.net/download/?z=PureBDcraft%20%2016x%20MC110&dl=bdcee96e7a816b6eb3ebda4549acd222641"),
FAITHFUL("§eFaithful", Material.WOOD, "http://mods.curse.com/texture-packs/minecraft/236821-faithful-1-10/2310424#"),
CHROMA_HILLS("§eChroma Hills", Material.SAND, "http://chromahills.com/zipfiles/ChromaHills128x-1.9-v.1.zip"),
DOKUCRAFT("§eDokucraft", Material.BRICK, "https://www.dokucraft.co.uk/dl/1.9-Dokucraft-TSC-Light.zip"),
SOARTEX_FANVER("§eSoartex Fanver", Material.MOSSY_COBBLESTONE, "http://mods.curse.com/texture-packs/minecraft/soartex-fanver-vanilla/2311293#"),
DANDELION("§eDandelion", Material.YELLOW_FLOWER, "http://www.mediafire.com/download/7mmk531lf41f7ex/Dandelion+v1.8.1.zip");
private final String name;
private final Material material;
private final String url;
ResourcePack(String name, Material material, String url) {
this.name = name;
this.material = material;
this.url = url;
}
public static ResourcePack valueOf(Material material) {
for(ResourcePack pack : values()) {
if(material == pack.getMaterial()) return pack;
}
return null;
}
public String getName() {
return name;
}
public Material getMaterial() {
return material;
}
public String getUrl() {
return url;
}
}