+ custom advancements

+ camera movements
+ custom items
+ attribute modification
+ easy gui creation
- cleanup
This commit is contained in:
BuildTools 2017-09-07 22:36:54 +02:00
parent 44100f10ad
commit b53720692f
186 changed files with 2491 additions and 3029 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/server
/build
Core.iml
run-server.sh

View File

@ -1,8 +0,0 @@
image: maven:3-jdk-8
build:
script: "mvn clean --settings .gitlab/settings.xml"
artifacts:
name: "Core"
paths:
- "target/*.jar"

View File

@ -1,18 +0,0 @@
<settings>
<servers>
<server>
<id>univentoEU</id>
<username>download</username>
<password>${env.password}</password>
</server>
</servers>
<mirrors>
<mirror>
<id>univentoEU</id>
<name>univentoEU Mirror Repo</name>
<url>http://play.univento.eu:8081/repository/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</settings>

View File

@ -20,25 +20,35 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.11.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.12.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.mojang:authlib:1.5.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" 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.17" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-all:5.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.11.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.11.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.11.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
<orderEntry type="library" name="Maven: co.aikar:taskchain-bukkit:3.4.3" level="project" />
<orderEntry type="library" name="Maven: co.aikar:taskchain-core:3.4.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.12.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.16" level="project" />
<orderEntry type="library" name="Maven: co.aikar:taskchain-bukkit:3.6.0" level="project" />
<orderEntry type="library" name="Maven: co.aikar:taskchain-core:3.6.0" level="project" />
<orderEntry type="library" name="Maven: pl.kacperduras:tasket-core:1.1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.6" level="project" />
<orderEntry type="library" name="Maven: pl.kacperduras:tasket-bukkit:1.1.0" level="project" />
<orderEntry type="library" name="Maven: io.github.lordakkarin:nbt:1.0" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:5.0.0.Alpha2" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:5.0.0.Alpha2" level="project" />
@ -64,6 +74,7 @@
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.12.1" level="project" />
<orderEntry type="library" name="Maven: com.github.mauricio:postgresql-async_2.12:0.2.21" level="project" />
<orderEntry type="library" name="Maven: com.github.mauricio:db-async-common_2.12:0.2.21" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.7" level="project" />
<orderEntry type="library" name="Maven: org.joda:joda-convert:1.8.1" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" name="Maven: com.github.mauricio:mysql-async_2.12:0.2.21" level="project" />
@ -73,17 +84,18 @@
<orderEntry type="library" name="Maven: org.mongodb:bson:3.4.1" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-rabbitmq-client:3.4.1" level="project" />
<orderEntry type="library" name="Maven: com.rabbitmq:amqp-client:3.6.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" name="Maven: com.github.TheHolyWaffle:TeamSpeak-3-Java-API:v1.0.13" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-web-client:3.4.2" level="project" />
<orderEntry type="library" name="Maven: io.vertx:vertx-web-common:3.4.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: io.sentry:sentry:1.2.2" level="project" />
<orderEntry type="library" name="Maven: com.github.ben-manes.caffeine:caffeine:2.5.2" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: com.github.nsp:JSkills:master-0.9.0-g8b333ec-15" level="project" />
<orderEntry type="library" name="Maven: org.ejml:simple:0.28" level="project" />
<orderEntry type="library" name="Maven: org.ejml:core:0.28" level="project" />
<orderEntry type="library" name="Maven: org.ejml:dense64:0.28" level="project" />
<orderEntry type="library" name="Maven: org.gitlab:java-gitlab-api:1.2.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.dytanic.cloudnet:cloudnet-api:2.0" level="project" />
</component>
</module>

58
pom.xml
View File

@ -13,7 +13,7 @@
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Univento.eu Core System</name>
<name>univento.eu Core System</name>
<build>
<plugins>
@ -53,61 +53,69 @@
</plugins>
</build>
<distributionManagement>
<repository>
<id>univentoEU</id>
<url>http://play.univento.eu:8081/repository/univento/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<version>1.12.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<version>1.12.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
<version>1.16.16</version>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>taskchain-bukkit</artifactId>
<version>3.4.3</version>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>pl.kacperduras</groupId>
<artifactId>tasket-core</artifactId>
<version>1.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>pl.kacperduras</groupId>
<artifactId>tasket-bukkit</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.github.lordakkarin</groupId>
<artifactId>nbt</artifactId>
<version>1.0</version>
</dependency>
<!--
<dependency>
<groupId>com.github.timtomtim7</groupId>
<artifactId>ChatMenuAPI</artifactId>
<version>v1.0.1</version>
</dependency>
-->
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Commons</artifactId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.dytanic.cloudnet</groupId>
<artifactId>cloudnet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,26 +1,43 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core;
import co.aikar.taskchain.BukkitTaskChainFactory;
import co.aikar.taskchain.TaskChainFactory;
import eu.univento.commons.Commons;
import eu.univento.commons.server.TPS;
import eu.univento.core.antihack.AntiHack;
import eu.univento.core.api.Config;
import eu.univento.core.api.advancement.CustomAdvancement;
import eu.univento.core.api.cloud.CloudApiWrapper;
import eu.univento.core.api.command.CommandFramework;
import eu.univento.core.api.effects.Blackscreen;
import eu.univento.core.api.events.MoveEventFilter;
import eu.univento.core.api.items.InventoryManager;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.commands.*;
import eu.univento.core.customitems.weapons.closecombat.CloseCombatEvents;
import eu.univento.core.listeners.*;
import eu.univento.core.listeners.cloud.Servers;
import io.sentry.Sentry;
import io.sentry.SentryClient;
import io.sentry.jul.SentryHandler;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Recipe;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import pl.kacperduras.tasket.Tasket;
import pl.kacperduras.tasket.bukkit.BukkitTasket;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.logging.Level;
/**
* main class
@ -33,6 +50,9 @@ public class Core extends JavaPlugin{
@Getter private static Core instance;
@Getter private static Commons commons;
@Getter private static CommandFramework commandFramework;
@Getter private static TaskChainFactory taskChainFactory;
@Getter private static Tasket tasket;
@Getter private static CloudApiWrapper cloudAPI;
public static String getNMSVersion() {
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
@ -52,7 +72,21 @@ public class Core extends JavaPlugin{
public void onEnable() {
commons = new Commons();
System.out.println("\n" +
SentryClient sentryClient = Sentry.init(commons.getConfigurationHandler().getString("Sentry.DSN.Core"));
try {
sentryClient.setServerName(InetAddress.getLocalHost().getHostName());
sentryClient.setEnvironment("");
sentryClient.setDist("Core");
sentryClient.setRelease("1.0.0");
} catch (UnknownHostException e) {
e.printStackTrace();
}
SentryHandler logHandler = new SentryHandler();
logHandler.setLevel(Level.INFO);
getLogger().addHandler(logHandler);
getLogger().info("\n" +
"\n" +
" \n" +
" \n" +
@ -85,20 +119,14 @@ public class Core extends JavaPlugin{
e.printStackTrace();
}
instance = this;
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new Commands(), this);
pm.registerEvents(new JoinQuit(), this);
pm.registerEvents(new Chat(), this);
pm.registerEvents(new Events(), this);
pm.registerEvents(new WeaponEvents(), this);
pm.registerEvents(new SpectatorEvents(), this);
pm.registerEvents(new MoveEventFilter(getServer()), this);
pm.registerEvents(new InventoryManager(), this);
pm.registerEvents(new WorkbenchEvents(), this);
pm.registerEvents(new NPCEvents(), this);
taskChainFactory = BukkitTaskChainFactory.create(this);
tasket = new BukkitTasket(this);
cloudAPI = new CloudApiWrapper();
commandFramework = new CommandFramework(this);
commandFramework.registerCommands(new AdminCommands());
commandFramework.registerCommands(new DevCommands());
commandFramework.registerCommands(new ModCommands());
commandFramework.registerCommands(new BuilderCommands());
@ -107,11 +135,25 @@ public class Core extends JavaPlugin{
commandFramework.registerCommands(new HologramCommands());
new AntiHack().registerListeners();
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new Commands(), this);
pm.registerEvents(new JoinQuit(), this);
pm.registerEvents(new Chat(), this);
pm.registerEvents(new Events(), this);
pm.registerEvents(new WeaponEvents(), this);
pm.registerEvents(new SpectatorEvents(), this);
pm.registerEvents(new MoveEventFilter(getServer()), this);
pm.registerEvents(new WorkbenchEvents(), this);
pm.registerEvents(new NPCEvents(), this);
pm.registerEvents(new CloseCombatEvents(), this);
new SetRank(this, "setrank", "sets the rank for other players", "sr");
PluginMessenger pluginMessenger = new PluginMessenger();
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", pluginMessenger);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "5zig_Set");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "5zig_Set", pluginMessenger);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "LABYMOD");
@ -124,7 +166,21 @@ public class Core extends JavaPlugin{
Servers.register();
Blackscreen.setupUtil(getInstance());
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> System.out.println("\n" +
for(CustomAdvancement advancement : CustomAdvancement.values()) advancement.load();
Iterator<Recipe> iterator = Bukkit.recipeIterator();
while(iterator.hasNext()) {
Recipe recipe = iterator.next();
//TODO: remove unwanted recipes and add own recipies
/*
if() {
iterator.remove();
}
*/
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> getLogger().info("\n" +
"\n" +
"\n" +
" _ _ \n" +
@ -137,7 +193,15 @@ public class Core extends JavaPlugin{
" \n" +
"\n"), 0L);
Bukkit.getScheduler().runTask(this, new TPS());
/*
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
String[] args = new SimpleDateFormat("HH:mm").format(new Date()).split(":");
long time = (Integer.parseInt(args[0])*1000) + (Integer.parseInt(args[1])*100/60) + 18000;
for(World world : Bukkit.getWorlds()) world.setTime(time);
}, 20L, 1L);
*/
}
@Override
@ -145,7 +209,7 @@ public class Core extends JavaPlugin{
Bukkit.getMessenger().unregisterIncomingPluginChannel(this);
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this);
System.out.println("\n" +
getLogger().info("\n" +
"\n" +
" \n" +
" \n" +
@ -172,7 +236,6 @@ public class Core extends JavaPlugin{
" \n" +
" \n" +
"\n");
//new PluginUpdater("Core").update();
commons.shutdown();
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack;
import eu.univento.commons.player.warn.WarnReason;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack;
public enum Hack {

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.core.api.events.MoveEventFilter;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import com.destroystokyo.paper.event.player.IllegalPacketEvent;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;

View File

@ -1,7 +1,13 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -22,5 +28,13 @@ public class SelfHit implements Listener {
e.setDamage(0.0D);
}
}
if(!e.isCancelled() && e.getEntity() instanceof Player && e.getDamager() instanceof Projectile) {
CustomPlayer p = (CustomPlayer) e.getEntity();
Projectile projectile = (Projectile) e.getDamager();
if(projectile.getShooter().equals(p)) {
e.setCancelled(true);
e.setDamage(0.0D);
}
}
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api;
import org.bukkit.Bukkit;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api;
import org.bukkit.Bukkit;
@ -14,6 +19,7 @@ import java.sql.SQLException;
* @author joethei
* @version 1.1
*/
@Deprecated
public class Config {
/**config file*/

View File

@ -1,15 +1,20 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import net.minecraft.server.v1_11_R1.EntityArmorStand;
import net.minecraft.server.v1_11_R1.EnumHand;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_12_R1.EntityArmorStand;
import net.minecraft.server.v1_12_R1.EnumHand;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;

View File

@ -1,177 +0,0 @@
package eu.univento.core.api;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
import java.io.File;
import java.util.List;
/**
* some utils you may need
*
* @author joethei
* @version 1.0
*/
public class Utils {
/**
* plays sound for all players
*
* @param s Sound
*/
public static void playSoundToAll(Sound s) {
for (Player all : Bukkit.getOnlinePlayers())
all.playSound(all.getLocation(), s, 3.0F, 3.0F);
}
/**
* plays effect for all players
*
* @param e Effect
*/
public static void playEffectToAll(Effect e) {
for (Player all : Bukkit.getOnlinePlayers())
all.playEffect(all.getLocation(), e, 3);
}
/**
* checks if server version is from spigot
*
* @return true/false
*/
public static boolean isSpigot() {
return Bukkit.getVersion().contains("Spigot");
}
/**
* deletes all folders and files in directory
*
* @param file File
*/
private static void deleteDir(File file) {
if (file.isDirectory()) {
if (file.list().length == 0) {
file.delete();
} else {
String[] files = file.list();
for (String tmp : files) {
File fileDelete = new File(file, tmp);
deleteDir(fileDelete);
}
if (file.list().length == 0)
file.delete();
}
} else
file.delete();
}
/**
* creates a random number
*
* @param low lowest possible value
* @param high highest possible value
* @return double
*/
public static double random(int low, int high) {
return Math.random() * (high - low) + low;
}
/**
* checks if player has empty inventory
*
* @param p Player
* @return true/false
*/
public static boolean hasEmptyInventory(Player p) {
for (ItemStack item : p.getInventory().getContents()) {
if ((item != null) && (item.getType() != Material.AIR))
return false;
}
for (ItemStack item : p.getInventory().getArmorContents()) {
if ((item != null) && (item.getType() != Material.AIR))
return false;
}
return true;
}
/**
* removes list of entity and counts them
*
* @param e Entity list
* @return Integer
*/
public static int removeEntitys(List<Entity> e) {
int i = 0;
for (Entity en : e) {
en.remove();
i++;
}
return i;
}
/**
* clears all potion effects from player
*
* @param player Player
*/
public static void clearPotionEffects(Player player) {
for (PotionEffect effect : player.getActivePotionEffects())
player.removePotionEffect(effect.getType());
}
/**
* calculates vector from one location to another
*
* @param from Location
* @param to Location
* @return Vector
*/
public static Vector calculateVector(Location from, Location to) {
Location b = to;
// calculate the distance between the locations (a => from || b => to)
double dX = from.getX() - b.getX();
double dY = from.getY() - b.getY();
double dZ = from.getZ() - b.getZ();
// -------------------------
// calculate the yaw
double yaw = Math.atan2(dZ, dX);
// -------------------------
// calculate the pitch
double pitch = Math.atan2(Math.sqrt(dZ * dZ + dX * dX), dY) + Math.PI;
// -------------------------
// calculate and create the new vector
double x = Math.sin(pitch) * Math.cos(yaw);
double y = Math.sin(pitch) * Math.sin(yaw);
double z = Math.cos(pitch);
// -------------------------
return new Vector(x, z, y);
}
/**
* restarts server
*/
public static void restart() {
Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getInstance(), () -> {
if(Core.getOnlinePlayers().size() != 0) {
for(CustomPlayer players : Core.getOnlinePlayers())
//TODO: add connect to optimal lobby server here
players.connectToServer("Lobby01");
}
Bukkit.spigot().restart();
}, 10 * 20L);
}
}

View File

@ -0,0 +1,179 @@
package eu.univento.core.api.advancement;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.Getter;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.util.List;
/**
* Created by charliej on 14/05/2017.
* Last modification DiscowZombie on 5/06/2017.
*/
@Getter
public class Advancement {
private NamespacedKey id;
private String title, parent, trigger, icon, description, background;
private boolean announce, toast;
private FrameType frame;
private List<ItemStack> items;
public Advancement(NamespacedKey id) {
this.id = id;
this.items = Lists.newArrayList();
this.announce = true;
this.toast = true;
}
public Advancement withIcon(String icon) {
this.icon = icon;
return this;
}
public String getDescription() {
return description;
}
public Advancement withDescription(String description) {
this.description = description;
return this;
}
public Advancement withBackground(String url) {
this.background = url;
return this;
}
public Advancement withBackground(AdvancementBackground background) {
this.background = background.getUrl();
return this;
}
public Advancement withTitle(String title) {
this.title = title;
return this;
}
public Advancement withParent(String parent) {
this.parent = parent;
return this;
}
public Advancement withTrigger(String trigger) {
this.trigger = trigger;
return this;
}
public Advancement withItem(ItemStack is) {
items.add(is);
return this;
}
public Advancement withFrame(FrameType frame) {
this.frame = frame;
return this;
}
public Advancement withAnnouncement(boolean announce){
this.announce = announce;
return this;
}
public Advancement withToast(boolean toast){
this.toast = toast;
return this;
}
public String getJSON() {
JSONObject json = new JSONObject();
JSONObject icon = new JSONObject();
icon.put("item", getIcon());
JSONObject display = new JSONObject();
display.put("icon", icon);
display.put("title", getTitle());
display.put("description", getDescription());
display.put("background", getBackground());
display.put("frame", getFrame().toString());
display.put("announce_to_chat", isAnnounce());
display.put("show_toast", isToast());
json.put("parent", getParent());
JSONObject criteria = new JSONObject();
JSONObject conditions = new JSONObject();
JSONObject elytra = new JSONObject();
JSONArray itemArray = new JSONArray();
JSONObject itemJSON = new JSONObject();
for(ItemStack i : getItems()) {
itemJSON.put("item", "minecraft:"+ i.getType().name().toLowerCase());
itemJSON.put("amount", i.getAmount());
itemArray.add(itemJSON);
}
/**
* Define each criteria, for each criteria in list,
* add items, trigger and conditions
*/
conditions.put("items", itemArray);
elytra.put("trigger", getTrigger());
elytra.put("conditions", conditions);
criteria.put("elytra", elytra);
json.put("criteria", criteria);
json.put("display", display);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
return gson.toJson(json);
}
public enum FrameType {
TASK("task"),
GOAL("goal"),
CHALLENGE("challenge");
private String name = "task";
FrameType(String name){
this.name = name;
}
public String toString(){
return name;
}
}
public enum AdvancementBackground{
ADVENTURE("minecraft:textures/gui/advancements/backgrounds/adventure.png"),
END("minecraft:textures/gui/advancements/backgrounds/end.png"),
HUSBANDRY("minecraft:textures/gui/advancements/backgrounds/husbandry.png"),
NETHER("minecraft:textures/gui/advancements/backgrounds/nether.png"),
STONE("minecraft:textures/gui/advancements/backgrounds/stone.png"),
fromNamespace(null);
@Getter private String url;
AdvancementBackground(String url){
this.url = url;
}
public void fromNamespace(String string) {
url = string;
}
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.advancement;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
/**
* @author joethei
* @version 1.0
*/
@Getter
public enum CustomAdvancement {
CHAT_T(new Advancement(new NamespacedKey(Core.getInstance(), "chat_t")).withTrigger("minecraft:impossible").withIcon("minecraft:apple")
.withBackground(Advancement.AdvancementBackground.ADVENTURE).withFrame(Advancement.FrameType.GOAL).withTitle("Chatten").withDescription("Schreibe etwas in den Chat").withItem(new ItemStack(Material.TNT)).withAnnouncement(false).withToast(true));
private Advancement advancement;
CustomAdvancement(Advancement advancement) {
this.advancement = advancement;
}
public void load() {
if(Bukkit.getAdvancement(advancement.getId()) == null)
Bukkit.getUnsafe().loadAdvancement(advancement.getId(), advancement.getJSON());
}
public void award(CustomPlayer p, String criteria) {
if(!p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).isDone()) {
p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).awardCriteria(criteria);
}
}
public void revoke(CustomPlayer p, String criteria) {
if(p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).isDone()) {
p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).revokeCriteria(criteria);
}
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.blocks;
import org.bukkit.*;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.blocks.banners;
import org.bukkit.DyeColor;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.blocks.banners;
import org.bukkit.block.Banner;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.blocks.banners;
/**

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.blocks.banners;
import org.bukkit.DyeColor;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.blocks.banners;
import org.bukkit.DyeColor;

View File

@ -1,50 +1,29 @@
package eu.univento.core.api.utils;
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Location;
package eu.univento.core.api.camera;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
class Camera {
/**
* @author CrushedPixel
* @version 1.0
*/
public class CameraUtil {
//TODO: add full functionality
private int time;
private ArrayList<CustomPlayer> players = new ArrayList<>();
private ArrayList<Location> locations = new ArrayList<>();
private double round(double unrounded, int precision) {
BigDecimal bigDecimal = new BigDecimal(unrounded);
BigDecimal rounded = bigDecimal.setScale(precision, 4);
public static double round(double unrounded, int precision) {
BigDecimal bd = new BigDecimal(unrounded);
BigDecimal rounded = bd.setScale(precision, 4);
return rounded.doubleValue();
}
private double positionDifference(Location loc1, Location loc2) {
double x1 = loc1.getX();
double y1 = loc1.getY();
double z1 = loc1.getZ();
double x2 = loc2.getX();
double y2 = loc2.getY();
double z2 = loc2.getZ();
double x = x2 - x1;
if (x < 0.0D)
x = -x;
double z = z2 - z1;
if (z < 0.0D)
z = -z;
double xz = Math.hypot(x, z);
double y = y2 - y1;
if (y < 0.0D)
y = -y;
return Math.hypot(xz, y);
}
private Date parseTimeString(String timeString) throws ParseException {
public static int parseTimeString(String timeString) throws java.text.ParseException {
Date length;
try {
SimpleDateFormat formatter = new SimpleDateFormat("mm'm'ss's'");
@ -83,18 +62,11 @@ class Camera {
}
}
}
return length;
}
private void load() {
Calendar cal = GregorianCalendar.getInstance();
cal.setTime(length);
}
public Camera(String name) {
load();
}
public void start(CustomPlayer p) {
return (cal.get(Calendar.MINUTE) * 60 + cal.get(Calendar.SECOND)) * 20;
}
}

View File

@ -0,0 +1,141 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.camera;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author Redstoneore, joethei
* @version 1.0
*/
public class Traveller {
private CustomPlayer player;
@Getter private List<Location> points = new ArrayList<>();
@Getter private int time;
private boolean traveling = false;
private String finished;
private String failed;
public Traveller(CustomPlayer player, String route) {
this.player = player;
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("routes", new JsonObject().put("route", route), null, event -> {
finished = event.result().getString("finished");
failed = event.result().getString("failed");
time = event.result().getInteger("time");
JsonArray locations = event.result().getJsonArray("locations");
for(int i = 0; i > locations.size(); i++) {
JsonObject json = locations.getJsonObject(i);
points.add(new Location(Bukkit.getWorld(json.getString("world")), json.getDouble("X"), json.getDouble("Y"), json.getDouble("Z"), json.getFloat("Yaw"), json.getFloat("Pitch")));
}
});
}
public void travel() {
if(points.size() == 0) {
player.sendMessage(failed);
return;
}
List<Double> diffs = new ArrayList<>();
List<Integer> travelTimes = new ArrayList<>();
Double totalDiff = 0.0D;
for (int i = 0; i < points.size() - 1; i++) {
Location start = points.get(i);
Location next = points.get(i + 1);
Double diff = start.distance(next);
totalDiff += diff;
diffs.add(diff);
}
for (Double d : diffs) {
travelTimes.add((int) (d / totalDiff * time));
}
final List<Location> tps = new ArrayList<>();
UUID world = player.getLocation().getWorld().getUID();
for (int i = 0; i < points.size() - 1; i++) {
Location thisPoint = points.get(i);
Location nextPoint = points.get(i + 1);
int travelPoint = travelTimes.get(i);
double moveX = nextPoint.getX() - thisPoint.getX();
double moveY = nextPoint.getY() - thisPoint.getY();
double moveZ = nextPoint.getZ() - thisPoint.getZ();
double movePitch = nextPoint.getPitch() - thisPoint.getPitch();
double yawDiff = Math.abs(nextPoint.getYaw() - thisPoint.getYaw());
double c;
if (yawDiff <= 180.0) {
if (thisPoint.getYaw() < nextPoint.getYaw()) {
c = yawDiff;
} else {
c = -yawDiff;
}
} else if (thisPoint.getYaw() < nextPoint.getYaw()) {
c = -(360.0 - yawDiff);
} else {
c = 360.0 - yawDiff;
}
double d = c / travelPoint;
for (int x = 0; x < travelPoint; x++) {
Location l = new Location(Bukkit.getWorld(world), thisPoint.getX() + moveX / travelPoint * x, thisPoint.getY() + moveY / travelPoint * x, thisPoint.getZ() + moveZ / travelPoint * x, (float) (thisPoint.getYaw() + d * x), (float) (thisPoint.getPitch() + movePitch / travelPoint * x));
tps.add(l);
}
}
try {
player.teleport(tps.get(0));
Bukkit.getScheduler().runTaskLater(Core.getInstance(), new Runnable() {
private int ticks = 0;
public void run() {
if (this.ticks < tps.size()) {
player.teleport(tps.get(this.ticks));
// check if they cancelled
if (traveling) {
Bukkit.getScheduler().runTaskLater(Core.getInstance(), this, 1L);
}
this.ticks += 1;
} else {
traveling = false;
player.sendMessage(finished);
}
}
}, 1L);
} catch (Exception e) {
player.sendMessage(failed);
e.printStackTrace();
}
}
//TODO: GitHub repo to code after: https://github.com/redstone/RCameraStudio
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.cloud;
import de.dytanic.cloudnet.api.CloudAPI;
import de.dytanic.cloudnet.lib.server.ServerState;
import de.dytanic.cloudnet.lib.server.info.ServerInfo;
import eu.univento.commons.server.ServerType;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import lombok.Getter;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
/**
* @author joethei
* @version 1.0
*/
public class CloudApiWrapper {
@Getter private CloudAPI cloudAPI;
public CloudApiWrapper() {
cloudAPI = CloudAPI.getInstance();
}
public CompletableFuture<String> getOptimalServer(CustomPlayer player, ServerType type) {
CompletableFuture<String> future = new CompletableFuture<>();
Collection<ServerInfo> servers = cloudAPI.getServers(type.getName());
Core.getCommons().getPartyManager().isInParty(player.getDatabasePlayer()).whenComplete(((bool, throwable) -> servers.forEach(serverInfo -> {
if (serverInfo.isOnline() && serverInfo.getServerState() == ServerState.LOBBY) {
if (bool) {
Core.getCommons().getPartyManager().getParty(player.getDatabasePlayer()).whenComplete((party, throwable1) -> {
if (serverInfo.getOnlineCount() < serverInfo.getMaxPlayers() - party.getMembers().size()) {
future.complete(serverInfo.getServiceId().getServerId());
}
});
} else {
if (serverInfo.getOnlineCount() < serverInfo.getMaxPlayers() - 1) {
future.complete(serverInfo.getServiceId().getServerId());
}
}
}
})));
return future;
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.command;
import org.apache.commons.lang3.Validate;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.command;
import org.bukkit.command.CommandSender;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.command;
import eu.univento.commons.player.rank.Group;
@ -28,17 +33,17 @@ public @interface Command {
*
* @return
*/
public String name();
String name();
/**
* Gets the required permission of the command
*
* @return
*/
public Rank rank() default Rank.Player;
public Group group() default Group.None;
Rank rank() default Rank.Player;
Group group() default Group.None;
public ServerType serverType() default ServerType.NONE;
ServerType serverType() default ServerType.NONE;
/**
* The message sent to the player when they do not have permission to
@ -46,7 +51,7 @@ public @interface Command {
*
* @return
*/
public String notAllowed() default "§cYou do not have permission to perform that action";
String notAllowed() default "§cYou do not have permission to perform that action";
/**
* A list of alternate names that the command is executed under. See
@ -54,26 +59,26 @@ public @interface Command {
*
* @return
*/
public String[] aliases() default {};
String[] aliases() default {};
/**
* The description that will appear in /help of the command
*
* @return
*/
public String description() default "";
String description() default "";
/**
* The usage that will appear in /help (commandname)
*
* @return
*/
public String usage() default "";
String usage() default "";
/**
* Whether or not the command is available to players only
*
* @return
*/
public boolean inGameOnly() default false;
boolean inGameOnly() default false;
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.command;
import eu.univento.core.api.player.CustomPlayer;
@ -19,17 +24,14 @@ public class CommandArgs {
private String label;
private String[] args;
protected CommandArgs(CommandSender sender, org.bukkit.command.Command command, String label, String[] args,
int subCommand) {
protected CommandArgs(CommandSender sender, org.bukkit.command.Command command, String label, String[] args, int subCommand) {
String[] modArgs = new String[args.length - subCommand];
for (int i = 0; i < args.length - subCommand; i++) {
modArgs[i] = args[i + subCommand];
}
System.arraycopy(args, subCommand, modArgs, 0, args.length - subCommand);
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
buffer.append(label);
for (int x = 0; x < subCommand; x++) {
buffer.append("." + args[x]);
buffer.append(".").append(args[x]);
}
String cmdLabel = buffer.toString();
this.sender = sender;
@ -41,7 +43,7 @@ public class CommandArgs {
/**
* Gets the command sender
*
* @return
* @return CommandSender
*/
public CommandSender getSender() {
return sender;
@ -50,7 +52,7 @@ public class CommandArgs {
/**
* Gets the original command object
*
* @return
* @return Command
*/
public org.bukkit.command.Command getCommand() {
return command;
@ -70,7 +72,7 @@ public class CommandArgs {
* label was test.subcommand and the arguments were subcommand foo foo, it
* would only return 'foo foo' because 'subcommand' is part of the command
*
* @return
* @return String[]
*/
public String[] getArgs() {
return args;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.command;
import eu.univento.commons.player.rank.Group;
@ -26,7 +31,7 @@ import java.util.*;
* Command Framework - CommandFramework <br>
* The main command framework class used for controlling the framework.
*
* @author minnymin3
* @author minnymin3, joethei
*/
public class CommandFramework implements CommandExecutor {

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.command;
import java.lang.annotation.ElementType;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems;
/**

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems;
import lombok.Builder;
import lombok.Getter;
import org.bukkit.inventory.ItemStack;
/**
* @author joethei
* @version 1.0
*/
@Getter
@Builder
public class CustomItem {
private ItemStack itemStack;
private Rarity rarity;
private CustomItemActions actions;
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems;
import eu.univento.core.api.customitems.actions.InteractBlockAction;
import eu.univento.core.api.customitems.actions.InteractPlayerAction;
import eu.univento.core.api.customitems.actions.PlayerHitAction;
import lombok.Builder;
import lombok.Getter;
/**
* @author joethei
* @version 1.0
*/
@Getter
@Builder
public class CustomItemActions {
private PlayerHitAction playerHitAction;
private InteractBlockAction interactBlockAction;
private InteractPlayerAction interactPlayerAction;
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems;
/**

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.items.attribute.Attribute;
import eu.univento.core.api.items.attribute.ItemSlot;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
/**
* @author joethei
* @version 1.0
*/
@Getter
public enum CustomItems {
Thiefs_Dagger(CustomItem.builder().itemStack(new ItemBuilder(Material.DIAMOND_SWORD).attribute(Attribute.ATTACK_SPEED, "ThiefsDaggerSpeed", ItemSlot.MAIN_HAND, 0, 0.0D)
.name(Rarity.Epic.getColor() + "Dolch des Diebes").build()).rarity(Rarity.Epic).actions(CustomItemActions.builder()
.playerHitAction((player, hitPlayer, damage, cause) -> player.sendMessage("Du hast " + hitPlayer.getDisplayName() + " geschlagen"))
.interactBlockAction((player, action, block, blockFace) -> player.sendMessage("Du hast auf einen " + block.getType().name() + " geklickt"))
.interactPlayerAction((player, interactPlayer) -> player.sendMessage("Du hast auf den Spieler " + interactPlayer.getDisplayName() + " geklickt"))
.build()).build());
private CustomItem item;
CustomItems(CustomItem item) {
this.item = item;
}
public static CustomItem valueOf(ItemStack item) {
return null;
/*
for (CustomItems customItems : values()) {
if (item.equals(customItems.getItem().getItemStack())) return customItems.getItem();
}
return null;
*/
}
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author joethei
* @version 1.0
*/
@AllArgsConstructor
public enum Rarity {
Normal("§7", "Normal"),
Rare("§6", "Selten"),
Epic("§5", "Episch"),
Legendary("§f", "Legendär"),
Secret("§8", "Geheim"),
Unique("§c", "Einzigartig");
@Getter private String color;
@Getter private String name;
}

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems.actions;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.block.Action;
/**
* @author joethei
* @version 1.0
*/
public interface InteractBlockAction {
void onInteract(CustomPlayer player, Action action, Block block, BlockFace blockFace);
}

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems.actions;
import eu.univento.core.api.player.CustomPlayer;
/**
* @author joethei
* @version 1.0
*/
public interface InteractPlayerAction {
void onInteract(CustomPlayer player, CustomPlayer interactPlayer);
}

View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems.actions;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.event.entity.EntityDamageEvent;
/**
* @author joethei
* @version 0.1
*/
public interface PlayerHitAction {
void onHit(CustomPlayer player, CustomPlayer hitPlayer, double damage, EntityDamageEvent.DamageCause cause);
}

View File

@ -1,38 +1,25 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems.swords;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.inventory.ItemStack;
/**
* @author joethei
* @version 0.1
*/
public class CustomSword{
public interface CustomSword{
public CustomPlayer player;
void primaryAttack();
public CustomSword(CustomPlayer player) {
this.player = player;
CustomSwordManager.add(this);
}
public void primaryAttack() {
}
public void secondaryAttack() {
}
public void sneakingAttack() {
}
public ItemStack getItem() {
return null;
}
public void addItem() {
player.getInventory().addItem(getItem());
}
void secondaryAttack();
void sneakingAttack();
ItemStack getItem();
void addItem();
}

View File

@ -1,9 +1,15 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems.swords;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author joethei
@ -11,23 +17,24 @@ import java.util.List;
*/
public class CustomSwordManager {
private static List<CustomSword> swords = new LinkedList<>();
private static Map<CustomPlayer, CustomSword> swords = new LinkedHashMap<>();
public static CustomSword valueOf(ItemStack item) {
for(CustomSword sword : swords)
for(CustomSword sword : swords.values())
if(sword.getItem().equals(item)) return sword;
return null;
}
public static void add(CustomSword sword) {
swords.add(sword);
public static void add(CustomPlayer p, CustomSword sword) {
swords.put(p, sword);
}
public static void remove(CustomSword sword) {
swords.remove(sword);
public static void remove(CustomPlayer p, CustomSword sword) {
if(swords.get(p).equals(sword))
swords.remove(p);
}
public static boolean contains(CustomSword sword) {
return swords.contains(sword);
return swords.containsValue(sword);
}
}

View File

@ -1,35 +1,26 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.effects;
import eu.univento.core.api.player.CustomPlayer;
import net.minecraft.server.v1_12_R1.PacketPlayOutGameStateChange;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author janhektor
* @author janhektor, joethei
*/
public class Blackscreen {
private static Object packetObject;
private static Class<?> packetClass;
private static Map<UUID, Integer> ticksLeft = new HashMap<>();
static {
String path = Bukkit.getServer().getClass().getPackage().getName();
String VERSION = path.substring(path.lastIndexOf(".") + 1, path.length());
try {
packetClass = Class.forName("net.minecraft.server." + VERSION + ".Packet");
Class<?> packetGameStateClass = Class.forName("net.minecraft.server." + VERSION + ".PacketPlayOutGameStateChange");
packetObject = packetGameStateClass.getConstructor(new Class[]{Integer.TYPE, Float.TYPE}).newInstance(4, 0);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void setupUtil(Plugin instance) {
Bukkit.getScheduler().runTaskTimer(instance, () -> {
for (UUID uuid : Blackscreen.ticksLeft.keySet()) {
@ -46,20 +37,10 @@ public class Blackscreen {
, 0L, 2);
}
private static void sendPacket(Player p) {
try {
Object nmsPlayer = p.getClass().getMethod("getHandle", new Class[0]).invoke(p);
Field playerConnectionField = nmsPlayer.getClass().getField("playerConnection");
Object pConnection = playerConnectionField.get(nmsPlayer);
Method sendPacket = pConnection.getClass().getMethod("sendPacket", packetClass);
sendPacket.invoke(pConnection, packetObject);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void setBlack(Player p, int seconds) {
public static void setBlack(CustomPlayer p, int seconds) {
ticksLeft.put(p.getUniqueId(), seconds * 20);
sendPacket(p);
PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(4, 0);
p.sendPacket(packet);
}
}

View File

@ -1,10 +1,15 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.effects;
import eu.univento.core.Core;
import net.minecraft.server.v1_11_R1.EnumParticle;
import net.minecraft.server.v1_11_R1.PacketPlayOutWorldParticles;
import net.minecraft.server.v1_12_R1.EnumParticle;
import net.minecraft.server.v1_12_R1.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
/**

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.effects;
import eu.univento.core.api.utils.reflection.ReflectionUtils;

View File

@ -1,7 +1,9 @@
package eu.univento.core.api.effects;
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
import java.util.ArrayList;
import java.util.List;
package eu.univento.core.api.effects;
import eu.univento.core.api.events.BorderLeaveEvent;
import org.bukkit.Bukkit;
@ -12,6 +14,9 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
/**
* @author Janhektor
* @version 1.0

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.entity;
import org.bukkit.Location;
@ -12,33 +17,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* The original thread that this code belongs to can be found here:
* https://www.spigotmc.org/threads/armor-stand-animator-class.152863/
* MIT License
Copyright (c) 2016 Bram Stout
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
* @author Bram
*
*/
public class ArmorStandAnimator {
/**

View File

@ -1,13 +1,18 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.entity;
import eu.univento.core.Core;
import net.minecraft.server.v1_11_R1.EntityLiving;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.EntityLiving;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -20,7 +25,7 @@ import java.lang.reflect.Field;
public class EntityModifier {
private static org.bukkit.entity.Entity entity;
private static CraftEntity craftentity;
private static net.minecraft.server.v1_11_R1.Entity entityS;
private static net.minecraft.server.v1_12_R1.Entity entityS;
private static int scheduler;
private static Plugin plugin = Core.getInstance();
private static Player player = null;
@ -100,7 +105,7 @@ public class EntityModifier {
public Builder setInvulnerable(boolean invulnerable) {
try {
Field invulnerableField = net.minecraft.server.v1_11_R1.Entity.class.getDeclaredField("invulnerable");
Field invulnerableField = net.minecraft.server.v1_12_R1.Entity.class.getDeclaredField("invulnerable");
invulnerableField.setAccessible(true);
invulnerableField.setBoolean(EntityModifier.entityS, invulnerable);
} catch (Exception ex) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,12 +1,12 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.entity.pathfinding;
/**
* @author joethei
* @author Adamk11s
* @version 1.0
*/
public enum PathingResult {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.events;
import org.bukkit.entity.Player;

View File

@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class HologramClickEvent extends PlayerInteractEntityEvent{

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.events;
import org.bukkit.Location;

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.game;
import eu.univento.core.api.player.CustomPlayer;
@ -7,7 +12,7 @@ import java.util.List;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class PlayerManager {

View File

@ -1,59 +1,51 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.game;
import eu.univento.core.api.player.CustomPlayer;
import lombok.Getter;
import org.bukkit.Bukkit;
import java.util.ArrayList;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
@Getter
public class Team {
private final ArrayList<CustomPlayer> players = new ArrayList<>();
private ArrayList<CustomPlayer> players = new ArrayList<>();
private final String name;
private final String prefix;
private final org.bukkit.scoreboard.Team team;
private final org.bukkit.scoreboard.Team scoreboardTeam;
public Team(String name, String prefix) {
this.name = name;
this.prefix = prefix;
if(Bukkit.getScoreboardManager().getMainScoreboard().getTeam(name) == null) {
team = Bukkit.getScoreboardManager().getMainScoreboard().registerNewTeam(name);
scoreboardTeam = Bukkit.getScoreboardManager().getMainScoreboard().registerNewTeam(name);
}else{
team = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(name);
scoreboardTeam = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(name);
}
team.setPrefix(prefix);
scoreboardTeam.setPrefix(prefix);
}
public void addPlayer(CustomPlayer p) {
players.add(p);
team.addEntry(p.getName());
scoreboardTeam.addEntry(p.getName());
}
public void removePlayer(CustomPlayer p) {
players.remove(p);
team.removeEntry(p.getName());
scoreboardTeam.removeEntry(p.getName());
}
public boolean isPlayer(CustomPlayer p) {
return players.contains(p);
}
public String getName() {
return name;
}
public String getPrefix() {
return prefix;
}
public ArrayList<CustomPlayer> getPlayers() {
return players;
}
public org.bukkit.scoreboard.Team getScoreboardTeam() {
return team;
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.game;
import eu.univento.core.api.player.CustomPlayer;
@ -6,7 +11,7 @@ import java.util.ArrayList;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class TeamManager {

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.gui;
import eu.univento.core.api.player.CustomPlayer;
/**
* @author joethei
* @version 1.0
*/
public interface Action {
void onClick(CustomPlayer player);
}

View File

@ -1,9 +1,14 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.gui;
import eu.univento.core.Core;
import net.minecraft.server.v1_11_R1.*;
import net.minecraft.server.v1_12_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.gui;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
/**
* @author joethei
* @version 1.0
*/
public class InventoryGUI implements Listener{
private CustomPlayer player;
private Inventory inventory;
private Map<Integer, Action> actions;
public InventoryGUI(CustomPlayer player, int size, String title) {
this.player = player;
inventory = Bukkit.createInventory(player, size, title);
actions = new HashMap<>();
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
}
public void addItem(int slot, ItemStack item, Action action) {
inventory.setItem(slot, item);
actions.put(slot, action);
}
public void open() {
player.openInventory(inventory);
}
@EventHandler
private void onClick(InventoryClickEvent e) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
if(e.getInventory().getTitle().equals(inventory.getTitle())) {
if(actions.get(e.getSlot()) != null) {
actions.get(e.getSlot()).onClick(p);
}
}
}
}

View File

@ -1,21 +0,0 @@
package eu.univento.core.api.gui;
import eu.univento.core.api.player.CustomPlayer;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.PacketPlayOutOpenSignEditor;
/**
* @author joethei
* @version 0.1
*/
class SignInput {
public static void openSignInput(CustomPlayer p) {
EntityPlayer player = p.getHandle();
BlockPosition bp = new BlockPosition(p.getHandle());
PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(bp);
player.playerConnection.sendPacket(packet);
SignInputHandler.injectNetty(p);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/

View File

@ -1,4 +1,9 @@
package eu.univento.core.api.gui;
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.gui.sign;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@ -16,7 +21,6 @@ class PlayerSignInputEvent extends PlayerEvent{
public PlayerSignInputEvent(Player p, String[] lines) {
super(p);
this.lines = lines;
SignInputHandler.ejectNetty(p);
}
@Override

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.gui.sign;
import eu.univento.core.api.player.CustomPlayer;
import lombok.Getter;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.PacketPlayOutOpenSignEditor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
/**
* @author joethei
* @version 1.0
*/
class SignInput implements Listener{
@Getter private CustomPlayer player;
@Getter private String[] lines;
public SignInput(CustomPlayer player, String[] lines) {
this.player = player;
this.lines = lines;
}
private static Map<UUID, CompletableFuture<SignInput>> futures = new HashMap<>();
public static CompletableFuture<SignInput> openSignInput(CustomPlayer p) {
CompletableFuture<SignInput> future = new CompletableFuture<>();
p.sendPacket(new PacketPlayOutOpenSignEditor(new BlockPosition(p.getHandle())));
SignInputHandler.injectNetty(p);
futures.put(p.getUniqueId(), future);
return future;
}
@EventHandler
public void onSignInput(PlayerSignInputEvent e) {
if(futures.get(e.getPlayer().getUniqueId()) != null) {
futures.get(e.getPlayer().getUniqueId()).complete(new SignInput(CustomPlayer.getPlayer(e.getPlayer()), e.getLines()));
SignInputHandler.ejectNetty(e.getPlayer());
}
}
/*
public static void openSignInput(CustomPlayer p) {
EntityPlayer player = p.getHandle();
BlockPosition bp = new BlockPosition(p.getHandle());
PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(bp);
player.playerConnection.sendPacket(packet);
SignInputHandler.injectNetty(p);
}
*/
}

View File

@ -1,13 +1,18 @@
package eu.univento.core.api.gui;
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.gui.sign;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.minecraft.server.v1_11_R1.NetworkManager;
import net.minecraft.server.v1_11_R1.Packet;
import net.minecraft.server.v1_11_R1.PacketPlayInUpdateSign;
import net.minecraft.server.v1_12_R1.NetworkManager;
import net.minecraft.server.v1_12_R1.Packet;
import net.minecraft.server.v1_12_R1.PacketPlayInUpdateSign;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
@ -22,15 +27,15 @@ class SignInputHandler {
private static Field channelField = null;
static{
for(Field filed : NetworkManager.class.getDeclaredFields()) {
for(Field field : NetworkManager.class.getDeclaredFields()) {
if(channelField.getType().isAssignableFrom(Channel.class)) {
channelField = filed;
channelField = field;
break;
}
}
}
public static void injectNetty(final Player player) {
static void injectNetty(final Player player) {
try {
Channel channel = (Channel) channelField.get(((CraftPlayer) player).getHandle().playerConnection.networkManager);
if (channel != null) {
@ -52,7 +57,7 @@ class SignInputHandler {
}
}
public static void ejectNetty(Player player) {
static void ejectNetty(Player player) {
try {
Channel channel = (Channel) channelField.get(((CraftPlayer) player).getHandle().playerConnection.networkManager);
if (channel != null) {

View File

@ -9,13 +9,13 @@ import eu.univento.core.Core;
import eu.univento.core.api.events.HologramClickEvent;
import eu.univento.core.api.player.CustomPlayer;
import lombok.Getter;
import net.minecraft.server.v1_11_R1.EntityArmorStand;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_12_R1.EntityArmorStand;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.entity.ArmorStand;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View File

@ -11,7 +11,7 @@ import java.util.HashMap;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class HologramManager {

View File

@ -1,238 +0,0 @@
package eu.univento.core.api.items;
import eu.univento.core.api.items.events.NamedCloseEvent;
import eu.univento.core.api.items.events.PageCloseEvent;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.reflect.Array;
import java.util.HashMap;
/**
* @author joethei
* @version 0.1
*/
public abstract class ClickInventory<E>{
protected static JavaPlugin plugin;
protected Inventory currentInventory;
protected boolean inventoryInUse;
private boolean modifiable;
private CustomPlayer player;
private boolean playerInventoryUsed;
private ItemStack[] previousContents;
private String inventoryName;
private HashMap<Object, Object> savedData;
protected void saveContents() {
this.previousContents = this.getPlayer().getInventory().getContents().clone();
}
public Object getData(final Object key) {
return this.savedData.get(key);
}
public ClickInventory setData(final Object key, final Object obj) {
if (obj == null) {
this.savedData.remove(key);
}
else {
this.savedData.put(key, obj);
}
return this;
}
public ClickInventory(String inventoryName, final CustomPlayer player) {
this.savedData = new HashMap<>();
this.player = player;
if (inventoryName == null) {
inventoryName = this.getClass().getSimpleName();
}
this.inventoryName = inventoryName;
}
public String getName() {
return this.inventoryName;
}
public ClickInventory setPlayerInventory() {
if (!this.isInUse()) {
this.playerInventoryUsed = true;
}
return this;
}
public void closeInventory() {
this.closeInventory(true);
}
protected void onInventoryDrag(final InventoryDragEvent event) {
if (!this.isModifiable()) {
event.getRawSlots().stream().filter(this::checkInMenu).forEachOrdered(slot -> event.setCancelled(true));
}
}
protected boolean checkInMenu(int rawSlot) {
if (this.isPlayerInventory()) {
if (this.getPlayer().getOpenInventory().getTopInventory().getHolder() != this.getPlayer()) {
rawSlot -= this.getPlayer().getOpenInventory().getTopInventory().getSize();
}
return rawSlot >= 0 && rawSlot < this.currentInventory.getSize();
}
return rawSlot < this.currentInventory.getSize();
}
public boolean isPlayerInventory() {
return this.playerInventoryUsed;
}
protected abstract void onInventoryClick(final InventoryClickEvent e);
private void closeInventory(final boolean forceClose, final boolean restoreInventory) {
InventoryManager.removeInventory(this);
this.inventoryInUse = false;
if (this.getPlayer().hasMetadata(this.getClass().getSimpleName())) {
final E[] invs = (E[])this.getPlayer().getMetadata(this.getClass().getSimpleName()).get(0).value();
if (invs[isPlayerInventory() ? 1 : 0] == this)
invs[isPlayerInventory() ? 1 : 0] = null;
}
if (this instanceof NamedInventory) {
Bukkit.getPluginManager().callEvent(new NamedCloseEvent((NamedInventory) this));
}
if (this instanceof PageInventory) {
Bukkit.getPluginManager().callEvent(new PageCloseEvent((PageInventory) this));
}
if (forceClose && (!this.isPlayerInventory() || this.getPlayer().getOpenInventory().getTopInventory().equals(this.currentInventory))) {
this.getPlayer().closeInventory();
}
if (this.isPlayerInventory() && restoreInventory) {
this.getPlayer().getInventory().clear();
this.getPlayer().getInventory().setContents(this.previousContents);
Bukkit.getScheduler().scheduleSyncDelayedTask(ClickInventory.plugin, () -> ClickInventory.this.getPlayer().updateInventory());
}
}
public void closeInventory(final boolean forceClose) {
this.closeInventory(forceClose, true);
}
public ItemStack getItem(int slot) {
if (this.isPlayerInventory()) {
slot += 9;
if (slot >= 36) {
slot -= 36;
}
}
if (this.currentInventory != null && this.currentInventory.getSize() > slot) {
return this.currentInventory.getItem(slot);
}
return null;
}
protected void setItems(final ItemStack[] items) {
if (this.isPlayerInventory()) {
for (int i = 0; i < items.length; ++i) {
this.setItem(i, items[i]);
}
}
else {
this.currentInventory.setContents(items);
}
}
protected void setItem(int slot, final ItemStack item) {
if (this.isPlayerInventory()) {
slot += 9;
if (slot >= 36) {
slot -= 36;
}
}
this.currentInventory.setItem(slot, item);
}
public CustomPlayer getPlayer() {
return this.player;
}
public boolean isInUse() {
return this.inventoryInUse;
}
public boolean isModifiable() {
return this.modifiable;
}
protected void openInventory() {
final boolean isSwitchingInventory = this.isInUse();
ItemStack heldItem = null;
final ClickInventory[] invs = new ClickInventory[2];
for (final String inv : new String[] { "PageInventory", "NamedInventory", "AnvilInventory" }) {
if (this.getPlayer().hasMetadata(inv)) {
final E[] invss = (E[])(this.getPlayer().hasMetadata(inv) ? this.getPlayer().getMetadata(inv).get(0).value() : null);
if (invss != null) {
for (int i = 0; i < 2; ++i) {
if (invss[i] != null) {
invs[i] = (ClickInventory)invss[i];
}
}
}
}
}
if (!this.isPlayerInventory()) {
this.inventoryInUse = false;
boolean previous = false;
if (invs[1] != null) {
previous = invs[1].inventoryInUse;
invs[1].inventoryInUse = false;
}
if (isSwitchingInventory) {
heldItem = this.getPlayer().getItemOnCursor();
this.getPlayer().setItemOnCursor(new ItemStack(Material.AIR));
}
if (invs[1] != null) {
invs[1].inventoryInUse = previous;
}
}
else {
this.getPlayer().updateInventory();
if (!isSwitchingInventory && this.getPlayer().getOpenInventory().getTopInventory().getHolder() == this.getPlayer()) {
this.getPlayer().openInventory(Bukkit.createInventory(null, 0, this.getTitle()));
}
}
if (!isSwitchingInventory) {
InventoryManager.addInventory(this);
final int slot = this.isPlayerInventory() ? 1 : 0;
if (invs[slot] != null) {
if (invs[slot].inventoryInUse) {
invs[slot].closeInventory(false, false);
}
if (this.isPlayerInventory()) {
this.previousContents = invs[1].previousContents;
}
}
final E[] inv2 = (E[])(this.getPlayer().hasMetadata(this.getClass().getSimpleName()) ? this.getPlayer().getMetadata(this.getClass().getSimpleName()).get(0).value() : ((Object[]) Array.newInstance(this.getClass(), 2)));
inv2[slot] = (E)this;
this.getPlayer().setMetadata(this.getClass().getSimpleName(), new FixedMetadataValue(ClickInventory.plugin, inv2));
}
else if (heldItem != null && heldItem.getType() != Material.AIR) {
this.getPlayer().setItemOnCursor(heldItem);
this.getPlayer().updateInventory();
}
this.inventoryInUse = true;
}
public abstract String getTitle();
public void setModifiable(final boolean modifiable) {
this.modifiable = modifiable;
}
public abstract void setTitle(final String p0);
}

View File

@ -1,94 +0,0 @@
package eu.univento.core.api.items;
import eu.univento.core.api.player.CustomPlayer;
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.InventoryDragEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* @author joethei
* @version 0.1
*/
public class InventoryManager implements Listener{
private static List<ClickInventory> inventoryList;
public static List<ClickInventory> getInventoryList() {
return inventoryList;
}
public static void addInventory(ClickInventory inventory) {
inventoryList.add(inventory);
}
public static void removeInventory(ClickInventory inventory) {
inventoryList.remove(inventory);
}
public static NamedInventory[] getNamedInventories(final CustomPlayer p) {
if(!p.hasMetadata("NamedInventory")) return new NamedInventory[2];
return ((NamedInventory[])p.getMetadata("NamedInventory").get(0).value()).clone();
}
public static NamedInventory getNamedInventory(final CustomPlayer p) {
return getNamedInventories(p)[0];
}
public static PageInventory[] getPageInventories(final CustomPlayer p) {
if(!p.hasMetadata("PageInventory")) return new PageInventory[2];
return ((PageInventory[])p.getMetadata("PageInventory").get(0).value()).clone();
}
public static PageInventory getPageInventory(CustomPlayer p) {
return getPageInventories(p)[0];
}
public static ItemStack[] generateEmptyPage(int size) {
size = (int) (Math.ceil(size / 9.0) * 9);
return new ItemStack[Math.min(54, size)];
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
int i = 0;
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
if(e.getInventory() instanceof ClickInventory) {
for(ClickInventory inventory : inventoryList) {
if(inventory.getPlayer() == p)
inventory.onInventoryClick(e);
if(i++ == 1) break;
}
}
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
int i = 0;
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
for(ClickInventory inventory : inventoryList) {
if(inventory.getPlayer() == p) {
inventory.onInventoryDrag(e);
if(i++ == 1) break;
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
int i = 0;
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(inventoryList == null) return;
for(ClickInventory inventory : inventoryList) {
if(inventory.getPlayer() == p) {
if(inventory.isInUse()) inventory.closeInventory(false);
if(i ++ == 1) break;
}
}
}
}

View File

@ -1,5 +1,19 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.items;
import com.mojang.authlib.GameProfile;
import eu.univento.commons.player.language.MessageConstant;
import eu.univento.commons.player.user.UserInformation;
import eu.univento.core.api.items.attribute.Attribute;
import eu.univento.core.api.items.attribute.AttributeModifier;
import eu.univento.core.api.items.attribute.ItemAttributes;
import eu.univento.core.api.items.attribute.ItemSlot;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.utils.GameProfileBuilder;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -10,6 +24,8 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.MaterialData;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
/**
@ -28,8 +44,9 @@ import java.util.*;
public class ItemBuilder {
private final ItemStack item;
private final ItemMeta itemM;
private CustomPlayer player;
private ItemStack item;
private ItemMeta meta;
/**
* Init item chainable via given Material parameter.
@ -40,29 +57,20 @@ public class ItemBuilder {
*/
public ItemBuilder(final Material itemType) {
item = new ItemStack(itemType);
itemM = item.getItemMeta();
meta = item.getItemMeta();
}
/**
* Init item chainable via given ItemStack parameter.
* Init item chainable via given Material parameter.
*
* @param itemStack the {@link ItemStack} to initialize the instance with.
* @param itemType the {@link Material} to initiate the instance with.
*
* @since 1.0
*/
public ItemBuilder(final ItemStack itemStack){
item = itemStack;
itemM = item.getItemMeta();
}
/**
* Init the item chainable with no defined Material/ItemStack
*
* @since 1.0
*/
public ItemBuilder(){
item = new ItemStack(Material.AIR);
itemM = item.getItemMeta();
public ItemBuilder(final CustomPlayer player, final Material itemType) {
this.player = player;
item = new ItemStack(itemType);
meta = item.getItemMeta();
}
/**
@ -74,7 +82,7 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder type(final Material material) {
make().setType(material);
item.setType(material);
return this;
}
@ -87,7 +95,7 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder amount(final Integer itemAmt) {
make().setAmount(itemAmt);
item.setAmount(itemAmt);
return this;
}
@ -100,8 +108,15 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder name(final String name) {
meta().setDisplayName(name);
make().setItemMeta(meta());
meta.setDisplayName(name);
item.setItemMeta(meta);
return this;
}
public ItemBuilder name(final MessageConstant messageConstant) {
if(player == null) return this;
meta.setDisplayName(player.getDatabasePlayer().getLanguage().getMessage(messageConstant));
item.setItemMeta(meta);
return this;
}
@ -114,11 +129,11 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder lore(final String lore) {
List<String> lores = meta().getLore();
List<String> lores = meta.getLore();
if(lores == null){lores = new ArrayList<>();}
lores.add(lore);
meta().setLore(lores);
make().setItemMeta(meta());
meta.setLore(lores);
item.setItemMeta(meta);
return this;
}
@ -131,16 +146,16 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder lores(final String[] lores) {
List<String> loresList = meta().getLore();
if(loresList == null){loresList = new ArrayList<>();}
List<String> loresList = meta.getLore();
if(loresList == null) loresList = new ArrayList<>();
else{loresList.clear();}
Collections.addAll(loresList, lores);
meta().setLore(loresList);
meta.setLore(loresList);
return this;
}
public ItemBuilder durability(short durability) {
make().setDurability(durability);
item.setDurability(durability);
return this;
}
@ -154,7 +169,7 @@ public class ItemBuilder {
*/
@SuppressWarnings("deprecation")
public ItemBuilder data(final int data) {
make().setData(new MaterialData(make().getType(), (byte)data));
item.setData(new MaterialData(build().getType(), (byte)data));
return this;
}
@ -169,7 +184,7 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder enchantment(final Enchantment enchantment, final int level) {
make().addUnsafeEnchantment(enchantment, level);
item.addUnsafeEnchantment(enchantment, level);
return this;
}
@ -182,7 +197,7 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder enchantment(final Enchantment enchantment) {
make().addUnsafeEnchantment(enchantment, 1);
item.addUnsafeEnchantment(enchantment, 1);
return this;
}
@ -197,9 +212,9 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder enchantments(final Enchantment[] enchantments, final int level) {
make().getEnchantments().clear();
item.getEnchantments().clear();
for(Enchantment enchantment : enchantments){
make().addUnsafeEnchantment(enchantment, level);
item.addUnsafeEnchantment(enchantment, level);
}
return this;
}
@ -213,9 +228,9 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder enchantments(final Enchantment[] enchantments) {
make().getEnchantments().clear();
item.getEnchantments().clear();
for(Enchantment enchantment : enchantments){
make().addUnsafeEnchantment(enchantment, 1);
item.addUnsafeEnchantment(enchantment, 1);
}
return this;
}
@ -229,7 +244,7 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder clearEnchantment(final Enchantment enchantment) {
Map<Enchantment, Integer> itemEnchantments = make().getEnchantments();
Map<Enchantment, Integer> itemEnchantments = item.getEnchantments();
itemEnchantments.keySet().stream().filter(enchantmentC -> enchantment == enchantmentC).forEach(itemEnchantments::remove);
return this;
}
@ -241,12 +256,19 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder clearEnchantments() {
make().getEnchantments().clear();
item.getEnchantments().clear();
return this;
}
public ItemBuilder attribute(Attribute attribute, String name, ItemSlot slot, int operation, double amount) {
ItemAttributes attributes = new ItemAttributes();
attributes.addModifier(new AttributeModifier(attribute, name, slot, operation, amount, UUID.randomUUID()));
this.item = attributes.apply(this.item);
return this;
}
public ItemBuilder glow() {
meta().addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
meta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
return this;
}
@ -259,10 +281,10 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder clearLore(final String lore) {
if(meta().getLore().contains(lore)){
meta().getLore().remove(lore);
if(meta.getLore().contains(lore)){
meta.getLore().remove(lore);
}
make().setItemMeta(meta());
item.setItemMeta(meta);
return this;
}
@ -273,8 +295,8 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder clearLores() {
meta().getLore().clear();
make().setItemMeta(meta());
meta.getLore().clear();
item.setItemMeta(meta);
return this;
}
@ -287,13 +309,13 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder color(final Color color) {
if(make().getType() == Material.LEATHER_HELMET
|| make().getType() == Material.LEATHER_CHESTPLATE
|| make().getType() == Material.LEATHER_LEGGINGS
|| make().getType() == Material.LEATHER_BOOTS ){
LeatherArmorMeta meta = (LeatherArmorMeta) meta();
if(item.getType() == Material.LEATHER_HELMET
|| item.getType() == Material.LEATHER_CHESTPLATE
|| item.getType() == Material.LEATHER_LEGGINGS
|| item.getType() == Material.LEATHER_BOOTS ){
LeatherArmorMeta meta = (LeatherArmorMeta) this.meta;
meta.setColor(color);
make().setItemMeta(meta);
item.setItemMeta(meta);
}
return this;
}
@ -305,13 +327,13 @@ public class ItemBuilder {
* @since 1.0
*/
public ItemBuilder clearColor() {
if(make().getType() == Material.LEATHER_HELMET
|| make().getType() == Material.LEATHER_CHESTPLATE
|| make().getType() == Material.LEATHER_LEGGINGS
|| make().getType() == Material.LEATHER_BOOTS ){
LeatherArmorMeta meta = (LeatherArmorMeta) meta();
if(item.getType() == Material.LEATHER_HELMET
|| item.getType() == Material.LEATHER_CHESTPLATE
|| item.getType() == Material.LEATHER_LEGGINGS
|| item.getType() == Material.LEATHER_BOOTS ){
LeatherArmorMeta meta = (LeatherArmorMeta) this.meta;
meta.setColor(null);
make().setItemMeta(meta);
item.setItemMeta(meta);
}
return this;
}
@ -319,17 +341,32 @@ public class ItemBuilder {
/**
* Sets the skullOwner {@link SkullMeta} of the current SKULL_ITEM {@link Material} type {@link ItemStack}
*
* @param name the {@link String} value to set the SkullOwner meta to for the SKULL_ITEM Material type ItemStack.
* @param uuid the {@link String} value to set the SkullOwner meta to for the SKULL_ITEM Material type ItemStack.
*
* @return the current instance for chainable application
* @since 1.0
*/
public ItemBuilder skullOwner(final String name){
if(make().getType() == Material.SKULL_ITEM && make().getDurability() == (byte) 3){
SkullMeta skullMeta = (SkullMeta) meta();
skullMeta.setOwner(name);
make().setItemMeta(meta());
public ItemBuilder skullOwner(final UUID uuid) {
if(item.getType() == Material.SKULL_ITEM && item.getDurability() == (byte) 3){
SkullMeta skullMeta = (SkullMeta) meta;
try {
GameProfile profile = GameProfileBuilder.fetch(uuid);
Field field = skullMeta.getClass().getDeclaredField("profile");
field.setAccessible(true);
field.set(skullMeta, profile);
item.setItemMeta(meta);
} catch (IOException | NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
return this;
}
public ItemBuilder skullOwner(final String name) {
UserInformation.get(name).whenComplete((userInformation, throwable) -> skullOwner(userInformation.getUuid()));
return this;
}
@ -339,7 +376,7 @@ public class ItemBuilder {
* @return the ItemMeta of the ItemStack.
*/
private ItemMeta meta() {
return itemM;
return meta;
}
/**
@ -347,7 +384,7 @@ public class ItemBuilder {
*
* @return the ItemStack of the ItemBuilder instance.
*/
public ItemStack make(){
public ItemStack build() {
item.getItemMeta().addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
return item;
}

View File

@ -1,205 +0,0 @@
package eu.univento.core.api.items;
import eu.univento.core.api.items.events.NamedPageClickEvent;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/**
* @author joethei
* @version 0.1
*/
public class NamedInventory extends ClickInventory{
protected Page currentPage;
protected HashMap<ItemStack, Page> pageDirectors;
protected HashMap<Page, ItemStack[]> pages;
public NamedInventory(final CustomPlayer player) {
this(null, player);
}
public NamedInventory(final CustomPlayer player, final boolean dymanicInventory) {
this(player);
}
public NamedInventory(final String inventoryName, final CustomPlayer player) {
super(inventoryName, player);
this.pageDirectors = new HashMap<>();
this.pages = new HashMap<>();
}
public Page getCurrentPage() {
return this.currentPage;
}
public ItemStack[] getPage(final Page page) {
return this.pages.get(page);
}
public Page getPage(final String pageName) {
for (final Page page : this.pages.keySet()) {
if (page.getPageName().equals(pageName)) {
return page;
}
}
return null;
}
public Page getPageLink(final ItemStack item) {
return this.pageDirectors.get(item);
}
public HashMap<Page, ItemStack[]> getPages() {
return this.pages;
}
@Override
public String getTitle() {
return this.currentPage.getPageDisplayTitle();
}
public void linkPage(final ItemStack item, final Page page) {
this.pageDirectors.put(item, page);
}
public void linkPage(final ItemStack item, final String pageName) {
final Page page = this.getPage(pageName);
if (page != null) {
this.linkPage(item, page);
}
}
@Override
protected void onInventoryClick(final InventoryClickEvent event) {
final ItemStack item = event.getCurrentItem();
if (this.checkInMenu(event.getRawSlot())) {
if (item != null && this.pageDirectors.containsKey(item)) {
event.setCancelled(true);
this.setPage(this.pageDirectors.get(item));
return;
}
int slot = event.getSlot();
if (this.isPlayerInventory()) {
slot -= 9;
if (slot < 0) {
slot += 36;
}
}
final NamedPageClickEvent itemClickEvent = new NamedPageClickEvent(this, this.currentPage, slot, event);
if (!this.isModifiable()) {
itemClickEvent.setCancelled(true);
}
Bukkit.getPluginManager().callEvent(itemClickEvent);
if (itemClickEvent.isCancelled()) {
event.setCancelled(true);
}
}
else if (!this.isModifiable() && event.isShiftClick() && item != null && item.getType() != Material.AIR) {
for (int slot = 0; slot < this.currentInventory.getSize(); ++slot) {
final ItemStack invItem = this.currentInventory.getItem(slot);
if (invItem == null || invItem.getType() == Material.AIR || (invItem.isSimilar(item) && invItem.getAmount() < invItem.getMaxStackSize())) {
event.setCancelled(true);
break;
}
}
}
}
public void openInventory() {
if (this.isInUse()) {
return;
}
if (this.isPlayerInventory()) {
this.saveContents();
}
if (this.currentPage == null) {
if (this.pages.isEmpty()) {
this.pages.put(new Page("Inventory"), new ItemStack[0]);
}
this.currentPage = this.pages.keySet().iterator().next();
}
if (this.currentInventory == null) {
final ItemStack[] pageItems = this.getPage(this.currentPage);
if (this.isPlayerInventory()) {
this.currentInventory = this.getPlayer().getInventory();
}
else {
this.currentInventory = Bukkit.createInventory(null, pageItems.length, this.getTitle());
}
this.setItems(pageItems);
}
this.openInventory();
}
public void removePage(final Page page) {
this.pages.remove(page);
}
public void setPage(final Page newPage) {
if (this.pages.containsKey(newPage)) {
final Page oldPage = this.currentPage;
this.currentPage = newPage;
if (this.isInUse()) {
final ItemStack[] pageItems = this.pages.get(this.currentPage);
if (!this.isPlayerInventory() && (pageItems.length != this.currentInventory.getSize() || !oldPage.getPageDisplayTitle().equals(this.getTitle()))) {
(this.currentInventory = Bukkit.createInventory(null, pageItems.length, this.getTitle())).setContents(pageItems);
this.openInventory();
}
else {
this.setItems(pageItems);
}
}
}
}
public void setPage(final Page page, ItemStack... items) {
if (items.length % 9 != 0) {
items = Arrays.copyOf(items, (int)(Math.ceil(items.length / 9.0) * 9.0));
}
if (items.length > (this.isPlayerInventory() ? 36 : 54)) {
throw new RuntimeException("A inventory size of " + items.length + " was passed when the max is " + (this.isPlayerInventory() ? 36 : 54));
}
this.pages.put(page, items);
if (this.currentPage == null) {
this.currentPage = page;
}
else if (this.currentPage.equals(page)) {
this.setPage(page);
}
}
public void setPage(final Page page, final List<ItemStack> items) {
this.setPage(page, (ItemStack[])items.toArray(new ItemStack[items.size()]));
}
public void setPage(final String pageName) {
final Page page = this.getPage(pageName);
if (page != null) {
this.setPage(page);
}
}
@Override
public NamedInventory setPlayerInventory() {
super.setPlayerInventory();
return this;
}
@Override
public void setTitle(final String newTitle) {
if (newTitle != null && this.getCurrentPage() != null && !this.getCurrentPage().getPageDisplayTitle().equals(newTitle)) {
this.setPage(new Page(this.getCurrentPage().getPageName(), newTitle), this.getPage(this.getCurrentPage()));
}
}
public void unlinkPage(final ItemStack item) {
this.pageDirectors.remove(item);
}
}

View File

@ -1,59 +0,0 @@
package eu.univento.core.api.items;
/**
* @author joethei
* @version 0.1
*/
public class Page {
private String pageName;
private String pageTitle;
public Page(final String pageName) {
this(pageName, pageName);
}
public Page(final String pageName, final String pageDisplayTitle) {
this.pageTitle = pageDisplayTitle;
this.pageName = pageName;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
final Page other = (Page)obj;
return this.getPageName().equals(other.getPageName());
}
public String getPageDisplayTitle() {
return this.pageTitle;
}
public String getPageName() {
return this.pageName;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = 31 * result + this.getPageName().hashCode();
return result;
}
public void setDisplayTitle(final String newTitle) {
this.pageTitle = newTitle;
}
@Override
public String toString() {
return "Page[Name=" + this.getPageName() + ", Title=" + this.getPageDisplayTitle() + "]";
}
}

View File

@ -1,328 +0,0 @@
package eu.univento.core.api.items;
import eu.univento.core.api.items.events.PagesClickEvent;
import eu.univento.core.api.items.events.PagesTurnEvent;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
/**
* @author joethei
* @version 0.1
*/
public class PageInventory extends ClickInventory{
protected ItemStack backAPage;
protected ItemStack forwardsAPage;
protected ItemStack exitInventory;
protected int currentPage;
protected boolean dynamicInventorySize;
private int inventorySize;
protected boolean pageDisplayedInTitle;
protected HashMap<Integer, ItemStack[]> pages;
protected String title;
private String titleFormat;
public PageInventory(final CustomPlayer player) {
this(null, player);
}
public PageInventory(final CustomPlayer player, final boolean dynamicInventory) {
this(null, player, dynamicInventory);
}
public PageInventory(final CustomPlayer player, final int inventorySize) {
this(null, player, inventorySize);
}
public PageInventory(final String inventoryName, final CustomPlayer player) {
super(inventoryName, player);
this.dynamicInventorySize = true;
this.inventorySize = 54;
this.pages = new HashMap<>();
this.title = "Inventory";
this.titleFormat = "%Title% - Page %Page%";
}
public PageInventory(final String inventoryName, final CustomPlayer player, final boolean dynamicInventorySize) {
super(inventoryName, player);
this.dynamicInventorySize = true;
this.inventorySize = 54;
this.pages = new HashMap<>();
this.title = "Inventory";
this.titleFormat = "%Title% - Page %Page%";
this.dynamicInventorySize = dynamicInventorySize;
}
public PageInventory(final String inventoryName, final CustomPlayer player, final int inventorySize) {
super(inventoryName, player);
this.dynamicInventorySize = true;
this.inventorySize = 54;
this.pages = new HashMap<>();
this.title = "Inventory";
this.titleFormat = "%Title% - Page %Page%";
this.inventorySize = Math.min(54, (int)Math.ceil(inventorySize / 9.0) * 9);
this.dynamicInventorySize = false;
this.pages.put(0, new ItemStack[0]);
}
public ItemStack getExitInventory() {
return this.exitInventory;
}
public void setExitInventory(final ItemStack item) {
this.exitInventory = item;
}
public ItemStack getBackPage() {
if (this.backAPage == null) {
this.backAPage = new ItemBuilder(Material.SIGN).name("Zurück").make();
}
return this.backAPage;
}
public int getCurrentPage() {
return this.currentPage;
}
public ItemStack getForwardsPage() {
if (this.forwardsAPage == null) {
this.forwardsAPage = new ItemBuilder(Material.SIGN).name("Vorwärts").make();
}
return this.forwardsAPage;
}
@Override
public String getTitle() {
return this.getPageTitle();
}
public ItemStack[] getPage(final int pageNumber) {
if (this.pages.containsKey(pageNumber)) {
return this.pages.get(pageNumber);
}
return null;
}
public HashMap<Integer, ItemStack[]> getPages() {
return this.pages;
}
protected String getPageTitle() {
return this.isPageDisplayedInTitle() ? this.titleFormat.replace("%Title%", this.title).replace("%Page%", this.getCurrentPage() + 1 + "") : this.title;
}
public boolean isPageDisplayedInTitle() {
return this.pageDisplayedInTitle;
}
@Override
protected void onInventoryClick(final InventoryClickEvent event) {
final ItemStack item = event.getCurrentItem();
if (this.checkInMenu(event.getRawSlot())) {
if (item != null) {
int newPage = 0;
if (item.equals(this.getBackPage())) {
newPage = -1;
}
else if (item.equals(this.getForwardsPage())) {
newPage = 1;
}
if (newPage != 0) {
final PagesTurnEvent newEvent = new PagesTurnEvent(this, event.getSlot(), event, this.getCurrentPage() + newPage);
Bukkit.getPluginManager().callEvent(newEvent);
if (!newEvent.isCancelled()) {
this.setPage(this.getCurrentPage() + newPage);
}
event.setCancelled(true);
return;
}
}
int slot = event.getSlot();
if (this.isPlayerInventory()) {
slot -= 9;
if (slot < 0) {
slot += 36;
}
}
final PagesClickEvent itemClickEvent = new PagesClickEvent(this, slot, event);
if (!this.isModifiable()) {
itemClickEvent.setCancelled(true);
}
Bukkit.getPluginManager().callEvent(itemClickEvent);
if (itemClickEvent.isCancelled()) {
event.setCancelled(true);
}
}
else if (!this.isModifiable() && event.isShiftClick() && item != null && item.getType() != Material.AIR) {
for (int slot = 0; slot < this.currentInventory.getSize(); ++slot) {
final ItemStack invItem = this.currentInventory.getItem(slot);
if (invItem == null || invItem.getType() == Material.AIR || (invItem.isSimilar(item) && item.getAmount() < item.getMaxStackSize())) {
event.setCancelled(true);
break;
}
}
}
}
public void openInventory() {
if (this.isInUse()) {
return;
}
this.saveContents();
final ItemStack[] pageItems = this.getItemsForPage();
if (this.currentInventory == null) {
if (this.isPlayerInventory()) {
this.currentInventory = this.getPlayer().getInventory();
}
else {
this.currentInventory = Bukkit.createInventory(null, pageItems.length, this.getPageTitle());
}
}
this.setItems(pageItems);
this.openInventory();
}
private ItemStack[] getItemsForPage() {
ItemStack[] pageItems = this.pages.get(Math.max(this.getCurrentPage(), 0));
int pageSize = pageItems.length;
if (this.pages.size() > 1 || this.getExitInventory() != null) {
pageSize += 9;
}
if (!this.dynamicInventorySize || this.isPlayerInventory()) {
pageSize = (this.isPlayerInventory() ? 36 : this.inventorySize);
}
else {
pageSize = (pageSize + 8) / 9 * 9;
}
pageItems = Arrays.copyOf(pageItems, pageSize);
if (this.getCurrentPage() > 0 || this.getExitInventory() != null) {
pageItems[pageItems.length - 9] = ((this.getCurrentPage() == 0) ? this.getExitInventory() : this.getBackPage());
}
if (this.pages.size() - 1 > this.getCurrentPage()) {
pageItems[pageItems.length - 1] = this.getForwardsPage();
}
return pageItems;
}
public void setBackPage(final ItemStack newBack) {
this.backAPage = newBack;
}
public void setForwardsPage(final ItemStack newForwards) {
this.forwardsAPage = newForwards;
}
public ArrayList<ItemStack> getItems() {
final ArrayList<ItemStack> items = new ArrayList<>();
for (int i = 0; i < this.pages.size(); ++i) {
final ItemStack[] itemArray = this.pages.get(i);
for (int a = 0; a < itemArray.length - ((this.pages.size() > 1) ? 9 : 0); ++a) {
items.add(itemArray[a]);
}
}
return items;
}
public void setPage(final int newPage) {
if (this.pages.containsKey(newPage)) {
this.currentPage = newPage;
if (this.isInUse()) {
final ItemStack[] pageItems = this.getItemsForPage();
if (!this.isPlayerInventory() && (pageItems.length != this.currentInventory.getSize() || !this.currentInventory.getTitle().equalsIgnoreCase(this.getPageTitle()))) {
(this.currentInventory = Bukkit.createInventory(null, pageItems.length, this.getPageTitle())).setContents(pageItems);
this.openInventory();
}
else {
this.setItems(pageItems);
}
}
}
}
public void setPageDisplayedInTitle(final boolean displayPage) {
if (this.isPageDisplayedInTitle() != displayPage) {
this.pageDisplayedInTitle = displayPage;
if (this.isInUse()) {
this.setPage(this.getCurrentPage());
}
}
}
public void setPageDisplayTitleFormat(final String titleFormat) {
this.titleFormat = titleFormat;
if (this.isInUse()) {
this.setPage(this.getCurrentPage());
}
}
public void setPages(final ArrayList<ItemStack> allItems) {
this.setPages((ItemStack[])allItems.toArray(new ItemStack[allItems.size()]));
}
public void setPages(final ItemStack... allItems) {
this.pages.clear();
int invPage = 0;
final boolean usePages = this.getExitInventory() != null || allItems.length > this.inventorySize;
ItemStack[] items = null;
int currentSlot = 0;
final int baseSize = this.isPlayerInventory() ? 36 : this.inventorySize;
for (int currentItem = 0; currentItem < allItems.length; ++currentItem) {
if (items == null) {
int newSize = allItems.length - currentItem;
if (usePages && newSize + 9 > baseSize) {
newSize = baseSize - 9;
}
else if (newSize > baseSize) {
newSize = baseSize;
}
items = new ItemStack[newSize];
}
final ItemStack item = allItems[currentItem];
items[currentSlot++] = item;
if (currentSlot == items.length) {
this.pages.put(invPage, items);
++invPage;
currentSlot = 0;
items = null;
}
}
if (this.pages.keySet().size() < this.getCurrentPage()) {
this.currentPage = this.pages.keySet().size() - 1;
}
if (allItems.length == 0) {
int size = this.isPlayerInventory() ? 36 : this.inventorySize;
if (!this.isPlayerInventory() && this.dynamicInventorySize) {
size = 9;
}
items = InventoryManager.generateEmptyPage(size);
if (this.getExitInventory() != null) {
items[0] = this.getExitInventory();
}
this.pages.put(0, items);
}
this.setPage(this.getCurrentPage());
}
@Override
public PageInventory setPlayerInventory() {
super.setPlayerInventory();
return this;
}
@Override
public void setTitle(final String newTitle) {
if (!this.getTitle().equals(newTitle)) {
this.title = newTitle;
if (this.isInUse()) {
this.setPage(this.getCurrentPage());
}
}
}
}

View File

@ -1,58 +0,0 @@
package eu.univento.core.api.items;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
/**
* @author joethei
* @version 0.1
*/
public class PageLayout {
private static String empty = "X";
private static String full = "O";
private int invSize;
private ArrayList<Integer> size;
public static void setStringFormat(final String noItem, final String aItem) {
PageLayout.empty = noItem;
PageLayout.full = aItem;
}
public PageLayout(final String... strings) {
this.invSize = 0;
this.size = new ArrayList<Integer>();
this.invSize = strings.length * 9;
for (int slot = 0; slot < strings.length * 9; ++slot) {
final String string = strings[(int)Math.floor(slot / 9.0)];
if (string.length() != 9) {
throw new RuntimeException("String is not a length of 9. String is a length of " + string.length() + ". " + string);
}
final String letter = string.substring(slot % 9, slot % 9 + 1);
if (!letter.equalsIgnoreCase(PageLayout.empty)) {
if (!letter.equalsIgnoreCase(PageLayout.full)) {
throw new RuntimeException("Unrecognised value " + letter);
}
this.size.add(slot);
}
}
}
public ItemStack[] generate(final ArrayList<ItemStack> items) {
return this.generate((ItemStack[])items.toArray(new ItemStack[items.size()]));
}
public ItemStack[] generate(final ItemStack... items) {
final ItemStack[] itemArray = new ItemStack[this.invSize];
for (int i = 0; i < this.size.size(); ++i) {
if (i < items.length) {
final ItemStack itemToInsert = items[i];
if (itemToInsert != null) {
itemArray[this.size.get(i)] = itemToInsert.clone();
}
}
}
return itemArray;
}
}

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.items;
import java.util.ArrayList;

View File

@ -1,120 +0,0 @@
package eu.univento.core.api.items;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
public class ScrollingInventory implements Listener{
private final Inventory inv;
private final ArrayList<ItemStack> items = new ArrayList<>();
private ItemStack next;
private ItemStack back;
private int side = 0;
private int rows = 4;
private final CustomPlayer player;
public ScrollingInventory(CustomPlayer player, String name){
this.player = player;
int var = 1;
for(int i = 0; i > 27 * 9; i = i + 9)
var++;
inv = Bukkit.createInventory(player, var * 9 + 9, name);
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
this.rows = 27;
side = 0;
}
public void addItem(ItemStack item){
items.add(item);
}
public void removeItem(ItemStack item){
items.remove(item);
}
private void clearItems(){
for(ItemStack is : inv.getContents()){
inv.remove(is);
}
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent e){
if(e.getInventory().equals(inv)){
if(inv.getViewers().size() == 0)
HandlerList.unregisterAll(this);
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e){
if(e.getInventory().equals(inv)){
e.setCancelled(true);
if(e.getCurrentItem() != null){
if(e.getCurrentItem().equals(back)) {
setDisplaySide(side - 1);
}
else if(e.getCurrentItem().equals(next)) {
setDisplaySide(side + 1);
}
}
}
}
private void setDisplaySide(int i) {
clearItems();
if(items.size() - side * rows > (side + 1) * rows)
setNext();
if(side > 0)
setBack();
int from = side * rows;
int to = (side + 1) * rows;
int a = 0;
for(ItemStack is : items.subList(from, (to > items.size() ? items.size() : to))){
inv.setItem(a, is);
a++;
}
}
private void setNext(){
if(next == null){
next = new ItemStack(Material.TIPPED_ARROW);
PotionMeta nextMeta = (PotionMeta) next.getItemMeta();
nextMeta.addCustomEffect(new PotionEffect(PotionEffectType.LUCK, 5 * 20, 1), true);
nextMeta.setDisplayName("§aVor");
next.setItemMeta(nextMeta);
}
inv.setItem(inv.getSize()-2, next);
}
private void setBack(){
if(back == null){
back = new ItemStack(Material.TIPPED_ARROW);
PotionMeta backMeta = (PotionMeta) back.getItemMeta();
backMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEAL, 5 * 20, 1), true);
backMeta.setDisplayName("§cZurück");
back.setItemMeta(backMeta);
}
inv.setItem(inv.getSize()-8, next);
}
public void openInventory(){
setDisplaySide(0);
player.openInventory(inv);
}
public void setNextItem(ItemStack item){
next = item;
setNext();
}
public void setBackItem(ItemStack item){
back = item;
setBack();
}
}

Some files were not shown because too many files have changed in this diff Show More