From 67fce8d9349e4f34684da15f5e3854a9b0d82484 Mon Sep 17 00:00:00 2001 From: hibo98 Date: Thu, 27 Jul 2017 16:37:39 +0200 Subject: [PATCH] Updated to Minecraft 1.12 --- src/de/anura/core/API/Core.java | 10 +- src/de/anura/core/AnuraCore.java | 3 - src/de/anura/core/FlowerPots.java | 2 +- src/de/anura/core/Setup.java | 6 - src/de/anura/core/events/PlayerMove.java | 2 +- .../anura/core/events/VotifierListener.java | 119 ------------------ 6 files changed, 5 insertions(+), 137 deletions(-) delete mode 100644 src/de/anura/core/events/VotifierListener.java diff --git a/src/de/anura/core/API/Core.java b/src/de/anura/core/API/Core.java index 22a01d8..3cef9da 100644 --- a/src/de/anura/core/API/Core.java +++ b/src/de/anura/core/API/Core.java @@ -8,15 +8,14 @@ import java.sql.ResultSet; import java.util.HashMap; import java.util.Map; import java.util.Set; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.material.MaterialData; @@ -314,9 +313,6 @@ public class Core { } public static void sendActionBar(Player P, String msg) { - CraftPlayer pl = (CraftPlayer) P; - IChatBaseComponent cbc = IChatBaseComponent.ChatSerializer.a("{\"text\":\"" + msg + "\"}"); - PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte) 2); - pl.getHandle().playerConnection.sendPacket(ppoc); + P.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(msg)); } } diff --git a/src/de/anura/core/AnuraCore.java b/src/de/anura/core/AnuraCore.java index 1e00123..6b9bb62 100644 --- a/src/de/anura/core/AnuraCore.java +++ b/src/de/anura/core/AnuraCore.java @@ -51,9 +51,6 @@ public class AnuraCore extends JavaPlugin { if (this.getConfig().getBoolean("is-main-lobby")) { Setup.setupXPBattle(); } - if (this.getConfig().getBoolean("enable-votifier")) { - Setup.setupVotifier(); - } this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", signs); this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new Teleports()); sql.queryUpdate("DELETE FROM coreServers WHERE name = '" + this.getConfig().getString("server-name") + "'"); diff --git a/src/de/anura/core/FlowerPots.java b/src/de/anura/core/FlowerPots.java index 92c2fda..6a33191 100644 --- a/src/de/anura/core/FlowerPots.java +++ b/src/de/anura/core/FlowerPots.java @@ -112,7 +112,7 @@ public class FlowerPots { for (int i = 0; i < 20; i++) { loc.getWorld().playEffect(loc, Effect.FIREWORKS_SPARK, 4); } - P.playSound(loc, Sound.LEVEL_UP, 1, (float) 1.5); + P.playSound(loc, Sound.ENTITY_PLAYER_LEVELUP, 1, (float) 1.5); ResultSet rs = AnuraCore.getSql().querySelect("SELECT id, url, name, money FROM corePots WHERE id = '" + pot + "'"); rs.first(); Money.payMoney(P, rs.getInt("money")); diff --git a/src/de/anura/core/Setup.java b/src/de/anura/core/Setup.java index f644755..5e6bdec 100644 --- a/src/de/anura/core/Setup.java +++ b/src/de/anura/core/Setup.java @@ -45,7 +45,6 @@ public class Setup { c.addDefault("spawn.Z", 0); c.addDefault("spawn.yaw", 0d); c.addDefault("spawn.pitch", 0d); - c.addDefault("enable-votifier", false); c.options().copyDefaults(true); c.options().header("Config File of the Anura Core-Plugin:"); } @@ -277,9 +276,4 @@ public class Setup { s.registerNewObjective("xpBattleIngame", "dummy"); } } - - public static void setupVotifier() { - AnuraCore.getInstance().getServer().getPluginManager().registerEvents(new VotifierListener(), AnuraCore.getInstance()); - AnuraCore.getInstance().getServer().getMessenger().registerIncomingPluginChannel(AnuraCore.getInstance(), "BungeeCord", new VotifierListener()); - } } diff --git a/src/de/anura/core/events/PlayerMove.java b/src/de/anura/core/events/PlayerMove.java index a4e6a41..019672f 100644 --- a/src/de/anura/core/events/PlayerMove.java +++ b/src/de/anura/core/events/PlayerMove.java @@ -71,7 +71,7 @@ public class PlayerMove implements Listener { p.setVelocity(p.getLocation().getDirection().multiply(new Vector(rs.getDouble("height"), 1, rs.getDouble("height")))); p.setVelocity(p.getVelocity().setY(1.3)); p.getWorld().spigot().playEffect(p.getLocation(), Effect.LAVA_POP, 0, 0, (float) 0.1, (float) 0.1, (float) 0.1, (float) 0.3, 10, 1); - p.playSound(p.getLocation(), Sound.EXPLODE, 1, 1); + p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1, 1); } } catch(Throwable ex) { Errors.reportException(ex); diff --git a/src/de/anura/core/events/VotifierListener.java b/src/de/anura/core/events/VotifierListener.java deleted file mode 100644 index df07e4b..0000000 --- a/src/de/anura/core/events/VotifierListener.java +++ /dev/null @@ -1,119 +0,0 @@ -package de.anura.core.events; - -import com.vexsoftware.votifier.model.Vote; -import com.vexsoftware.votifier.model.VotifierEvent; -import de.anura.core.API.Core; -import de.anura.core.API.Errors; -import de.anura.core.API.Money; -import de.anura.core.AnuraCore; -import java.io.*; -import java.net.Socket; -import java.sql.ResultSet; -import java.sql.SQLException; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.plugin.messaging.PluginMessageListener; - -public class VotifierListener implements Listener, PluginMessageListener { - - @EventHandler - public void onVotifierEvent(VotifierEvent event) { - Vote vote = event.getVote(); - String timestamp = vote.getTimeStamp(); - int timestampInt; - try { - timestampInt = Integer.parseInt(timestamp); - } catch (NumberFormatException ex) { - timestampInt = (int) (System.currentTimeMillis() / 1000); - } - try { - ResultSet rs1 = Core.getMySql().querySelect("SELECT id FROM `players` WHERE name = '" + vote.getUsername() + "'"); - if (!rs1.next()) { - return; - } - int money = 25; - int playerId; - playerId = rs1.getInt("id"); - ResultSet rs2 = Core.getMySql().querySelect("SELECT * FROM `voteUsers` WHERE playerId = '" + playerId + "'"); - if (rs2.first()) { - int lastVoteDate = rs2.getInt("dateOfLastVote"); - int votesInRow; - votesInRow = rs2.getInt("votesInARow"); - if (lastVoteDate > ((System.currentTimeMillis() / 1000) - (60 * 60 * 24))) { - votesInRow++; - if (votesInRow == 10) { - money += 50; - votesInRow = 0; - } - } else { - votesInRow = 1; - } - Core.getMySql().queryUpdate("UPDATE `voteUsers` SET `dateOfLastVote`=" + timestampInt + ",`votesInARow`=" + votesInRow + " WHERE playerId=" + playerId); - } else { - Core.getMySql().queryUpdate("INSERT INTO `voteUsers`(`playerId`, `dateOfLastVote`, `votesInARow`) VALUES (SELECT id FROM `players` WHERE name = '" + vote.getUsername() + "'," + timestampInt + ",1)"); - } - addPlayerMoney(money, vote); - } catch (SQLException ex) { - Errors.reportException(ex); - } - } - - public void addPlayerMoney(int money, Vote vote) { - try { - if (AnuraCore.getInstance().getServer().getOnlinePlayers().isEmpty()) { - Socket so = new Socket("127.0.0.1", 27767); - OutputStream os = so.getOutputStream(); - BufferedWriter ps = new BufferedWriter(new OutputStreamWriter(os)); - ps.write("X3Nw;a+F!R_p~(Wj#LZc"); - ps.newLine(); - ps.write("vote"); - ps.newLine(); - ps.write(vote.getUsername()); - ps.newLine(); - ps.write(money + ""); - ps.newLine(); - ps.flush(); - ps.close(); - so.close(); - } else { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(stream); - out.writeUTF("money"); - out.writeUTF(vote.getUsername()); - out.writeInt(money); - Player p = Bukkit.getOnlinePlayers().iterator().next(); - p.sendPluginMessage(AnuraCore.getInstance(), "BungeeCord", stream.toByteArray()); - } - - } catch (Exception ex) { - Errors.reportException(ex); - } - } - - @Override - public void onPluginMessageReceived(String channel, Player player, byte[] bytes) { - if (!channel.equals("BungeeCord")) { - return; - } - try { - ByteArrayInputStream stream = new ByteArrayInputStream(bytes); - DataInputStream in = new DataInputStream(stream); - - if (in.readUTF().equalsIgnoreCase("money")) { - String playername = in.readUTF(); - Player p = Bukkit.getPlayer(playername); - int money = Integer.parseInt(in.readUTF()); - Core.statusMsg(p, "Vote_Normal", true); - if (money == 75) { - Core.statusMsg(p, "Vote_10_Times", true); - } - Money.payMoney(p, money); - } - } catch (IOException ex) { - Errors.reportException(ex); - } - } - -}