Updated to Minecraft 1.12
This commit is contained in:
@@ -8,15 +8,14 @@ import java.sql.ResultSet;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
@@ -314,9 +313,6 @@ public class Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendActionBar(Player P, String msg) {
|
public static void sendActionBar(Player P, String msg) {
|
||||||
CraftPlayer pl = (CraftPlayer) P;
|
P.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(msg));
|
||||||
IChatBaseComponent cbc = IChatBaseComponent.ChatSerializer.a("{\"text\":\"" + msg + "\"}");
|
|
||||||
PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte) 2);
|
|
||||||
pl.getHandle().playerConnection.sendPacket(ppoc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,9 +51,6 @@ public class AnuraCore extends JavaPlugin {
|
|||||||
if (this.getConfig().getBoolean("is-main-lobby")) {
|
if (this.getConfig().getBoolean("is-main-lobby")) {
|
||||||
Setup.setupXPBattle();
|
Setup.setupXPBattle();
|
||||||
}
|
}
|
||||||
if (this.getConfig().getBoolean("enable-votifier")) {
|
|
||||||
Setup.setupVotifier();
|
|
||||||
}
|
|
||||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", signs);
|
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", signs);
|
||||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new Teleports());
|
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new Teleports());
|
||||||
sql.queryUpdate("DELETE FROM coreServers WHERE name = '" + this.getConfig().getString("server-name") + "'");
|
sql.queryUpdate("DELETE FROM coreServers WHERE name = '" + this.getConfig().getString("server-name") + "'");
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class FlowerPots {
|
|||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
loc.getWorld().playEffect(loc, Effect.FIREWORKS_SPARK, 4);
|
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 + "'");
|
ResultSet rs = AnuraCore.getSql().querySelect("SELECT id, url, name, money FROM corePots WHERE id = '" + pot + "'");
|
||||||
rs.first();
|
rs.first();
|
||||||
Money.payMoney(P, rs.getInt("money"));
|
Money.payMoney(P, rs.getInt("money"));
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class Setup {
|
|||||||
c.addDefault("spawn.Z", 0);
|
c.addDefault("spawn.Z", 0);
|
||||||
c.addDefault("spawn.yaw", 0d);
|
c.addDefault("spawn.yaw", 0d);
|
||||||
c.addDefault("spawn.pitch", 0d);
|
c.addDefault("spawn.pitch", 0d);
|
||||||
c.addDefault("enable-votifier", false);
|
|
||||||
c.options().copyDefaults(true);
|
c.options().copyDefaults(true);
|
||||||
c.options().header("Config File of the Anura Core-Plugin:");
|
c.options().header("Config File of the Anura Core-Plugin:");
|
||||||
}
|
}
|
||||||
@@ -277,9 +276,4 @@ public class Setup {
|
|||||||
s.registerNewObjective("xpBattleIngame", "dummy");
|
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.getLocation().getDirection().multiply(new Vector(rs.getDouble("height"), 1, rs.getDouble("height"))));
|
||||||
p.setVelocity(p.getVelocity().setY(1.3));
|
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.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) {
|
} catch(Throwable ex) {
|
||||||
Errors.reportException(ex);
|
Errors.reportException(ex);
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user