From ed8a5fb22916900284c4505cb4536468514c5c2c Mon Sep 17 00:00:00 2001 From: joethei Date: Sun, 8 May 2016 10:45:34 +0200 Subject: [PATCH] changed language mechanics & added BetterPvP blocker --- Core.iml | 16 +- pom.xml | 16 +- .../core/api/map/CustomPlayerHead.java | 8 - src/main/java/eu/univento/core/Core.java | 15 +- .../eu/univento/core/antihack/AntiHack.java | 2 +- .../java/eu/univento/core/antihack/Hack.java | 3 +- .../univento/core/antihack/modules/Reach.java | 3 +- .../univento/core/api/languages/Language.java | 25 +++ .../core/api/languages/Language_DE.java | 2 +- .../univento/core/api/player/BetterPvP.java | 97 +++++++++ .../core/api/player/CustomPlayer.java | 201 +++++++++--------- .../eu/univento/core/api/player/LabyMod.java | 19 ++ .../eu/univento/core/api/player/NickName.java | 22 +- .../eu/univento/core/api/player/Skin.java | 73 ------- .../univento/core/api/player/Spectator.java | 6 +- .../core/api/server/ServerSettings.java | 13 ++ .../core/api/utils/reflection/Reflection.java | 193 ++++++----------- .../java/eu/univento/core/commands/Nick.java | 7 +- .../eu/univento/core/listeners/Events.java | 44 +--- .../eu/univento/core/listeners/JoinQuit.java | 146 +++++-------- .../core/listeners/PluginMessenger.java | 22 ++ src/main/resources/language.properties | 4 + src/main/resources/language_de.properties | 11 + 23 files changed, 465 insertions(+), 483 deletions(-) delete mode 100644 src/eu/univento/core/api/map/CustomPlayerHead.java create mode 100644 src/main/java/eu/univento/core/api/languages/Language.java create mode 100644 src/main/java/eu/univento/core/api/player/BetterPvP.java create mode 100644 src/main/java/eu/univento/core/api/player/LabyMod.java delete mode 100644 src/main/java/eu/univento/core/api/player/Skin.java create mode 100644 src/main/java/eu/univento/core/listeners/PluginMessenger.java create mode 100644 src/main/resources/language.properties create mode 100644 src/main/resources/language_de.properties diff --git a/Core.iml b/Core.iml index dff817f..07cf8c4 100644 --- a/Core.iml +++ b/Core.iml @@ -16,7 +16,7 @@ - + @@ -25,11 +25,23 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index b12116c..9c1b146 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 1.8 1.8 @@ -50,13 +49,15 @@ - - spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + inventive-repo + https://repo.inventivetalent.org/content/groups/public/ + @@ -68,12 +69,12 @@ org.mongodb mongodb-driver-async - 3.2.2 + LATEST io.netty netty-all - 4.0.31.Final + LATEST org.projectlombok @@ -98,6 +99,11 @@ 1.9.2-R0.1-SNAPSHOT provided + + org.inventivetalent.npclib + api + RELEASE + \ No newline at end of file diff --git a/src/eu/univento/core/api/map/CustomPlayerHead.java b/src/eu/univento/core/api/map/CustomPlayerHead.java deleted file mode 100644 index b6a8714..0000000 --- a/src/eu/univento/core/api/map/CustomPlayerHead.java +++ /dev/null @@ -1,8 +0,0 @@ -package eu.univento.core.api.map; - -/** - * @author joethei - * @version 0.1 - */ -public class CustomPlayerHead { -} diff --git a/src/main/java/eu/univento/core/Core.java b/src/main/java/eu/univento/core/Core.java index 2f53d90..bd71458 100644 --- a/src/main/java/eu/univento/core/Core.java +++ b/src/main/java/eu/univento/core/Core.java @@ -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"); @@ -120,9 +116,13 @@ public class Core extends JavaPlugin{ new ChatClear(this, "chatclear", "chatclear", "cc"); 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"); } diff --git a/src/main/java/eu/univento/core/antihack/AntiHack.java b/src/main/java/eu/univento/core/antihack/AntiHack.java index 71b0fd8..e4dcf69 100644 --- a/src/main/java/eu/univento/core/antihack/AntiHack.java +++ b/src/main/java/eu/univento/core/antihack/AntiHack.java @@ -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 entry : AutoClicker.clicks.entrySet()) { if(entry.getValue() > 16) { diff --git a/src/main/java/eu/univento/core/antihack/Hack.java b/src/main/java/eu/univento/core/antihack/Hack.java index 6ba5a08..9aac7b0 100644 --- a/src/main/java/eu/univento/core/antihack/Hack.java +++ b/src/main/java/eu/univento/core/antihack/Hack.java @@ -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) { diff --git a/src/main/java/eu/univento/core/antihack/modules/Reach.java b/src/main/java/eu/univento/core/antihack/modules/Reach.java index 83b748a..1172837 100644 --- a/src/main/java/eu/univento/core/antihack/modules/Reach.java +++ b/src/main/java/eu/univento/core/antihack/modules/Reach.java @@ -26,9 +26,10 @@ public class Reach implements Listener{ } @EventHandler - public void onBlockBreak(BlockBreakEvent e ) { + 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); diff --git a/src/main/java/eu/univento/core/api/languages/Language.java b/src/main/java/eu/univento/core/api/languages/Language.java new file mode 100644 index 0000000..ba75c0c --- /dev/null +++ b/src/main/java/eu/univento/core/api/languages/Language.java @@ -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 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); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/languages/Language_DE.java b/src/main/java/eu/univento/core/api/languages/Language_DE.java index e715542..0f332d9 100644 --- a/src/main/java/eu/univento/core/api/languages/Language_DE.java +++ b/src/main/java/eu/univento/core/api/languages/Language_DE.java @@ -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() { diff --git a/src/main/java/eu/univento/core/api/player/BetterPvP.java b/src/main/java/eu/univento/core/api/player/BetterPvP.java new file mode 100644 index 0000000..1ed9bda --- /dev/null +++ b/src/main/java/eu/univento/core/api/player/BetterPvP.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/player/CustomPlayer.java b/src/main/java/eu/univento/core/api/player/CustomPlayer.java index 427941f..e745670 100644 --- a/src/main/java/eu/univento/core/api/player/CustomPlayer.java +++ b/src/main/java/eu/univento/core/api/player/CustomPlayer.java @@ -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 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 getFriends() { FindIterable 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 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 cursor = userCollection.find(new Document("uuid", getUniqueId().toString())); + FindIterable 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 cursor = userCollection.find(new Document("uuid", getUniqueId().toString())); + FindIterable 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 cursor = userCollection.find(new Document("uuid", getUniqueId().toString())); + FindIterable 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 cursor = userCollection.find(new Document("uuid", getUniqueId().toString())); + FindIterable cursor = playerCollection.find(new Document("uuid", getUniqueId().toString())); cursor.cursorType(CursorType.NonTailable); Document doc = cursor.first(); @@ -620,7 +631,7 @@ public class CustomPlayer extends CraftPlayer { private String getSuffix(Ranks r) { switch(r) { case Admin: return "§8 Ȥ7 "; - case SrDeveloper: return "§8 Ȥ7"; + case SrDeveloper: return "§8 Ȥ7 "; case Developer: return "§8 Ȥ7 "; case SrModerator: return "§8 Ȥ7 "; case HeadBuilder: return "§8 Ȥ7 "; @@ -726,9 +737,9 @@ public class CustomPlayer extends CraftPlayer { } - public void setLabyModFeatures(HashMap list) { + public void setLabyModFeatures(HashMap list) { HashMap 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; + } + } \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/player/LabyMod.java b/src/main/java/eu/univento/core/api/player/LabyMod.java new file mode 100644 index 0000000..db12616 --- /dev/null +++ b/src/main/java/eu/univento/core/api/player/LabyMod.java @@ -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) { + + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/player/NickName.java b/src/main/java/eu/univento/core/api/player/NickName.java index fd4f966..5c52453 100644 --- a/src/main/java/eu/univento/core/api/player/NickName.java +++ b/src/main/java/eu/univento/core/api/player/NickName.java @@ -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 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 { diff --git a/src/main/java/eu/univento/core/api/player/Skin.java b/src/main/java/eu/univento/core/api/player/Skin.java deleted file mode 100644 index 12324b1..0000000 --- a/src/main/java/eu/univento/core/api/player/Skin.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/eu/univento/core/api/player/Spectator.java b/src/main/java/eu/univento/core/api/player/Spectator.java index 7c28315..6c768d0 100644 --- a/src/main/java/eu/univento/core/api/player/Spectator.java +++ b/src/main/java/eu/univento/core/api/player/Spectator.java @@ -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); diff --git a/src/main/java/eu/univento/core/api/server/ServerSettings.java b/src/main/java/eu/univento/core/api/server/ServerSettings.java index faf0450..9cf13d8 100644 --- a/src/main/java/eu/univento/core/api/server/ServerSettings.java +++ b/src/main/java/eu/univento/core/api/server/ServerSettings.java @@ -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() { diff --git a/src/main/java/eu/univento/core/api/utils/reflection/Reflection.java b/src/main/java/eu/univento/core/api/utils/reflection/Reflection.java index 6c4dd1d..c07997e 100644 --- a/src/main/java/eu/univento/core/api/utils/reflection/Reflection.java +++ b/src/main/java/eu/univento/core/api/utils/reflection/Reflection.java @@ -1,141 +1,78 @@ 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"); +import org.bukkit.Bukkit; - 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(); - } - } - - public static String getVersion() { - String name = Bukkit.getServer().getClass().getPackage().getName(); - String version = name.substring(name.lastIndexOf('.') + 1) + "."; - return version; - } - - public static Class getNMSClass(String className) { - String fullName = "net.minecraft.server." + getVersion() + className; - Class clazz = null; - try { - clazz = Class.forName(fullName); - } catch (Exception e) { - e.printStackTrace(); - } - return clazz; - } - public static Class getCraftBukkitClass(String className) { - String fullName = "org.bukkit.craftbukkit." + getVersion() + className; - Class clazz = null; - try { - clazz = Class.forName(fullName); - } catch (Exception e) { - e.printStackTrace(); - } - 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(); +public class Reflection { + public static String getVersion() { + String name = Bukkit.getServer().getClass().getPackage().getName(); + String version = name.substring(name.lastIndexOf('.') + 1) + "."; + return version; } - return re; - } - - public static Field getField(Field f) { - f.setAccessible(true); - return f; - } - public static Constructor getConstructor(Class clazz, Class[] param) { - Constructor re = null; - try { - re = clazz.getConstructor(param); - } catch (Exception e) { - e.printStackTrace(); - } - return re; - } - public static Object getHandle(Entity entity) { - Object object = null; - try - { - object = getMethod(entity.getClass(), "getHandle").invoke(entity, new Object[0]); - } catch (Exception e) { - e.printStackTrace(); + public static Class getNMSClass(String className) { + String fullName = "net.minecraft.server." + getVersion() + className; + Class clazz = null; + try { + clazz = Class.forName(fullName); + } catch (Exception e) { + e.printStackTrace(); + } + return clazz; } - return object; - } - - public static Object getNMSPlayer(Player player) { - return getHandle(player); - } - - 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 Class getOBCClass(String className) { + String fullName = "org.bukkit.craftbukkit." + getVersion() + className; + Class clazz = null; + try { + clazz = Class.forName(fullName); + } catch (Exception e) { + e.printStackTrace(); + } + return clazz; } - return returnMethod; - } + public static Object getHandle(Object obj) { + try { + return getMethod(obj.getClass(), "getHandle", new Class[0]).invoke(obj, new Object[0]); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + 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 null; + } + + 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 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 equal; + } } \ No newline at end of file diff --git a/src/main/java/eu/univento/core/commands/Nick.java b/src/main/java/eu/univento/core/commands/Nick.java index f6926f2..49a31e3 100644 --- a/src/main/java/eu/univento/core/commands/Nick.java +++ b/src/main/java/eu/univento/core/commands/Nick.java @@ -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{ 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()); diff --git a/src/main/java/eu/univento/core/listeners/Events.java b/src/main/java/eu/univento/core/listeners/Events.java index 6afab8a..a9cf524 100644 --- a/src/main/java/eu/univento/core/listeners/Events.java +++ b/src/main/java/eu/univento/core/listeners/Events.java @@ -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); + } + } \ No newline at end of file diff --git a/src/main/java/eu/univento/core/listeners/JoinQuit.java b/src/main/java/eu/univento/core/listeners/JoinQuit.java index 9219641..52e51e9 100644 --- a/src/main/java/eu/univento/core/listeners/JoinQuit.java +++ b/src/main/java/eu/univento/core/listeners/JoinQuit.java @@ -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,123 +15,79 @@ 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()); +public class JoinQuit implements Listener { - for(Player players : Bukkit.getOnlinePlayers()) { + @EventHandler + public void onJoin(PlayerJoinEvent e) { + CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); + + for (Player players : Bukkit.getOnlinePlayers()) { CustomPlayer player = CustomPlayer.getPlayer(players); - if(Vanish.getPlayers().contains(player)) { + if (Vanish.getPlayers().contains(player)) { p.hidePlayer(player); } - if(Spectator.is(player)) { + if (Spectator.is(player)) { p.hidePlayer(player); } } - if(!p.hasPlayedBefore()) { - p.insertToDatabase(); - 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.hasPlayedBefore()) { + p.insertToDatabase(); + for (int i = 0; i <= 15; i++) { + Utils.randomFirework(p.getEyeLocation()); + } + } + if(!p.isOnline()) { + HashMap 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.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); + public void onQuit(PlayerQuitEvent e) { + CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); + if (Build.getPlayers().containsKey(p)) + Build.getPlayers().remove(p); + if (p.isNicked() && !ServerSettings.isLobby()) { + p.removeNick(); } - for(Team team : p.getScoreboard().getTeams()) { + for (Team team : p.getScoreboard().getTeams()) { team.removeEntry(p.getDisplayName()); } - 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; + p.onLeave(); } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onKick(PlayerKickEvent e) { + e.setLeaveMessage(null); + } + } \ No newline at end of file diff --git a/src/main/java/eu/univento/core/listeners/PluginMessenger.java b/src/main/java/eu/univento/core/listeners/PluginMessenger.java new file mode 100644 index 0000000..f53191c --- /dev/null +++ b/src/main/java/eu/univento/core/listeners/PluginMessenger.java @@ -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")); + } + } +} diff --git a/src/main/resources/language.properties b/src/main/resources/language.properties new file mode 100644 index 0000000..a37adf2 --- /dev/null +++ b/src/main/resources/language.properties @@ -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 = diff --git a/src/main/resources/language_de.properties b/src/main/resources/language_de.properties new file mode 100644 index 0000000..1194657 --- /dev/null +++ b/src/main/resources/language_de.properties @@ -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