Merged in development (pull request #2)

merge development with master
This commit is contained in:
Johannes Theiner 2016-05-08 11:05:48 +02:00
commit 419e604778
22 changed files with 465 additions and 475 deletions

View File

@ -16,7 +16,7 @@
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-async:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:bson:3.2.2" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.31.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:5.0.0.Alpha2" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
@ -25,11 +25,23 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.9.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent.npclib:api:1.8.5" level="project" />
<orderEntry type="library" name="Maven: org.spigotmc:spigot:1.9-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20140107" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent:reflectionhelper:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent:packetlistenerapi:2.5.2" level="project" />
<orderEntry type="library" name="Maven: org.mcstats.bukkit:metrics-lite:R7" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent.packetlistener:api:3.3.5" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent.nicknamer:api:3.7.2" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent:apimanager:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent:mc-wrappers:1.0.1" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent.data:api:0.1.0" level="project" />
<orderEntry type="library" name="Maven: org.inventivetalent.data:api-gson:0.1.0" level="project" />
</component>
</module>

16
pom.xml
View File

@ -17,7 +17,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -50,13 +49,15 @@
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>inventive-repo</id>
<url>https://repo.inventivetalent.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
@ -68,12 +69,12 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-async</artifactId>
<version>3.2.2</version>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.31.Final</version>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
@ -98,6 +99,11 @@
<version>1.9.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.inventivetalent.npclib</groupId>
<artifactId>api</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
</project>

View File

@ -103,10 +103,6 @@ public class Core extends JavaPlugin{
new Stats(this, "stats", "statistics");
new Nick(this, "nick", "nick");
}
if(!ServerSettings.isBuild()) {
new Build(this, "build", "build", "b");
pm.registerEvents(new Blocks(), this);
}
AntiHack.registerListeners();
new RunAs(this, "RunAs", "runas");
@ -121,8 +117,12 @@ public class Core extends JavaPlugin{
log(Level.INFO, "registered all commands");
PluginMessenger pluginMessenger = new PluginMessenger();
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "LABYMOD");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "WDL|INIT", pluginMessenger);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "WDL|CONTROL");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "PERMISSIONSREPL", pluginMessenger);
Blackscreen.setupUtil(getInstance());
mongoDB = new MongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.User"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
@ -133,6 +133,11 @@ public class Core extends JavaPlugin{
@Override
public void onDisable() {
mongoDB.getClient().close();
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this, "LABYMOD");
Bukkit.getMessenger().unregisterIncomingPluginChannel(this, "WDL_INIT");
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this, "WDL|CONTROL");
log(Level.INFO, "Plugin stoped");
}

View File

@ -29,7 +29,7 @@ public class AntiHack implements Listener{
pm.registerEvents(new Regen(), Core.getInstance());
pm.registerEvents(new AutoRespawn(), Core.getInstance());
pm.registerEvents(new FastPlace(), Core.getInstance());
pm.registerEvents(new KillAura(), Core.getInstance());
//pm.registerEvents(new KillAura(), Core.getInstance());
for(Map.Entry<CustomPlayer, Integer> entry : AutoClicker.clicks.entrySet()) {
if(entry.getValue() > 16) {

View File

@ -11,7 +11,8 @@ public enum Hack {
AUTORESPAWN(10),
FASTPLACE(10),
KILLAURA(10),
FLY(10);
FLY(10),
WDL(10);
private int id;
private Hack(int id) {

View File

@ -29,6 +29,7 @@ public class Reach implements Listener{
public void onBlockBreak(BlockBreakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
Block b = e.getBlock();
if(p.getWorld() != b.getWorld()) return;
if(p.getLocation().distance(b.getLocation()) > 6.1) {
e.setCancelled(true);
CloudMessenger.sendHackMessage(Hack.REACH, p);

View File

@ -0,0 +1,25 @@
package eu.univento.core.api.languages;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
public class Language {
private Map<String, Locale> languages;
private ResourceBundle translation;
public Language(String language) {
languages = new HashMap<>();
languages.put("DE", Locale.GERMAN);
languages.put("EN", Locale.ENGLISH);
languages.put("IT", Locale.ITALY);
translation = ResourceBundle.getBundle("language", languages.get(language));
}
public String getWord(String keyword) {
return translation.getString(keyword);
}
}

View File

@ -8,7 +8,7 @@ import eu.univento.core.api.player.Ranks;
* @version 1.0
*/
public class Language_DE implements Languages{
class Language_DE implements Languages{
@Override
public String UNKNOWN_ERROR() {

View File

@ -0,0 +1,97 @@
package eu.univento.core.api.player;
public class BetterPvP {
public BetterPvP() {
}
private boolean minimap = false;
private boolean armourStatus = true;
private boolean potionStatus = true;
private boolean archeryStatus = true;
private boolean notifications = true;
private boolean xpDrops = true;
private boolean betterSprint = true;
private boolean toggleSneak = true;
private boolean quickItemUse = true;
private boolean armourStatusShowEnchants = true;
private boolean minimapDisplayPlayers = false;
private boolean minimapDisplayMobs =false;
private boolean minimapDisplayItems = false;
private boolean minimapDisplayOther = false;
private boolean caveMaps = false;
private boolean minimapDisplayOtherTeam = false;
private boolean minimapDisplayWaypoints = false;
private boolean notificationHunger = true;
private boolean notificationHp = false;
private boolean notificationTnt = false;
private boolean notificationArrow = false;
private boolean deathpoints = true;
private boolean notificationAir = true;
private boolean entityInfo = true;
private int minimapMask = 1;
private int armourStatusMask = 2;
private int potionStatusMask = 4;
private int archeryStatusMask = 8;
private int notificationsMask = 16;
private int xpDropsMask = 32;
private int betterSprintMask = 64;
private int toggleSneakMask = 128;
private int quickItemUseMask = 256;
private int armourStatusShowEnchantsMask = 512;
private int minimapDisplayPlayersMask = 1024;
private int minimapDisplayMobsMask = 2048;
private int minimapDisplayItemsMask = 4096;
private int minimapDisplayOtherMask = 8192;
private int caveMapsMask = 16384;
private int minimapDisplayOtherTeamMask = 32768;
private int minimapDisplayWaypointsMask = 65536;
private int notificationHungerMask = 131072;
private int notificationHpMask = 262144;
private int notificationTntMask = 524288;
private int notificationArrowMask = 1048576;
private int deathpointsMask = 2097152;
private int notificationAirMask = 4194304;
private int entityInfoMask = 8388608;
public String getCodeString() {
String toReturn = "§c §r§5 §r§1 §r§f";
String code = String.valueOf(getCodeToSend());
int size = code.length();
for (int i = 0; i < size; i++)
toReturn = toReturn + " " + "§r§" + code.substring(i, i + 1);
toReturn = toReturn + " ";
return toReturn;
}
private int getCodeToSend() {
int code = 0;
code |= (minimap ? minimapMask : 0);
code |= (armourStatus ? armourStatusMask : 0);
code |= (potionStatus ? potionStatusMask : 0);
code |= (archeryStatus ? archeryStatusMask : 0);
code |= (notifications ? notificationsMask : 0);
code |= (xpDrops ? xpDropsMask : 0);
code |= (betterSprint ? betterSprintMask : 0);
code |= (toggleSneak ? toggleSneakMask : 0);
code |= (quickItemUse ? quickItemUseMask : 0);
code |= (armourStatusShowEnchants ? armourStatusShowEnchantsMask : 0);
code |= (minimapDisplayPlayers ? minimapDisplayPlayersMask : 0);
code |= (minimapDisplayMobs ? minimapDisplayMobsMask : 0);
code |= (minimapDisplayItems ? minimapDisplayItemsMask : 0);
code |= (minimapDisplayOther ? minimapDisplayOtherMask : 0);
code |= (caveMaps ? caveMapsMask : 0);
code |= (minimapDisplayOtherTeam ? minimapDisplayOtherTeamMask : 0);
code |= (minimapDisplayWaypoints ? minimapDisplayWaypointsMask : 0);
code |= (notificationHunger ? notificationHungerMask : 0);
code |= (notificationHp ? notificationHpMask : 0);
code |= (notificationTnt ? notificationTntMask : 0);
code |= (notificationArrow ? notificationArrowMask : 0);
code |= (deathpoints ? deathpointsMask : 0);
code |= (notificationAir ? notificationAirMask : 0);
code |= (entityInfo ? entityInfoMask : 0);
return code;
}
}

View File

@ -10,17 +10,16 @@ import eu.univento.core.api.Actionbar;
import eu.univento.core.api.Utils;
import eu.univento.core.api.database.MongoDB;
import eu.univento.core.api.effects.Effects;
import eu.univento.core.api.languages.Language;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.server.Game;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.core.api.server.Servers;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_9_R1.*;
import org.bson.Document;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
@ -33,6 +32,7 @@ import org.bukkit.scoreboard.Team;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;
import java.util.*;
public class CustomPlayer extends CraftPlayer {
@ -40,23 +40,26 @@ public class CustomPlayer extends CraftPlayer {
private static final HashMap<String, CustomPlayer> PLAYERS = new HashMap<>();
private final Player PLAYER;
private String customPrefix;
private String customSuffix;
private String customColor;
private String nickname;
private boolean openInventory;
private MongoDB mongoDB = Core.getMongoDB();
private MongoCollection userCollection;
private MongoCollection playerCollection;
private MongoCollection friendCollection;
private MongoCollection onlinePlayerCollection;
private CustomPlayer(Player player) {
super((CraftServer) Bukkit.getServer(), ((CraftPlayer) player).getHandle());
PLAYERS.put(player.getName().toLowerCase(), this);
PLAYER = player;
userCollection = mongoDB.getDatabase().getCollection("users");
MongoDB mongoDB = Core.getMongoDB();
playerCollection = mongoDB.getDatabase().getCollection("players");
friendCollection = mongoDB.getDatabase().getCollection("friends");
onlinePlayerCollection = mongoDB.getDatabase().getCollection("online-players");
}
public void onLeave() {
@ -70,7 +73,9 @@ public class CustomPlayer extends CraftPlayer {
location.put("Yaw", getLocation().getYaw());
location.put("Pitch", getLocation().getPitch());
if(Bukkit.getServerName().contains("Lobby")) setInDatabase("Pos", new BasicDBObject(location));
if(ServerSettings.isLobby()) setInDatabase("Pos", new BasicDBObject(location));
onlinePlayerCollection.deleteOne(new Document("uuid", getUniqueId().toString()));
if (PLAYERS.containsKey(getName().toLowerCase())) PLAYERS.remove(getName().toLowerCase());
}
@ -119,9 +124,12 @@ public class CustomPlayer extends CraftPlayer {
settings.put("friendRequests", true);
settings.put("friendJump", true);
settings.put("chatSounds", true);
settings.put("tsMove", false);
settings.put("scoreboard", true);
settings.put("effects", true);
settings.put("storyMode", true);
settings.put("language", "EN");
settings.put("nicked", false);
settings.put("language", "DE");
doc.put("Settings", new BasicDBObject(settings));
@ -133,12 +141,12 @@ public class CustomPlayer extends CraftPlayer {
location.put("Pitch", getLocation().getPitch());
doc.put("Pos", new BasicDBObject(location));
userCollection.insertOne(doc);
playerCollection.insertOne(doc);
}
@Override
public boolean hasPlayedBefore() {
FindIterable cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
FindIterable cursor = playerCollection.find(new Document("uuid", getUniqueId().toString()));
cursor.cursorType(CursorType.NonTailable);
Object obj = cursor.first();
@ -148,9 +156,17 @@ public class CustomPlayer extends CraftPlayer {
}
public void updateDatabaseEntry() {
setInDatabase("lastName", getName());
setInDatabase("lastLogin", new Date());
setInDatabase("lastIP", getAddress().getHostName());
setInDatabase("timesJoined", getTimesJoined() + 1);
Document doc = new Document("uuid", getUniqueId().toString());
doc.put("name", getName());
doc.put("server", getServer().getServerName());
onlinePlayerCollection.insertOne(doc);
}
public void setRank(Ranks rank) {
@ -296,6 +312,14 @@ public class CustomPlayer extends CraftPlayer {
return (String) getSettings().get("language");
}
public boolean hasTsMove() {
return (boolean) getSettings().get("tsMove");
}
public boolean hasScoreboard() {
return (boolean) getSettings().get("scoreboard");
}
public void setPlayerVisibility(String visibility) {
setSetting("playerVisibility", visibility);
}
@ -336,8 +360,12 @@ public class CustomPlayer extends CraftPlayer {
setSetting("language", language);
}
public boolean isJoined() {
return true;
public void setTsMove(boolean tsMove) {
setSetting("tsMove", tsMove);
}
public void setScoreboard(boolean scoreboard) {
setSetting("scoreboard", scoreboard);
}
public void connectToServer(String server) {
@ -348,6 +376,7 @@ public class CustomPlayer extends CraftPlayer {
return getRank().value >= rank.value;
}
public ArrayList<UUID> getFriends() {
FindIterable<Document> cursor = friendCollection.find(new Document("uuid", getUniqueId().toString()));
cursor.cursorType(CursorType.NonTailable);
@ -376,49 +405,6 @@ public class CustomPlayer extends CraftPlayer {
//TODO: add actual function
}
/**
public boolean isAllowed(Ranks.Ranks rank) {
try {
return Ranks.isAllowed(this, rank);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
return false;
}
}
/**
public Ranks.Ranks getRank() {
try {
return Ranks.getRank(this);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
return Ranks.Ranks.Player;
}
}
public Ranks.Ranks getFreshRank() {
try{
return Ranks.getRankFresh(this);
}catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
return Ranks.Ranks.Player;
}
}
public void setRank(Ranks.Ranks r) {
try {
Ranks.setRank(this, r);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
*/
public String getPrefix() {
if(customPrefix != null) return customPrefix;
if(isNicked()) return getPrefix(Ranks.Premium);
@ -440,19 +426,6 @@ public class CustomPlayer extends CraftPlayer {
public Team getTeam() {
if(isNicked()) return getTeam(Ranks.Premium);
return getTeam(getRank());
}
//TODO: add function back in
public boolean isNicked() {
return false;
}
public boolean isNickedReal() {
return false;
}
public void setNicked(boolean nick) {
}
public Color getArmorColor() {
@ -544,16 +517,54 @@ public class CustomPlayer extends CraftPlayer {
return new Messages(this);
}
public String getMessage(String message) {
Language lang = new Language(getLanguage());
return lang.getWord(message);
}
public Statistics getStatistics(Game game) {
return new Statistics(this, game);
}
public boolean isNicked() {
return (boolean) getSettings().get("nicked");
}
public void setNicked(boolean nicked) {
setSetting("nicked", nicked);
}
public void removeNick() {
//NickNamerAPI.getNickManager().removeNick(getUniqueId());
//NickNamerAPI.getNickManager().removeSkin(getUniqueId());
//NickNamerAPI.getNickManager().refreshPlayer(this);
}
public String getNick() {
if(nickname != null) return nickname;
return "";
}
public void setNick(String name) {
//NickNamerAPI.getNickManager().setNick(getUniqueId(), name);
//NickNamerAPI.getNickManager().setSkin(getUniqueId(), "md_5");
//NickNamerAPI.getNickManager().refreshPlayer(this);
}
@Override
public boolean isOnline() {
FindIterable<Document> cursor = onlinePlayerCollection.find(new Document("uuid", getUniqueId().toString()));
cursor.cursorType(CursorType.NonTailable);
Document doc = cursor.first();
return doc != null;
}
private void setInDatabase(String name, Object obj) {
userCollection.updateOne(new Document("uuid", getUniqueId().toString()), new Document("$set", new Document(name, obj)));
playerCollection.updateOne(new Document("uuid", getUniqueId().toString()), new Document("$set", new Document(name, obj)));
}
private Object getObjectFromDatbase(String name) {
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", getUniqueId().toString()));
cursor.cursorType(CursorType.NonTailable);
Document doc = cursor.first();
@ -563,7 +574,7 @@ public class CustomPlayer extends CraftPlayer {
}
private int getIntegerFromDatabase(String name) {
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", getUniqueId().toString()));
cursor.cursorType(CursorType.NonTailable);
Document doc = cursor.first();
@ -573,7 +584,7 @@ public class CustomPlayer extends CraftPlayer {
}
private String getStringFromDatabase(String name) {
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", getUniqueId().toString()));
cursor.cursorType(CursorType.NonTailable);
Document doc = cursor.first();
@ -583,7 +594,7 @@ public class CustomPlayer extends CraftPlayer {
}
private Date getDateFromDatabase(String name) {
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", getUniqueId().toString()));
cursor.cursorType(CursorType.NonTailable);
Document doc = cursor.first();
@ -726,9 +737,9 @@ public class CustomPlayer extends CraftPlayer {
}
public void setLabyModFeatures(HashMap<LabyModFeature, Boolean> list) {
public void setLabyModFeatures(HashMap<LabyMod, Boolean> list) {
HashMap<String, Boolean> temp = new HashMap<>();
for(LabyModFeature feature : list.keySet()) {
for(LabyMod feature : list.keySet()) {
temp.put(feature.name(), list.get(feature));
}
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
@ -746,28 +757,26 @@ public class CustomPlayer extends CraftPlayer {
}
public enum LabyModFeature{
FOOD("FOOD", 0),
GUI("GUI", 1),
NICK("NICK", 2),
BLOCKBUILD("BLOCKBUILD", 3),
CHAT("CHAT", 4),
EXTRAS("EXTRAS", 5),
ANIMATIONS("ANIMATIONS", 6),
POTIONS("POTIONS", 7),
ARMOR("ARMOR", 8),
DAMAGEINDICATOR("DAMAGEINDICATOR", 9),
MINIMAP_RADAR("MINIMAP_RADAR", 10);
private LabyModFeature(String s, int n) {
}
}
public void crashClient() {
getHandle().playerConnection.sendPacket(new PacketPlayOutExplosion(9999999999D,
9999999999D, 9999999999D, 9999999999F,
new ArrayList<>(), new Vec3D(9999999999D,
9999999999D, 9999999999D)));
}
public void sendPacket(Packet<?> packet) {
getHandle().playerConnection.sendPacket(packet);
}
private Field getField(Class<?> clazz, String name) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,19 @@
package eu.univento.core.api.player;
public enum LabyMod {
FOOD("FOOD", 0),
GUI("GUI", 1),
NICK("NICK", 2),
BLOCKBUILD("BLOCKBUILD", 3),
CHAT("CHAT", 4),
EXTRAS("EXTRAS", 5),
ANIMATIONS("ANIMATIONS", 6),
POTIONS("POTIONS", 7),
ARMOR("ARMOR", 8),
DAMAGEINDICATOR("DAMAGEINDICATOR", 9),
MINIMAP_RADAR("MINIMAP_RADAR", 10);
LabyMod(String s, int n) {
}
}

View File

@ -1,7 +1,6 @@
package eu.univento.core.api.player;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import eu.univento.core.Core;
import eu.univento.core.api.database.MySQL;
import net.minecraft.server.v1_9_R1.Packet;
@ -95,7 +94,7 @@ public class NickName {
* gets random Nickname
* @return String
*/
private static String getRandomNick() {
public static String getRandomNick() {
ArrayList<String> names = new ArrayList<>();
names.add("GommeHD");
names.add("Notch");
@ -146,25 +145,6 @@ public class NickName {
return names.get(i);
}
static void changeSkin(CustomPlayer p, String name) {
Skin skin = new Skin(Bukkit.getOfflinePlayer(name).getUniqueId().toString().replace("_", ""));
if(skin.getName() != null) {
GameProfile profile = p.getProfile();
profile.getProperties().clear();
profile.getProperties().put(skin.getName(), new Property(skin.getName(), skin.getValue(), skin.getSignature()));
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
for(Player players : Bukkit.getOnlinePlayers()) {
players.hidePlayer(p);
}
}, 1L);
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
for(Player players : Bukkit.getOnlinePlayers()) {
players.showPlayer(p);
}
}, 1L);
}
}
static void setName(CustomPlayer p, String name) {
p.setDisplayName(name);
try {

View File

@ -1,73 +0,0 @@
package eu.univento.core.api.player;
import eu.univento.core.Core;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
import java.util.logging.Level;
/**
* @author joethei
* @version 1.0
*/
public class Skin {
String uuid;
String name;
String value;
String signature;
public Skin(final String uuid) {
this.uuid = uuid;
this.load();
}
private void load() {
try {
URL url = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + this.uuid + "?unsigned=false");
URLConnection uc = url.openConnection();
uc.setUseCaches(false);
uc.setDefaultUseCaches(false);
uc.addRequestProperty("User-Agent", "Mozilla/5.0");
uc.addRequestProperty("Cache-Control", "no-cache, no-store, must-revalidate");
uc.addRequestProperty("Pragma", "no-cache");
String json = new Scanner(uc.getInputStream(), "UTF-8").useDelimiter("\\A").next();
JSONParser parser = new JSONParser();
Object obj = parser.parse(json);
JSONArray properties = (JSONArray)((JSONObject)obj).get("properties");
for (int i = 0; i < properties.size(); ++i) {
try {
JSONObject property = (JSONObject)properties.get(i);
String name = (String)property.get("name");
String value = (String)property.get("value");
String signature = property.containsKey("signature") ? ((String)property.get("signature")) : null;
this.name = name;
this.value = value;
this.signature = signature;
}
catch (Exception e) {
Core.log(Level.WARNING, "Failed to apply auth property");
e.printStackTrace();
}
}
}
catch (Exception ex) {}
}
public String getValue() {
return this.value;
}
public String getName() {
return this.name;
}
public String getSignature() {
return this.signature;
}
}

View File

@ -1,7 +1,7 @@
package eu.univento.core.api.player;
import eu.univento.core.Core;
import eu.univento.core.api.server.ServerSettings;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
@ -24,7 +24,7 @@ public class Spectator {
* @param p CustomPlayer
*/
public static void add(CustomPlayer p) {
for (Player on : Bukkit.getOnlinePlayers()) {
for (Player on : Core.getOnlinePlayers()) {
on.hidePlayer(p);
}
spectators.add(p);
@ -38,7 +38,7 @@ public class Spectator {
* @param p CustomPlayer
*/
public static void remove(CustomPlayer p) {
for (Player on : Bukkit.getOnlinePlayers()) {
for (Player on : Core.getOnlinePlayers()) {
on.showPlayer(p);
}
spectators.remove(p);

View File

@ -1,6 +1,13 @@
package eu.univento.core.api.server;
import eu.univento.core.Core;
import eu.univento.core.commands.Build;
import eu.univento.core.listeners.Blocks;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.plugin.PluginManager;
import java.util.logging.Level;
/**
* @author joethei
@ -47,6 +54,12 @@ public class ServerSettings {
public static void setBuild(boolean build) {
ServerSettings.build = build;
if(!build) {
PluginManager pm = Bukkit.getPluginManager();
new Build(Core.getInstance(), "build", "build", "b");
pm.registerEvents(new Blocks(), Core.getInstance());
Core.log(Level.INFO, "Build Modus aktiviert");
}
}
public static boolean isLobby() {

View File

@ -1,63 +1,11 @@
package eu.univento.core.api.utils.reflection;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Reflection
{
public static final Class<?> CLASS_CRAFTITEMSTACK = getCraftBukkitClass("inventory.CraftItemStack");
public static final Method METHOD_ASNMSCOPY = getMethod(CLASS_CRAFTITEMSTACK, "asNMSCopy");
public static void sendPacket(Player p, Object packet) {
try {
Object nmsPlayer = getNMSPlayer(p);
Object connection = nmsPlayer.getClass()
.getField("playerConnection").get(nmsPlayer);
connection.getClass()
.getMethod("sendPacket", new Class[] { getNMSClass("Packet") })
.invoke(connection, new Object[] { packet });
} catch (Exception e) {
e.printStackTrace();
}
}
public static Field getField(Class<?> clazz, String field) {
Field re = null;
try {
re = clazz.getDeclaredField(field);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
}
return re;
}
public static void sendPacket(Player p, String packetName, Class<?>[] parameterclass, Object[] parameters) {
try {
Object nmsPlayer = getNMSPlayer(p);
Object connection = nmsPlayer.getClass()
.getField("playerConnection").get(nmsPlayer);
Object packet =
Class.forName(
nmsPlayer.getClass().getPackage().getName() + "." +
packetName)
.getConstructor(parameterclass).newInstance(parameters);
connection.getClass()
.getMethod("sendPacket", new Class[] { getNMSClass("Packet") })
.invoke(connection, new Object[] { packet });
} catch (Exception e) {
e.printStackTrace();
}
}
import org.bukkit.Bukkit;
public class Reflection {
public static String getVersion() {
String name = Bukkit.getServer().getClass().getPackage().getName();
String version = name.substring(name.lastIndexOf('.') + 1) + ".";
@ -66,7 +14,7 @@ public class Reflection
public static Class<?> getNMSClass(String className) {
String fullName = "net.minecraft.server." + getVersion() + className;
Class<?> clazz = null;
Class clazz = null;
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
@ -74,9 +22,10 @@ public class Reflection
}
return clazz;
}
public static Class<?> getCraftBukkitClass(String className) {
public static Class<?> getOBCClass(String className) {
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
Class<?> clazz = null;
Class clazz = null;
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
@ -85,57 +34,45 @@ public class Reflection
return clazz;
}
public static Object asNMSCopy(ItemStack i) throws IllegalAccessException, InvocationTargetException {
Object re = null;
try
{
METHOD_ASNMSCOPY.invoke(null, new Object[] { i });
}
catch (java.lang.IllegalArgumentException e) {
e.printStackTrace();
}
return re;
}
public static Field getField(Field f) {
f.setAccessible(true);
return f;
}
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>[] param) {
Constructor<?> re = null;
public static Object getHandle(Object obj) {
try {
re = clazz.getConstructor(param);
return getMethod(obj.getClass(), "getHandle", new Class[0]).invoke(obj, new Object[0]);
} catch (Exception e) {
e.printStackTrace();
}
return re;
return null;
}
public static Object getHandle(Entity entity) {
Object object = null;
try
{
object = getMethod(entity.getClass(), "getHandle").invoke(entity, new Object[0]);
public static Field getField(Class<?> clazz, String name) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field;
} catch (Exception e) {
e.printStackTrace();
}
return object;
return null;
}
public static Object getNMSPlayer(Player player) {
return getHandle(player);
public static Method getMethod(Class<?> clazz, String name, Class<?>[] args) {
for (Method m : clazz.getMethods()) {
if ((m.getName().equals(name)) && ((args.length == 0) || (ClassListEqual(args, m.getParameterTypes())))) {
m.setAccessible(true);
return m;
}
}
return null;
}
public static Method getMethod(Class<?> c, String methodName) {
Method returnMethod = null;
for (Method m : c.getDeclaredMethods()) {
if (m.getName().equals(methodName)) {
returnMethod = m;
public static boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
boolean equal = true;
if (l1.length != l2.length) return false;
for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) {
equal = false;
break;
}
}
return returnMethod;
return equal;
}
}

View File

@ -4,6 +4,7 @@ import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.NickName;
import eu.univento.core.api.player.Ranks;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -37,17 +38,15 @@ public class Nick extends AutoCommand<Core>{
if(p.isNicked()) {
p.getTeam().removeEntry(p.getDisplayName());
p.setNicked(false);
p.setDisplayName(p.getName());
p.getTeam().addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_OFF());
//p.unnick();
p.removeNick();
}else {
p.getTeam().removeEntry(p.getDisplayName());
p.setNicked(true);
//p.setDisplayName(p.getNick());
p.getTeam().addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_ON());
//p.nick(p.getNick());
p.setNick(NickName.getRandomNick());
}
}else {
p.sendMessage(msgs.NO_PERMS());

View File

@ -2,14 +2,11 @@ package eu.univento.core.listeners;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.server.ServerSettings;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.inventory.Inventory;
/**
* some basic events
@ -18,43 +15,16 @@ import org.bukkit.inventory.Inventory;
*/
public class Events implements Listener{
@EventHandler
public void onInventoryClose(InventoryCloseEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
if(e.getInventory().getName().equals(JoinQuit.getLanguageChooser(p).getName())) {
p.openInventory(JoinQuit.getLanguageChooser(p));
p.sendMessage("§cPlease choose a language");
return;
}
p.setOpenInventory(false);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent e) {
Inventory inv = e.getInventory();
if(e.getWhoClicked() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
if(inv.getName().equals(JoinQuit.getLanguageChooser(p).getName())) {
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§6english")) {
p.setLanguage("EN");
p.closeInventory();
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§6Deutsch")) {
p.setLanguage("DE");
p.closeInventory();
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§6Italiano")) {
p.setLanguage("IT");
p.closeInventory();
}
}
}
}
@EventHandler
public void onServerListPing(ServerListPingEvent e) {
if(ServerSettings.isGame()) e.setMotd(ServerSettings.getPlayedGame().toString() + ";" + ServerSettings.getGameState());
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
p.setOpenInventory(false);
}
}

View File

@ -1,16 +1,12 @@
package eu.univento.core.listeners;
import eu.univento.core.Core;
import eu.univento.core.api.Title;
import eu.univento.core.api.Utils;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.NickName;
import eu.univento.core.api.player.Spectator;
import eu.univento.core.api.player.*;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.core.commands.Build;
import eu.univento.core.commands.Vanish;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -19,21 +15,16 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scoreboard.Team;
import java.util.HashMap;
/**
* @author joethei
* @version 1.0
*/
public class JoinQuit implements Listener {
/**
* Handles JoinMessage and vanished players
* @param e event
*/
@EventHandler
public void onJoin(PlayerJoinEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
@ -53,49 +44,40 @@ public class JoinQuit implements Listener{
for (int i = 0; i <= 15; i++) {
Utils.randomFirework(p.getEyeLocation());
}
Title.sendTitle(p, 0, 100, 0, "§6Welcome", "§aPlease choose a language");
Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getInstance(), () -> p.openInventory(getLanguageChooser(p)), 100L);
}
if(!p.isOnline()) {
HashMap<LabyMod, Boolean> labyModFeatures = new HashMap<>();
labyModFeatures.put(LabyMod.DAMAGEINDICATOR, false);
labyModFeatures.put(LabyMod.MINIMAP_RADAR, false);
labyModFeatures.put(LabyMod.ARMOR, false);
labyModFeatures.put(LabyMod.POTIONS, false);
labyModFeatures.put(LabyMod.ANIMATIONS, false);
p.setLabyModFeatures(labyModFeatures);
p.sendMessage(new BetterPvP().getCodeString());
}
p.updateDatabaseEntry();
Title.sendTabTitle(p, p.getMessages().Core_TAB_TITLE() + Bukkit.getServerName() , p.getMessages().TAB_PREFIX());
p.setGameMode(ServerSettings.getGameMode());
p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
p.initScoreboard();
if(p.isNicked()) {
//TODO: add nicking back in
if (p.isNicked() && !ServerSettings.isLobby()) {
p.setNick(NickName.getRandomNick());
}
for(Player players : Bukkit.getOnlinePlayers()){
CustomPlayer player = CustomPlayer.getPlayer(players);
for (CustomPlayer player : Core.getOnlinePlayers()) {
p.getScoreboard().getTeam(player.getTeam().getName()).addEntry(player.getDisplayName());
player.getScoreboard().getTeam(p.getTeam().getName()).addEntry(p.getDisplayName());
}
}
@EventHandler
public void onLogin(PlayerLoginEvent e) {
//CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
//Core.log(Level.INFO, "PlayerLogin " + p.getName() + " | " + p.isBanned());
//if(p.isBanned()) {
// e.disallow(PlayerLoginEvent.Result.KICK_BANNED, "§cYou have been banned. §6Reason: " + p.getBanReason() + "\nUntil: " + p.getBanTime());
//}
}
/**
* Handles QuitMessage and other needed stuff
* @param e event
*/
@EventHandler
public void onQuit(PlayerQuitEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (Build.getPlayers().containsKey(p))
Build.getPlayers().remove(p);
if(ServerSettings.isGame()) {
p.setDisplayName(p.getName());
NickName.remove(p);
if (p.isNicked() && !ServerSettings.isLobby()) {
p.removeNick();
}
for (Team team : p.getScoreboard().getTeams()) {
team.removeEntry(p.getDisplayName());
@ -103,39 +85,9 @@ public class JoinQuit implements Listener{
p.onLeave();
}
/**
* Handles KickMessage
* @param e event
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onKick(PlayerKickEvent e) {
e.setLeaveMessage(null);
}
static Inventory getLanguageChooser(CustomPlayer p) {
Inventory inv = Bukkit.createInventory(p, 9, "§6Language Chooser");
ItemStack en = new ItemStack(Material.PAPER);
ItemMeta enMeta = en.getItemMeta();
enMeta.setDisplayName("§6english");
en.setItemMeta(enMeta);
ItemStack de = new ItemStack(Material.PAPER);
ItemMeta deMeta = de.getItemMeta();
deMeta.setDisplayName("§6Deutsch");
de.setItemMeta(deMeta);
ItemStack it = new ItemStack(Material.PAPER);
ItemMeta itMeta = it.getItemMeta();
itMeta.setDisplayName("§6Italiano");
it.setItemMeta(itMeta);
inv.setItem(0, en);
inv.setItem(1, de);
inv.setItem(2, it);
return inv;
}
}

View File

@ -0,0 +1,22 @@
package eu.univento.core.listeners;
import eu.univento.core.antihack.Hack;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
public class PluginMessenger implements PluginMessageListener{
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
CustomPlayer p = CustomPlayer.getPlayer(player);
if(channel.equals("WDL|INIT")) {
p.warn(Hack.WDL);
p.kickPlayer(p.getMessage("Prefix") + p.getMessage("Hack.WorldDownloader"));
}
if(channel.equals("PERMISSIONSREPL") && new String(data).contains("mod.worlddownloader")) {
p.warn(Hack.WDL);
p.kickPlayer(p.getMessage("Prefix") + p.getMessage("Hack.WorldDownloader"));
}
}
}

View File

@ -0,0 +1,4 @@
Prefix = undefined
Tab_Prefix = §8• §6U N I V E N T O §8•
Not_a_player = You are not a valid player
No_perms =

View File

@ -0,0 +1,11 @@
Prefix = §6univento §8»
Tab_Prefix = §8• §6U N I V E N T O §8•
Unknown_error = §cEs ist ein unbekannter Fehler aufgetreten
No_perms = §cDu hast keine Berechtigung diesen Befehl auszuführen
Error = §cFehler:
Not_online = §7Der angegebene Spieler ist §cnicht §7 online
Kick_restart = §cDer Server wurde neu gestartet
Kick_full = §cDieser Server ist bereits voll
Command_no_found = §cDieser Befehl konnte nicht gefunden werden
Core.fix_own = §7Du wurdest §egefixt