Browse Source

auf meiner Festplatte

master
BuildTools 4 years ago
parent
commit
ddcbb21254
  1. 4
      .gitignore
  2. 49
      Lobby.iml
  3. 28
      pom.xml
  4. 19
      src/main/Lobby.iml
  5. 31
      src/main/java/eu/univento/lobby/Lobby.java
  6. 95
      src/main/java/eu/univento/lobby/listeners/Events.java
  7. 73
      src/main/java/eu/univento/lobby/listeners/FoundItems.java
  8. 84
      src/main/java/eu/univento/lobby/listeners/FunStuff.java
  9. 33
      src/main/java/eu/univento/lobby/listeners/ItemEvents.java
  10. 16
      src/main/java/eu/univento/lobby/listeners/JoinQuit.java
  11. 54
      src/main/java/eu/univento/lobby/listeners/Menu.java
  12. 312
      src/main/java/eu/univento/lobby/listeners/MenuEvents.java
  13. 16
      src/main/java/eu/univento/lobby/listeners/Parkour.java
  14. 124
      src/main/java/eu/univento/lobby/listeners/PetInteract.java
  15. 20
      src/main/java/eu/univento/lobby/listeners/PlayerHider.java
  16. 10
      src/main/java/eu/univento/lobby/utils/CustomMapRenderer.java
  17. 555
      src/main/java/eu/univento/lobby/utils/InventoryManager.java
  18. 57
      src/main/java/eu/univento/lobby/utils/PetManager.java
  19. 69
      src/main/java/eu/univento/lobby/utils/Pets.java
  20. 151
      src/main/java/eu/univento/lobby/utils/Scoreboards.java

4
.gitignore vendored

@ -1 +1,3 @@
/bin/
/bin/
/target/
Lobby.iml

49
Lobby.iml

@ -20,31 +20,35 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: eu.univento:commons:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.mojang:authlib:1.5.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.17" 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: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-all:5.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
<orderEntry type="module" module-name="Core" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-bukkit:3.4.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-core:3.4.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.dmulloy2:PacketWrapper:master-2b4bfddd12-1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-bukkit:3.6.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: pl.kacperduras:tasket-core:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: pl.kacperduras:tasket-bukkit:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.github.lordakkarin:nbt:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-buffer:5.0.0.Alpha2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-common:5.0.0.Alpha2" level="project" />
<orderEntry type="module" module-name="Commons" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: ai.api:libai:1.4.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-core:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-handler:4.1.8.Final" level="project" />
@ -65,6 +69,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:postgresql-async_2.12:0.2.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:db-async-common_2.12:0.2.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: joda-time:joda-time:2.9.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.joda:joda-convert:1.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:mysql-async_2.12:0.2.21" level="project" />
@ -74,17 +79,13 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:bson:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-rabbitmq-client:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.rabbitmq:amqp-client:3.6.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-web-client:3.4.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-web-common:3.4.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TheHolyWaffle:TeamSpeak-3-Java-API:v1.0.13" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.sentry:sentry:1.2.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ben-manes.caffeine:caffeine:2.5.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.nsp:JSkills:master-0.9.0-g8b333ec-15" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:simple:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:core:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:dense64:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.gitlab:java-gitlab-api:1.2.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.dagger:dagger:2.14.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
</component>
</module>

28
pom.xml

@ -48,38 +48,26 @@
</plugins>
</build>
<repositories>
<repository>
<id>univentoEU</id>
<url>http://dev.joethei.de:8081/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<artifactId>craftbukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>

19
src/main/Lobby.iml

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

31
src/main/java/eu/univento/lobby/Lobby.java

@ -1,10 +1,15 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby;
import eu.univento.commons.server.ServerType;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.lobby.commands.DropItem;
import eu.univento.lobby.commands.Setloc;
import eu.univento.lobby.listeners.*;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
@ -19,42 +24,30 @@ import org.bukkit.plugin.java.JavaPlugin;
*/
public class Lobby extends JavaPlugin{
private static Lobby instance;
public static Lobby getInstance() {
return instance;
}
@Getter private static Lobby instance;
@Override
public void onEnable() {
instance = this;
PluginManager pm = Bukkit.getPluginManager();;
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new Jumppads(), this);
pm.registerEvents(new JoinQuit(), this);
pm.registerEvents(new MenuEvents(), this);
pm.registerEvents(new Events(), this);
pm.registerEvents(new Menu(), this);
pm.registerEvents(new PlayerHider(), this);
pm.registerEvents(new ItemEvents(), this);
pm.registerEvents(new FoundItems(), this);
pm.registerEvents(new Parkour(), this);
pm.registerEvents(new PetInteract(), this);
pm.registerEvents(new PlayerInteract(), this);
pm.registerEvents(new FunStuff(), this);
//pm.registerEvents(new MenuEvents(), this);
new Setloc(this, "setloc", "Setzt Teleport Punkte");
new DropItem(this, "dropitem", "Setzt EasterEggs");
if(ServerSettings.isDebug()) System.out.println("Befehle registriert");
for(World w : Bukkit.getWorlds()) w.setDifficulty(Difficulty.PEACEFUL);
ServerSettings.setGameMode(GameMode.ADVENTURE);
ServerSettings.setLobby(true);
ServerSettings.setServerType(ServerType.LOBBY);
ServerSettings.setup(ServerType.LOBBY, GameMode.ADVENTURE);
System.out.println(" Plugin ver." + getDescription().getVersion() + " gestartet");
}
@Override

95
src/main/java/eu/univento/lobby/listeners/Events.java

@ -1,22 +1,16 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.story.missions.StartMission;
import eu.univento.lobby.utils.CustomMapRenderer;
import eu.univento.lobby.utils.PetManager;
import eu.univento.lobby.utils.Pets;
import eu.univento.lobby.utils.Scoreboards;
import net.minecraft.server.v1_11_R1.EnumParticle;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Skull;
import org.bukkit.entity.Creature;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
@ -33,7 +27,6 @@ import org.bukkit.event.server.MapInitializeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.map.MapView;
import org.bukkit.util.Vector;
/**
* some short events
@ -137,31 +130,9 @@ public class Events implements Listener {
if (e.getClickedBlock().getType() == Material.SPRUCE_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.WOOD_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.WOODEN_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.SKULL) {
Skull skull = (Skull) e.getClickedBlock().getState();
if (skull.getOwner().equals("MHF_Chest")) {
p.playSound(p.getEyeLocation(), Sound.BLOCK_PORTAL_TRAVEL, 5.0F, 1.0F);
p.playParticle(skull.getLocation().add(0.5D, 1.5D, 0.5D), EnumParticle.ENCHANTMENT_TABLE, 0.3F, 500);
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), () -> {
p.playParticle(skull.getLocation().add(0.5D, 0.0D, 0.5D), EnumParticle.SPELL_WITCH, 0.4F, 500);
p.sendTitle(10, 50, 10, "Versteck", "§eDu hast ein Versteck gefunden");
p.getDatabasePlayer().addCoins(100);
Scoreboards.updateScoreboard(p);
}, 3 * 20L);
}
}
if(e.getClickedBlock().getType() == Material.STONE_BUTTON) {
new StartMission(p);
}
}
}
@EventHandler
public void onItemDespawn(ItemDespawnEvent e) {
e.setCancelled(true);
}
@EventHandler
public void onHangingBreak(HangingBreakByEntityEvent e) {
if (e.getEntity() instanceof ItemFrame)
@ -192,62 +163,24 @@ public class Events implements Listener {
if (PlayerHider.getSilentlobby().contains(p)) e.setCancelled(true);
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (PetManager.hasPet(p)) {
new Pets().followPlayer((Creature) PetManager.getPet(p), p, 1.4);
}
if ((p.getLocation().getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getVehicle() == null) && (p.getGameMode() != GameMode.CREATIVE)
&& (!p.isFlying())) {
p.setGliding(true);
}
if ((p.getLocation().getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getVehicle() == null)) {
p.setGliding(false);
}
//only for debugging purposes
if(p.getLocation().getY() >= 5.0D && p.getLocation().getBlock().getType() == Material.STATIONARY_WATER) {
Vector v = p.getLocation().getDirection().multiply(0D).setY(3D);
p.setVelocity(v);
}
}
@EventHandler
public void onEntityToggleGlideEvent(EntityToggleGlideEvent e) {
if(e.getEntity() instanceof Player) {
final CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER) {
p.setVelocity(new Vector(p.getLocation().getDirection().getX() * 1, 1 * -1.0, p.getLocation().getDirection().getZ() * 0.1));
e.setCancelled(true);
}
if(p.isSneaking()) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onToogleSneak(PlayerToggleSneakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.isSneaking()) {
p.setGliding(true);
}
}
@EventHandler
public void onEntityBlockChange(EntityChangeBlockEvent e) {
e.setCancelled(true);
}
/*
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e) {
if (e.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM) {
e.setCancelled(true);
}
}
*/
@EventHandler
public void onEntityInteract(EntityInteractEvent e) {
if (e.getBlock().getType() == Material.CROPS && e.getEntity() instanceof LivingEntity)
e.setCancelled(true);
}
}

73
src/main/java/eu/univento/lobby/listeners/FoundItems.java

@ -1,73 +0,0 @@
package eu.univento.lobby.listeners;
import org.bukkit.event.Listener;
/**
* handels all posible easter eggs
* @author joethei
* @version 0.1
*/
public class FoundItems implements Listener{
/*
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
Messages msgs = new Messages(p);
if(e.getItem().getItemStack().getType() == Material.RECORD_3) {
if(!hasFound("music_3")) {
setFound("music_3");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Music_3");
p.addExperience(5);
}
}
if(e.getItem().getItemStack().getType() == Material.SUGAR) {
if(!hasFound("sugar")) {
setFound("su1gar");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Sugar");
p.addExperience(5);
}
}
if(e.getItem().getItemStack().getType() == Material.RED_ROSE) {
if(!hasFound("hearts")) {
setFound("hearts");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Hearts");
p.addExperience(3);
}
}
if(e.getItem().getItemStack().getType() == Material.FEATHER) {
if(!hasFound("feather")) {
setFound("feather");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Feather");
}
}
e.setCancelled(true);
}
public static boolean hasFound(String item) {
int id = 8;
MySQL sql = Core.getCommons().getDatabaseManager().getMySQL();
try {
PreparedStatement st = sql.getConnection().prepareStatement("SELECT * FROM FoundItems WHERE ID='" + id + "';");
ResultSet rs = st.executeQuery();
return rs.next() && rs.getInt(item) == 1;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
private void setFound(String item) {
int id = 8;
MySQL sql = Core.getCommons().getDatabaseManager().getMySQL();
try {
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE FoundItems SET " + item + "='1' WHERE ID='" + id + "';");
st.execute();
} catch (SQLException e) {
e.printStackTrace();
}
}
*/
}

84
src/main/java/eu/univento/lobby/listeners/FunStuff.java

@ -0,0 +1,84 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
/**
* @author joethei
* @version 1.0
*/
public class FunStuff implements Listener{
@EventHandler
public void onMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if ((p.getLocation().getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getVehicle() == null) && (p.getGameMode() != GameMode.CREATIVE)
&& (!p.isFlying())) {
p.setGliding(true);
}
if ((p.getLocation().getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getVehicle() == null)) {
p.setGliding(false);
}
//only for debugging purposes
if(p.getLocation().getY() <= 5.0D && p.getLocation().getBlock().getType() == Material.STATIONARY_WATER) {
Vector v = p.getLocation().getDirection().multiply(0D).setY(3D);
p.setVelocity(v);
}
}
@EventHandler
public void onEntityToggleGlideEvent(EntityToggleGlideEvent e) {
if(e.getEntity() instanceof Player) {
final CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER) {
p.setVelocity(new Vector(p.getLocation().getDirection().getX() * 1, 1 * -1.0, p.getLocation().getDirection().getZ() * 0.1));
e.setCancelled(true);
}
if(p.isSneaking()) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onToogleSneak(PlayerToggleSneakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.isSneaking()) {
p.setGliding(true);
}
}
@EventHandler
public void onEntityHit(EntityDamageByEntityEvent e) {
if(e.getDamager() instanceof Player && e.getEntity() instanceof Creature) {
Creature creature = (Creature) e.getEntity();
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getDamager());
creature.setGlowing(true);
creature.setCustomName(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §8hat mir das angetan");
creature.setCustomNameVisible(true);
creature.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 60, 5, false));
}
}
}

33
src/main/java/eu/univento/lobby/listeners/ItemEvents.java

@ -1,7 +1,16 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.commons.server.ServerType;
import eu.univento.core.Core;
import eu.univento.core.api.Config;
import eu.univento.core.api.gui.inventory.InventoryGUI;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import org.bukkit.*;
@ -53,6 +62,30 @@ public class ItemEvents implements Listener {
e.setCancelled(true);
}
if(item.getType() == Material.COMPASS) {
e.setCancelled(true);
InventoryGUI gui = new InventoryGUI(p, 9, "§aNavigator");
gui.addItem(2, new ItemBuilder(Material.ENCHANTMENT_TABLE).name("§cBalance").build(), player -> {
player.closeInventory();
//CloudProxy.getInstance().sendPlayer(p.getUniqueId(), CloudNetAPI.getInstance().getServerInfos("Free4All").get(0));
player.connectToServer(ServerType.SECRET_GAME_FREE4ALL);
player.teleport(Config.readLocation("Lobby.Locs.FFA"));
});
gui.addItem(4, new ItemBuilder(Material.FLOWER_POT_ITEM).name("§aBauserver").build(), player -> {
player.closeInventory();
//CloudProxy.getInstance().sendPlayer(p.getUniqueId(), Core.getCloudNetAPI().getServerInfos("TeamVento").get(0));
player.connectToServer(ServerType.TEAM_BUILD);
player.teleport(Config.readLocation("Lobby.Locs.Build"));
});
gui.addItem(6, new ItemBuilder(Material.BOOK).name("§bDevelopment").build(), player -> {
player.closeInventory();
//CloudProxy.getInstance().sendPlayer(p.getUniqueId(), Core.getCloudNetAPI().getServerInfos("TrashGames").get(0));
player.connectToServer(ServerType.SECRET_GAME_TRASHGAMES);
player.teleport(Config.readLocation("Lobby.Locs.TrashGames"));
});
gui.open();
}
}
}

16
src/main/java/eu/univento/lobby/listeners/JoinQuit.java

@ -1,9 +1,14 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.Hologram;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.PetManager;
import eu.univento.lobby.utils.Scoreboards;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -36,6 +41,8 @@ public class JoinQuit implements Listener {
p.setFoodLevel(20);
p.setExp(0F);
p.setLevel(0);
p.getInventory().clear();
p.getInventory().setItem(4, new ItemBuilder(Material.COMPASS).name("§aNavigator").glow().build());
//InventoryManager invs = new InventoryManager(p);
@ -55,16 +62,17 @@ public class JoinQuit implements Listener {
}
});
String[] text = {e@univentoEU"};
String[] text = {2univento§8.§aeu"};
Hologram holo = new Hologram(new ItemStack(Material.WOOD_AXE), text, p.getWorld().getSpawnLocation());
holo.showPlayer(p);
BossBar bar = Bukkit.createBossBar(cAchtung, frisch gestrichen", BarColor.GREEN, BarStyle.SEGMENTED_6, BarFlag.CREATE_FOG);
BossBar bar = Bukkit.createBossBar(7Nutze den §aNavigator§8!", BarColor.GREEN, BarStyle.SEGMENTED_6, BarFlag.CREATE_FOG);
bar.addPlayer(p);
//p.sendActionBar(p.getMessages().LobbyBoard_NEW() + " " + p.getMessages().LobbyBoard_NEWS());
Scoreboards.updateScoreboard(p);
p.getLastLocation().whenComplete((location, throwable) -> p.teleport(location));
}
@ -81,8 +89,6 @@ public class JoinQuit implements Listener {
e.setQuitMessage(null);
if (PlayerHider.getHidden().contains(p))
PlayerHider.getHidden().remove(p);
if (PetManager.hasPet(p))
PetManager.removePet(p);
}
}

54
src/main/java/eu/univento/lobby/listeners/Menu.java

@ -1,54 +0,0 @@
package eu.univento.lobby.listeners;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.InventoryManager;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
/**
* opens menus
* @author joethei
* @version 1.0
*/
public class Menu implements Listener{
@EventHandler
public void onInteract(PlayerInteractEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
ItemStack item = p.getItemInHand();
if(!p.hasOpenInventory()) {
InventoryManager invs = new InventoryManager(p);
if(item.getType() == Material.WORKBENCH) {
p.setOpenInventory(true);
p.openInventory(invs.getNavigatorInventory());
}
if(item.getType() == Material.CHEST) {
p.setOpenInventory(true);
p.openInventory(invs.getFunChestInventory());
e.getPlayer().playSound(p.getEyeLocation(), Sound.BLOCK_CHEST_OPEN, 10.0F, 1.0F);
}
if(item.getType() == Material.SKULL_ITEM) {
p.setOpenInventory(true);
p.openInventory(invs.getProfileInventory());
}
if(item.getType() == Material.EXP_BOTTLE) {
e.setCancelled(true);
invs.setYoutuberInventory();
}
if(item.getType() == Material.BARRIER) {
invs.setMainInventory(true);
}if(item.getType() == Material.BLAZE_ROD) {
p.setOpenInventory(true);
p.openInventory(invs.getLobbySwitcherInventory());
}
}
}
}
}

312
src/main/java/eu/univento/lobby/listeners/MenuEvents.java

@ -1,275 +1,75 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.commons.server.ServerType;
import eu.univento.core.Core;
import eu.univento.core.api.Config;
import eu.univento.core.api.effects.Effects;
import eu.univento.core.api.gui.inventory.InventoryGUI;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.utils.InventoryManager;
import net.minecraft.server.v1_11_R1.EnumParticle;
import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
/**
* handles teleport menus
* @author joethei
* @version 1.0
*/
public class MenuEvents implements Listener {
private ArrayList<CustomPlayer> heartPlayers = new ArrayList<>();
private ArrayList<CustomPlayer> lavaPlayers = new ArrayList<>();
@EventHandler
public void onClick(InventoryClickEvent e) {
if (e.getWhoClicked() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
InventoryManager invs = new InventoryManager(p);
//Messages msgs = new Messages(p);
if(!e.getSlotType().equals(SlotType.OUTSIDE) && e.getInventory().getType() == InventoryType.CHEST) {
if (e.getInventory().getName().equals(invs.getNavigatorInventory().getName())) {
if (e.getCurrentItem().getType() == Material.GOLD_BLOCK) {
teleport(p, "TheBlock");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.SNOW_BALL) {
teleport(p, "FlagAttack");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.LEATHER_HELMET) {
teleport(p, "TrashGames");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.MAGMA_CREAM) {
teleport(p, "Spawn");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.EYE_OF_ENDER) {
teleport(p, "PremiumHub");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.LEATHER_BOOTS) {
teleport(p, "TempleRun");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.SLIME_BALL) {
teleport(p, "HulkFight");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.FLOWER_POT_ITEM) {
p.closeInventory();
p.connectToServer("build");
} else {
e.setCancelled(true);
}
}
if (e.getInventory().getName().equals(invs.getProfileInventory().getName())) {
if (e.getCurrentItem().getType() == Material.COMPASS) {
p.closeInventory();
p.openInventory(invs.getStatsInventory());
}
if (e.getCurrentItem().getType() == Material.PUMPKIN) {
p.closeInventory();
p.openInventory(invs.getFriendsInventory());
}
if (e.getCurrentItem().getType() == Material.NAME_TAG) {
p.closeInventory();
p.openInventory(invs.getSettingsInventory());
} else {
e.setCancelled(true);
}
}
if (e.getInventory().getName().equals(invs.getSettingsInventory().getName())) {
if(e.getSlot() == 0) {
p.getDatabasePlayer().getSettings().setPartyRequests(!p.getDatabasePlayer().getSettings().hasPartyRequestsEnabled());
p.closeInventory();
p.openInventory(invs.getSettingsInventory());
}
}
if(e.getInventory().getName().equals(invs.getLanguagesInventory().getName())) {
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eDeutsch")) {
p.getDatabasePlayer().getSettings().setLanguage("DE");
p.closeInventory();
//p.sendMessage(msgs.PREFIX() + "§7Sprache auf §eDeutsch §7geändert");
invs.setMainInventory(true);
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eEnglish")) {
p.getDatabasePlayer().getSettings().setLanguage("EN");
p.closeInventory();
//p.sendMessage(msgs.PREFIX() + "§7Language changed to §eenglish");
invs.setMainInventory(true);
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eitaliano")) {
p.getDatabasePlayer().getSettings().setLanguage("IT");
p.closeInventory();
//p.sendMessage(msgs.PREFIX() + "§7Da fehlt doch noch was");
invs.setMainInventory(true);
}
}
if (e.getInventory().getName().equals(invs.getFunChestInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.RECORD_3) {
p.closeInventory();
p.openInventory(invs.getMusicInventory());
}
if (e.getCurrentItem().getType() == Material.ARMOR_STAND) {
p.closeInventory();
p.openInventory(invs.getGadgetsInventory());
}
if (e.getCurrentItem().getType() == Material.NOTE_BLOCK) {
p.closeInventory();
p.openInventory(invs.getParticleInventory());
}
if(e.getCurrentItem().getType() == Material.MONSTER_EGG) {
p.closeInventory();
p.openInventory(invs.getPetsInventory());
}
}
if (e.getInventory().getName().equals(invs.getStatsInventory().getName())) {
e.setCancelled(true);
}
if (e.getInventory().getName().equals(invs.getFriendsInventory().getName())) {
e.setCancelled(true);
}
if (e.getInventory().getName().equals(invs.getMusicInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.RECORD_3) {
p.closeInventory();
p.playSound(p.getEyeLocation(), "records.11", 100000000000.0F, 1.0F);
//p.sendActionBar(msgs.Lobby_PLAYING_MUSIC_PREFIX() + ": Milky Way Stars | Janji feat. TR");
}
}
if (e.getInventory().getName().equals(invs.getGadgetsInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.SUGAR) {
p.closeInventory();
if (p.getWalkSpeed() == 0.2F) {
p.setWalkSpeed(0.5F);
} else {
p.setWalkSpeed(0.2F);
}
}
if (e.getCurrentItem().getType() == Material.FEATHER) {
p.closeInventory();
}
}
if (e.getInventory().getName().equals(invs.getParticleInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.RED_ROSE) {
if (heartPlayers.contains(p)) {
heartPlayers.remove(p);
} else {
heartPlayers.add(p);
}
}else if(e.getCurrentItem().getType() == Material.LAVA_BUCKET) {
if(lavaPlayers.contains(p)) {
lavaPlayers.remove(p);
}else{
lavaPlayers.add(p);
}
}
/*
}if (e.getInventory().getName().equals(invs.getPetsInventory().getName())) {
e.setCancelled(true);
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_PIG())) {
p.closeInventory();
PetManager.setPet(p, EntityType.PIG);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_COW())) {
p.closeInventory();
PetManager.setPet(p, EntityType.COW);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_CHICKEN())) {
p.closeInventory();
PetManager.setPet(p, EntityType.CHICKEN);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_RABBIT())) {
p.closeInventory();
PetManager.setPet(p, EntityType.RABBIT);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_MUSHROM_COW())) {
p.closeInventory();
PetManager.setPet(p, EntityType.MUSHROOM_COW);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("Horse")) {
p.closeInventory();
PetManager.setPet(p, EntityType.HORSE);
Horse horse = (Horse) PetManager.getPet(p);
horse.setJumpStrength(20.0D);
horse.setVariant(Horse.Variant.UNDEAD_HORSE);
horse.setTamed(true);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("PolarBear")) {
p.closeInventory();
PetManager.setPet(p, EntityType.POLAR_BEAR);
PolarBear polarBear = (PolarBear) PetManager.getPet(p);
polarBear.setAI(false);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getType() == Material.BARRIER) {
p.closeInventory();
PetManager.removePet(p);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_REMOVE());
}
*/
}else {
e.setCancelled(true);
}
private Inventory lobbySwitcher;
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (e.getItem().getType() == Material.BUCKET) {
p.openInventory(lobbySwitcher);
p.playSound(p.getEyeLocation(), Sound.BLOCK_CHEST_OPEN, 1.0F, 1.0F);
}
if(e.getItem().getType() == Material.NETHER_STAR) {
InventoryGUI gui = new InventoryGUI(p, 27, "Lobby Navigator");
//spawn teleport
gui.addItem(1, new ItemBuilder(p, Material.SLIME_BALL).name("Spawn").build(), player -> {
player.closeInventory();
player.teleport(player.getWorld().getSpawnLocation());
});
//build server teleport
if(p.getDatabasePlayer().isAllowed(Rank.Sound)) {
gui.addItem(0, new ItemBuilder(p, Material.GRASS).name("Bau Server").build(), player -> {
player.closeInventory();
player.connectToServer(ServerType.TEAM_BUILD);
});
}
}
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
List<Player> players = new ArrayList<>();
players.addAll(Core.getOnlinePlayers());
if(heartPlayers.contains(p))
Effects.playEffect(p.getLocation(), EnumParticle.HEART, 5);
if(lavaPlayers.contains(p))
Effects.playEffect(p.getLocation(), EnumParticle.DRIP_LAVA, 5);
}
private void teleport(CustomPlayer p, String location) {
Vector v = p.getLocation().getDirection().multiply(0D).setY(2D);
p.setVelocity(v);
p.playSound(p.getEyeLocation(), Sound.ENTITY_GENERIC_EXPLODE, 5.0F, 1.0F);
p.playEffect(p.getEyeLocation(), Effect.CHORUS_FLOWER_DEATH, 20);
Location loc = Config.readLocation("Lobby.Locs." + location);
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), () -> {
for (Player players : Bukkit.getOnlinePlayers()) {
players.playSound(p.getEyeLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F);
players.playEffect(p.getEyeLocation(), Effect.DRAGON_BREATH, 20);
p.teleport(loc);
players.playSound(p.getEyeLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F);
players.playEffect(p.getEyeLocation(), Effect.SMOKE, 20);
gui.open();
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
if (e.getClickedInventory() == null && e.getCurrentItem() == null) return;
if (e.getClickedInventory() == lobbySwitcher) {
e.setCancelled(true);
String server = ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName());
if (Core.getCloudAPI().getServerId().equals(server)) {
p.sendMessage("Nope, da bist du doch schon");
return;
}
}, 40L);
}
p.connectToServer(server);
p.closeInventory();
}
}
}

16
src/main/java/eu/univento/lobby/listeners/Parkour.java

@ -1,11 +1,18 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.core.Core;
import eu.univento.core.api.events.MoveEventFilter;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.utils.PetManager;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -29,16 +36,15 @@ public class Parkour implements Listener{
public void onBlockMove(MoveEventFilter.PlayerBlockMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
//Messages msgs = new Messages(p);
Block block = p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
Block block = e.getTo().subtract(0.0D, 1.0D, 0.0D).getBlock();
if (block.getType() == Material.STAINED_CLAY) {
if (players.contains(p)) {
spawnRandomBlock(block.getLocation());
}else if(p.getLocation().getBlock().getType() == Material.IRON_PLATE) {
}else if(e.getTo().getBlock().getType() == Material.IRON_PLATE) {
players.add(p);
//p.sendMessage(msgs.PREFIX() + msgs.Lobby_PARKOUR_ON());
spawnRandomBlock(block.getLocation());
p.setWalkSpeed(0.2F);
if(PetManager.hasPet(p)) PetManager.removePet(p);
}
} else {
if (block.getType() != Material.AIR && players.contains(p) && block.getType() != Material.IRON_PLATE) {

124
src/main/java/eu/univento/lobby/listeners/PetInteract.java

@ -1,124 +0,0 @@
package eu.univento.lobby.listeners;
import eu.univento.core.api.gui.AnvilGUI;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.PetManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* @author joethei
* @version 1.0
*/
public class PetInteract implements Listener {
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent e) {
e.setCancelled(true);
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
Entity entity = e.getRightClicked();
if (PetManager.getPet(p) == entity) {
p.openInventory(getInventory(p));
}
}
Inventory getInventory(CustomPlayer p) {
//Messages msgs = new Messages(p);
Inventory inv = Bukkit.createInventory(p, 9,"Nachricht");
ItemStack name = new ItemStack(Material.NAME_TAG);
ItemMeta nameMeta = name.getItemMeta();
//nameMeta.setDisplayName(msgs.LobbyItems_PETS_NAME());
name.setItemMeta(nameMeta);
ItemStack baby = new ItemStack(Material.SUGAR);
ItemMeta babyMeta = baby.getItemMeta();
//babyMeta.setDisplayName(msgs.LobbyItems_PETS_AGE());
baby.setItemMeta(babyMeta);
ItemStack mount = new ItemStack(Material.SADDLE);
ItemMeta mountMeta = mount.getItemMeta();
//mountMeta.setDisplayName(msgs.LobbyItems_PETS_RIDE());
mount.setItemMeta(mountMeta);
ItemStack delete = new ItemStack(Material.BARRIER);
ItemMeta deleteMeta = delete.getItemMeta();
//deleteMeta.setDisplayName(msgs.LobbyItems_PETS_REMOVE());
delete.setItemMeta(deleteMeta);
inv.setItem(0, name);
inv.setItem(1, baby);
inv.setItem(2, mount);
inv.setItem(8, delete);
return inv;
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (e.getWhoClicked() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
//Messages msgs = new Messages(p);
if (e.getInventory().getName().equals(getInventory(p).getName())) {
if (e.getCurrentItem().getType() == Material.NAME_TAG) {
assert p != null;
p.closeInventory();
AnvilGUI gui = new AnvilGUI(p, event -> {
if(event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
event.setWillClose(true);
event.setWillDestroy(true);
PetManager.setName(p, p.getDatabasePlayer().getRank().getColor() + event.getName());
}else{
event.setWillDestroy(true);
event.setWillClose(true);
}
});
ItemStack name = new ItemStack(Material.NAME_TAG);
ItemMeta nameMeta = name.getItemMeta();
nameMeta.setDisplayName(PetManager.getName(p));
name.setItemMeta(nameMeta);
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, name);
gui.open();
}
if(e.getCurrentItem().getType() == Material.SUGAR) {
p.closeInventory();
Entity pet = PetManager.getPet(p);
Ageable age = (Ageable) pet;
if(age.isAdult()) {
age.setBaby();
}else {
age.setAdult();
}
}
if(e.getCurrentItem().getType() == Material.SADDLE) {
p.closeInventory();
Entity pet = PetManager.getPet(p);
if(pet.getPassenger() != null) {
pet.setPassenger(null);
}else {
pet.setPassenger(p);
}
}
if (e.getCurrentItem().getType() == Material.BARRIER) {
p.closeInventory();
PetManager.removePet(p);
//p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_REMOVE());
}
}
}
}
}

20
src/main/java/eu/univento/lobby/listeners/PlayerHider.java

@ -1,8 +1,13 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.InventoryManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -24,15 +29,9 @@ import java.util.ArrayList;
public class PlayerHider implements Listener{
private static ArrayList<CustomPlayer> hidden = new ArrayList<>();
public static ArrayList<CustomPlayer> getHidden() {
return hidden;
}
@Getter private static ArrayList<CustomPlayer> hidden = new ArrayList<>();
private static ArrayList<CustomPlayer> silentlobby = new ArrayList<>();
public static ArrayList<CustomPlayer> getSilentlobby() {
return silentlobby;
}
@Getter private static ArrayList<CustomPlayer> silentlobby = new ArrayList<>();
private ItemStack getHide(CustomPlayer p) {
//Messages msgs = new Messages(p);
@ -92,9 +91,8 @@ public class PlayerHider implements Listener{
if(p.getDatabasePlayer().isAllowed(Rank.VIP)) {
if(silentlobby.contains(p)) {
silentlobby.remove(p);
InventoryManager invs = new InventoryManager(p);
p.getInventory().clear();
invs.setMainInventory(true);
//p.sendMessage(msgs.PREFIX() + msgs.Lobby_SILENT_LOBBY_OFF());
for(Player players : Bukkit.getOnlinePlayers()) {
p.showPlayer(players);

10
src/main/java/eu/univento/lobby/utils/CustomMapRenderer.java

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.utils;
import eu.univento.core.api.player.CustomPlayer;
@ -17,8 +22,7 @@ public class CustomMapRenderer extends MapRenderer{
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
CustomPlayer p = CustomPlayer.getPlayer(player);
mapCanvas.drawText(1, 10, MinecraftFont.Font, "Hallo " + p.getName());
mapCanvas.drawText(1, 20, MinecraftFont.Font, "Du bist ein " + p.getDatabasePlayer().getRank().name());
mapCanvas.drawText(1, 30, MinecraftFont.Font, p.getDatabasePlayer().getFirstLogin().toString());
mapCanvas.drawText(1, 40, MinecraftFont.Font, "Sprache " + p.getDatabasePlayer().getLanguage());
mapCanvas.drawText(1, 20, MinecraftFont.Font, "Du bist ein " + p.getDatabasePlayer().getRank().getColor() + p.getDatabasePlayer().getRank().name());
mapCanvas.drawText(1, 40, MinecraftFont.Font, "Sprache " + p.getDatabasePlayer().getLanguage().getLocale().getLanguage());
}
}

555
src/main/java/eu/univento/lobby/utils/InventoryManager.java

@ -1,555 +0,0 @@
package eu.univento.lobby.utils;
import eu.univento.commons.player.language.Language;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;