>, Method>>> _loadedMethods = new HashMap<>();
-
- /**
- * Retrieves a {@link Method} instance declared by the specified class with the specified name and argument types.
- * Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
- * returned will be an instance or static field.
- *
- * A global caching mechanism within this class is used to store method. Combined with synchronization, this guarantees that
- * no method will be reflectively looked up twice.
- *
- *
- * If a method is deemed suitable for return, {@link Method#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned.
- * This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
- *
- *
- * This method does not search superclasses of the specified type for methods with the specified signature.
- * Callers wishing this behavior should use {@link Class#getDeclaredMethod(String, Class...)}.
- *
- * @param clazz The class which contains the method to retrieve.
- * @param name The declared name of the method in the class.
- * @param args The formal argument types of the method.
- * @return A method object with the specified name declared by the specified class.
- */
- private synchronized static Method getMethod(Class> clazz, String name,
- Class>... args) {
- if (!_loadedMethods.containsKey(clazz)) {
- _loadedMethods.put(clazz, new HashMap<>());
- }
-
- Map>, Method>> loadedMethodNames = _loadedMethods.get(clazz);
- if (!loadedMethodNames.containsKey(name)) {
- loadedMethodNames.put(name, new HashMap<>());
- }
-
- Map>, Method> loadedSignatures = loadedMethodNames.get(name);
- ArrayWrapper> wrappedArg = new ArrayWrapper<>(args);
- if (loadedSignatures.containsKey(wrappedArg)) {
- return loadedSignatures.get(wrappedArg);
- }
-
- for (Method m : clazz.getMethods())
- if (m.getName().equals(name) && Arrays.equals(args, m.getParameterTypes())) {
- m.setAccessible(true);
- loadedSignatures.put(wrappedArg, m);
- return m;
- }
- loadedSignatures.put(wrappedArg, null);
- return null;
- }
-
-}
\ 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 9d77f73..a6a4fbe 100644
--- a/src/main/java/eu/univento/core/commands/Nick.java
+++ b/src/main/java/eu/univento/core/commands/Nick.java
@@ -40,14 +40,14 @@ public class Nick extends AutoCommand{
p.getDatabasePlayer().getSettings().setNickStatus(false);
p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_OFF());
- p.removeNick();
+ p.removeNickName();
}else {
p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).removeEntry(p.getDisplayName());
p.getDatabasePlayer().getSettings().setNickStatus(true);
p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_ON());
String nick = NickName.getRandomNick();
- p.setNick(nick);
+ p.setNickName(nick);
//Core.getDebugManager().sendOverlay("der Nick ist " + nick);
}
}else {
diff --git a/src/main/java/eu/univento/core/commands/Timeout.java b/src/main/java/eu/univento/core/commands/Timeout.java
index 53afc9e..fd88d1d 100644
--- a/src/main/java/eu/univento/core/commands/Timeout.java
+++ b/src/main/java/eu/univento/core/commands/Timeout.java
@@ -1,6 +1,7 @@
package eu.univento.core.commands;
import eu.univento.commons.player.Rank;
+import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.languages.Messages;
@@ -35,13 +36,13 @@ public class Timeout extends AutoCommand {
Core.getTimeout().add(p);
}
} else {
- p.sendMessage(p.getDatabasePlayer().getMessage("Command.not_online"));
+ p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NOT_ONLINE));
}
} else {
p.sendMessage("Nicht genug Argumente");
}
} else {
- p.sendMessage(p.getDatabasePlayer().getMessage("Command.no_perms"));
+ p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NO_PERMS));
}
} else {
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
diff --git a/src/main/java/eu/univento/core/listeners/Chat.java b/src/main/java/eu/univento/core/listeners/Chat.java
index f67fc6b..836ca8e 100644
--- a/src/main/java/eu/univento/core/listeners/Chat.java
+++ b/src/main/java/eu/univento/core/listeners/Chat.java
@@ -1,12 +1,12 @@
package eu.univento.core.listeners;
import eu.univento.commons.player.Rank;
+import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.blocks.MiniBlock;
import eu.univento.core.api.customitems.swords.BestSwordEver;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer;
-import eu.univento.core.api.player.WarnReason;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.core.api.shop.ShopItem;
import eu.univento.core.api.shop.ShopMenu;
diff --git a/src/main/java/eu/univento/core/listeners/Commands.java b/src/main/java/eu/univento/core/listeners/Commands.java
index 6fa84f8..11476f4 100644
--- a/src/main/java/eu/univento/core/listeners/Commands.java
+++ b/src/main/java/eu/univento/core/listeners/Commands.java
@@ -1,6 +1,7 @@
package eu.univento.core.listeners;
import eu.univento.commons.player.Rank;
+import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
@@ -29,7 +30,7 @@ public class Commands implements Listener{
String cmd = e.getMessage().split(" ")[0];
HelpTopic topic = Bukkit.getServer().getHelpMap().getHelpTopic(cmd);
if (topic == null) {
- p.sendMessage(p.getDatabasePlayer().getMessage("Command.not_found"));
+ p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NOT_FOUND));
e.setCancelled(true);
}
}
@@ -44,7 +45,7 @@ public class Commands implements Listener{
Bukkit.spigot().restart();
}, 100L);
}else {
- p.sendMessage(p.getDatabasePlayer().getMessage("Command.no_perms"));
+ p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_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 d1bbb26..602df17 100644
--- a/src/main/java/eu/univento/core/listeners/Events.java
+++ b/src/main/java/eu/univento/core/listeners/Events.java
@@ -1,25 +1,34 @@
package eu.univento.core.listeners;
import eu.univento.core.api.player.CustomPlayer;
+import eu.univento.core.api.player.SpectateManager;
import eu.univento.core.api.server.ServerSettings;
+import eu.univento.core.commands.Vanish;
+import org.bukkit.Location;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Player;
+import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.Vector;
/**
* some basic events
+ *
* @author joethei
* @version 0.2
*/
-public class Events implements Listener{
+public class Events implements Listener {
@EventHandler
public void onServerListPing(ServerListPingEvent e) {
- if(ServerSettings.isGame()) e.setMotd(ServerSettings.getServerType().toString() + ";" + ServerSettings.getGameState());
+ e.setMotd(ServerSettings.getServerType().name() + ";" + (ServerSettings.isGame() ? ServerSettings.getGameState() : ""));
}
@EventHandler
@@ -31,10 +40,54 @@ public class Events implements Listener{
@EventHandler
public void onMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
- if(p.getLocation().getY() <= 0) {
+ if (p.getLocation().getY() <= 0) {
p.setVelocity(new Vector().setY(10.0D).multiply(1.0D));
p.setGliding(true);
}
}
+ @EventHandler
+ public void onEntityTarget(EntityTargetEvent e) {
+ if (e.isCancelled()) return;
+ final Entity entity = e.getEntity();
+ final Entity target = e.getTarget();
+ if (!(target instanceof Player)) return;
+ CustomPlayer p = CustomPlayer.getPlayer((Player) target);
+ if (Vanish.getPlayers().contains(p) || SpectateManager.contains(p)) {
+ if (entity instanceof Tameable) {
+ e.setTarget(null);
+ }
+
+ if (entity instanceof ExperienceOrb) {
+ repellExpOrb((Player) target, (ExperienceOrb) entity);
+ e.setCancelled(true);
+ e.setTarget(null);
+ }
+ }
+ }
+
+ private void repellExpOrb(Player player, ExperienceOrb orb) {
+ final Location pLoc = player.getLocation();
+ final Location oLoc = orb.getLocation();
+ final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
+ final double dx = Math.abs(dir.getX());
+ final double dz = Math.abs(dir.getZ());
+ if ((dx == 0.0) && (dz == 0.0)) {
+ // Special case probably never happens
+ dir.setX(0.001);
+ }
+ if ((dx < 3.0) && (dz < 3.0)) {
+ final Vector nDir = dir.normalize();
+ final Vector newV = nDir.clone().multiply(0.3);
+ newV.setY(0);
+ orb.setVelocity(newV);
+ if ((dx < 1.0) && (dz < 1.0)) {
+ // maybe oLoc
+ orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), PlayerTeleportEvent.TeleportCause.PLUGIN);
+ }
+ if ((dx < 0.5) && (dz < 0.5)) {
+ orb.remove();
+ }
+ }
+ }
}
\ 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 1d5c536..ab48fb0 100644
--- a/src/main/java/eu/univento/core/listeners/JoinQuit.java
+++ b/src/main/java/eu/univento/core/listeners/JoinQuit.java
@@ -37,6 +37,9 @@ public class JoinQuit implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
+ if(!p.hasPlayedBefore()) {
+
+ }
for (Player players : Bukkit.getOnlinePlayers()) {
CustomPlayer player = CustomPlayer.getPlayer(players);
@@ -77,7 +80,7 @@ public class JoinQuit implements Listener {
p.initScoreboard();
p.sendTabHeaderAndFooter(p.getMessages().Core_TAB_TITLE() + Bukkit.getServerName(), p.getMessages().TAB_PREFIX());
if (p.getDatabasePlayer().getSettings().isNicked() && !ServerSettings.isLobby()) {
- p.setNick(NickName.getRandomNick());
+ p.setNickName(NickName.getRandomNick());
}
for (CustomPlayer player : Core.getOnlinePlayers()) {
p.getScoreboard().getTeam(player.getDatabasePlayer().getRank().getTeam()).addEntry(player.getDisplayName());
@@ -118,7 +121,7 @@ public class JoinQuit implements Listener {
if (Build.getPlayers().containsKey(p))
Build.getPlayers().remove(p);
if (p.getDatabasePlayer().getSettings().isNicked() && !ServerSettings.isLobby()) {
- p.removeNick();
+ p.removeNickName();
}
for (Team team : p.getScoreboard().getTeams()) {
team.removeEntry(p.getDisplayName());
diff --git a/src/main/java/eu/univento/core/listeners/PluginMessenger.java b/src/main/java/eu/univento/core/listeners/PluginMessenger.java
index db1ab78..6597471 100644
--- a/src/main/java/eu/univento/core/listeners/PluginMessenger.java
+++ b/src/main/java/eu/univento/core/listeners/PluginMessenger.java
@@ -2,9 +2,9 @@ package eu.univento.core.listeners;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
+import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
-import eu.univento.core.api.player.WarnReason;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
@@ -24,7 +24,7 @@ public class PluginMessenger implements PluginMessageListener {
e.printStackTrace();
}
Core.getCommons().getLoggingHandler().getCore().info(p.getName() + " hat WDL installiert. Version : " + version);
- p.sendMessage(p.getDatabasePlayer().getMessage("Prefix") + p.getDatabasePlayer().getMessage("Hack.WorldDownloader"));
+ p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader"));
}
if(channel.equals("WDL|CONTROL")) {
p.sendPluginMessage(Core.getInstance(), "WDL|CONTROL", createWDLPacket(0, false, false, false, false));
@@ -32,7 +32,7 @@ public class PluginMessenger implements PluginMessageListener {
if (channel.equals("PERMISSIONSREPL") && new String(data).contains("mod.worlddownloader")) {
//TODO: change to real warn reason
p.warn(WarnReason.SPAM, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks");
- p.sendMessage(p.getDatabasePlayer().getMessage("Prefix") + p.getDatabasePlayer().getMessage("Hack.WorldDownloader"));
+ p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader"));
}
if(channel.equals("5zig_Set")) {
try {
diff --git a/src/main/java/eu/univento/core/listeners/SpectatorEvents.java b/src/main/java/eu/univento/core/listeners/SpectatorEvents.java
index fde5561..ab7e2ab 100644
--- a/src/main/java/eu/univento/core/listeners/SpectatorEvents.java
+++ b/src/main/java/eu/univento/core/listeners/SpectatorEvents.java
@@ -1,5 +1,6 @@
package eu.univento.core.listeners;
+import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.SpectateManager;
import eu.univento.core.api.player.Spectator;
@@ -59,7 +60,7 @@ public class SpectatorEvents implements Listener{
public void onInventoryClick(InventoryClickEvent e) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
if(SpectateManager.contains(p)) {
- if (e.getInventory().getName().equals(p.getDatabasePlayer().getMessage("Game.Menu.SpectateMenu"))) {
+ if (e.getInventory().getName().equals(p.getDatabasePlayer().getLanguage().getWord("Game.Menu.SpectateMenu"))) {
if(e.getCurrentItem().getType() == Material.SKULL_ITEM) {
SkullMeta meta = (SkullMeta) e.getCurrentItem().getItemMeta();
CustomPlayer player = CustomPlayer.getPlayer(meta.getOwner());
@@ -70,7 +71,7 @@ public class SpectatorEvents implements Listener{
p.closeInventory();
spectator.spectate(player);
}else{
- p.sendMessage(p.getDatabasePlayer().getMessage("Not_online"));
+ p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NOT_ONLINE));
}
}
}