added basic custom map renderer
This commit is contained in:
parent
fcbd8be269
commit
e630ea2e6d
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="F:/DevServer/Spigot/spigot.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
/bin/
|
||||
/bin/
|
17
.project
17
.project
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Lobby</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/eu/univento/lobby/utils/StatusSignUtil.java=UTF-8
|
@ -1,11 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
36
Lobby.iml
Normal file
36
Lobby.iml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
|
||||
<orderEntry type="module" module-name="Core" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-async:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:bson:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" 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" />
|
||||
</component>
|
||||
</module>
|
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Lobby Plugin for univento.eu
|
||||
|
||||
Written by joethei
|
||||
|
||||
API Doku at: http://dev.univento.eu/docs/Lobby
|
84
pom.xml
Normal file
84
pom.xml
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>groupId</groupId>
|
||||
<artifactId>Lobby</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>univento.eu Lobby System</name>
|
||||
<url>http://univento.eu</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2-beta-5</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>eu.univento.lobby.Lobby</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.univento</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,82 +0,0 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
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.SlotType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* handles teleport menus
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Teleport implements Listener {
|
||||
|
||||
/**
|
||||
* clicking items
|
||||
* @param e InventoryClickEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
if (e.getWhoClicked() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
|
||||
if(e.getInventory().getName() == "§6Server-Menü") {
|
||||
if(!e.getSlotType().equals(SlotType.OUTSIDE)) {
|
||||
if(e.getCurrentItem().getType() == Material.GOLD_BLOCK) {
|
||||
teleport(p, "TheBlock");
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.SNOW_BALL) {
|
||||
teleport(p, "FlagAttack");
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* teleports player with effects to location
|
||||
* @param p CustomPlayer
|
||||
* @param location String
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void teleport(CustomPlayer p, String location) {
|
||||
Vector v = p.getLocation().getDirection().multiply(0D).setY(4D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
||||
p.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
||||
Location loc = Config.readLocation("Lobby.Locs." + location);
|
||||
Lobby.getOpenInventorys().add(p);
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
||||
players.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
||||
}
|
||||
p.teleport(loc);
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
||||
players.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
||||
}
|
||||
Lobby.getOpenInventorys().remove(p);
|
||||
|
||||
}
|
||||
|
||||
}, 80L);
|
||||
}
|
||||
|
||||
}
|
19
src/main/Lobby.iml
Normal file
19
src/main/Lobby.iml
Normal file
@ -0,0 +1,19 @@
|
||||
<?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>
|
100
src/main/java/eu/univento/lobby/Lobby.java
Normal file
100
src/main/java/eu/univento/lobby/Lobby.java
Normal file
@ -0,0 +1,100 @@
|
||||
package eu.univento.lobby;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import eu.univento.core.api.pet.NMSHandler;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import eu.univento.lobby.listeners.*;
|
||||
import eu.univento.lobby.utils.PetManager;
|
||||
import eu.univento.lobby.utils.StatusSignManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import eu.univento.lobby.commands.DropItem;
|
||||
import eu.univento.lobby.commands.Setloc;
|
||||
|
||||
/**
|
||||
* main class...
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Lobby extends JavaPlugin{
|
||||
|
||||
/**
|
||||
* plugin instance
|
||||
*/
|
||||
public static Lobby instance;
|
||||
/**
|
||||
* @return instance of plugin
|
||||
*/
|
||||
public static Lobby getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logger to log to
|
||||
*/
|
||||
private static Logger logger = Bukkit.getLogger();
|
||||
|
||||
/**
|
||||
* @param level Log level
|
||||
* @param string String
|
||||
*/
|
||||
public static void log(Level level, String string) {
|
||||
if(ServerSettings.isDebug()) {
|
||||
logger.log(level, "[" + Lobby.getInstance().getDescription().getName() + "] " + string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
ServerSettings.setLobby(true);
|
||||
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 StatusSigns(), this);
|
||||
pm.registerEvents(new PlayerInteract(), this);
|
||||
|
||||
if(ServerSettings.isDebug()) log(Level.INFO, "Events registriert");
|
||||
|
||||
new Setloc(this, "setloc", "Setzt Teleport Punkte");
|
||||
|
||||
new DropItem(this, "dropitem", "Setzt EasterEggs");
|
||||
|
||||
if(ServerSettings.isDebug()) log(Level.INFO, "Befehle registriert");
|
||||
|
||||
for(World w : Bukkit.getWorlds()) {
|
||||
w.setDifficulty(Difficulty.PEACEFUL);
|
||||
}
|
||||
ServerSettings.setGameMode(GameMode.ADVENTURE);
|
||||
ServerSettings.setLobby(true);
|
||||
StatusSignManager.loadSigns();
|
||||
StatusSignManager.updateSigns();
|
||||
NMSHandler.registerEnties();
|
||||
log(Level.INFO, " Plugin ver." + getDescription().getVersion() + " gestartet");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
StatusSignManager.saveSigns();
|
||||
PetManager.clearPets();
|
||||
log(Level.INFO, "Plugin beendet");
|
||||
}
|
||||
|
||||
}
|
78
src/main/java/eu/univento/lobby/commands/DropItem.java
Normal file
78
src/main/java/eu/univento/lobby/commands/DropItem.java
Normal file
@ -0,0 +1,78 @@
|
||||
package eu.univento.lobby.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* drops items for easter eggs
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DropItem extends AutoCommand<Lobby>{
|
||||
|
||||
|
||||
/**
|
||||
* @param plugin main class
|
||||
* @param command command to execute
|
||||
* @param description describes the command
|
||||
* @param aliases aliases of command
|
||||
*/
|
||||
public DropItem(Lobby plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Rank.Admin)) {
|
||||
if(args.length == 1) {
|
||||
if(args[0].equalsIgnoreCase("music_3")) {
|
||||
ItemStack music_3 = new ItemStack(Material.RECORD_3);
|
||||
p.getWorld().dropItem(p.getLocation(), music_3);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_DROP_ITEM());
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("feather")) {
|
||||
ItemStack feather = new ItemStack(Material.FEATHER);
|
||||
p.getWorld().dropItem(p.getLocation(), feather);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_DROP_ITEM());
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("hearts")) {
|
||||
ItemStack hearts = new ItemStack(Material.RED_ROSE);
|
||||
p.getWorld().dropItem(p.getLocation(), hearts);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_DROP_ITEM());
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("sugar")) {
|
||||
ItemStack sugar = new ItemStack(Material.SUGAR);
|
||||
p.getWorld().dropItem(p.getLocation(), sugar);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_DROP_ITEM());
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_DROP_ITEM_USAGE());
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(msgs.NO_PERMS());
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
66
src/main/java/eu/univento/lobby/commands/Setloc.java
Normal file
66
src/main/java/eu/univento/lobby/commands/Setloc.java
Normal file
@ -0,0 +1,66 @@
|
||||
package eu.univento.lobby.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* sets teleport locations
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Setloc extends AutoCommand<Lobby>{
|
||||
|
||||
/**
|
||||
* @param plugin main class
|
||||
* @param command command to execute
|
||||
* @param description describes the command
|
||||
* @param aliases aliases of command
|
||||
*/
|
||||
public Setloc(Lobby plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Rank.SrDeveloper)) {
|
||||
if(args.length == 1) {
|
||||
Config.write("Lobby.Locs." + args[0], p.getLocation());
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_SET_LOCATION());
|
||||
}else {
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_SET_LOCATION_USAGE());
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(msgs.NO_PERMS());
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
|
||||
list.add("Spawn");
|
||||
list.add("Maya");
|
||||
list.add("WoolGet");
|
||||
list.add("PremiumHub");
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
306
src/main/java/eu/univento/lobby/listeners/Events.java
Normal file
306
src/main/java/eu/univento/lobby/listeners/Events.java
Normal file
@ -0,0 +1,306 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import eu.univento.core.api.Title;
|
||||
import eu.univento.lobby.Lobby;
|
||||
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_10_R1.EnumParticle;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.server.MapInitializeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* some short events
|
||||
*
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMapInit(MapInitializeEvent e) {
|
||||
MapView map = e.getMap();
|
||||
map.getRenderers().forEach(map::removeRenderer);
|
||||
map.addRenderer(new CustomMapRenderer());
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels food level changes
|
||||
*
|
||||
* @param e FoodLevelChangeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels weather changes
|
||||
*
|
||||
* @param e WeatherChangeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels item consume
|
||||
*
|
||||
* @param e PlayerItemConsumeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onConsume(PlayerItemConsumeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels death message and drops
|
||||
*
|
||||
* @param e PlayerDeathEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
e.setDeathMessage(null);
|
||||
e.setKeepInventory(true);
|
||||
e.setKeepLevel(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemMove(InventoryMoveItemEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSwapHands(PlayerSwapHandItemsEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets respawn location
|
||||
*
|
||||
* @param e PlayerRespawnEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
e.setRespawnLocation(Config.readLocation("Lobby.Locs.Spawn"));
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels inventory dropping in creative
|
||||
*
|
||||
* @param e InventoryCreativeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInventoryCreative(InventoryCreativeEvent e) {
|
||||
e.setCancelled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels item drop
|
||||
*
|
||||
* @param e PlayerDropItemEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels player damage
|
||||
*
|
||||
* @param e EntityDamageEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels explosions
|
||||
*
|
||||
* @param e EntityExplodeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
e.blockList().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels block destroying when block burns
|
||||
*
|
||||
* @param e BlockBurnEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onBurn(BlockBurnEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e BlockIgniteEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onBlockIgnite(BlockIgniteEvent e) {
|
||||
if (e.getCause() == IgniteCause.SPREAD) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels chest opening and stuff + some easter egg
|
||||
*
|
||||
* @param e PlayerInteract
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.SOIL)
|
||||
e.setCancelled(true);
|
||||
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
if (e.getClickedBlock().getType() == Material.CHEST) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.FURNACE) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.BURNING_FURNACE) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.WORKBENCH) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.BREWING_STAND) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.ARMOR_STAND) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.ACACIA_DOOR) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.BIRCH_DOOR) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.DARK_OAK_DOOR) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.JUNGLE_DOOR) e.setCancelled(true);
|
||||
if (e.getClickedBlock().getType() == Material.TRAP_DOOR) e.setCancelled(true);
|
||||
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.BEDROCK) {
|
||||
p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
p.setPlayerTime(15000, true);
|
||||
p.sendBlockChange(e.getClickedBlock().getLocation(), Material.TNT, (byte) 0);
|
||||
p.getWorld().strikeLightning(p.getTargetBlock((Set<Material>) null, 500).getLocation());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> p.getWorld().strikeLightning(p.getTargetBlock((Set<Material>) null, 500).getLocation()), 5 * 20L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> {
|
||||
p.resetPlayerWeather();
|
||||
p.resetPlayerTime();
|
||||
p.sendBlockChange(e.getClickedBlock().getLocation(), Material.BEDROCK, (byte) 0);
|
||||
p.getWorld().strikeLightning(p.getTargetBlock((Set<Material>) null, 500).getLocation());
|
||||
}, 10 * 20L);
|
||||
|
||||
}
|
||||
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);
|
||||
|
||||
Title.sendTitle(p, 10, 50, 10, "§eDu hast ein Versteck gefunden", "§6Name hier einfügen");
|
||||
p.addCoins(100);
|
||||
Scoreboards.updateScoreboard(p);
|
||||
}, 3 * 20L);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* prevents item despawning
|
||||
*
|
||||
* @param e ItemDespawnEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onItemDespawn(ItemDespawnEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakByEntityEvent e) {
|
||||
if (e.getEntity() instanceof ItemFrame) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onStructureGrow(StructureGrowEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onArmorstandManipulate(PlayerArmorStandManipulateEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
|
||||
for (CustomPlayer players : PlayerHider.getSilentlobby()) {
|
||||
e.getRecipients().remove(players);
|
||||
}
|
||||
|
||||
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);
|
||||
}else{
|
||||
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 onEntityBlockChange(EntityChangeBlockEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCreatureSpawn(CreatureSpawnEvent e) {
|
||||
if (e.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
108
src/main/java/eu/univento/lobby/listeners/FoundItems.java
Normal file
108
src/main/java/eu/univento/lobby/listeners/FoundItems.java
Normal file
@ -0,0 +1,108 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
import eu.univento.core.api.Title;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
|
||||
/**
|
||||
* handels all posible easter eggs
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class FoundItems implements Listener{
|
||||
|
||||
/**
|
||||
* handels item pickup
|
||||
* @param e PlayerPickupItemEvent
|
||||
*/
|
||||
@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", p)) {
|
||||
setFound("music_3", p);
|
||||
Title.sendTitle(p, 5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Music_3");
|
||||
p.addExperience(5);
|
||||
}
|
||||
}
|
||||
if(e.getItem().getItemStack().getType() == Material.SUGAR) {
|
||||
if(!hasFound("sugar", p)) {
|
||||
setFound("sugar", p);
|
||||
Title.sendTitle(p, 5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Sugar");
|
||||
p.addExperience(5);
|
||||
}
|
||||
}
|
||||
if(e.getItem().getItemStack().getType() == Material.RED_ROSE) {
|
||||
if(!hasFound("hearts", p)) {
|
||||
setFound("hearts", p);
|
||||
Title.sendTitle(p, 5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Hearts");
|
||||
p.addExperience(3);
|
||||
}
|
||||
}
|
||||
if(e.getItem().getItemStack().getType() == Material.FEATHER) {
|
||||
if(!hasFound("feather", p)) {
|
||||
setFound("feather", p);
|
||||
Title.sendTitle(p, 5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Feather");
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if player has found item
|
||||
* @param item name of item
|
||||
* @param p CustomPlayer
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean hasFound(String item, CustomPlayer p) {
|
||||
int id = 8;
|
||||
MySQL sql = Core.getMySQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT * FROM FoundItems WHERE ID='" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if(rs.next()) {
|
||||
boolean has = rs.getInt(item) == 1;
|
||||
sql.closeConnection();
|
||||
return has;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* sets item to found
|
||||
* @param item name of item
|
||||
* @param p CustomPlayer
|
||||
*/
|
||||
void setFound(String item, CustomPlayer p) {
|
||||
int id = 8;
|
||||
MySQL sql = Core.getMySQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE FoundItems SET " + item + "='1' WHERE ID='" + id + "';");
|
||||
st.execute();
|
||||
sql.closeConnection();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
103
src/main/java/eu/univento/lobby/listeners/ItemEvents.java
Normal file
103
src/main/java/eu/univento/lobby/listeners/ItemEvents.java
Normal file
@ -0,0 +1,103 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
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;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.lobby.Lobby;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* some item events
|
||||
*
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ItemEvents implements Listener {
|
||||
|
||||
private HashMap<CustomPlayer, Integer> forcefield = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
ItemStack item = p.getItemInHand();
|
||||
if (item.getType() == Material.NAME_TAG) {
|
||||
if (p.isAllowed(Rank.Partner)) {
|
||||
if (p.isNicked()) {
|
||||
p.setNicked(false);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Lobby_AUTONICK_OFF());
|
||||
} else {
|
||||
p.setNicked(true);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Lobby_AUTONICK_ON());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.getType() == Material.EYE_OF_ENDER) {
|
||||
if (p.isAllowed(Rank.Partner)) {
|
||||
if (forcefield.containsKey(p)) {
|
||||
Bukkit.getScheduler().cancelTask(forcefield.get(p));
|
||||
forcefield.remove(p);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Lobby_FORCEFIELD_OFF());
|
||||
} else {
|
||||
forcefield.put(p, force(p));
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Lobby_FORCEFIELD_ON());
|
||||
}
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int force(CustomPlayer p) {
|
||||
return Bukkit.getScheduler().scheduleSyncRepeatingTask(Lobby.getInstance(), () -> {
|
||||
if (forcefield.containsKey(p)) {
|
||||
playEffect(p.getLocation(), Effect.ENDER_SIGNAL, true);
|
||||
|
||||
Core.getOnlinePlayers().stream().filter(players -> !p.getName().equals(players.getName()) &&
|
||||
p.getLocation().distance(players.getLocation()) <= 5 &&
|
||||
!Parkour.getPlayers().contains(players) &&
|
||||
!PlayerHider.getSilentlobby().contains(p)).forEach(players -> {
|
||||
|
||||
int aX = p.getLocation().getBlockX();
|
||||
int aY = p.getLocation().getBlockY();
|
||||
int aZ = p.getLocation().getBlockZ();
|
||||
|
||||
int bX = p.getLocation().getBlockX();
|
||||
int bY = p.getLocation().getBlockY();
|
||||
int bZ = p.getLocation().getBlockZ();
|
||||
|
||||
int x = aX - bX;
|
||||
int y = aY - bY;
|
||||
int z = aZ - bZ;
|
||||
|
||||
Vector v = new Vector(x, y, z).normalize();
|
||||
v.multiply(2.0D);
|
||||
v.setY(1.5D);
|
||||
players.setVelocity(v);
|
||||
players.playEffect(p.getEyeLocation(), Effect.SMOKE, 3);
|
||||
players.playSound(players.getLocation(), Sound.ENTITY_FIREWORK_BLAST, 3.0F, 3.0F);
|
||||
});
|
||||
}
|
||||
|
||||
}, 0L, 5L);
|
||||
}
|
||||
|
||||
private void playEffect(Location loc, Effect effect, boolean v) {
|
||||
for (int i = 0; i <= 8; i += ((!v) && (i == 3) ? 2 : 1))
|
||||
Core.getOnlinePlayers().stream().filter(p -> p.hasEffects()).forEach(p -> p.playEffect(loc, effect, 1.0F));
|
||||
}
|
||||
}
|
98
src/main/java/eu/univento/lobby/listeners/JoinQuit.java
Normal file
98
src/main/java/eu/univento/lobby/listeners/JoinQuit.java
Normal file
@ -0,0 +1,98 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import eu.univento.core.api.*;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.lobby.utils.PetManager;
|
||||
import eu.univento.lobby.utils.Scoreboards;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.lobby.utils.Inventorys;
|
||||
import net.minecraft.server.v1_10_R1.EnumParticle;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.5
|
||||
*/
|
||||
public class JoinQuit implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(PlayerJoinEvent e) throws ClassNotFoundException, SQLException {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
|
||||
e.setJoinMessage(null);
|
||||
|
||||
p.setMaxHealth(10.0D);
|
||||
p.setHealth(10.0D);
|
||||
p.setFoodLevel(20);
|
||||
p.setExp(0F);
|
||||
p.setLevel(0);
|
||||
|
||||
if (!p.hasPlayedBefore()) {
|
||||
p.teleport(Config.readLocation("Lobby.Locs.Spawn"));
|
||||
}
|
||||
|
||||
Inventorys invs = new Inventorys(p);
|
||||
p.playParticle(p.getEyeLocation(), EnumParticle.SPELL_MOB, 2.0F, 500);
|
||||
p.giveExp(p.getExperience());
|
||||
|
||||
Title.sendTitle(p, 10, 50, 10, p.getMessages().Lobby_JOIN_TITLE_1(), p.getMessages().Lobby_JOIN_TITLE_2());
|
||||
invs.setMainInventory(false);
|
||||
|
||||
|
||||
if (!p.isAllowed(Rank.Supporter)) {
|
||||
for (CustomPlayer players : PlayerHider.getHidden()) {
|
||||
players.hidePlayer(p);
|
||||
}
|
||||
}
|
||||
for (CustomPlayer players : PlayerHider.getSilentlobby()) {
|
||||
players.hidePlayer(p);
|
||||
p.hidePlayer(players);
|
||||
}
|
||||
|
||||
String[] text = {"§e@univentoEU"};
|
||||
Hologram holo = new Hologram(text, p.getWorld().getSpawnLocation());
|
||||
holo.showPlayer(p);
|
||||
|
||||
BossBar bar = Bukkit.createBossBar("§cAchtung, frisch gestrichen", BarColor.GREEN, BarStyle.SEGMENTED_6, BarFlag.CREATE_FOG);
|
||||
bar.addPlayer(p);
|
||||
|
||||
Actionbar.send(p, p.getMessages().LobbyBoard_NEW() + " " + p.getMessages().LobbyBoard_NEWS());
|
||||
|
||||
Scoreboards.updateScoreboard(p);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* removes player from lists
|
||||
*
|
||||
* @param e PlayerQuitEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
p.getInventory().clear();
|
||||
p.getInventory().setChestplate(null);
|
||||
e.setQuitMessage(null);
|
||||
if (PlayerHider.getHidden().contains(p))
|
||||
PlayerHider.getHidden().remove(p);
|
||||
if (PetManager.hasPet(p))
|
||||
PetManager.removePet(p);
|
||||
}
|
||||
|
||||
}
|
186
src/main/java/eu/univento/lobby/listeners/Jumppads.java
Normal file
186
src/main/java/eu/univento/lobby/listeners/Jumppads.java
Normal file
@ -0,0 +1,186 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* fun for player
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Jumppads implements Listener{
|
||||
|
||||
/**
|
||||
* contains players flying from premium lobby to spawn
|
||||
*/
|
||||
private ArrayList<CustomPlayer> flySpawn = new ArrayList<>();
|
||||
/**
|
||||
* contains players flying from spawn to premium lobby
|
||||
*/
|
||||
private ArrayList<CustomPlayer> flyPremium = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* lets players jump over pads
|
||||
* @param e PlayerMoveEvent
|
||||
* @throws InterruptedException thread closed
|
||||
*/
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) throws InterruptedException {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
|
||||
Block block = p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
|
||||
|
||||
if(p.getLocation().getBlock().getType() == Material.STONE_PLATE) {
|
||||
|
||||
if(block.getType() == Material.REDSTONE_BLOCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(3D).setY(1D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(block.getType() == Material.BEDROCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(0D).setY(3D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(block.getType() == Material.IRON_BLOCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(3D).setY(4D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(block.getType() == Material.DIAMOND_BLOCK) {
|
||||
if(p.isAllowed(Rank.Premium)) {
|
||||
if(!flyPremium.contains(p)) {
|
||||
Vector v = p.getLocation().getDirection().multiply(1D).setY(3D);
|
||||
p.setVelocity(v);
|
||||
p.setHealth(1.0);
|
||||
flyPremium.add(p);
|
||||
runTimer(p);
|
||||
p.playEffect(p.getLocation(), Effect.BLAZE_SHOOT, 10);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(block.getType() == Material.OBSIDIAN) {
|
||||
Vector v = p.getLocation().getDirection().multiply(4D).setY(1D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(block.getType() == Material.WOOL) {
|
||||
p.setWalkSpeed(0.2F);
|
||||
|
||||
Vector v = p.getLocation().getDirection().multiply(1.5D).setY(1D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(block.getType() == Material.LAPIS_BLOCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(6D).setY(1D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(block.getType() == Material.EMERALD_BLOCK) {
|
||||
if(!flySpawn.contains(p)) {
|
||||
Vector v = p.getLocation().getDirection().multiply(3.0D).setY(1.0D);
|
||||
p.setVelocity(v);
|
||||
flySpawn.add(p);
|
||||
p.setHealth(1.0);
|
||||
runTimer(p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(block.getType() == Material.STATIONARY_WATER) {
|
||||
if(flySpawn.contains(p)) {
|
||||
flySpawn.remove(p);
|
||||
teleport("Spawn", p);
|
||||
}
|
||||
if(flyPremium.contains(p)) {
|
||||
flyPremium.remove(p);
|
||||
teleport("PremiumHub", p);
|
||||
}
|
||||
}
|
||||
if(block.getType() == Material.SPONGE) {
|
||||
Vector v = p.getLocation().getDirection().multiply(0.0D).setY(1.0D);
|
||||
Block b = p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_PLAYER_SPLASH, 5.0F, 1.0F);
|
||||
p.playEffect(p.getEyeLocation(), Effect.BLAZE_SHOOT, 200);
|
||||
Block tempBlock = p.getLocation().add(0.0D, 5.0D, 0.0D).getBlock();
|
||||
tempBlock.setType(Material.WATER);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> tempBlock.setType(Material.AIR), 20L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> {
|
||||
b.setType(Material.SPONGE);
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.playSound(b.getLocation(), Sound.BLOCK_PISTON_EXTEND, 5.0F, 1.0F);
|
||||
players.playEffect(b.getLocation(), Effect.BOW_FIRE, 200);
|
||||
}
|
||||
}, 100L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels fall damage
|
||||
* @param e EntityDamageEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent e) {
|
||||
if(e.getEntity() instanceof Player) {
|
||||
if(e.getCause() == DamageCause.FALL) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* teleports player to location
|
||||
* @param loc name of location
|
||||
* @param p CustomPlayer
|
||||
*/
|
||||
private void teleport(String loc, CustomPlayer p) {
|
||||
p.teleport(Config.readLocation("Lobby.Locs." + loc));
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 5.0F, 1.0F);
|
||||
p.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 20);
|
||||
p.playEffect(p.getEyeLocation(), Effect.BLAZE_SHOOT, 20);
|
||||
p.setHealth(10.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs cancel timer
|
||||
* @param p CustomPlayer
|
||||
*/
|
||||
private void runTimer(CustomPlayer p) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> {
|
||||
if(flyPremium.contains(p)) {
|
||||
teleport("PremiumHub", p);
|
||||
flyPremium.remove(p);
|
||||
}
|
||||
if(flySpawn.contains(p)) {
|
||||
teleport("Spawn", p);
|
||||
flySpawn.remove(p);
|
||||
}
|
||||
}, 20L * 10);
|
||||
}
|
||||
}
|
58
src/main/java/eu/univento/lobby/listeners/Menu.java
Normal file
58
src/main/java/eu/univento/lobby/listeners/Menu.java
Normal file
@ -0,0 +1,58 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.lobby.utils.Inventorys;
|
||||
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{
|
||||
|
||||
/**
|
||||
* opens and creates menus
|
||||
* @param e PlayerInteract
|
||||
*/
|
||||
@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()) {
|
||||
Inventorys invs = new Inventorys(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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
297
src/main/java/eu/univento/lobby/listeners/MenuEvents.java
Normal file
297
src/main/java/eu/univento/lobby/listeners/MenuEvents.java
Normal file
@ -0,0 +1,297 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.effects.Effects;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.lobby.utils.PetManager;
|
||||
import net.minecraft.server.v1_10_R1.EnumParticle;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.PolarBear;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.lobby.Lobby;
|
||||
import eu.univento.lobby.utils.Inventorys;
|
||||
|
||||
/**
|
||||
* 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<>();
|
||||
|
||||
|
||||
/**
|
||||
* clicking items
|
||||
* @param e InventoryClickEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
if (e.getWhoClicked() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
|
||||
Inventorys invs = new Inventorys(p);
|
||||
Messages msgs = new Messages(p);
|
||||
if(!e.getSlotType().equals(SlotType.OUTSIDE)) {
|
||||
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.setPartyRequests(!p.hasPartyRequests());
|
||||
p.closeInventory();
|
||||
p.openInventory(invs.getSettingsInventory());
|
||||
}
|
||||
}
|
||||
|
||||
if(e.getInventory().getName().equals(invs.getLanguagesInventory().getName())) {
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eDeutsch")) {
|
||||
p.setLanguage("DE");
|
||||
p.closeInventory();
|
||||
p.sendMessage(msgs.PREFIX() + "§7Sprache auf §eDeutsch §7geändert");
|
||||
invs.setMainInventory(true);
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eEnglish")) {
|
||||
p.setLanguage("EN");
|
||||
p.closeInventory();
|
||||
p.sendMessage(msgs.PREFIX() + "§7Language changed to §eenglish");
|
||||
invs.setMainInventory(true);
|
||||
}
|
||||
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eitaliano")) {
|
||||
p.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* plays effects on player move
|
||||
* @param e PlayerMoveEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
List<Player> players = Core.getOnlinePlayers().stream().map(CustomPlayer::getPLAYER).collect(Collectors.toList());
|
||||
|
||||
if(heartPlayers.contains(p))
|
||||
Effects.playEffect(p.getLocation(), EnumParticle.HEART, 5, 5);
|
||||
if(lavaPlayers.contains(p))
|
||||
Effects.playEffect(p.getLocation(), EnumParticle.DRIP_LAVA, 5, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* teleports player with effects to location
|
||||
* @param p CustomPlayer
|
||||
* @param location String
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}, 40L);
|
||||
}
|
||||
|
||||
}
|
91
src/main/java/eu/univento/lobby/listeners/Parkour.java
Normal file
91
src/main/java/eu/univento/lobby/listeners/Parkour.java
Normal file
@ -0,0 +1,91 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.events.MoveEventFilter;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.lobby.Lobby;
|
||||
import eu.univento.lobby.utils.PetManager;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Parkour implements Listener{
|
||||
|
||||
static ArrayList<CustomPlayer> players = new ArrayList<>();
|
||||
public static ArrayList<CustomPlayer> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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();
|
||||
if (block.getType() == Material.STAINED_CLAY) {
|
||||
if (players.contains(p)) {
|
||||
spawnRandomBlock(block.getLocation());
|
||||
}else if(p.getLocation().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) {
|
||||
players.remove(p);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PARKOUR_OFF());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void spawnRandomBlock(Location loc) {
|
||||
List<Location> locations = circle(loc, 3, 1, false, false, 1);
|
||||
Random r = new Random();
|
||||
Block block = locations.get(r.nextInt(locations.size())).getBlock();
|
||||
if(block.getType() == Material.AIR) {
|
||||
Random cr = new Random();
|
||||
int color = cr.nextInt(15);
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.setData((byte) color);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> {
|
||||
block.setType(Material.AIR);
|
||||
for(CustomPlayer players : Core.getOnlinePlayers()) {
|
||||
players.playSound(block.getLocation(), Sound.BLOCK_NOTE_BASS, 1.0F, 1.0F);
|
||||
}
|
||||
}, 20L * 10);
|
||||
}
|
||||
else{
|
||||
spawnRandomBlock(loc);
|
||||
}
|
||||
}
|
||||
|
||||
List<Location> circle (Location loc, Integer r, Integer h, Boolean hollow, Boolean sphere, int plus_y) {
|
||||
List<Location> circleblocks = new ArrayList<>();
|
||||
int cx = loc.getBlockX();
|
||||
int cy = loc.getBlockY();
|
||||
int cz = loc.getBlockZ();
|
||||
for (int x = cx - r; x <= cx +r; x++)
|
||||
for (int z = cz - r; z <= cz +r; z++)
|
||||
for (int y = (sphere ? cy - r : cy); y < (sphere ? cy + r : cy + h); y++) {
|
||||
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
|
||||
if (dist < r*r && !(hollow && dist < (r-1)*(r-1))) {
|
||||
Location l = new Location(loc.getWorld(), x, y + plus_y, z);
|
||||
circleblocks.add(l);
|
||||
}
|
||||
}
|
||||
|
||||
return circleblocks;
|
||||
}
|
||||
|
||||
}
|
126
src/main/java/eu/univento/lobby/listeners/PetInteract.java
Normal file
126
src/main/java/eu/univento/lobby/listeners/PetInteract.java
Normal file
@ -0,0 +1,126 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import eu.univento.core.api.gui.AnvilGUI;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
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 0.1
|
||||
*/
|
||||
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, msgs.LobbyItems_YOUR_PET());
|
||||
|
||||
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.getColor() + event.getName());
|
||||
p.refreshExperience();
|
||||
}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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
132
src/main/java/eu/univento/lobby/listeners/PlayerHider.java
Normal file
132
src/main/java/eu/univento/lobby/listeners/PlayerHider.java
Normal file
@ -0,0 +1,132 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import eu.univento.lobby.utils.Inventorys;
|
||||
import org.bukkit.Bukkit;
|
||||
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.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
|
||||
/**
|
||||
* lets players show/hide other players
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PlayerHider implements Listener{
|
||||
|
||||
|
||||
private static ArrayList<CustomPlayer> hidden = new ArrayList<>();
|
||||
public static ArrayList<CustomPlayer> getHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
private static ArrayList<CustomPlayer> silentlobby = new ArrayList<>();
|
||||
public static ArrayList<CustomPlayer> getSilentlobby() {
|
||||
return silentlobby;
|
||||
}
|
||||
/**
|
||||
* item to hide
|
||||
* @return ItemStack
|
||||
*/
|
||||
private ItemStack getHide(CustomPlayer p) {
|
||||
Messages msgs = new Messages(p);
|
||||
ItemStack hide = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
ItemMeta hideMeta = hide.getItemMeta();
|
||||
hideMeta.setDisplayName(msgs.LobbyItems_PLAYER_HIDER_ON());
|
||||
hide.setItemMeta(hideMeta);
|
||||
|
||||
return hide;
|
||||
}
|
||||
|
||||
/**
|
||||
* item to show
|
||||
* @return ItemStack
|
||||
*/
|
||||
private ItemStack getShow(CustomPlayer p) {
|
||||
Messages msgs = new Messages(p);
|
||||
ItemStack show = new ItemStack(Material.SUGAR);
|
||||
ItemMeta showMeta = show.getItemMeta();
|
||||
showMeta.setDisplayName(msgs.LobbyItems_PLAYER_HIDER_OFF());
|
||||
show.setItemMeta(showMeta);
|
||||
|
||||
return show;
|
||||
}
|
||||
|
||||
/**
|
||||
* player interacts with item
|
||||
* @param e PlayerInteract
|
||||
* @throws InterruptedException threads closed
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) throws InterruptedException {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
ItemStack item = p.getItemInHand();
|
||||
if(item.getType() == Material.SUGAR) {
|
||||
hidden.remove(p);
|
||||
|
||||
Bukkit.getOnlinePlayers().stream().filter(players -> !silentlobby.contains(players)).forEach(p::showPlayer);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PLAYERS_SHOW());
|
||||
|
||||
p.getInventory().remove(getShow(p));
|
||||
p.getInventory().addItem(getHide(p));
|
||||
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0F, 1.0F);
|
||||
}
|
||||
if(item.getType() == Material.GLOWSTONE_DUST) {
|
||||
hidden.add(p);
|
||||
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
CustomPlayer player = CustomPlayer.getPlayer(players.getName());
|
||||
if(!player.isAllowed(Rank.Supporter)) {
|
||||
p.hidePlayer(players);
|
||||
}
|
||||
}
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PLAYERS_HIDE());
|
||||
|
||||
p.getInventory().remove(getHide(p));
|
||||
p.getInventory().addItem(getShow(p));
|
||||
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0F, 1.0F);
|
||||
|
||||
}
|
||||
if(item.getType() == Material.TNT) {
|
||||
if(p.isAllowed(Rank.Partner)) {
|
||||
if(silentlobby.contains(p)) {
|
||||
silentlobby.remove(p);
|
||||
Inventorys invs = new Inventorys(p);
|
||||
p.getInventory().clear();
|
||||
invs.setMainInventory(true);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_SILENT_LOBBY_OFF());
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
p.showPlayer(players);
|
||||
if(!hidden.contains(players)) {
|
||||
players.showPlayer(p);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
silentlobby.add(p);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Lobby_SILENT_LOBBY_ON());
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
p.hidePlayer(players);
|
||||
players.hidePlayer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
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;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PlayerInteract implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onInteractPlayer(PlayerInteractEntityEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
Entity entity = e.getRightClicked();
|
||||
if(entity instanceof Player) {
|
||||
CustomPlayer clicked = CustomPlayer.getPlayer(e.getRightClicked().getName());
|
||||
openInventory(p, clicked);
|
||||
}
|
||||
}
|
||||
|
||||
private void openInventory(CustomPlayer p, CustomPlayer clicked) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, clicked.getColor() + clicked.getName() + "'s " + p.getMessages().LobbyItems_PLAYER_MENU());
|
||||
|
||||
ItemStack friend = new ItemStack(Material.PUMPKIN);
|
||||
ItemMeta friendMeta = friend.getItemMeta();
|
||||
friendMeta.setDisplayName(p.getMessages().LobbyItems_PLAYER_FRIEND());
|
||||
friend.setItemMeta(friendMeta);
|
||||
|
||||
ItemStack party = new ItemStack(Material.FIREWORK);
|
||||
ItemMeta partyMeta = party.getItemMeta();
|
||||
partyMeta.setDisplayName(p.getMessages().LobbyItems_PLAYER_PARTY());
|
||||
party.setItemMeta(partyMeta);
|
||||
|
||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||
meta.setOwner(clicked.getName());
|
||||
meta.setDisplayName(p.getMessages().LobbyItems_PLAYER_PROFILE());
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
ItemStack stats = new ItemStack(Material.GOLD_SWORD);
|
||||
ItemMeta statsMeta = stats.getItemMeta();
|
||||
statsMeta.setDisplayName(p.getMessages().LobbyItems_PLAYER_STATS());
|
||||
stats.setItemMeta(statsMeta);
|
||||
|
||||
inv.setItem(0, friend);
|
||||
inv.setItem(1, party);
|
||||
inv.setItem(4, skull);
|
||||
inv.setItem(5, stats);
|
||||
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
|
||||
//TODO: add functionality here
|
||||
}
|
||||
}
|
45
src/main/java/eu/univento/lobby/listeners/StatusSigns.java
Normal file
45
src/main/java/eu/univento/lobby/listeners/StatusSigns.java
Normal file
@ -0,0 +1,45 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.lobby.utils.StatusSign;
|
||||
import eu.univento.lobby.utils.StatusSignManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class StatusSigns implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(e.getLine(0).equals("[join]") && p.isAllowed(Rank.Developer)) {
|
||||
StatusSignManager.addSign(e.getLine(1), e.getBlock().getLocation());
|
||||
Messages msgs = new Messages(p);
|
||||
p.sendMessage(msgs.Lobby_SET_SIGN());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Block block = e.getClickedBlock();
|
||||
if(block.getType() == Material.WALL_SIGN) {
|
||||
if(StatusSignManager.isStatusSign(block.getLocation())) {
|
||||
StatusSign sign = StatusSignManager.getSign(block.getLocation());
|
||||
p.connectToServer(sign.getServerName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
src/main/java/eu/univento/lobby/utils/CustomMapRenderer.java
Normal file
25
src/main/java/eu/univento/lobby/utils/CustomMapRenderer.java
Normal file
@ -0,0 +1,25 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.map.MinecraftFont;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 05.07.2016
|
||||
*/
|
||||
public class CustomMapRenderer extends MapRenderer{
|
||||
|
||||
@Override
|
||||
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.getRank().name());
|
||||
mapCanvas.drawText(1, 30, MinecraftFont.Font, p.getFirstLogin().toString());
|
||||
mapCanvas.drawText(1, 40, MinecraftFont.Font, "Sprache " + p.getLanguage());
|
||||
}
|
||||
}
|
599
src/main/java/eu/univento/lobby/utils/Inventorys.java
Normal file
599
src/main/java/eu/univento/lobby/utils/Inventorys.java
Normal file
@ -0,0 +1,599 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import eu.univento.core.api.server.ServerInfo;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.lobby.Lobby;
|
||||
import eu.univento.lobby.listeners.FoundItems;
|
||||
import org.bukkit.material.Dye;
|
||||
|
||||
/**
|
||||
* opens inventorys for players
|
||||
*
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Inventorys {
|
||||
|
||||
private CustomPlayer player;
|
||||
private ItemStack empty = new ItemStack(Material.AIR);
|
||||
|
||||
|
||||
public Inventorys(CustomPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void setMainInventory(boolean forcetime) {
|
||||
Inventory inv = player.getInventory();
|
||||
|
||||
ItemStack nav = new ItemStack(Material.WORKBENCH);
|
||||
ItemMeta navMeta = nav.getItemMeta();
|
||||
navMeta.setDisplayName(player.getMessage("Lobby.Item.Navigator"));
|
||||
nav.setItemMeta(navMeta);
|
||||
|
||||
ItemStack lobby = new ItemStack(Material.BLAZE_POWDER);
|
||||
ItemMeta lobbyMeta = lobby.getItemMeta();
|
||||
lobbyMeta.setDisplayName(player.getMessage("Lobby.Item.LobbySwitcher"));
|
||||
lobby.setItemMeta(lobbyMeta);
|
||||
|
||||
ItemStack adventure = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
ItemMeta adventureMeta = adventure.getItemMeta();
|
||||
adventureMeta.setDisplayName(player.getMessage("Lobby.Item.Adventure"));
|
||||
adventure.setItemMeta(adventureMeta);
|
||||
|
||||
ItemStack fun = new ItemStack(Material.CHEST);
|
||||
ItemMeta funMeta = fun.getItemMeta();
|
||||
funMeta.setDisplayName(player.getMessage("Lobby.Item.FunChest"));
|
||||
fun.setItemMeta(funMeta);
|
||||
|
||||
ItemStack youtube = new ItemStack(Material.EXP_BOTTLE);
|
||||
ItemMeta youtubeMeta = youtube.getItemMeta();
|
||||
youtubeMeta.setDisplayName(player.getMessage("Lobby.Item.Youtuber"));
|
||||
youtube.setItemMeta(youtubeMeta);
|
||||
|
||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||
meta.setOwner(player.getName());
|
||||
meta.setDisplayName(player.getMessage("Lobby.Item.Profile"));
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
inv.setItem(2, empty);
|
||||
inv.setItem(3, empty);
|
||||
inv.setItem(4, empty);
|
||||
inv.setItem(6, empty);
|
||||
timeItem(inv, 0, nav, Sound.ENTITY_CHICKEN_EGG, 20L, false, forcetime);
|
||||
timeItem(inv, 8, skull, Sound.ENTITY_CHICKEN_EGG, 40L, false, forcetime);
|
||||
timeItem(inv, 1, lobby, Sound.ENTITY_CHICKEN_EGG, 60L, false, forcetime);
|
||||
timeItem(inv, 7, fun, Sound.ENTITY_CHICKEN_EGG, 80L, false, forcetime);
|
||||
if (player.isAllowed(Rank.Partner)) {
|
||||
timeItem(inv, 5, youtube, Sound.ENTITY_CHICKEN_EGG, 120L, false, forcetime);
|
||||
timeItem(inv, 3, adventure, Sound.ENTITY_CHICKEN_DEATH, 140L, false, forcetime);
|
||||
} else {
|
||||
timeItem(inv, 5, adventure, Sound.ENTITY_CHICKEN_EGG, 120L, false, forcetime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gets inventory for navigation
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getNavigatorInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_NAVIGATOR());
|
||||
|
||||
ItemStack spawn = new ItemStack(Material.FIREWORK_CHARGE);
|
||||
ItemMeta spawnMeta = spawn.getItemMeta();
|
||||
spawnMeta.setDisplayName(player.getMessage("Lobby.Menu.Nav.Spawn"));
|
||||
spawnMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
spawn.setItemMeta(spawnMeta);
|
||||
|
||||
ItemStack strive = new ItemStack(Material.WOOL, 1, (byte) 11);
|
||||
ItemMeta striveMeta = strive.getItemMeta();
|
||||
striveMeta.setDisplayName(player.getMessage("Lobby.Menu.Nav.Strive"));
|
||||
strive.setItemMeta(striveMeta);
|
||||
|
||||
ItemStack hustle = new ItemStack(Material.CHAINMAIL_BOOTS);
|
||||
ItemMeta hustleMeta = hustle.getItemMeta();
|
||||
hustleMeta.setDisplayName(player.getMessage("Lobby.Menu.Nav.Hustle"));
|
||||
hustleMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
hustle.setItemMeta(hustleMeta);
|
||||
|
||||
|
||||
ItemStack build = new ItemStack(Material.FLOWER_POT_ITEM);
|
||||
ItemMeta buildMeta = build.getItemMeta();
|
||||
buildMeta.setDisplayName(player.getMessage("Lobby.Menu.Nav.Build"));
|
||||
ArrayList<String> buildLore = new ArrayList<>();
|
||||
ServerInfo buildInfo = new ServerInfo("build");
|
||||
buildLore.add(buildInfo.getOnlinePlayers() + player.getMessages().LobbyItems_PLAYERS_ONLINE());
|
||||
buildMeta.setLore(buildLore);
|
||||
build.setItemMeta(buildMeta);
|
||||
|
||||
inv.setItem(21, hustle);
|
||||
inv.setItem(23, strive);
|
||||
inv.setItem(31, spawn);
|
||||
if (player.isAllowed(Rank.Supporter)) inv.setItem(26, build);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getLobbySwitcherInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 18, "Lobbys");
|
||||
|
||||
for (int i = 1; i <= 19; i++) {
|
||||
ServerInfo info = new ServerInfo("Lobby" + i);
|
||||
Material material;
|
||||
if (!info.isOnline()) material = Material.BARRIER;
|
||||
if (info.getOnlinePlayers() >= 50) material = Material.CHEST;
|
||||
if (info.getOnlinePlayers() < 50) material = Material.ANVIL;
|
||||
else material = Material.GRASS;
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Lobby" + i);
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(info.getOnlinePlayers() + " | " + info.getMaxPlayers());
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
inv.addItem(item);
|
||||
}
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void setYoutuberInventory() {
|
||||
Inventory inv = player.getInventory();
|
||||
|
||||
String nickState;
|
||||
if(player.isNicked()) nickState = "on"; else nickState = "off";
|
||||
|
||||
ItemStack nick = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta nickMeta = nick.getItemMeta();
|
||||
nickMeta.setDisplayName(player.getMessage("Lobby.Item.YT.Nick." + nickState));
|
||||
nick.setItemMeta(nickMeta);
|
||||
|
||||
ItemStack silent = new ItemStack(Material.TNT);
|
||||
ItemMeta silentMeta = silent.getItemMeta();
|
||||
silentMeta.setDisplayName(player.getMessage("Lobby.Item.YT.SilentLobby"));
|
||||
silent.setItemMeta(silentMeta);
|
||||
|
||||
ItemStack force = new ItemStack(Material.EYE_OF_ENDER);
|
||||
ItemMeta forceMeta = force.getItemMeta();
|
||||
forceMeta.setDisplayName(player.getMessage("Lobby.Item.YT.Forcefield"));
|
||||
force.setItemMeta(forceMeta);
|
||||
|
||||
ItemStack extras = new ItemStack(Material.MILK_BUCKET);
|
||||
ItemMeta extrasMeta = extras.getItemMeta();
|
||||
extrasMeta.setDisplayName(player.getMessage("Lobby.Item.YT.Extras"));
|
||||
extras.setItemMeta(extrasMeta);
|
||||
|
||||
Dye dye = new Dye();
|
||||
dye.setColor(DyeColor.RED);
|
||||
ItemStack back = dye.toItemStack();
|
||||
ItemMeta backMeta = back.getItemMeta();
|
||||
backMeta.setDisplayName(player.getMessage("Lobby.Item.YT.Back"));
|
||||
back.setItemMeta(backMeta);
|
||||
|
||||
inv.setItem(0, force);
|
||||
inv.setItem(1, empty);
|
||||
inv.setItem(2, nick);
|
||||
inv.setItem(3, empty);
|
||||
inv.setItem(4, silent);
|
||||
inv.setItem(5, empty);
|
||||
inv.setItem(6, extras);
|
||||
inv.setItem(7, empty);
|
||||
inv.setItem(8, back);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets inventory for funchest
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getFunChestInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_FUN_CHEST());
|
||||
|
||||
ItemStack music = new ItemStack(Material.RECORD_3);
|
||||
ItemMeta musicMeta = music.getItemMeta();
|
||||
musicMeta.setLore(null);
|
||||
musicMeta.setDisplayName(player.getMessages().LobbyItems_MUSIC());
|
||||
music.setItemMeta(musicMeta);
|
||||
|
||||
ItemStack gadgets = new ItemStack(Material.ARMOR_STAND);
|
||||
ItemMeta gadgetsMeta = gadgets.getItemMeta();
|
||||
gadgetsMeta.setDisplayName(player.getMessages().LobbyItems_GADGETS());
|
||||
gadgets.setItemMeta(gadgetsMeta);
|
||||
|
||||
ItemStack particle = new ItemStack(Material.NOTE_BLOCK);
|
||||
ItemMeta particleMeta = particle.getItemMeta();
|
||||
particleMeta.setDisplayName(player.getMessages().LobbyItems_PARTICLE());
|
||||
particle.setItemMeta(particleMeta);
|
||||
|
||||
ItemStack pets = new ItemStack(Material.MONSTER_EGG);
|
||||
ItemMeta petsMeta = pets.getItemMeta();
|
||||
petsMeta.setDisplayName(player.getMessages().LobbyItems_PETS());
|
||||
pets.setItemMeta(petsMeta);
|
||||
|
||||
inv.setItem(11, music);
|
||||
inv.setItem(15, gadgets);
|
||||
inv.setItem(29, particle);
|
||||
inv.setItem(33, pets);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets inventory for music
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getMusicInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_MUSIC());
|
||||
|
||||
|
||||
ItemStack music_3 = new ItemStack(Material.RECORD_3);
|
||||
ItemMeta music_3Meta = music_3.getItemMeta();
|
||||
List<String> music_3Lore = new ArrayList<>();
|
||||
music_3Lore.add("§6Jetzt abspielen");
|
||||
music_3Meta.setDisplayName("§5Milky Way Stars | Janji feat. TR");
|
||||
music_3Meta.setLore(music_3Lore);
|
||||
music_3.setItemMeta(music_3Meta);
|
||||
|
||||
|
||||
if (FoundItems.hasFound("music_3", player)) inv.setItem(2, music_3);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets inventory for gadgets
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getGadgetsInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_GADGETS());
|
||||
|
||||
ItemStack sugar = new ItemStack(Material.SUGAR);
|
||||
ItemMeta sugarMeta = sugar.getItemMeta();
|
||||
sugarMeta.setDisplayName("§6Einen Teelöffel Zucker");
|
||||
sugar.setItemMeta(sugarMeta);
|
||||
|
||||
ItemStack feather = new ItemStack(Material.FEATHER);
|
||||
ItemMeta featherMeta = feather.getItemMeta();
|
||||
featherMeta.setDisplayName("§6Federleicht");
|
||||
feather.setItemMeta(featherMeta);
|
||||
|
||||
if (FoundItems.hasFound("sugar", player)) inv.setItem(0, sugar);
|
||||
if (FoundItems.hasFound("feather", player)) inv.setItem(1, feather);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets inventory for particle effects
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getParticleInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_PARTICLE());
|
||||
|
||||
ItemStack hearts = new ItemStack(Material.RED_ROSE);
|
||||
ItemMeta heartsMeta = hearts.getItemMeta();
|
||||
heartsMeta.setDisplayName("§6Herzen");
|
||||
hearts.setItemMeta(heartsMeta);
|
||||
|
||||
ItemStack lava = new ItemStack(Material.LAVA_BUCKET);
|
||||
ItemMeta lavaMeta = lava.getItemMeta();
|
||||
lavaMeta.setDisplayName("§6Lava");
|
||||
lava.setItemMeta(lavaMeta);
|
||||
|
||||
if (FoundItems.hasFound("hearts", player)) inv.setItem(0, hearts);
|
||||
//if(FoundItems.hasFound("lava", player)) inv.setItem(1, lava);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getPetsInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_PETS());
|
||||
|
||||
ItemStack pig = new ItemStack(Material.MONSTER_EGG, 1, (short) 90);
|
||||
ItemMeta pigMeta = pig.getItemMeta();
|
||||
pigMeta.setDisplayName(player.getMessages().LobbyItems_PETS_PIG());
|
||||
pig.setItemMeta(pigMeta);
|
||||
|
||||
ItemStack cow = new ItemStack(Material.MONSTER_EGG, 1, (short) 92);
|
||||
ItemMeta cowMeta = cow.getItemMeta();
|
||||
cowMeta.setDisplayName(player.getMessages().LobbyItems_PETS_COW());
|
||||
cow.setItemMeta(cowMeta);
|
||||
|
||||
ItemStack chicken = new ItemStack(Material.MONSTER_EGG, 1, (short) 93);
|
||||
ItemMeta chickenMeta = chicken.getItemMeta();
|
||||
chickenMeta.setDisplayName(player.getMessages().LobbyItems_PETS_CHICKEN());
|
||||
chicken.setItemMeta(chickenMeta);
|
||||
|
||||
ItemStack rabbit = new ItemStack(Material.MONSTER_EGG, 1, (short) 101);
|
||||
ItemMeta rabbitMeta = rabbit.getItemMeta();
|
||||
rabbitMeta.setDisplayName(player.getMessages().LobbyItems_PETS_RABBIT());
|
||||
rabbit.setItemMeta(rabbitMeta);
|
||||
|
||||
ItemStack mushroom = new ItemStack(Material.MONSTER_EGG, 1, (short) 96);
|
||||
ItemMeta mushroomMeta = mushroom.getItemMeta();
|
||||
mushroomMeta.setDisplayName(player.getMessages().LobbyItems_PETS_MUSHROM_COW());
|
||||
mushroom.setItemMeta(mushroomMeta);
|
||||
|
||||
ItemStack horse = new ItemStack(Material.MONSTER_EGG, 1, (short) 101);
|
||||
ItemMeta horseMeta = horse.getItemMeta();
|
||||
horseMeta.setDisplayName("Horse");
|
||||
horse.setItemMeta(horseMeta);
|
||||
|
||||
ItemStack polar = new ItemStack(Material.MONSTER_EGG, 1, (short) 101);
|
||||
ItemMeta polarMeta = polar.getItemMeta();
|
||||
polarMeta.setDisplayName("PolarBear");
|
||||
polar.setItemMeta(polarMeta);
|
||||
|
||||
ItemStack delete = new ItemStack(Material.BARRIER);
|
||||
ItemMeta deleteMeta = delete.getItemMeta();
|
||||
deleteMeta.setDisplayName(player.getMessages().LobbyItems_PETS_REMOVE());
|
||||
delete.setItemMeta(deleteMeta);
|
||||
|
||||
inv.setItem(0, pig);
|
||||
inv.setItem(1, cow);
|
||||
inv.setItem(2, chicken);
|
||||
inv.setItem(3, rabbit);
|
||||
inv.setItem(4, mushroom);
|
||||
inv.setItem(5, horse);
|
||||
inv.setItem(6, polar);
|
||||
inv.setItem(44, delete);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets inventory for profile
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getProfileInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 9, player.getMessages().LobbyItems_PROFILE());
|
||||
|
||||
ItemStack stats = new ItemStack(Material.COMPASS);
|
||||
ItemMeta statsMeta = stats.getItemMeta();
|
||||
statsMeta.setDisplayName(player.getMessages().LobbyItems_STATS());
|
||||
stats.setItemMeta(statsMeta);
|
||||
|
||||
ItemStack quests = new ItemStack(Material.PRISMARINE_SHARD);
|
||||
|
||||
ItemStack secrets = new ItemStack(Material.CHEST);
|
||||
|
||||
ItemStack friends = new ItemStack(Material.PUMPKIN);
|
||||
ItemMeta friendsMeta = friends.getItemMeta();
|
||||
friendsMeta.setDisplayName(player.getMessages().LobbyItems_FRIENDS());
|
||||
friends.setItemMeta(friendsMeta);
|
||||
|
||||
ItemStack settings = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta settingsMeta = settings.getItemMeta();
|
||||
settingsMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS());
|
||||
settings.setItemMeta(settingsMeta);
|
||||
|
||||
inv.setItem(0, stats);
|
||||
inv.setItem(1, friends);
|
||||
inv.setItem(2, quests);
|
||||
inv.setItem(3, secrets);
|
||||
inv.setItem(8, settings);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets inventory for settings
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getSettingsInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 18, player.getMessages().LobbyItems_SETTINGS());
|
||||
|
||||
ArrayList<String> on = new ArrayList<>();
|
||||
on.add(player.getMessages().LobbyItems_SETTINGS_ON());
|
||||
|
||||
ArrayList<String> off = new ArrayList<>();
|
||||
off.add(player.getMessages().LobbyItems_SETTINGS_OFF());
|
||||
|
||||
ItemStack fastMenu = new ItemStack(Material.ANVIL);
|
||||
ItemMeta fastMenuMeta = fastMenu.getItemMeta();
|
||||
fastMenuMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_FASTMENU());
|
||||
if (player.hasInventoryAnimation()) fastMenuMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasInventoryAnimation()) fastMenuMeta.setLore(on);
|
||||
else fastMenuMeta.setLore(off);
|
||||
fastMenu.setItemMeta(fastMenuMeta);
|
||||
|
||||
ItemStack teleport = new ItemStack(Material.ENDER_PEARL);
|
||||
ItemMeta teleportMeta = teleport.getItemMeta();
|
||||
teleportMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_SERVER_TELEPORT());
|
||||
if (player.hasTeleportAnimation()) teleportMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasTeleportAnimation()) teleportMeta.setLore(on);
|
||||
else fastMenuMeta.setLore(off);
|
||||
teleport.setItemMeta(teleportMeta);
|
||||
|
||||
ItemStack requestsParty = new ItemStack(Material.FIREWORK);
|
||||
ItemMeta requestsPartyMeta = requestsParty.getItemMeta();
|
||||
requestsPartyMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_PARTY_REQUESTS());
|
||||
if (player.hasPartyRequests()) requestsPartyMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasPartyRequests()) requestsPartyMeta.setLore(on);
|
||||
else requestsPartyMeta.setLore(off);
|
||||
requestsParty.setItemMeta(requestsPartyMeta);
|
||||
|
||||
ItemStack requestsFriends = new ItemStack(Material.PUMPKIN);
|
||||
ItemMeta requestsFriendsMeta = requestsFriends.getItemMeta();
|
||||
requestsFriendsMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_FRIEND_REQUESTS());
|
||||
if (player.hasFriendRequests()) requestsFriendsMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasFriendRequests()) requestsFriendsMeta.setLore(on);
|
||||
else requestsFriendsMeta.setLore(off);
|
||||
requestsFriends.setItemMeta(requestsFriendsMeta);
|
||||
|
||||
ItemStack friendJump = new ItemStack(Material.ELYTRA);
|
||||
ItemMeta friendJumpMeta = friendJump.getItemMeta();
|
||||
friendJumpMeta.setDisplayName("Freunde springen nicht gerne");
|
||||
if (player.hasFriendJump()) friendJumpMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasFriendJump()) friendJumpMeta.setLore(on);
|
||||
else friendJumpMeta.setLore(off);
|
||||
friendJump.setItemMeta(friendJumpMeta);
|
||||
|
||||
ItemStack chat = new ItemStack(Material.SIGN);
|
||||
ItemMeta chatMeta = chat.getItemMeta();
|
||||
chatMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_CHATSOUNDS());
|
||||
if (player.hasChatSounds()) chatMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasChatSounds()) chatMeta.setLore(on);
|
||||
else chatMeta.setLore(off);
|
||||
chat.setItemMeta(chatMeta);
|
||||
|
||||
ItemStack effects = new ItemStack(Material.BLAZE_POWDER);
|
||||
ItemMeta effectsMeta = effects.getItemMeta();
|
||||
effectsMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_EFFECTS());
|
||||
if (player.hasEffects()) effectsMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasEffects()) effectsMeta.setLore(on);
|
||||
else effectsMeta.setLore(off);
|
||||
effects.setItemMeta(effectsMeta);
|
||||
|
||||
ItemStack storyMode = new ItemStack(Material.BOOK_AND_QUILL);
|
||||
ItemMeta storyModeMeta = storyMode.getItemMeta();
|
||||
storyModeMeta.setDisplayName("Geschichtsmodus ist auch noch da");
|
||||
if (player.hasStoryMode()) storyModeMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
if (player.hasStoryMode()) storyModeMeta.setLore(on);
|
||||
else storyModeMeta.setLore(off);
|
||||
storyMode.setItemMeta(storyModeMeta);
|
||||
|
||||
ItemStack languages = new ItemStack(Material.BOOK);
|
||||
ItemMeta languagesMeta = languages.getItemMeta();
|
||||
languagesMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_LANGUAGES());
|
||||
languages.setItemMeta(languagesMeta);
|
||||
|
||||
|
||||
inv.setItem(0, fastMenu);
|
||||
inv.setItem(1, teleport);
|
||||
inv.setItem(2, requestsParty);
|
||||
inv.setItem(3, requestsFriends);
|
||||
inv.setItem(4, friendJump);
|
||||
inv.setItem(5, chat);
|
||||
inv.setItem(6, effects);
|
||||
inv.setItem(7, storyMode);
|
||||
inv.setItem(17, languages);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getLanguagesInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 9, player.getMessages().LobbyItems_SETTINGS_LANGUAGES());
|
||||
|
||||
ItemStack de = new ItemStack(Material.PAPER);
|
||||
ItemMeta deMeta = de.getItemMeta();
|
||||
deMeta.setDisplayName("§eDeutsch");
|
||||
if (player.getLanguage().equals("DE")) deMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
de.setItemMeta(deMeta);
|
||||
|
||||
ItemStack en = new ItemStack(Material.PAPER);
|
||||
ItemMeta enMeta = en.getItemMeta();
|
||||
enMeta.setDisplayName("§eEnglish");
|
||||
if (player.getLanguage().equals("EN")) enMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
en.setItemMeta(enMeta);
|
||||
|
||||
ItemStack it = new ItemStack(Material.PAPER);
|
||||
ItemMeta itMeta = it.getItemMeta();
|
||||
itMeta.setDisplayName("§eitaliano");
|
||||
if (player.getLanguage().equals("IT")) itMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
|
||||
it.setItemMeta(itMeta);
|
||||
|
||||
inv.setItem(0, de);
|
||||
inv.setItem(1, en);
|
||||
inv.setItem(2, it);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets friends inventory
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public Inventory getFriendsInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_FRIENDS());
|
||||
/**
|
||||
ArrayList<UUID> list = player.getFriends();
|
||||
|
||||
for(int i = 0; i >= list.size(); i++) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(list.get(i));
|
||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||
meta.setOwner(p.getName());
|
||||
meta.setDisplayName(p.getName());
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
inv.addItem(skull);
|
||||
}
|
||||
*/
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getStatsInventory() {
|
||||
Inventory inv = Bukkit.createInventory(player, 45, player.getMessages().LobbyItems_STATS());
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* time item appearance of item
|
||||
*
|
||||
* @param inv inventory
|
||||
* @param slot Inventory slot
|
||||
* @param item ItemStack
|
||||
* @param sound Sound
|
||||
* @param time long
|
||||
* @param menu is menu ?
|
||||
* @param forcedtime if true settings will be ignored
|
||||
*/
|
||||
private void timeItem(Inventory inv, int slot, ItemStack item, Sound sound, long time, boolean menu, boolean forcedtime) {
|
||||
if (!player.hasInventoryAnimation() || forcedtime) {
|
||||
addItem(inv, slot, item, null, menu);
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), () -> addItem(inv, slot, item, sound, menu), time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add item to inventory
|
||||
*
|
||||
* @param inv inventory
|
||||
* @param slot Inventory slot
|
||||
* @param item ItemStack
|
||||
* @param sound Sound
|
||||
* @param menu is menu ?
|
||||
*/
|
||||
public void addItem(Inventory inv, int slot, ItemStack item, Sound sound, boolean menu) {
|
||||
if (menu) {
|
||||
String name = inv.getTitle();
|
||||
if (player.getOpenInventory().getTitle().equals(name)) {
|
||||
inv.setItem(slot, item);
|
||||
player.playSound(player.getEyeLocation(), sound, 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
inv.setItem(slot, item);
|
||||
player.playSound(player.getEyeLocation(), sound, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
57
src/main/java/eu/univento/lobby/utils/PetManager.java
Normal file
57
src/main/java/eu/univento/lobby/utils/PetManager.java
Normal file
@ -0,0 +1,57 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PetManager {
|
||||
|
||||
private static HashMap<CustomPlayer, Entity> pets = new HashMap<>();
|
||||
|
||||
public static HashMap<CustomPlayer, Entity> getPets() {
|
||||
return pets;
|
||||
}
|
||||
|
||||
public static boolean hasPet(CustomPlayer p) {
|
||||
return pets.containsKey(p);
|
||||
}
|
||||
|
||||
public static Entity getPet(CustomPlayer p) {
|
||||
return pets.get(p);
|
||||
}
|
||||
|
||||
public static void removePet(CustomPlayer p) {
|
||||
pets.get(p).remove();
|
||||
}
|
||||
|
||||
public static void setPet(CustomPlayer p, EntityType e) {
|
||||
if(hasPet(p)) {
|
||||
removePet(p);
|
||||
}
|
||||
new Pets().createPet(p, e);
|
||||
}
|
||||
|
||||
public static void setName(CustomPlayer p, String name) {
|
||||
if(hasPet(p)) {
|
||||
getPet(p).setCustomName(name);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(CustomPlayer p) {
|
||||
if(hasPet(p)) {
|
||||
return getPet(p).getCustomName();
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearPets() {
|
||||
pets.values().forEach(Entity::remove);
|
||||
}
|
||||
}
|
69
src/main/java/eu/univento/lobby/utils/Pets.java
Normal file
69
src/main/java/eu/univento/lobby/utils/Pets.java
Normal file
@ -0,0 +1,69 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import eu.univento.core.api.pet.NMSHandler;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftCreature;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Pets {
|
||||
|
||||
public Pets(){
|
||||
}
|
||||
|
||||
void createPet(CustomPlayer p, EntityType type){
|
||||
Entity entity = NMSHandler.spawn(type, p.getLocation());
|
||||
assert entity != null;
|
||||
entity.setCustomName(p.getColor() + p.getDisplayName() + "'s");
|
||||
entity.setCustomNameVisible(true);
|
||||
PetManager.getPets().put(p, entity);
|
||||
}
|
||||
|
||||
public void followPlayer(Creature creature, Player player, double speed){
|
||||
Location location = player.getLocation();
|
||||
|
||||
|
||||
Random rnd = new Random();
|
||||
int rand = rnd.nextInt(6);
|
||||
switch(rand){
|
||||
case 0:
|
||||
location.add(1.5,0,1.5);
|
||||
break;
|
||||
case 1:
|
||||
location.add(0,0,1.5);
|
||||
break;
|
||||
case 2:
|
||||
location.add(1.5,0,0);
|
||||
break;
|
||||
case 3:
|
||||
location.subtract(1.5,0,1.5);
|
||||
break;
|
||||
case 4:
|
||||
location.subtract(0,0,1.5);
|
||||
break;
|
||||
case 5:
|
||||
location.subtract(1.5,0,0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(location.distanceSquared(creature.getLocation()) > 100){
|
||||
if(player.isFlying()){
|
||||
return;
|
||||
}
|
||||
creature.teleport(location);
|
||||
}else{
|
||||
((CraftCreature)creature).getHandle().getNavigation().a(location.getX(),location.getY(),location.getZ(),speed);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
68
src/main/java/eu/univento/lobby/utils/Scoreboards.java
Normal file
68
src/main/java/eu/univento/lobby/utils/Scoreboards.java
Normal file
@ -0,0 +1,68 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Scoreboards {
|
||||
|
||||
public static void updateScoreboard(CustomPlayer p) {
|
||||
Messages msgs = p.getMessages();
|
||||
Scoreboard board = p.getScoreboard();
|
||||
if(board.getObjective("Lobby") != null) board.getObjective("Lobby").unregister();
|
||||
|
||||
Objective obj = board.registerNewObjective("Lobby", "dummy");
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
obj.setDisplayName(msgs.TAB_PREFIX());
|
||||
|
||||
Score empty = obj.getScore(" ");
|
||||
empty.setScore(13);
|
||||
|
||||
Score coinsMsg = obj.getScore(msgs.LobbyBoard_COINS());
|
||||
coinsMsg.setScore(12);
|
||||
|
||||
Score coins = obj.getScore("§7" + p.getCoins());
|
||||
coins.setScore(11);
|
||||
|
||||
Score empty1 = obj.getScore(" ");
|
||||
empty1.setScore(10);
|
||||
|
||||
Score foundMsg = obj.getScore(msgs.LobbyBoard_FOUND_SECRETS());
|
||||
foundMsg.setScore(9);
|
||||
|
||||
Score found = obj.getScore("§7" + p.getSecrets());
|
||||
found.setScore(8);
|
||||
|
||||
Score empty2 = obj.getScore(" ");
|
||||
empty2.setScore(7);
|
||||
|
||||
Score forumMsg = obj.getScore(msgs.LobbyBoard_FORUM());
|
||||
forumMsg.setScore(6);
|
||||
|
||||
Score forum = obj.getScore("§7forum.univento.eu");
|
||||
forum.setScore(5);
|
||||
|
||||
Score empty3 = obj.getScore(" ");
|
||||
empty3.setScore(4);
|
||||
|
||||
Score tsMsg = obj.getScore(msgs.LobbyBoard_TS());
|
||||
tsMsg.setScore(3);
|
||||
|
||||
Score ts = obj.getScore("§7ts.univento.eu");
|
||||
ts.setScore(2);
|
||||
|
||||
Score empty4 = obj.getScore(" ");
|
||||
empty4.setScore(1);
|
||||
|
||||
Score end = obj.getScore(" §8-*-");
|
||||
end.setScore(0);
|
||||
|
||||
}
|
||||
}
|
90
src/main/java/eu/univento/lobby/utils/StatusSign.java
Normal file
90
src/main/java/eu/univento/lobby/utils/StatusSign.java
Normal file
@ -0,0 +1,90 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import eu.univento.core.api.server.ServerInfo;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.2
|
||||
*/
|
||||
public class StatusSign {
|
||||
|
||||
String name;
|
||||
Location loc;
|
||||
|
||||
public StatusSign(String name, Location loc) {
|
||||
this.name = name;
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
ServerInfo info = new ServerInfo(this.name);
|
||||
Block block = loc.getBlock();
|
||||
if(block.getType() == Material.WALL_SIGN) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
org.bukkit.material.Sign s = (org.bukkit.material.Sign) block.getState().getData();
|
||||
Block behind = block.getRelative(s.getAttachedFace());
|
||||
if(info.isOnline()) {
|
||||
if(info.getMotd().contains("Ingame")) {
|
||||
sign.setLine(0, "§8-§6*§8-");
|
||||
sign.setLine(1, "§6" + info.getName());
|
||||
sign.setLine(2, "§e" + info.getOnlinePlayers() + "§8/§6" + info.getMaxPlayers());
|
||||
sign.setLine(3, "§6Ingame");
|
||||
sign.update();
|
||||
behind.setData(DyeColor.CYAN.getWoolData());
|
||||
}
|
||||
else if(info.getMotd().contains("Lobby")) {
|
||||
if(info.getMaxPlayers() >= info.getOnlinePlayers()) {
|
||||
sign.setLine(0, "§8-§2*§8-");
|
||||
sign.setLine(1, "§a" + info.getName());
|
||||
sign.setLine(2, "§a" + info.getOnlinePlayers() + "§8/§2" + info.getMaxPlayers());
|
||||
sign.setLine(3, "§aLobby");
|
||||
sign.update();
|
||||
behind.setData(DyeColor.LIME.getWoolData());
|
||||
}else{
|
||||
sign.setLine(0, "§8-§6*§8-");
|
||||
sign.setLine(1, "§7" + info.getName());
|
||||
sign.setLine(2, "§a" + info.getOnlinePlayers() + "§8/§3" + info.getMaxPlayers());
|
||||
sign.setLine(3, "§aLobby");
|
||||
sign.update();
|
||||
behind.setData(DyeColor.YELLOW.getWoolData());
|
||||
}
|
||||
}
|
||||
else if(info.getMotd().contains("Restart")) {
|
||||
sign.setLine(0, "§8-§6*§8-");
|
||||
sign.setLine(1, "§cRestart");
|
||||
sign.setLine(2, "§c" + info.getName());
|
||||
sign.setLine(3, "§8-§6*§8-");
|
||||
sign.update();
|
||||
behind.setData(DyeColor.ORANGE.getWoolData());
|
||||
}else{
|
||||
sign.setLine(0, "§8-§6*§8-");
|
||||
sign.setLine(1, "§6" + info.getName());
|
||||
sign.setLine(2, "§e" + info.getOnlinePlayers() + "§8/§6" + info.getMaxPlayers());
|
||||
sign.setLine(3, "§8-§6*§8-");
|
||||
sign.update();
|
||||
behind.setData(DyeColor.GREEN.getWoolData());
|
||||
}
|
||||
}else {
|
||||
sign.setLine(0, "§8-§6*§8-");
|
||||
sign.setLine(1, "§4Offline");
|
||||
sign.setLine(2, "§e" + info.getName());
|
||||
sign.setLine(3, "§8-§6*§8-");
|
||||
sign.update();
|
||||
behind.setData(DyeColor.RED.getWoolData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return name;
|
||||
}
|
||||
}
|
102
src/main/java/eu/univento/lobby/utils/StatusSignManager.java
Normal file
102
src/main/java/eu/univento/lobby/utils/StatusSignManager.java
Normal file
@ -0,0 +1,102 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import eu.univento.lobby.Lobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class StatusSignManager {
|
||||
|
||||
static File file = new File("plugins/Core", "signs.yml");
|
||||
static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
static ArrayList<StatusSign> signs = new ArrayList<>();
|
||||
|
||||
public static StatusSign getSign(String name) {
|
||||
for(StatusSign sign : signs) {
|
||||
if(sign.getServerName().equals(name)) {
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static StatusSign getSign(Location loc) {
|
||||
for(StatusSign sign : signs) {
|
||||
if(sign.getLocation().equals(loc)) {
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isStatusSign(Location loc) {
|
||||
return getSign(loc) != null;
|
||||
}
|
||||
|
||||
public static void addSign(String name, Location loc) {
|
||||
StatusSign sign = new StatusSign(name, loc);
|
||||
signs.add(sign);
|
||||
}
|
||||
|
||||
public static void removeSign(String name) {
|
||||
signs.remove(getSign(name));
|
||||
}
|
||||
|
||||
public static void updateSigns() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Lobby.getInstance(), () -> signs.forEach(StatusSign::update), 20 * 20L, 5L);
|
||||
}
|
||||
|
||||
public static void saveSigns() {
|
||||
for(String key : cfg.getKeys(false)){
|
||||
cfg.set(key,null);
|
||||
}
|
||||
for(StatusSign sign : signs) {
|
||||
cfg.set("Sign." + sign.getServerName() + ".World", sign.getLocation().getWorld().getName());
|
||||
cfg.set("Sign." + sign.getServerName() + ".X", sign.getLocation().getX());
|
||||
cfg.set("Sign." + sign.getServerName() + ".Y", sign.getLocation().getY());
|
||||
cfg.set("Sign." + sign.getServerName() + ".Z", sign.getLocation().getZ());
|
||||
}
|
||||
try {
|
||||
cfg.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadSigns() {
|
||||
for(String key : cfg.getConfigurationSection("Sign").getKeys(false)) {
|
||||
String world = cfg.getString("Sign." + key + ".World");
|
||||
double x = cfg.getDouble("Sign." + key + ".X");
|
||||
double y = cfg.getDouble("Sign." + key + ".Y");
|
||||
double z = cfg.getDouble("Sign." + key + ".Z");
|
||||
Location loc = new Location(Bukkit.getWorld(world), x, y, z);
|
||||
addSign(key, loc);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadSign(String name) {
|
||||
if(cfg.contains("Sign." + name)) {
|
||||
String world = cfg.getString("Sign." + name + ".World");
|
||||
double x = cfg.getDouble("Sign." + name + ".X");
|
||||
double y = cfg.getDouble("Sign." + name + ".Y");
|
||||
double z = cfg.getDouble("Sign." + name + ".Z");
|
||||
Location loc = new Location(Bukkit.getWorld(world), x, y, z);
|
||||
if(!isStatusSign(loc)) {
|
||||
addSign(name, loc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
6
src/main/resources/plugin.yml
Normal file
6
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,6 @@
|
||||
main: eu.univento.lobby.Lobby
|
||||
name: Lobby
|
||||
version: 0.6
|
||||
author: joethei
|
||||
website: http://joethei.de
|
||||
depend: [Core]
|
Loading…
Reference in New Issue
Block a user