Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c73a9f3bd5
@ -238,10 +238,12 @@ public class UtilBlock
|
|||||||
blockUseSet.add((byte)69); //Lever
|
blockUseSet.add((byte)69); //Lever
|
||||||
blockUseSet.add((byte)71); //Iron Door
|
blockUseSet.add((byte)71); //Iron Door
|
||||||
blockUseSet.add((byte)77); //Button
|
blockUseSet.add((byte)77); //Button
|
||||||
|
blockUseSet.add((byte)85); //Fence (stupid minecraft)
|
||||||
blockUseSet.add((byte)93); //Repeater
|
blockUseSet.add((byte)93); //Repeater
|
||||||
blockUseSet.add((byte)94); //Repeater
|
blockUseSet.add((byte)94); //Repeater
|
||||||
blockUseSet.add((byte)96); //Trapdoor
|
blockUseSet.add((byte)96); //Trapdoor
|
||||||
blockUseSet.add((byte)107); //Fence Gate
|
blockUseSet.add((byte)107); //Fence Gate
|
||||||
|
blockUseSet.add((byte)113); //Nether Fence (stupid minecraft)
|
||||||
blockUseSet.add((byte)116); //Enchantment Table
|
blockUseSet.add((byte)116); //Enchantment Table
|
||||||
blockUseSet.add((byte)117); //Brewing Stand
|
blockUseSet.add((byte)117); //Brewing Stand
|
||||||
blockUseSet.add((byte)130); //Ender Chest
|
blockUseSet.add((byte)130); //Ender Chest
|
||||||
@ -249,6 +251,22 @@ public class UtilBlock
|
|||||||
blockUseSet.add((byte)146); //Trapped Chest
|
blockUseSet.add((byte)146); //Trapped Chest
|
||||||
blockUseSet.add((byte)154); //Hopper
|
blockUseSet.add((byte)154); //Hopper
|
||||||
blockUseSet.add((byte)158); //Dropper
|
blockUseSet.add((byte)158); //Dropper
|
||||||
|
|
||||||
|
blockUseSet.add((byte)184); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)185); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)186); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)187); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)188); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)189); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)190); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)191); //Fences/Gates
|
||||||
|
blockUseSet.add((byte)192); //Fences/Gates
|
||||||
|
|
||||||
|
blockUseSet.add((byte)193); //Wood Doors
|
||||||
|
blockUseSet.add((byte)194); //Wood Doors
|
||||||
|
blockUseSet.add((byte)195); //Wood Doors
|
||||||
|
blockUseSet.add((byte)196); //Wood Doors
|
||||||
|
blockUseSet.add((byte)197); //Wood Doors
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockUseSet.contains(block);
|
return blockUseSet.contains(block);
|
||||||
|
@ -0,0 +1,121 @@
|
|||||||
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class UtilInput
|
||||||
|
{
|
||||||
|
//Valid Chars
|
||||||
|
protected static HashSet<Character> validSet = new HashSet<Character>();
|
||||||
|
protected static HashSet<String> filterSet = new HashSet<String>();
|
||||||
|
|
||||||
|
public static boolean valid(String input)
|
||||||
|
{
|
||||||
|
if (validSet.isEmpty())
|
||||||
|
addChars();
|
||||||
|
|
||||||
|
for (char cur : input.toCharArray())
|
||||||
|
if (!validSet.contains(cur))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String filter(String input)
|
||||||
|
{
|
||||||
|
if (filterSet.isEmpty())
|
||||||
|
addDictionary();
|
||||||
|
|
||||||
|
for (String cur : filterSet)
|
||||||
|
{
|
||||||
|
if (input.equalsIgnoreCase(cur))
|
||||||
|
{
|
||||||
|
String out = "" + input.charAt(0);
|
||||||
|
while (out.length() < input.length())
|
||||||
|
out += '*';
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addDictionary()
|
||||||
|
{
|
||||||
|
filterSet.add("fuck");
|
||||||
|
filterSet.add("shit");
|
||||||
|
filterSet.add("cunt");
|
||||||
|
filterSet.add("ass");
|
||||||
|
filterSet.add("asshole");
|
||||||
|
filterSet.add("faggot");
|
||||||
|
filterSet.add("fag");
|
||||||
|
filterSet.add("gay");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addChars()
|
||||||
|
{
|
||||||
|
validSet.add('1');
|
||||||
|
validSet.add('2');
|
||||||
|
validSet.add('3');
|
||||||
|
validSet.add('4');
|
||||||
|
validSet.add('5');
|
||||||
|
validSet.add('6');
|
||||||
|
validSet.add('7');
|
||||||
|
validSet.add('8');
|
||||||
|
validSet.add('9');
|
||||||
|
validSet.add('0');
|
||||||
|
|
||||||
|
validSet.add('a');
|
||||||
|
validSet.add('b');
|
||||||
|
validSet.add('c');
|
||||||
|
validSet.add('d');
|
||||||
|
validSet.add('e');
|
||||||
|
validSet.add('f');
|
||||||
|
validSet.add('g');
|
||||||
|
validSet.add('h');
|
||||||
|
validSet.add('i');
|
||||||
|
validSet.add('j');
|
||||||
|
validSet.add('k');
|
||||||
|
validSet.add('l');
|
||||||
|
validSet.add('m');
|
||||||
|
validSet.add('n');
|
||||||
|
validSet.add('o');
|
||||||
|
validSet.add('p');
|
||||||
|
validSet.add('q');
|
||||||
|
validSet.add('r');
|
||||||
|
validSet.add('s');
|
||||||
|
validSet.add('t');
|
||||||
|
validSet.add('u');
|
||||||
|
validSet.add('v');
|
||||||
|
validSet.add('w');
|
||||||
|
validSet.add('x');
|
||||||
|
validSet.add('y');
|
||||||
|
validSet.add('z');
|
||||||
|
|
||||||
|
validSet.add('A');
|
||||||
|
validSet.add('B');
|
||||||
|
validSet.add('C');
|
||||||
|
validSet.add('D');
|
||||||
|
validSet.add('E');
|
||||||
|
validSet.add('F');
|
||||||
|
validSet.add('G');
|
||||||
|
validSet.add('H');
|
||||||
|
validSet.add('I');
|
||||||
|
validSet.add('J');
|
||||||
|
validSet.add('K');
|
||||||
|
validSet.add('L');
|
||||||
|
validSet.add('M');
|
||||||
|
validSet.add('N');
|
||||||
|
validSet.add('O');
|
||||||
|
validSet.add('P');
|
||||||
|
validSet.add('Q');
|
||||||
|
validSet.add('R');
|
||||||
|
validSet.add('S');
|
||||||
|
validSet.add('T');
|
||||||
|
validSet.add('U');
|
||||||
|
validSet.add('V');
|
||||||
|
validSet.add('W');
|
||||||
|
validSet.add('X');
|
||||||
|
validSet.add('Y');
|
||||||
|
validSet.add('Z');
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package mineplex.core;
|
package mineplex.core;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ import net.minecraft.server.v1_7_R4.Packet;
|
|||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||||
import net.minecraft.server.v1_7_R4.WatchableObject;
|
import net.minecraft.server.v1_7_R4.WatchableObject;
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
|||||||
private NautHashMap<Player, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<Player, NautHashMap<Integer, String>>();
|
private NautHashMap<Player, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<Player, NautHashMap<Integer, String>>();
|
||||||
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityVehicleMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
|
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityVehicleMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
|
||||||
private NautHashMap<Player, Long> _loggedIn = new NautHashMap<Player, Long>();
|
private NautHashMap<Player, Long> _loggedIn = new NautHashMap<Player, Long>();
|
||||||
|
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
|
||||||
|
|
||||||
private Field _destroyId;
|
private Field _destroyId;
|
||||||
|
|
||||||
@ -149,7 +152,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
|||||||
{
|
{
|
||||||
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
|
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
|
||||||
|
|
||||||
if (!_entityMap.get(owner).containsKey(metaPacket.a) && metaPacket.a != 777777)
|
if (!_entityMap.get(owner).containsKey(metaPacket.a) && metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
|
||||||
{
|
{
|
||||||
String entityName = "";
|
String entityName = "";
|
||||||
boolean nameShowing = false;
|
boolean nameShowing = false;
|
||||||
@ -199,6 +202,14 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
|||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (packet instanceof PacketPlayOutSpawnEntity)
|
||||||
|
{
|
||||||
|
PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet;
|
||||||
|
if (spawnPacket.j == 66 && spawnPacket.a != 777777)
|
||||||
|
{
|
||||||
|
_ignoreSkulls.add(spawnPacket.a);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
else if (packet instanceof PacketPlayOutAttachEntity)
|
else if (packet instanceof PacketPlayOutAttachEntity)
|
||||||
{
|
{
|
||||||
|
@ -7,25 +7,20 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
|
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
|
||||||
{
|
{
|
||||||
private static Object _clientDataLock = new Object();
|
private static Object _clientDataLock = new Object();
|
||||||
|
|
||||||
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
|
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
|
||||||
|
|
||||||
|
|
||||||
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super(moduleName, plugin);
|
super(moduleName, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void loadPlayer(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
loadClientInformation(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void UnloadPlayer(ClientUnloadEvent event)
|
public void UnloadPlayer(ClientUnloadEvent event)
|
||||||
{
|
{
|
||||||
@ -70,6 +65,4 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract DataType AddPlayer(String player);
|
protected abstract DataType AddPlayer(String player);
|
||||||
|
|
||||||
protected abstract void loadClientInformation(RetrieveClientInformationEvent event);
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package mineplex.core;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.ILoginProcessor;
|
||||||
|
|
||||||
|
public abstract class MiniDbClientPlugin<DataType extends Object> extends MiniClientPlugin<DataType> implements ILoginProcessor
|
||||||
|
{
|
||||||
|
protected CoreClientManager ClientManager = null;
|
||||||
|
|
||||||
|
public MiniDbClientPlugin(String moduleName, JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
|
{
|
||||||
|
super(moduleName, plugin);
|
||||||
|
|
||||||
|
ClientManager = clientManager;
|
||||||
|
|
||||||
|
clientManager.addStoredProcedureLoginProcessor(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
||||||
|
}
|
@ -1,123 +0,0 @@
|
|||||||
package mineplex.core;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.inventory.InventoryManager;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public class RankBenefitsGiver9000 extends MiniPlugin
|
|
||||||
{
|
|
||||||
private CoreClientManager _clientManager;
|
|
||||||
private InventoryManager _inventoryManager;
|
|
||||||
private RankBenefitsGiver9000Repository _repository;
|
|
||||||
|
|
||||||
private NautHashMap<String, String> _playersNeedingBenefit = new NautHashMap<String, String>();
|
|
||||||
|
|
||||||
public RankBenefitsGiver9000(JavaPlugin plugin, CoreClientManager clientManager, InventoryManager inventoryManager)
|
|
||||||
{
|
|
||||||
super("RankBenefitsGiver9000", plugin);
|
|
||||||
|
|
||||||
_clientManager = clientManager;
|
|
||||||
_inventoryManager = inventoryManager;
|
|
||||||
_repository = new RankBenefitsGiver9000Repository(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void loadPlayer(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
boolean treasureUpdate = false;
|
|
||||||
boolean horrorUpdate = false;
|
|
||||||
|
|
||||||
for (String benefit : _repository.retrievePlayerBenefits(event.getUniqueId().toString()))
|
|
||||||
{
|
|
||||||
if (benefit.equalsIgnoreCase("TreasureUpdate"))
|
|
||||||
treasureUpdate = true;
|
|
||||||
|
|
||||||
if (benefit.equalsIgnoreCase("HalloweenHorror"))
|
|
||||||
horrorUpdate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!horrorUpdate)
|
|
||||||
{
|
|
||||||
_playersNeedingBenefit.put(event.getPlayerName(), "Horror");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!treasureUpdate)
|
|
||||||
{
|
|
||||||
_playersNeedingBenefit.put(event.getPlayerName(), "Treasure");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void giveBenefit(final PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
if (!_playersNeedingBenefit.containsKey(event.getPlayer().getName()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_playersNeedingBenefit.get(event.getPlayer().getName()).contains("Horror"))
|
|
||||||
{
|
|
||||||
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 2);
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
_repository.addBenefit(event.getPlayer().getUniqueId().toString(), "HalloweenHorror");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), C.cPurple + C.Strike + "=============================================");
|
|
||||||
UtilPlayer.message(event.getPlayer(), "");
|
|
||||||
UtilPlayer.message(event.getPlayer(), C.cGold + C.Strike + "HAPPY HALLOWEEN");
|
|
||||||
UtilPlayer.message(event.getPlayer(), "You received 2 Treasure Keys!");
|
|
||||||
UtilPlayer.message(event.getPlayer(), "");
|
|
||||||
UtilPlayer.message(event.getPlayer(), C.cPurple + C.Strike + "=============================================");
|
|
||||||
}
|
|
||||||
}, 5L);
|
|
||||||
}
|
|
||||||
else if (_playersNeedingBenefit.get(event.getPlayer().getName()).contains("Treasure"))
|
|
||||||
{
|
|
||||||
if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ALL)
|
|
||||||
{
|
|
||||||
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 1);
|
|
||||||
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 1);
|
|
||||||
}
|
|
||||||
else if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ULTRA)
|
|
||||||
{
|
|
||||||
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 20);
|
|
||||||
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 5);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 40);
|
|
||||||
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
_repository.addBenefit(event.getPlayer().getUniqueId().toString(), "TreasureUpdate");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_playersNeedingBenefit.remove(event.getPlayer().getName());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package mineplex.core;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import mineplex.core.database.DBPool;
|
|
||||||
import mineplex.core.database.RepositoryBase;
|
|
||||||
import mineplex.core.database.ResultSetCallable;
|
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public class RankBenefitsGiver9000Repository extends RepositoryBase
|
|
||||||
{
|
|
||||||
// private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
|
|
||||||
|
|
||||||
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);";
|
|
||||||
private static String RETRIEVE_BENEFITS = "SELECT benefit FROM rankBenefits WHERE uuid = ?;";
|
|
||||||
|
|
||||||
public RankBenefitsGiver9000Repository(JavaPlugin plugin)
|
|
||||||
{
|
|
||||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initialize()
|
|
||||||
{
|
|
||||||
// executeUpdate(CREATE_BENEFIT_TABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void update()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> retrievePlayerBenefits(String uuid)
|
|
||||||
{
|
|
||||||
final List<String> benefits = new ArrayList<String>();
|
|
||||||
|
|
||||||
executeQuery(RETRIEVE_BENEFITS, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
|
||||||
{
|
|
||||||
benefits.add(resultSet.getString(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
|
|
||||||
return benefits;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addBenefit(String uuid, String benefit)
|
|
||||||
{
|
|
||||||
executeUpdate(INSERT_BENEFIT, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("benefit", 100, benefit));
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,10 +10,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.command.UpdateRank;
|
import mineplex.core.account.command.UpdateRank;
|
||||||
import mineplex.core.account.event.AsyncClientLoadEvent;
|
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.account.repository.AccountRepository;
|
import mineplex.core.account.repository.AccountRepository;
|
||||||
import mineplex.core.account.repository.token.ClientToken;
|
import mineplex.core.account.repository.token.ClientToken;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
@ -41,11 +39,15 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class CoreClientManager extends MiniPlugin
|
public class CoreClientManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
private static NautHashMap<String, Object> _clientLoginLock = new NautHashMap<String, Object>();
|
||||||
|
|
||||||
private JavaPlugin _plugin;
|
private JavaPlugin _plugin;
|
||||||
private AccountRepository _repository;
|
private AccountRepository _repository;
|
||||||
private NautHashMap<String, CoreClient> _clientList;
|
private NautHashMap<String, CoreClient> _clientList;
|
||||||
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
||||||
|
|
||||||
|
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
||||||
|
|
||||||
private Object _clientLock = new Object();
|
private Object _clientLock = new Object();
|
||||||
|
|
||||||
private static int _connectingClients = 0;
|
private static int _connectingClients = 0;
|
||||||
@ -187,38 +189,11 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
client.SetAccountId(token.AccountId);
|
client.SetAccountId(token.AccountId);
|
||||||
client.SetRank(Rank.valueOf(token.Rank));
|
client.SetRank(Rank.valueOf(token.Rank));
|
||||||
|
|
||||||
final RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid);
|
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||||
clientInformationEvent.incrementProcessingCount();
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
_repository.login(uuid.toString(), client.GetPlayerName());
|
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent);
|
|
||||||
clientInformationEvent.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
|
|
||||||
// Load client in miniplugins
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
|
|
||||||
|
|
||||||
while (clientInformationEvent.processing())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(1);
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(GetPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTask(GetPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -235,40 +210,38 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");
|
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");
|
||||||
|
|
||||||
|
_clientLoginLock.put(client.GetPlayerName(), new Object());
|
||||||
ClientToken token = null;
|
ClientToken token = null;
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
final RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid);
|
runAsync(new Runnable()
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
_repository.login(uuid.toString(), client.GetPlayerName());
|
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||||
|
_clientLoginLock.remove(client.GetPlayerName());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TimingManager.start(client.GetPlayerName() + " GetClient.");
|
||||||
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
|
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
|
||||||
|
TimingManager.stop(client.GetPlayerName() + " GetClient.");
|
||||||
|
|
||||||
token = gson.fromJson(response, ClientToken.class);
|
token = gson.fromJson(response, ClientToken.class);
|
||||||
|
|
||||||
client.SetAccountId(token.AccountId);
|
client.SetAccountId(token.AccountId);
|
||||||
client.SetRank(Rank.valueOf(token.Rank));
|
client.SetRank(Rank.valueOf(token.Rank));
|
||||||
|
|
||||||
_repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
|
// _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
|
|
||||||
// Load client in miniplugins
|
while (_clientLoginLock.containsKey(client.GetPlayerName()))
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
|
|
||||||
|
|
||||||
while (clientInformationEvent.processing())
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep(1);
|
Thread.sleep(2);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
@ -429,4 +402,9 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
|
||||||
|
{
|
||||||
|
_loginProcessors.put(processor.getName(), processor);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package mineplex.core.account;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public interface ILoginProcessor
|
||||||
|
{
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
||||||
|
|
||||||
|
String getQuery(String uuid, String name);
|
||||||
|
}
|
@ -50,7 +50,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
|||||||
|
|
||||||
final Rank rank = tempRank;
|
final Rank rank = tempRank;
|
||||||
|
|
||||||
if (rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
if ((rank == Rank.YOUTUBE && Plugin.Get(caller).GetRank().Has(Rank.OWNER)) || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
||||||
{
|
{
|
||||||
Plugin.getRepository().MatchPlayerName(new Callback<List<String>>()
|
Plugin.getRepository().MatchPlayerName(new Callback<List<String>>()
|
||||||
{
|
{
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package mineplex.core.account.event;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
|
||||||
import mineplex.core.account.repository.token.ClientToken;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class AsyncClientLoadEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private ClientToken _token;
|
|
||||||
private CoreClient _client;
|
|
||||||
|
|
||||||
public AsyncClientLoadEvent(ClientToken token, CoreClient client)
|
|
||||||
{
|
|
||||||
_token = token;
|
|
||||||
_client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreClient GetClient()
|
|
||||||
{
|
|
||||||
return _client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientToken GetClientToken()
|
|
||||||
{
|
|
||||||
return _token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package mineplex.core.account.event;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class RetrieveClientInformationEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private String _playerName;
|
|
||||||
private UUID _uuid;
|
|
||||||
private int _processingCount;
|
|
||||||
|
|
||||||
public RetrieveClientInformationEvent(String playerName, UUID uuid)
|
|
||||||
{
|
|
||||||
_playerName = playerName;
|
|
||||||
_uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPlayerName()
|
|
||||||
{
|
|
||||||
return _playerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUniqueId()
|
|
||||||
{
|
|
||||||
return _uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementProcessingCount()
|
|
||||||
{
|
|
||||||
_processingCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean processing()
|
|
||||||
{
|
|
||||||
return _processingCount > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decreaseProcessingCount()
|
|
||||||
{
|
|
||||||
_processingCount--;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ package mineplex.core.account.repository;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -11,10 +12,12 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.account.ILoginProcessor;
|
||||||
import mineplex.core.account.repository.token.LoginToken;
|
import mineplex.core.account.repository.token.LoginToken;
|
||||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.database.DatabaseRunnable;
|
import mineplex.core.database.DatabaseRunnable;
|
||||||
import mineplex.core.database.RepositoryBase;
|
import mineplex.core.database.RepositoryBase;
|
||||||
@ -28,7 +31,6 @@ public class AccountRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
|
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
|
||||||
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
|
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
|
||||||
private static String ACCOUNT_LOGIN_UPDATE = "UPDATE accounts SET uuid=?, name=?, lastLogin=now() WHERE uuid = ?;";
|
|
||||||
private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||||
private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||||
private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
||||||
@ -41,9 +43,34 @@ public class AccountRepository extends RepositoryBase
|
|||||||
|
|
||||||
public AccountRepository(JavaPlugin plugin, String webAddress)
|
public AccountRepository(JavaPlugin plugin, String webAddress)
|
||||||
{
|
{
|
||||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true", "root", "tAbechAk3wR7tuTh");
|
||||||
|
|
||||||
_webAddress = webAddress;
|
_webAddress = webAddress;
|
||||||
|
|
||||||
|
Statement statement = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement = getConnection().createStatement();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -52,12 +79,105 @@ public class AccountRepository extends RepositoryBase
|
|||||||
executeUpdate(CREATE_ACCOUNT_TABLE);
|
executeUpdate(CREATE_ACCOUNT_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void login(String uuid, String name)
|
public void login(NautHashMap<String, ILoginProcessor> loginProcessors, String uuid, String name)
|
||||||
{
|
{
|
||||||
int affectedRows = executeUpdate(ACCOUNT_LOGIN_UPDATE, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid));
|
Statement statement = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
|
||||||
if (affectedRows == 0)
|
try
|
||||||
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name));
|
{
|
||||||
|
statement = getConnection().createStatement();
|
||||||
|
|
||||||
|
/*
|
||||||
|
boolean statementStatus = statement.execute(
|
||||||
|
"UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"
|
||||||
|
+ "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT benefit FROM rankBenefits WHERE rankBenefits.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = '" + uuid + "';"
|
||||||
|
+ "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';"
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';";
|
||||||
|
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||||
|
{
|
||||||
|
loginString += loginProcessor.getQuery(uuid, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
statement.execute(loginString);
|
||||||
|
|
||||||
|
/*
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (statementStatus)
|
||||||
|
{
|
||||||
|
System.out.println("ResultSet : " + statement.getResultSet().getMetaData().getColumnCount() + " columns:");
|
||||||
|
|
||||||
|
for (int i = 0; i < statement.getResultSet().getMetaData().getColumnCount(); i++)
|
||||||
|
{
|
||||||
|
System.out.println(statement.getResultSet().getMetaData().getColumnName(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (statement.getUpdateCount() == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
System.out.println("Update statement : " + statement.getUpdateCount() + " rows affected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
statementStatus = statement.getMoreResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Done");
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean accountExists = statement.getUpdateCount() != 0;
|
||||||
|
|
||||||
|
statement.getMoreResults();
|
||||||
|
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||||
|
{
|
||||||
|
loginProcessor.processLoginResultSet(name, statement.getResultSet());
|
||||||
|
statement.getMoreResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!accountExists)
|
||||||
|
{
|
||||||
|
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 100, name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultSet != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
resultSet.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetClient(String name, UUID uuid, String ipAddress)
|
public String GetClient(String name, UUID uuid, String ipAddress)
|
||||||
|
@ -279,7 +279,7 @@ public enum Achievement
|
|||||||
|
|
||||||
SUPER_PAINTBALL_SPEEDRUNNER("Speedrunner", 1000,
|
SUPER_PAINTBALL_SPEEDRUNNER("Speedrunner", 1000,
|
||||||
new String[]{"Super Paintball.Speedrunner"},
|
new String[]{"Super Paintball.Speedrunner"},
|
||||||
new String[]{"Win a game in 20 seconds"},
|
new String[]{"Win a game in 30 seconds"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.SUPER_PAINTBALL),
|
AchievementCategory.SUPER_PAINTBALL),
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ public enum Achievement
|
|||||||
|
|
||||||
SNAKE_CANNIBAL("Cannibal", 1600,
|
SNAKE_CANNIBAL("Cannibal", 1600,
|
||||||
new String[]{"Snake.Cannibal"},
|
new String[]{"Snake.Cannibal"},
|
||||||
new String[]{"Kill 8 players in a single game"},
|
new String[]{"Kill 6 players in a single game"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.SNAKE),
|
AchievementCategory.SNAKE),
|
||||||
|
|
||||||
@ -519,7 +519,7 @@ public enum Achievement
|
|||||||
|
|
||||||
MICRO_BATTLE_ANNIHILATION("Annihilation", 1200,
|
MICRO_BATTLE_ANNIHILATION("Annihilation", 1200,
|
||||||
new String[]{"Micro Battle.Annihilation"},
|
new String[]{"Micro Battle.Annihilation"},
|
||||||
new String[]{"Kill 12 players in one game"},
|
new String[]{"Kill 8 players in one game"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.MICRO_BATTLE),
|
AchievementCategory.MICRO_BATTLE),
|
||||||
|
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
package mineplex.core.antistack;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
import mineplex.core.updater.UpdateType;
|
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public class AntiStack extends MiniPlugin
|
|
||||||
{
|
|
||||||
private boolean _enabled = true;
|
|
||||||
|
|
||||||
private HashSet<Location> _ignoreAround = new HashSet<Location>();
|
|
||||||
|
|
||||||
public AntiStack(JavaPlugin plugin)
|
|
||||||
{
|
|
||||||
super("AntiStack", plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void BlockBreak(BlockBreakEvent event)
|
|
||||||
{
|
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.isCancelled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
_ignoreAround.add(event.getBlock().getLocation().add(0.5, 0.5, 0.5));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void ClearIgnoreAround(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getType() != UpdateType.TICK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_ignoreAround.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler (priority=EventPriority.HIGHEST)
|
|
||||||
public void ItemSpawn(ItemSpawnEvent event)
|
|
||||||
{
|
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.isCancelled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item item = event.getEntity();
|
|
||||||
|
|
||||||
for (Location loc : _ignoreAround)
|
|
||||||
if (UtilMath.offset(loc, event.getLocation()) < 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//ItemName()
|
|
||||||
if (item.getLocation().getY() < -10)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Get Name
|
|
||||||
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
|
|
||||||
|
|
||||||
//Append UID
|
|
||||||
name += ":" + item.getUniqueId();
|
|
||||||
|
|
||||||
//Set Name
|
|
||||||
((CraftItemStack)item.getItemStack()).getHandle().c(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler (priority=EventPriority.HIGHEST)
|
|
||||||
public void PlayerPickup(PlayerPickupItemEvent event)
|
|
||||||
{
|
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.isCancelled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item item = event.getItem();
|
|
||||||
|
|
||||||
removeUID(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void HopperPickup(InventoryPickupItemEvent event)
|
|
||||||
{
|
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.isCancelled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item item = event.getItem();
|
|
||||||
|
|
||||||
//Get Name
|
|
||||||
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
|
|
||||||
|
|
||||||
//Remove UID
|
|
||||||
if (name.contains(":"))
|
|
||||||
name = name.substring(0, name.indexOf(":" + item.getUniqueId()));
|
|
||||||
|
|
||||||
//Set Name
|
|
||||||
((CraftItemStack)item.getItemStack()).getHandle().c(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetEnabled(boolean var)
|
|
||||||
{
|
|
||||||
_enabled = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeUID(Item item)
|
|
||||||
{
|
|
||||||
//Get Name
|
|
||||||
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
|
|
||||||
|
|
||||||
//Remove UID
|
|
||||||
if (name.contains(":"))
|
|
||||||
name = name.substring(0, name.indexOf(":" + item.getUniqueId()));
|
|
||||||
|
|
||||||
//Set Name
|
|
||||||
((CraftItemStack)item.getItemStack()).getHandle().c(name);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package mineplex.core.benefit;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class BenefitData
|
||||||
|
{
|
||||||
|
public HashSet<String> Benefits = new HashSet<String>();
|
||||||
|
public boolean Loaded = false;
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package mineplex.core.benefit;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.benefit.benefits.BenefitBase;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.inventory.InventoryManager;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
||||||
|
{
|
||||||
|
private BenefitManagerRepository _repository;
|
||||||
|
|
||||||
|
private List<BenefitBase> _benefits = new ArrayList<BenefitBase>();
|
||||||
|
|
||||||
|
public BenefitManager(JavaPlugin plugin, CoreClientManager clientManager, InventoryManager inventoryManager)
|
||||||
|
{
|
||||||
|
super("Benefit Manager", plugin, clientManager);
|
||||||
|
|
||||||
|
_repository = new BenefitManagerRepository(plugin);
|
||||||
|
|
||||||
|
//_benefits.add(new Thanksgiving2014(plugin, _repository, inventoryManager));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void giveBenefit(final PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (Get(event.getPlayer()).Loaded)
|
||||||
|
{
|
||||||
|
for (final BenefitBase benefit : _benefits)
|
||||||
|
{
|
||||||
|
if (!Get(event.getPlayer()).Benefits.contains(benefit.getName()))
|
||||||
|
{
|
||||||
|
benefit.recordBenefit(event.getPlayer(), new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
benefit.rewardPlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.out.println("Benefit reward failed for " + event.getPlayer().getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 100L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BenefitData AddPlayer(String player)
|
||||||
|
{
|
||||||
|
return new BenefitData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.retrievePlayerBenefitData(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT benefit FROM rankBenefits WHERE rankBenefits.uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package mineplex.core.benefit;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import mineplex.core.database.RepositoryBase;
|
||||||
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class BenefitManagerRepository extends RepositoryBase
|
||||||
|
{
|
||||||
|
// private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
|
||||||
|
|
||||||
|
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);";
|
||||||
|
|
||||||
|
public BenefitManagerRepository(JavaPlugin plugin)
|
||||||
|
{
|
||||||
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initialize()
|
||||||
|
{
|
||||||
|
// executeUpdate(CREATE_BENEFIT_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addBenefit(String uuid, String benefit)
|
||||||
|
{
|
||||||
|
return executeUpdate(INSERT_BENEFIT, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("benefit", 100, benefit)) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BenefitData retrievePlayerBenefitData(ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
BenefitData playerBenefit = new BenefitData();
|
||||||
|
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
playerBenefit.Benefits.add(resultSet.getString(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return playerBenefit;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package mineplex.core.benefit.benefits;
|
||||||
|
|
||||||
|
import mineplex.core.benefit.BenefitManagerRepository;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public abstract class BenefitBase
|
||||||
|
{
|
||||||
|
private JavaPlugin _plugin;
|
||||||
|
private String _name;
|
||||||
|
private BenefitManagerRepository _repository;
|
||||||
|
|
||||||
|
protected BenefitBase(JavaPlugin plugin, String name, BenefitManagerRepository repository)
|
||||||
|
{
|
||||||
|
_plugin = plugin;
|
||||||
|
_name = name;
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JavaPlugin getPlugin()
|
||||||
|
{
|
||||||
|
return _plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BenefitManagerRepository getRepository()
|
||||||
|
{
|
||||||
|
return _repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void rewardPlayer(Player player);
|
||||||
|
|
||||||
|
public void recordBenefit(final Player player, final Callback<Boolean> callback)
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
boolean success = _repository.addBenefit(player.getUniqueId().toString(), _name);
|
||||||
|
|
||||||
|
callback.run(success);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package mineplex.core.benefit.benefits;
|
||||||
|
|
||||||
|
import mineplex.core.benefit.BenefitManagerRepository;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.inventory.InventoryManager;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class Thanksgiving2014 extends BenefitBase
|
||||||
|
{
|
||||||
|
private InventoryManager _inventoryManager;
|
||||||
|
|
||||||
|
public Thanksgiving2014(JavaPlugin plugin, BenefitManagerRepository repository, InventoryManager inventoryManager)
|
||||||
|
{
|
||||||
|
super(plugin, "Thanksgiving2014", repository);
|
||||||
|
|
||||||
|
_inventoryManager = inventoryManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rewardPlayer(final Player player)
|
||||||
|
{
|
||||||
|
_inventoryManager.addItemToInventory(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, C.cPurple + C.Strike + "=============================================");
|
||||||
|
UtilPlayer.message(player, "");
|
||||||
|
UtilPlayer.message(player, C.cGold + "HAPPY THANKSGIVING");
|
||||||
|
UtilPlayer.message(player, "You received 1 Treasure Key!");
|
||||||
|
UtilPlayer.message(player, "");
|
||||||
|
UtilPlayer.message(player, C.cPurple + C.Strike + "=============================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, player, "Treasure", "Treasure Key", 1);
|
||||||
|
}
|
||||||
|
}
|
@ -133,7 +133,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
Bukkit.getServer().getPluginManager().callEvent(boosterEvent);
|
Bukkit.getServer().getPluginManager().callEvent(boosterEvent);
|
||||||
|
|
||||||
if (!boosterEvent.isCancelled())
|
if (!boosterEvent.isCancelled())
|
||||||
Plugin.getInventoryManager().addItemToInventory(Player, "Utility", "Gem Booster", -1);
|
Plugin.getInventoryManager().addItemToInventory(null, Player, "Utility", "Gem Booster", -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -262,7 +262,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Plugin.getInventoryManager().addItemToInventory(Player, "Utility", "Gem Booster", 20);
|
Plugin.getInventoryManager().addItemToInventory(null, Player, "Utility", "Gem Booster", 20);
|
||||||
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
|
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
|
||||||
}
|
}
|
||||||
}, null, gemBoosterItem, CurrencyType.Coins, Player));
|
}, null, gemBoosterItem, CurrencyType.Coins, Player));
|
||||||
@ -322,7 +322,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Plugin.getInventoryManager().addItemToInventory(Player, "Treasure", "Treasure Key", 1);
|
Plugin.getInventoryManager().addItemToInventory(null, Player, "Treasure", "Treasure Key", 1);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
}, this, new TreasureKey(), CurrencyType.Coins, Player));
|
}, this, new TreasureKey(), CurrencyType.Coins, Player));
|
||||||
|
@ -92,7 +92,7 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Plugin.getInventoryManager().addItemToInventory(Player, "Mount", mount.GetName(), 1);
|
Plugin.getInventoryManager().addItemToInventory(null, Player, "Mount", mount.GetName(), 1);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
}, this, mount, CurrencyType.Coins, Player));
|
}, this, mount, CurrencyType.Coins, Player));
|
||||||
|
@ -103,7 +103,7 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
|
|
||||||
Plugin.getPetManager().Get(Player).GetPets().put(_pet.GetPetType(), token.PetName);
|
Plugin.getPetManager().Get(Player).GetPets().put(_pet.GetPetType(), token.PetName);
|
||||||
|
|
||||||
Plugin.getInventoryManager().addItemToInventory(Player, "Pet", _pet.GetPetType().toString(), 1);
|
Plugin.getInventoryManager().addItemToInventory(null, Player, "Pet", _pet.GetPetType().toString(), 1);
|
||||||
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
|
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
|
||||||
}
|
}
|
||||||
}, null, _petPurchase ? _pet : tag, CurrencyType.Coins, Player));
|
}, null, _petPurchase ? _pet : tag, CurrencyType.Coins, Player));
|
||||||
|
@ -10,6 +10,7 @@ import java.util.Iterator;
|
|||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.database.column.Column;
|
import mineplex.core.database.column.Column;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
|
import mineplex.core.timing.TimingManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
@ -77,6 +78,11 @@ public abstract class RepositoryBase implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected int executeUpdate(String query, Column<?>...columns)
|
protected int executeUpdate(String query, Column<?>...columns)
|
||||||
|
{
|
||||||
|
return executeUpdate(query, null, columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int executeUpdate(String query, ResultSetCallable callable, Column<?>...columns)
|
||||||
{
|
{
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
|
|
||||||
@ -95,6 +101,9 @@ public abstract class RepositoryBase implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
affectedRows = preparedStatement.executeUpdate();
|
affectedRows = preparedStatement.executeUpdate();
|
||||||
|
|
||||||
|
if (callable != null)
|
||||||
|
callable.processResultSet(preparedStatement.getGeneratedKeys());
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
@ -113,10 +113,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
|||||||
return _spawnPacketMap.get(entity.getEntityId());
|
return _spawnPacketMap.get(entity.getEntityId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addViewerToDisguise(DisguiseBase disguise, Player player)
|
public void addViewerToDisguise(DisguiseBase disguise, Player player, boolean reapply)
|
||||||
{
|
{
|
||||||
_disguisePlayerMap.get(disguise).add(player);
|
_disguisePlayerMap.get(disguise).add(player);
|
||||||
|
|
||||||
|
if (reapply)
|
||||||
reApplyDisguise(disguise, player);
|
reApplyDisguise(disguise, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +152,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
|||||||
_spawnPacketMap.put(disguise.GetEntityId(), disguise);
|
_spawnPacketMap.put(disguise.GetEntityId(), disguise);
|
||||||
_disguisePlayerMap.put(disguise, new HashSet<Player>());
|
_disguisePlayerMap.put(disguise, new HashSet<Player>());
|
||||||
|
|
||||||
|
for (Player player : players)
|
||||||
|
addViewerToDisguise(disguise, player, false);
|
||||||
|
|
||||||
if (disguise.GetEntity() instanceof Player && disguise instanceof DisguisePlayer)
|
if (disguise.GetEntity() instanceof Player && disguise instanceof DisguisePlayer)
|
||||||
{
|
{
|
||||||
if (!((Player)disguise.GetEntity()).getName().equalsIgnoreCase(((DisguisePlayer)disguise).getName()))
|
if (!((Player)disguise.GetEntity()).getName().equalsIgnoreCase(((DisguisePlayer)disguise).getName()))
|
||||||
|
@ -68,7 +68,7 @@ public class DonationManager extends MiniPlugin
|
|||||||
synchronized (_donorLock)
|
synchronized (_donorLock)
|
||||||
{
|
{
|
||||||
_donors.put(token.Name, new Donor(token.DonorToken));
|
_donors.put(token.Name, new Donor(token.DonorToken));
|
||||||
_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
//_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package mineplex.core.elo;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
|
public class EloClientData
|
||||||
|
{
|
||||||
|
public NautHashMap<String, Integer> Elos = new NautHashMap<String, Integer>();
|
||||||
|
}
|
@ -1,16 +1,17 @@
|
|||||||
package mineplex.core.elo;
|
package mineplex.core.elo;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class EloManager extends MiniPlugin
|
public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||||
{
|
{
|
||||||
private static Object _playerEloLock = new Object();
|
private static Object _playerEloLock = new Object();
|
||||||
|
|
||||||
@ -18,51 +19,15 @@ public class EloManager extends MiniPlugin
|
|||||||
private EloRatingSystem _ratingSystem;
|
private EloRatingSystem _ratingSystem;
|
||||||
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
||||||
|
|
||||||
public EloManager(JavaPlugin plugin)
|
public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
super("Elo Rating", plugin);
|
super("Elo Rating", plugin, clientManager);
|
||||||
|
|
||||||
setupConfigValues(plugin);
|
_repository = new EloRepository(plugin);
|
||||||
|
|
||||||
_repository = new EloRepository(plugin.getConfig().getString("elo.connectionurl"));
|
|
||||||
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
||||||
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupConfigValues(JavaPlugin plugin)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
plugin.getConfig().addDefault("elo.connectionurl", "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
|
|
||||||
plugin.getConfig().set("elo.connectionurl", plugin.getConfig().getString("elo.connectionurl"));
|
|
||||||
plugin.saveConfig();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void retrievePlayersElos(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
NautHashMap<String, Integer> eloMap = _repository.loadClientInformation(event.getUniqueId());
|
|
||||||
|
|
||||||
synchronized (_playerEloLock)
|
|
||||||
{
|
|
||||||
_playerElos.put(event.getUniqueId().toString(), eloMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getElo(UUID uuid, String gameType)
|
public int getElo(UUID uuid, String gameType)
|
||||||
{
|
{
|
||||||
int elo = 1000;
|
int elo = 1000;
|
||||||
@ -135,4 +100,22 @@ public class EloManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected EloClientData AddPlayer(String player)
|
||||||
|
{
|
||||||
|
return new EloClientData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,172 +1,50 @@
|
|||||||
package mineplex.core.elo;
|
package mineplex.core.elo;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class EloRepository
|
import mineplex.core.database.RepositoryBase;
|
||||||
|
import mineplex.core.database.column.ColumnInt;
|
||||||
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
|
||||||
|
public class EloRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
private String _connectionString;
|
|
||||||
private String _userName = "root";
|
|
||||||
private String _password = "tAbechAk3wR7tuTh";
|
|
||||||
|
|
||||||
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
||||||
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
||||||
private static String RETRIEVE_ELO = "SELECT gameType, elo FROM eloRating WHERE uuid = ?;";
|
|
||||||
|
|
||||||
private Connection _connection = null;
|
public EloRepository(JavaPlugin plugin)
|
||||||
|
|
||||||
public EloRepository(String connectionUrl)
|
|
||||||
{
|
{
|
||||||
_connectionString = connectionUrl;
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
PreparedStatement preparedStatement = null;
|
executeUpdate(CREATE_ELO_TABLE);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
|
||||||
|
|
||||||
// Create table
|
|
||||||
preparedStatement = _connection.prepareStatement(CREATE_ELO_TABLE);
|
|
||||||
preparedStatement.execute();
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (preparedStatement != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
preparedStatement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveElo(String uuid, String gameType, int elo)
|
public void saveElo(String uuid, String gameType, int elo)
|
||||||
{
|
{
|
||||||
PreparedStatement preparedStatement = null;
|
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
|
||||||
|
|
||||||
int affectedRows = 0;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_connection.isClosed())
|
|
||||||
{
|
|
||||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStatement = _connection.prepareStatement(INSERT_ELO);
|
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
|
|
||||||
preparedStatement.setString(1, uuid);
|
|
||||||
preparedStatement.setString(2, gameType);
|
|
||||||
preparedStatement.setInt(3, elo);
|
|
||||||
|
|
||||||
affectedRows = preparedStatement.executeUpdate();
|
|
||||||
|
|
||||||
if (affectedRows == 0)
|
|
||||||
{
|
{
|
||||||
System.out.println("Error saving Elo.");
|
EloClientData clientData = new EloClientData();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("Saved '" + uuid + "' for '" + gameType + "' new elo " + elo);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (preparedStatement != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
preparedStatement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public NautHashMap<String, Integer> loadClientInformation(UUID uuid)
|
|
||||||
{
|
|
||||||
NautHashMap<String, Integer> elos = new NautHashMap<String, Integer>();
|
|
||||||
|
|
||||||
ResultSet resultSet = null;
|
|
||||||
PreparedStatement preparedStatement = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_connection.isClosed())
|
|
||||||
{
|
|
||||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
|
||||||
}
|
|
||||||
|
|
||||||
preparedStatement = _connection.prepareStatement(RETRIEVE_ELO);
|
|
||||||
preparedStatement.setString(1, uuid.toString());
|
|
||||||
|
|
||||||
resultSet = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
elos.put(resultSet.getString(1), resultSet.getInt(2));
|
clientData.Elos.put(resultSet.getString(1), resultSet.getInt(2));
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (preparedStatement != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
preparedStatement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultSet != null)
|
return clientData;
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
resultSet.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return elos;
|
@Override
|
||||||
|
protected void update()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -153,49 +152,8 @@ public class Energy extends MiniClientPlugin<ClientEnergy>
|
|||||||
Get(player).MaxEnergyMods.remove(reason);
|
Get(player).MaxEnergyMods.remove(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean b)
|
public void setEnabled(boolean b)
|
||||||
{
|
{
|
||||||
_enabled = b;
|
_enabled = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ENERGY NO LONGER USED ON ATTACK
|
|
||||||
public void AddEnergySwingMod(Player player, String reason, int amount)
|
|
||||||
{
|
|
||||||
Get(player).SwingEnergyMods.put(reason, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveEnergySwingMod(Player player, String reason)
|
|
||||||
{
|
|
||||||
Get(player).SwingEnergyMods.remove(reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void WeaponSwing(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
if (!UtilEvent.isAction(event, ActionType.L))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (!UtilGear.isWeapon(player.getItemInHand()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.hasPotionEffect(PotionEffectType.FAST_DIGGING))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ModifyEnergy(player, -Get(player).SwingEnergy());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void ShootBow(EntityShootBowEvent event)
|
|
||||||
{
|
|
||||||
if (event.getEntity() instanceof Player)
|
|
||||||
ModifyEnergy((Player)event.getEntity(), -10);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,8 @@ public class Explosion extends MiniPlugin
|
|||||||
if (blocks.get(cur).getValue() == 0 || blocks.get(cur).getValue() == 3)
|
if (blocks.get(cur).getValue() == 0 || blocks.get(cur).getValue() == 3)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double chance = 0.2 + (double)_explosionBlocks.size()/(double)120;
|
double chance = 0.2 + (double)_explosionBlocks.size()/(double)80;
|
||||||
if (Math.random() > Math.min(0.95, chance))
|
if (Math.random() > Math.min(0.98, chance))
|
||||||
{
|
{
|
||||||
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
|
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.core.friend;
|
package mineplex.core.friend;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -11,9 +13,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
||||||
import mineplex.core.common.jsonchat.JsonMessage;
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
@ -31,19 +32,17 @@ import mineplex.core.preferences.PreferencesManager;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
public class FriendManager extends MiniClientPlugin<FriendData>
|
public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||||
{
|
{
|
||||||
private static FriendSorter _friendSorter = new FriendSorter();
|
private static FriendSorter _friendSorter = new FriendSorter();
|
||||||
|
|
||||||
private CoreClientManager _clientManager;
|
|
||||||
private PreferencesManager _preferenceManager;
|
private PreferencesManager _preferenceManager;
|
||||||
private FriendRepository _repository;
|
private FriendRepository _repository;
|
||||||
|
|
||||||
public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences)
|
public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences)
|
||||||
{
|
{
|
||||||
super("Friends", plugin);
|
super("Friends", plugin, clientManager);
|
||||||
|
|
||||||
_clientManager = clientManager;
|
|
||||||
_preferenceManager = preferences;
|
_preferenceManager = preferences;
|
||||||
_repository = new FriendRepository(plugin);
|
_repository = new FriendRepository(plugin);
|
||||||
}
|
}
|
||||||
@ -61,20 +60,6 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
|||||||
return new FriendData();
|
return new FriendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateFriends(UpdateEvent event)
|
public void updateFriends(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -262,7 +247,7 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
|||||||
|
|
||||||
public void showFriends(Player caller)
|
public void showFriends(Player caller)
|
||||||
{
|
{
|
||||||
boolean isStaff = _clientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
||||||
boolean gotAFriend = false;
|
boolean gotAFriend = false;
|
||||||
List<FriendStatus> friendStatuses = Get(caller).Friends;
|
List<FriendStatus> friendStatuses = Get(caller).Friends;
|
||||||
Collections.sort(friendStatuses, _friendSorter);
|
Collections.sort(friendStatuses, _friendSorter);
|
||||||
@ -379,4 +364,16 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
|||||||
|
|
||||||
caller.sendMessage(C.cAqua + C.Strike + "=====================================================");
|
caller.sendMessage(C.cAqua + C.Strike + "=====================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package mineplex.core.friend.data;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -17,15 +16,10 @@ public class FriendRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));";
|
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));";
|
||||||
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN ";
|
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN ";
|
||||||
private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;";
|
|
||||||
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ? FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ? FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
||||||
private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;";
|
private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;";
|
||||||
private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;";
|
private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;";
|
||||||
|
|
||||||
|
|
||||||
// Not mutual, need to drop accountFriend to recreate with constraint.
|
|
||||||
// On add record need to check for a reverse uuidsource/uuidtarget and set mutual
|
|
||||||
|
|
||||||
public FriendRepository(JavaPlugin plugin)
|
public FriendRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||||
@ -109,14 +103,10 @@ public class FriendRepository extends RepositoryBase
|
|||||||
return friends;
|
return friends;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FriendData loadClientInformation(final UUID uniqueId)
|
public FriendData loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final FriendData friendData = new FriendData();
|
FriendData friendData = new FriendData();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_FRIEND_RECORDS, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
FriendStatus friend = new FriendStatus();
|
FriendStatus friend = new FriendStatus();
|
||||||
@ -128,8 +118,6 @@ public class FriendRepository extends RepositoryBase
|
|||||||
|
|
||||||
friendData.Friends.add(friend);
|
friendData.Friends.add(friend);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuidSource", 100, uniqueId.toString()));
|
|
||||||
|
|
||||||
return friendData;
|
return friendData;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package mineplex.core.gadget.gadgets;
|
package mineplex.core.gadget.gadgets;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
@ -34,7 +34,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
|
|
||||||
public class ItemMelonLauncher extends ItemGadget implements IThrown
|
public class ItemMelonLauncher extends ItemGadget implements IThrown
|
||||||
{
|
{
|
||||||
private HashSet<Item> _melon = new HashSet<Item>();
|
private ArrayList<Item> _melon = new ArrayList<Item>();
|
||||||
|
|
||||||
public ItemMelonLauncher(GadgetManager manager)
|
public ItemMelonLauncher(GadgetManager manager)
|
||||||
{
|
{
|
||||||
@ -145,5 +145,11 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
|
|||||||
melon.remove();
|
melon.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (_melon.size() > 60)
|
||||||
|
{
|
||||||
|
Item item = _melon.remove(0);
|
||||||
|
item.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
package mineplex.core.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import net.minecraft.server.v1_7_R4.DataWatcher;
|
|
||||||
import net.minecraft.server.v1_7_R4.EnumEntitySize;
|
|
||||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
|
||||||
import net.minecraft.server.v1_7_R4.Packet;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
|
||||||
import net.minecraft.server.v1_7_R4.PlayerConnection;
|
|
||||||
|
|
||||||
import mineplex.core.common.DummyEntity;
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Shaun on 9/5/2014.
|
|
||||||
*/
|
|
||||||
public class ArmorStandHologram
|
|
||||||
{
|
|
||||||
private String _text;
|
|
||||||
private Packet _packet;
|
|
||||||
private int _entityId;
|
|
||||||
|
|
||||||
public ArmorStandHologram(Location location, String text)
|
|
||||||
{
|
|
||||||
_text = text;
|
|
||||||
|
|
||||||
_entityId = UtilEnt.getNewEntityId();
|
|
||||||
_packet = createArmorStandPacket(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendToPlayer(Player player)
|
|
||||||
{
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(_packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeForPlayer(Player player)
|
|
||||||
{
|
|
||||||
PacketPlayOutEntityDestroy entityDestroyPacket = new PacketPlayOutEntityDestroy(_entityId);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(entityDestroyPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PacketPlayOutSpawnEntityLiving createArmorStandPacket(Location location)
|
|
||||||
{
|
|
||||||
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
|
||||||
packet.a = _entityId;
|
|
||||||
packet.b = (byte) 30;
|
|
||||||
packet.c = MathHelper.floor(location.getX() * 32D);//(int) EnumEntitySize.SIZE_2.a(100);
|
|
||||||
packet.d = MathHelper.floor((location.getY() - 0.8) * 32D);//(int) MathHelper.floor(64 * 32.0D);
|
|
||||||
packet.e = MathHelper.floor(location.getZ() * 32D);//(int)EnumEntitySize.SIZE_2.a(100);
|
|
||||||
packet.f = 0; // Velocity X
|
|
||||||
packet.g = 0; // Velocity Y
|
|
||||||
packet.h = 0; // Velocity Z
|
|
||||||
packet.i = (byte) 0; // Yaw
|
|
||||||
packet.j = (byte) 0; // Pitch
|
|
||||||
packet.k = (byte) 0; // Head Pitch
|
|
||||||
|
|
||||||
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)location.getWorld()).getHandle()));
|
|
||||||
|
|
||||||
watcher.a(0, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(1, Short.valueOf((short)300));
|
|
||||||
watcher.a(2, _text);
|
|
||||||
watcher.a(3, Byte.valueOf((byte) 1));
|
|
||||||
watcher.a(4, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(7, Integer.valueOf(0));
|
|
||||||
watcher.a(8, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(9, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(6, Float.valueOf(1.0F));
|
|
||||||
watcher.a(10, Byte.valueOf((byte)0));
|
|
||||||
|
|
||||||
// Set invisible
|
|
||||||
int i1 = watcher.getInt(0);
|
|
||||||
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
|
|
||||||
|
|
||||||
// Set small and No Gravity
|
|
||||||
byte b1 = watcher.getByte(10);
|
|
||||||
b1 = (byte)(b1 | 0x1);
|
|
||||||
b1 = (byte)(b1 | 0x2);
|
|
||||||
watcher.watch(10, Byte.valueOf(b1));
|
|
||||||
|
|
||||||
packet.l = watcher;
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,68 +1,618 @@
|
|||||||
package mineplex.core.hologram;
|
package mineplex.core.hologram;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import java.util.ArrayList;
|
||||||
import org.bukkit.entity.Player;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.DataWatcher;
|
||||||
|
import net.minecraft.server.v1_7_R4.Packet;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by shaun on 2014-09-09.
|
|
||||||
*/
|
|
||||||
public class Hologram
|
public class Hologram
|
||||||
{
|
{
|
||||||
private HorseHologram _horseHologram;
|
|
||||||
private ArmorStandHologram _armorStandHologram;
|
|
||||||
|
|
||||||
|
public enum HologramTarget
|
||||||
|
{
|
||||||
|
BLACKLIST, WHITELIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Packet _destroy1_7;
|
||||||
|
private Packet _destroy1_8;
|
||||||
|
private boolean _destroyPackets = true;
|
||||||
|
/**
|
||||||
|
* 1.7 packets uses both EntityIDs while 1.8 uses only the first.
|
||||||
|
*/
|
||||||
|
private ArrayList<Entry<Integer, Integer>> _entityIds = new ArrayList<Entry<Integer, Integer>>();
|
||||||
|
private boolean _isWitherSkull;
|
||||||
|
/**
|
||||||
|
* Keeps track of the holograms movements. This fixes offset that occasionally happens when moving a hologram around.
|
||||||
|
*/
|
||||||
|
private Vector _lastMovement;
|
||||||
private Location _location;
|
private Location _location;
|
||||||
private String _text;
|
private boolean _makePackets = true;
|
||||||
|
private Packet[] _packets1_7;
|
||||||
|
private Packet[] _packets1_8;
|
||||||
|
private HashSet<String> _playersInList = new HashSet<String>();
|
||||||
|
private ArrayList<Player> _playersTracking = new ArrayList<Player>();
|
||||||
|
private HologramTarget _target = HologramTarget.BLACKLIST;
|
||||||
|
private String[] _text = new String[0];
|
||||||
|
private int _viewDistance = 70;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
public Hologram(Location location, String text)
|
public Hologram(HologramManager hologramManager, Location location, String... text)
|
||||||
{
|
{
|
||||||
_location = location;
|
_hologramManager = hologramManager;
|
||||||
_text = text;
|
_location = location.clone();
|
||||||
|
setText(text);
|
||||||
_horseHologram = new HorseHologram(location, text);
|
|
||||||
_armorStandHologram = new ArmorStandHologram(location, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToPlayer(Player player)
|
/**
|
||||||
|
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram addPlayer(Player player)
|
||||||
{
|
{
|
||||||
if (UtilPlayer.is1_8(player))
|
return addPlayer(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram addPlayer(String player)
|
||||||
{
|
{
|
||||||
_armorStandHologram.sendToPlayer(player);
|
_playersInList.add(player);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there a player entry in the hologram for Whitelist and Blacklist
|
||||||
|
*/
|
||||||
|
public boolean containsPlayer(Player player)
|
||||||
|
{
|
||||||
|
return _playersInList.contains(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there a player entry in the hologram for Whitelist and Blacklist
|
||||||
|
*/
|
||||||
|
public boolean containsPlayer(String player)
|
||||||
|
{
|
||||||
|
return _playersInList.contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Packet getDestroyPacket(Player player)
|
||||||
|
{
|
||||||
|
if (_destroyPackets)
|
||||||
|
{
|
||||||
|
makeDestroyPacket();
|
||||||
|
_destroyPackets = false;
|
||||||
|
}
|
||||||
|
return UtilPlayer.is1_8(player) ? _destroy1_8 : _destroy1_7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get who can see the hologram
|
||||||
|
*
|
||||||
|
* @Whitelist = Only people added can see the hologram
|
||||||
|
* @Blacklist = Anyone but people added can see the hologram
|
||||||
|
*/
|
||||||
|
public HologramTarget getHologramTarget()
|
||||||
|
{
|
||||||
|
return _target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the hologram location
|
||||||
|
*/
|
||||||
|
public Location getLocation()
|
||||||
|
{
|
||||||
|
return _location.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArrayList<Player> getNearbyPlayers()
|
||||||
|
{
|
||||||
|
ArrayList<Player> nearbyPlayers = new ArrayList<Player>();
|
||||||
|
for (Player player : getLocation().getWorld().getPlayers())
|
||||||
|
{
|
||||||
|
if (isVisible(player))
|
||||||
|
{
|
||||||
|
nearbyPlayers.add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nearbyPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Packet[] getSpawnPackets(Player player)
|
||||||
|
{
|
||||||
|
if (_makePackets)
|
||||||
|
{
|
||||||
|
makeSpawnPackets();
|
||||||
|
_makePackets = false;
|
||||||
|
}
|
||||||
|
return UtilPlayer.is1_8(player) ? _packets1_8 : _packets1_7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the text in the hologram
|
||||||
|
*/
|
||||||
|
public String[] getText()
|
||||||
|
{
|
||||||
|
// We reverse it again as the hologram would otherwise display the text from the bottom row to the top row
|
||||||
|
String[] reversed = new String[_text.length];
|
||||||
|
for (int i = 0; i < reversed.length; i++)
|
||||||
|
{
|
||||||
|
reversed[i] = _text[reversed.length - (i + 1)];
|
||||||
|
}
|
||||||
|
return reversed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the view distance the hologram is viewable from. Default is 70
|
||||||
|
*/
|
||||||
|
public int getViewDistance()
|
||||||
|
{
|
||||||
|
return _viewDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the hologram holograming?
|
||||||
|
*/
|
||||||
|
public boolean isInUse()
|
||||||
|
{
|
||||||
|
return _lastMovement != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the hologram use the wither skull for 1.8 clients?
|
||||||
|
*/
|
||||||
|
public boolean isUsingWitherSkull()
|
||||||
|
{
|
||||||
|
return _isWitherSkull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisible(Player player)
|
||||||
|
{
|
||||||
|
if (getLocation().getWorld() == player.getWorld())
|
||||||
|
{
|
||||||
|
if ((getHologramTarget() == HologramTarget.WHITELIST) == containsPlayer(player))
|
||||||
|
{
|
||||||
|
if (getLocation().distance(player.getLocation()) < getViewDistance())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeDestroyPacket()
|
||||||
|
{
|
||||||
|
int[] entityIds1_7 = new int[_entityIds.size() * 2];
|
||||||
|
int[] entityIds1_8 = new int[_entityIds.size()];
|
||||||
|
for (int i = 0; i < _entityIds.size(); i++)
|
||||||
|
{
|
||||||
|
Entry<Integer, Integer> entry = _entityIds.get(i);
|
||||||
|
entityIds1_7[i * 2] = entry.getKey();
|
||||||
|
entityIds1_7[(i * 2) + 1] = entry.getValue();
|
||||||
|
entityIds1_8[i] = entry.getKey();
|
||||||
|
}
|
||||||
|
_destroy1_7 = new PacketPlayOutEntityDestroy(entityIds1_7);
|
||||||
|
_destroy1_8 = new PacketPlayOutEntityDestroy(entityIds1_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeSpawnPackets()
|
||||||
|
{
|
||||||
|
_packets1_7 = new Packet[_text.length * 3];
|
||||||
|
_packets1_8 = new Packet[_text.length * (isUsingWitherSkull() ? 2 : 1)];
|
||||||
|
if (_entityIds.size() < _text.length)
|
||||||
|
{
|
||||||
|
_destroyPackets = true;
|
||||||
|
for (int i = _entityIds.size(); i < _text.length; i++)
|
||||||
|
{
|
||||||
|
_entityIds.add(new HashMap.SimpleEntry(UtilEnt.getNewEntityId(), UtilEnt.getNewEntityId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_horseHologram.sendToPlayer(player);
|
_destroyPackets = true;
|
||||||
|
while (_entityIds.size() > _text.length)
|
||||||
|
{
|
||||||
|
_entityIds.remove(_text.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int textRow = 0; textRow < _text.length; textRow++)
|
||||||
|
{
|
||||||
|
Entry<Integer, Integer> entityIds = this._entityIds.get(textRow);
|
||||||
|
Packet[] packets1_7 = makeSpawnPackets1_7(textRow, entityIds.getKey(), entityIds.getValue(), _text[textRow]);
|
||||||
|
for (int i = 0; i < packets1_7.length; i++)
|
||||||
|
{
|
||||||
|
_packets1_7[(textRow * 3) + i] = packets1_7[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet[] packets1_8 = makeSpawnPackets1_8(textRow, entityIds.getKey(), _text[textRow]);
|
||||||
|
for (int i = 0; i < packets1_8.length; i++)
|
||||||
|
{
|
||||||
|
_packets1_8[(textRow * (isUsingWitherSkull() ? 2 : 1)) + i] = packets1_8[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToPlayers(Player... players)
|
private Packet[] makeSpawnPackets1_7(int height, int witherId, int horseId, String horseName)
|
||||||
{
|
{
|
||||||
for (Player player : players)
|
// Spawn wither skull
|
||||||
|
PacketPlayOutSpawnEntity spawnWitherSkull = new PacketPlayOutSpawnEntity();
|
||||||
|
spawnWitherSkull.a = witherId;
|
||||||
|
spawnWitherSkull.b = (int) (getLocation().getX() * 32);
|
||||||
|
spawnWitherSkull.c = (int) ((getLocation().getY() + 54.6 + ((double) height * 0.285D)) * 32);
|
||||||
|
spawnWitherSkull.d = (int) (getLocation().getZ() * 32);
|
||||||
|
spawnWitherSkull.j = 66;
|
||||||
|
// Spawn horse
|
||||||
|
PacketPlayOutSpawnEntityLiving spawnHorse = new PacketPlayOutSpawnEntityLiving();
|
||||||
|
spawnHorse.a = horseId;
|
||||||
|
spawnHorse.b = 100;
|
||||||
|
spawnHorse.c = (int) (getLocation().getX() * 32);
|
||||||
|
spawnHorse.d = (int) ((getLocation().getY() + 54.83 + ((double) height * 0.285D) + 0.23D) * 32);
|
||||||
|
spawnHorse.e = (int) (getLocation().getZ() * 32);
|
||||||
|
// Setup datawatcher
|
||||||
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
|
watcher.a(0, (byte) 0);
|
||||||
|
watcher.a(1, (short) 300);
|
||||||
|
watcher.a(10, horseName);
|
||||||
|
watcher.a(11, (byte) 1);
|
||||||
|
watcher.a(12, -1700000);
|
||||||
|
spawnHorse.l = watcher;
|
||||||
|
// Make horse ride wither
|
||||||
|
PacketPlayOutAttachEntity attachEntity = new PacketPlayOutAttachEntity();
|
||||||
|
attachEntity.b = horseId;
|
||||||
|
attachEntity.c = witherId;
|
||||||
|
return new Packet[]
|
||||||
{
|
{
|
||||||
sendToPlayer(player);
|
spawnWitherSkull, spawnHorse, attachEntity
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeForPlayer(Player player)
|
private Packet[] makeSpawnPackets1_8(int textRow, int entityId, String lineOfText)
|
||||||
{
|
{
|
||||||
if (UtilPlayer.is1_8(player))
|
if (this.isUsingWitherSkull())
|
||||||
{
|
{
|
||||||
_armorStandHologram.removeForPlayer(player);
|
PacketPlayOutSpawnEntity spawnPacket = new PacketPlayOutSpawnEntity();
|
||||||
|
spawnPacket.a = entityId;
|
||||||
|
spawnPacket.b = (int) (getLocation().getX() * 32);
|
||||||
|
spawnPacket.c = (int) ((getLocation().getY() + -0.55 + ((double) textRow * 0.285)) * 32);
|
||||||
|
spawnPacket.d = (int) (getLocation().getZ() * 32);
|
||||||
|
spawnPacket.j = 66;
|
||||||
|
// Setup datawatcher for wither skull
|
||||||
|
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata();
|
||||||
|
metadataPacket.a = entityId;
|
||||||
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
|
watcher.a(0, (byte) 0);
|
||||||
|
watcher.a(2, lineOfText);
|
||||||
|
watcher.a(3, (byte) 1);
|
||||||
|
metadataPacket.b = watcher.c();
|
||||||
|
return new Packet[]
|
||||||
|
{
|
||||||
|
spawnPacket, metadataPacket
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_horseHologram.removeForPlayer(player);
|
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
||||||
|
packet.a = entityId;
|
||||||
|
packet.b = 30;
|
||||||
|
packet.c = (int) (getLocation().getX() * 32);
|
||||||
|
packet.d = (int) ((getLocation().getY() + -2.1 + ((double) textRow * 0.285)) * 32);
|
||||||
|
packet.e = (int) (getLocation().getZ() * 32);
|
||||||
|
// Setup datawatcher for armor stand
|
||||||
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
|
watcher.a(0, (byte) 32);
|
||||||
|
watcher.a(2, lineOfText);
|
||||||
|
watcher.a(3, (byte) 1);
|
||||||
|
packet.l = watcher;
|
||||||
|
return new Packet[]
|
||||||
|
{
|
||||||
|
packet
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeForPlayers(Player... players)
|
/**
|
||||||
|
* Removes the player from the Hologram so they are no longer effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram removePlayer(Player player)
|
||||||
{
|
{
|
||||||
for (Player player : players)
|
return addPlayer(player.getName());
|
||||||
{
|
|
||||||
removeForPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the player from the Hologram so they are no longer effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram removePlayer(String player)
|
||||||
|
{
|
||||||
|
_playersInList.remove(player);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set who can see the hologram
|
||||||
|
*
|
||||||
|
* @Whitelist = Only people added can see the hologram
|
||||||
|
* @Blacklist = Anyone but people added can see the hologram
|
||||||
|
*/
|
||||||
|
public Hologram setHologramTarget(HologramTarget newTarget)
|
||||||
|
{
|
||||||
|
this._target = newTarget;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the hologram to appear at this location
|
||||||
|
*/
|
||||||
|
public Hologram setLocation(Location newLocation)
|
||||||
|
{
|
||||||
|
_makePackets = true;
|
||||||
|
Location oldLocation = getLocation();
|
||||||
|
_location = newLocation.clone();
|
||||||
|
if (isInUse())
|
||||||
|
{
|
||||||
|
ArrayList<Player> canSee = getNearbyPlayers();
|
||||||
|
Iterator<Player> itel = _playersTracking.iterator();
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
Player player = itel.next();
|
||||||
|
if (!canSee.contains(player))
|
||||||
|
{
|
||||||
|
itel.remove();
|
||||||
|
if (player.getWorld() == getLocation().getWorld())
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(getDestroyPacket(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itel = canSee.iterator();
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
Player player = itel.next();
|
||||||
|
if (!_playersTracking.contains(player))
|
||||||
|
{
|
||||||
|
_playersTracking.add(player);
|
||||||
|
itel.remove();
|
||||||
|
for (Packet packet : getSpawnPackets(player))
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!canSee.isEmpty())
|
||||||
|
{
|
||||||
|
_lastMovement.add(new Vector(newLocation.getX() - oldLocation.getX(), newLocation.getY() - oldLocation.getY(),
|
||||||
|
newLocation.getZ() - oldLocation.getZ()));
|
||||||
|
int x = (int) Math.floor(32 * _lastMovement.getX());
|
||||||
|
int y = (int) Math.floor(32 * _lastMovement.getY());
|
||||||
|
int z = (int) Math.floor(32 * _lastMovement.getZ());
|
||||||
|
Packet[] packets1_7 = new Packet[_text.length];
|
||||||
|
Packet[] packets1_8 = new Packet[_text.length];
|
||||||
|
int i = 0;
|
||||||
|
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
|
||||||
|
{
|
||||||
|
_lastMovement.subtract(new Vector(x / 32D, y / 32D, z / 32D));
|
||||||
|
for (Entry<Integer, Integer> entityId : this._entityIds)
|
||||||
|
{
|
||||||
|
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
|
||||||
|
relMove.a = entityId.getKey();
|
||||||
|
relMove.b = (byte) x;
|
||||||
|
relMove.c = (byte) y;
|
||||||
|
relMove.d = (byte) z;
|
||||||
|
packets1_7[i] = relMove;
|
||||||
|
packets1_8[i] = relMove;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = (int) Math.floor(32 * newLocation.getX());
|
||||||
|
z = (int) Math.floor(32 * newLocation.getZ());
|
||||||
|
_lastMovement = new Vector(newLocation.getX() - (x / 32D), 0, newLocation.getZ() - (z / 32D));
|
||||||
|
for (Entry<Integer, Integer> entityId : this._entityIds)
|
||||||
|
{
|
||||||
|
for (int b = 0; b < 2; b++)
|
||||||
|
{
|
||||||
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
|
||||||
|
teleportPacket.a = entityId.getKey();
|
||||||
|
teleportPacket.b = x;
|
||||||
|
teleportPacket.c = (int) Math.floor((oldLocation.getY()
|
||||||
|
+ (b == 0 ? 54.6 : isUsingWitherSkull() ? -0.55 : -2.1) + ((double) i * 0.285)) * 32);
|
||||||
|
teleportPacket.d = z;
|
||||||
|
if (b == 0)
|
||||||
|
{
|
||||||
|
packets1_7[i] = teleportPacket;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packets1_8[i] = teleportPacket;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Player player : canSee)
|
||||||
|
{
|
||||||
|
for (Packet packet : UtilPlayer.is1_8(player) ? packets1_8 : packets1_7)
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the hologram text
|
||||||
|
*/
|
||||||
|
public Hologram setText(String... newText)
|
||||||
|
{
|
||||||
|
String[] reversed = new String[newText.length];
|
||||||
|
for (int i = 0; i < reversed.length; i++)
|
||||||
|
{
|
||||||
|
reversed[i] = newText[reversed.length - (i + 1)];
|
||||||
|
}
|
||||||
|
if (reversed.equals(_text))
|
||||||
|
return this;
|
||||||
|
_makePackets = true;
|
||||||
|
if (isInUse())
|
||||||
|
{
|
||||||
|
ArrayList<Packet> packets1_7 = new ArrayList<Packet>();
|
||||||
|
int[] destroy1_7 = new int[0];
|
||||||
|
int[] destroy1_8 = new int[0];
|
||||||
|
ArrayList<Packet> packets1_8 = new ArrayList<Packet>();
|
||||||
|
if (_text.length != reversed.length)
|
||||||
|
{
|
||||||
|
_destroyPackets = true;
|
||||||
|
}
|
||||||
|
for (int textRow = 0; textRow < Math.max(_text.length, reversed.length); textRow++)
|
||||||
|
{
|
||||||
|
// You can safely assume that _entityIds here is containing _text.length amount as this code is inside isInUse
|
||||||
|
if (textRow >= _text.length)
|
||||||
|
{
|
||||||
|
// Add entity id and send spawn packets
|
||||||
|
// You add a entity id because the new hologram needs
|
||||||
|
Entry<Integer, Integer> entry = new HashMap.SimpleEntry(UtilEnt.getNewEntityId(), UtilEnt.getNewEntityId());
|
||||||
|
_entityIds.add(entry);
|
||||||
|
packets1_7.addAll(Arrays.asList(makeSpawnPackets1_7(textRow, entry.getKey(), entry.getValue(),
|
||||||
|
reversed[textRow])));
|
||||||
|
packets1_8.addAll(Arrays.asList(makeSpawnPackets1_8(textRow, entry.getKey(), reversed[textRow])));
|
||||||
|
}
|
||||||
|
else if (textRow >= reversed.length)
|
||||||
|
{
|
||||||
|
// Remove entity id and send destroy packets
|
||||||
|
Entry<Integer, Integer> entry = _entityIds.remove(reversed.length);
|
||||||
|
destroy1_7 = Arrays.copyOf(destroy1_7, destroy1_7.length + 2);
|
||||||
|
destroy1_7[destroy1_7.length - 2] = entry.getKey();
|
||||||
|
destroy1_7[destroy1_7.length - 1] = entry.getValue();
|
||||||
|
destroy1_8 = Arrays.copyOf(destroy1_8, destroy1_8.length + 1);
|
||||||
|
destroy1_8[destroy1_8.length - 1] = entry.getKey();
|
||||||
|
}
|
||||||
|
else if (!reversed[textRow].equals(_text[textRow]))
|
||||||
|
{
|
||||||
|
// Send update metadata packets
|
||||||
|
Entry<Integer, Integer> entry = _entityIds.get(textRow);
|
||||||
|
PacketPlayOutEntityMetadata metadata1_7 = new PacketPlayOutEntityMetadata();
|
||||||
|
metadata1_7.a = entry.getValue();
|
||||||
|
DataWatcher watcher1_7 = new DataWatcher(null);
|
||||||
|
watcher1_7.a(0, (byte) 0);
|
||||||
|
watcher1_7.a(1, (short) 300);
|
||||||
|
watcher1_7.a(10, reversed[textRow]);
|
||||||
|
watcher1_7.a(11, (byte) 1);
|
||||||
|
watcher1_7.a(12, -1700000);
|
||||||
|
metadata1_7.b = watcher1_7.c();
|
||||||
|
packets1_7.add(metadata1_7);
|
||||||
|
|
||||||
|
PacketPlayOutEntityMetadata metadata1_8 = new PacketPlayOutEntityMetadata();
|
||||||
|
metadata1_8.a = entry.getKey();
|
||||||
|
DataWatcher watcher1_8 = new DataWatcher(null);
|
||||||
|
watcher1_8.a(0, (byte) 0);
|
||||||
|
watcher1_8.a(2, reversed[textRow]);
|
||||||
|
watcher1_8.a(3, (byte) 1);
|
||||||
|
metadata1_8.b = watcher1_8.c();
|
||||||
|
packets1_8.add(metadata1_8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (destroy1_7.length > 0)
|
||||||
|
{
|
||||||
|
packets1_7.add(new PacketPlayOutEntityDestroy(destroy1_7));
|
||||||
|
}
|
||||||
|
if (destroy1_8.length > 0)
|
||||||
|
{
|
||||||
|
packets1_8.add(new PacketPlayOutEntityDestroy(destroy1_8));
|
||||||
|
}
|
||||||
|
for (Player player : _playersTracking)
|
||||||
|
{
|
||||||
|
for (Packet packet : UtilPlayer.is1_8(player) ? packets1_8 : packets1_7)
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_text = reversed;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the hologram to use the wither skull instead of armorstand for 1.8 clients
|
||||||
|
*/
|
||||||
|
public Hologram setUsesWitherSkull()
|
||||||
|
{
|
||||||
|
_isWitherSkull = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the distance the hologram is viewable from. Default is 70
|
||||||
|
*/
|
||||||
|
public Hologram setViewDistance(int newDistance)
|
||||||
|
{
|
||||||
|
this._viewDistance = newDistance;
|
||||||
|
return setLocation(getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArrayList<Player> getPlayersTracking()
|
||||||
|
{
|
||||||
|
return _playersTracking;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the hologram
|
||||||
|
*/
|
||||||
|
public Hologram start()
|
||||||
|
{
|
||||||
|
if (!isInUse())
|
||||||
|
{
|
||||||
|
_hologramManager.addHologram(this);
|
||||||
|
_playersTracking.addAll(getNearbyPlayers());
|
||||||
|
for (Player player : _playersTracking)
|
||||||
|
{
|
||||||
|
for (Packet packet : getSpawnPackets(player))
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_lastMovement = new Vector();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the hologram
|
||||||
|
*/
|
||||||
|
public Hologram stop()
|
||||||
|
{
|
||||||
|
if (isInUse())
|
||||||
|
{
|
||||||
|
_hologramManager.removeHologram(this);
|
||||||
|
for (Player player : _playersTracking)
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(getDestroyPacket(player));
|
||||||
|
}
|
||||||
|
_playersTracking.clear();
|
||||||
|
_lastMovement = null;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
package mineplex.core.hologram;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import net.minecraft.server.v1_7_R4.Packet;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class HologramManager implements Listener
|
||||||
|
{
|
||||||
|
private ArrayList<Hologram> _activeHolograms = new ArrayList<Hologram>();
|
||||||
|
|
||||||
|
public HologramManager(JavaPlugin arcadeManager)
|
||||||
|
{
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, arcadeManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addHologram(Hologram hologram)
|
||||||
|
{
|
||||||
|
_activeHolograms.add(hologram);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeHologram(Hologram hologram)
|
||||||
|
{
|
||||||
|
_activeHolograms.remove(hologram);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onTick(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK || _activeHolograms.isEmpty())
|
||||||
|
return;
|
||||||
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
|
Iterator<Hologram> itel = _activeHolograms.iterator();
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
Hologram hologram = itel.next();
|
||||||
|
if (!worlds.contains(hologram.getLocation().getWorld()))
|
||||||
|
{
|
||||||
|
itel.remove();
|
||||||
|
hologram.stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ArrayList<Player> canSee = hologram.getNearbyPlayers();
|
||||||
|
Iterator<Player> itel2 = hologram.getPlayersTracking().iterator();
|
||||||
|
while (itel2.hasNext())
|
||||||
|
{
|
||||||
|
Player player = itel2.next();
|
||||||
|
if (!canSee.contains(player))
|
||||||
|
{
|
||||||
|
itel2.remove();
|
||||||
|
if (player.getWorld() == hologram.getLocation().getWorld())
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(hologram.getDestroyPacket(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Player player : canSee)
|
||||||
|
{
|
||||||
|
if (!hologram.getPlayersTracking().contains(player))
|
||||||
|
{
|
||||||
|
hologram.getPlayersTracking().add(player);
|
||||||
|
for (Packet packet : hologram.getSpawnPackets(player))
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,132 +0,0 @@
|
|||||||
package mineplex.core.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityFireball;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityHorse;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntitySmallFireball;
|
|
||||||
import net.minecraft.server.v1_7_R4.Packet;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
|
||||||
import net.minecraft.server.v1_7_R4.World;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Shaun on 8/29/2014.
|
|
||||||
*/
|
|
||||||
public class HorseHologram
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* HorseHologram creates the required entities to spawn in a hologram. It is possible to send the packets for the entities to a player,
|
|
||||||
* but it is also possible to add the entities to the nmsWorld to keep them loaded into the server.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private Location _location;
|
|
||||||
private String _text;
|
|
||||||
|
|
||||||
private World _nmsWorld;
|
|
||||||
private EntityFireball _fireball;
|
|
||||||
private EntityHorse _horse;
|
|
||||||
|
|
||||||
public HorseHologram(Location location, String text)
|
|
||||||
{
|
|
||||||
_location = location;
|
|
||||||
_text = text;
|
|
||||||
|
|
||||||
_nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
|
|
||||||
|
|
||||||
// Create Entities
|
|
||||||
_fireball = new EntitySmallFireball(_nmsWorld);
|
|
||||||
_horse = new EntityHorse(_nmsWorld);
|
|
||||||
|
|
||||||
// Location Data
|
|
||||||
_fireball.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0);
|
|
||||||
_horse.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0);
|
|
||||||
_horse.setAge(-1700000);
|
|
||||||
_horse.setCustomName(_text);
|
|
||||||
_horse.setCustomNameVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendToPlayer(Player player)
|
|
||||||
{
|
|
||||||
Packet fireballSpawn = getFireballSpawnPacket();
|
|
||||||
Packet horseSpawn = getHorseSpawnPacket();
|
|
||||||
Packet attachPacket = getAttachEntityPacket();
|
|
||||||
|
|
||||||
sendPacket(player, fireballSpawn);
|
|
||||||
sendPacket(player, horseSpawn);
|
|
||||||
sendPacket(player, attachPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeForPlayer(Player player)
|
|
||||||
{
|
|
||||||
Packet horseDestroy = getHorseDestroyPacket();
|
|
||||||
Packet fireballDestroy = getFireballDestroyPacket();
|
|
||||||
|
|
||||||
sendPacket(player, horseDestroy);
|
|
||||||
sendPacket(player, fireballDestroy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnWithPackets()
|
|
||||||
{
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
sendToPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeWithPackets()
|
|
||||||
{
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
removeForPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String text)
|
|
||||||
{
|
|
||||||
_text = text;
|
|
||||||
_horse.setCustomName(_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText()
|
|
||||||
{
|
|
||||||
return _text;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getHorseSpawnPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutSpawnEntityLiving(_horse);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getFireballSpawnPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutSpawnEntity(_fireball, 64);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getAttachEntityPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutAttachEntity(0, _horse, _fireball);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getHorseDestroyPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutEntityDestroy(_horse.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getFireballDestroyPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutEntityDestroy(_fireball.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendPacket(Player player, Packet packet)
|
|
||||||
{
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.core.inventory;
|
package mineplex.core.inventory;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -7,15 +9,16 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.inventory.command.GiveItemCommand;
|
import mineplex.core.inventory.command.GiveItemCommand;
|
||||||
import mineplex.core.inventory.data.Category;
|
import mineplex.core.inventory.data.Category;
|
||||||
import mineplex.core.inventory.data.InventoryRepository;
|
import mineplex.core.inventory.data.InventoryRepository;
|
||||||
import mineplex.core.inventory.data.Item;
|
import mineplex.core.inventory.data.Item;
|
||||||
|
|
||||||
public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
|
||||||
{
|
{
|
||||||
private static Object _inventoryLock = new Object();
|
private static Object _inventoryLock = new Object();
|
||||||
|
|
||||||
@ -24,9 +27,9 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
private NautHashMap<String, Item> _items = new NautHashMap<String, Item>();
|
private NautHashMap<String, Item> _items = new NautHashMap<String, Item>();
|
||||||
private NautHashMap<String, Category> _categories = new NautHashMap<String, Category>();
|
private NautHashMap<String, Category> _categories = new NautHashMap<String, Category>();
|
||||||
|
|
||||||
public InventoryManager(JavaPlugin plugin)
|
public InventoryManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
super("Inventory Manager", plugin);
|
super("Inventory Manager", plugin, clientManager);
|
||||||
|
|
||||||
_repository = new InventoryRepository(plugin);
|
_repository = new InventoryRepository(plugin);
|
||||||
|
|
||||||
@ -66,14 +69,36 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItemToInventory(Player player, String category, String item, int count)
|
public void addItemToInventory(final Player player, String category, final String item, final int count)
|
||||||
{
|
{
|
||||||
if (_items.containsKey(item))
|
if (_items.containsKey(item))
|
||||||
{
|
{
|
||||||
Get(player).addItem(new ClientItem(_items.get(item), count));
|
Get(player).addItem(new ClientItem(_items.get(item), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
addItemToInventoryForOffline(player.getUniqueId().toString(), category, item, count);
|
addItemToInventory(null, player, category, item, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItemToInventory(final Callback<Boolean> callback, final Player player, String category, final String item, final int count)
|
||||||
|
{
|
||||||
|
addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
System.out.println("Add item to Inventory FAILED for " + player.getName());
|
||||||
|
|
||||||
|
if (_items.containsKey(item))
|
||||||
|
{
|
||||||
|
Get(player).addItem(new ClientItem(_items.get(item), -count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback != null)
|
||||||
|
callback.run(success);
|
||||||
|
}
|
||||||
|
}, player.getUniqueId().toString(), category, item, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item getItem(String itemName)
|
public Item getItem(String itemName)
|
||||||
@ -93,7 +118,7 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItemToInventoryForOffline(final String uuidString, final String category, final String item, final int count)
|
public void addItemToInventoryForOffline(final Callback<Boolean> callback, final String uuidString, final String category, final String item, final int count)
|
||||||
{
|
{
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@ -123,7 +148,18 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
|
|
||||||
synchronized (_inventoryLock)
|
synchronized (_inventoryLock)
|
||||||
{
|
{
|
||||||
_repository.incrementClientInventoryItem(uuidString, _items.get(item).Id, count);
|
final boolean success = _repository.incrementClientInventoryItem(uuidString, _items.get(item).Id, count);
|
||||||
|
|
||||||
|
if (callback != null)
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getScheduler().runTask(GetPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
callback.run(success);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -135,23 +171,21 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
return new ClientInventory();
|
return new ClientInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId().toString()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void AddCommands()
|
public void AddCommands()
|
||||||
{
|
{
|
||||||
addCommand(new GiveItemCommand(this));
|
addCommand(new GiveItemCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -23,7 +24,7 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(final Player caller, String[] args)
|
||||||
{
|
{
|
||||||
if (args == null || args.length < 3)
|
if (args == null || args.length < 3)
|
||||||
{
|
{
|
||||||
@ -33,13 +34,15 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
|
|||||||
|
|
||||||
final String playerName = args[0];
|
final String playerName = args[0];
|
||||||
final int amount = Integer.parseInt(args[1]);
|
final int amount = Integer.parseInt(args[1]);
|
||||||
String itemName = "";
|
String itemNameTemp = "";
|
||||||
for (int i = 2; i < args.length; i++)
|
for (int i = 2; i < args.length; i++)
|
||||||
{
|
{
|
||||||
itemName += args[i] + " ";
|
itemNameTemp += args[i] + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
itemName = itemName.trim();
|
itemNameTemp = itemNameTemp.trim();
|
||||||
|
|
||||||
|
final String itemName = itemNameTemp;
|
||||||
|
|
||||||
Item item = Plugin.getItem(itemName);
|
Item item = Plugin.getItem(itemName);
|
||||||
Player player = UtilPlayer.searchExact(playerName);
|
Player player = UtilPlayer.searchExact(playerName);
|
||||||
@ -59,9 +62,14 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
|
|||||||
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
if (uuid != null)
|
if (uuid != null)
|
||||||
{
|
{
|
||||||
Plugin.addItemToInventoryForOffline(uuid.toString(), item.Category, item.Name, amount);
|
Plugin.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run (Boolean success)
|
||||||
|
{
|
||||||
UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName)));
|
UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName)));
|
||||||
}
|
}
|
||||||
|
}, uuid.toString(), item.Category, item.Name, amount);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Item", "Player " + F.name(playerName) + " does not exist!"));
|
UtilPlayer.message(caller, F.main("Item", "Player " + F.name(playerName) + " does not exist!"));
|
||||||
|
@ -27,7 +27,6 @@ public class InventoryRepository extends RepositoryBase
|
|||||||
private static String RETRIEVE_CATEGORIES = "SELECT id, name FROM itemCategories;";
|
private static String RETRIEVE_CATEGORIES = "SELECT id, name FROM itemCategories;";
|
||||||
|
|
||||||
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
||||||
private static String RETRIEVE_CLIENT_INVENTORY = "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = ?;";
|
|
||||||
|
|
||||||
public InventoryRepository(JavaPlugin plugin)
|
public InventoryRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
@ -93,25 +92,19 @@ public class InventoryRepository extends RepositoryBase
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incrementClientInventoryItem(String uuid, int itemId, int count)
|
public boolean incrementClientInventoryItem(String uuid, int itemId, int count)
|
||||||
{
|
{
|
||||||
executeUpdate(INSERT_CLIENT_INVENTORY, new ColumnInt("itemid", itemId), new ColumnInt("count", count), new ColumnVarChar("uuid", 100, uuid));
|
return executeUpdate(INSERT_CLIENT_INVENTORY, new ColumnInt("itemid", itemId), new ColumnInt("count", count), new ColumnVarChar("uuid", 100, uuid)) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientInventory loadClientInformation(String uuid)
|
public ClientInventory loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final ClientInventory clientInventory = new ClientInventory();
|
final ClientInventory clientInventory = new ClientInventory();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_CLIENT_INVENTORY, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
clientInventory.addItem(new ClientItem(new Item(resultSet.getString(1), resultSet.getString(2)), resultSet.getInt(3)));
|
clientInventory.addItem(new ClientItem(new Item(resultSet.getString(1), resultSet.getString(2)), resultSet.getInt(3)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
|
|
||||||
return clientInventory;
|
return clientInventory;
|
||||||
}
|
}
|
||||||
|
@ -857,9 +857,12 @@ public class ItemStackFactory extends MiniPlugin
|
|||||||
stack.setItemMeta(itemMeta);
|
stack.setItemMeta(itemMeta);
|
||||||
|
|
||||||
//Unbreakable
|
//Unbreakable
|
||||||
|
if (stack.getType().getMaxDurability() > 1)
|
||||||
|
{
|
||||||
ItemMeta meta = stack.getItemMeta();
|
ItemMeta meta = stack.getItemMeta();
|
||||||
meta.spigot().setUnbreakable(true);
|
meta.spigot().setUnbreakable(true);
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -210,9 +209,4 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
|||||||
{
|
{
|
||||||
return _clientManager;
|
return _clientManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package mineplex.core.movement;
|
package mineplex.core.movement;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -45,9 +44,4 @@ public class Movement extends MiniClientPlugin<ClientMovement>
|
|||||||
{
|
{
|
||||||
return new ClientMovement();
|
return new ClientMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.core.pet;
|
|||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.pet.repository.token.PetSalesToken;
|
import mineplex.core.pet.repository.token.PetSalesToken;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package mineplex.core.pet;
|
package mineplex.core.pet;
|
||||||
|
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import mineplex.core.pet.repository.token.PetExtraToken;
|
import mineplex.core.pet.repository.token.PetExtraToken;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -11,14 +11,10 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilInv;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityCreature;
|
import net.minecraft.server.v1_7_R4.EntityCreature;
|
||||||
import net.minecraft.server.v1_7_R4.EntityHuman;
|
import net.minecraft.server.v1_7_R4.EntityHuman;
|
||||||
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
||||||
@ -27,15 +23,7 @@ import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
|
|||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
|
||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -46,18 +34,13 @@ import org.bukkit.entity.Ageable;
|
|||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Skeleton;
|
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -395,11 +378,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
|||||||
return _activePetOwners.get(name);
|
return _activePetOwners.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DisableAll()
|
public void DisableAll()
|
||||||
{
|
{
|
||||||
for (Player player : UtilServer.getPlayers())
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package mineplex.core.preferences;
|
package mineplex.core.preferences;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,9 +13,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
@ -23,7 +23,7 @@ import mineplex.core.preferences.ui.PreferencesShop;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||||
{
|
{
|
||||||
private PreferencesRepository _repository;
|
private PreferencesRepository _repository;
|
||||||
private PreferencesShop _shop;
|
private PreferencesShop _shop;
|
||||||
@ -34,7 +34,7 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
|||||||
|
|
||||||
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||||
{
|
{
|
||||||
super("Preferences", plugin);
|
super("Preferences", plugin, clientManager);
|
||||||
|
|
||||||
setupConfigValues();
|
setupConfigValues();
|
||||||
|
|
||||||
@ -64,20 +64,6 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
|||||||
return new UserPreferences();
|
return new UserPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void savePreferences(Player caller)
|
public void savePreferences(Player caller)
|
||||||
{
|
{
|
||||||
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
|
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
|
||||||
@ -134,4 +120,16 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
|||||||
{
|
{
|
||||||
_shop.attemptShopOpen(caller);
|
_shop.attemptShopOpen(caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,17 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.database.RepositoryBase;
|
import mineplex.core.database.RepositoryBase;
|
||||||
import mineplex.core.database.ResultSetCallable;
|
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
|
||||||
public class PreferencesRepository extends RepositoryBase
|
public class PreferencesRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||||
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE uuid = ?;";
|
|
||||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
|
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
|
||||||
|
|
||||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||||
@ -62,7 +59,32 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
preparedStatement.addBatch();
|
preparedStatement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStatement.executeBatch();
|
int[] rowsAffected = preparedStatement.executeBatch();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (Entry<String, UserPreferences> entry : preferences.entrySet())
|
||||||
|
{
|
||||||
|
if (rowsAffected[i] < 1)
|
||||||
|
{
|
||||||
|
executeUpdate(INSERT_ACCOUNT, new ColumnVarChar("uuid", 100, entry.getKey()));
|
||||||
|
|
||||||
|
preparedStatement.setBoolean(1, entry.getValue().HubGames);
|
||||||
|
preparedStatement.setBoolean(2, entry.getValue().ShowPlayers);
|
||||||
|
preparedStatement.setBoolean(3, entry.getValue().ShowChat);
|
||||||
|
preparedStatement.setBoolean(4, entry.getValue().FriendChat);
|
||||||
|
preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging);
|
||||||
|
preparedStatement.setBoolean(6, entry.getValue().PartyRequests);
|
||||||
|
preparedStatement.setBoolean(7, entry.getValue().Invisibility);
|
||||||
|
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
|
||||||
|
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
||||||
|
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
||||||
|
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
|
||||||
|
preparedStatement.setString(12, entry.getKey());
|
||||||
|
preparedStatement.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -84,19 +106,11 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserPreferences loadClientInformation(final UUID uuid)
|
public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final UserPreferences preferences = new UserPreferences();
|
final UserPreferences preferences = new UserPreferences();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_ACCOUNT_PREFERENCES, new ResultSetCallable()
|
if (resultSet.next())
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
if (!resultSet.next())
|
|
||||||
{
|
|
||||||
executeUpdate(INSERT_ACCOUNT, new ColumnVarChar("uuid", 100, uuid.toString()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
preferences.HubGames = resultSet.getBoolean(1);
|
preferences.HubGames = resultSet.getBoolean(1);
|
||||||
preferences.ShowPlayers = resultSet.getBoolean(2);
|
preferences.ShowPlayers = resultSet.getBoolean(2);
|
||||||
@ -110,8 +124,6 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
||||||
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
|
||||||
|
|
||||||
return preferences;
|
return preferences;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
package mineplex.core.stats;
|
package mineplex.core.stats;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.stats.command.GiveStatCommand;
|
import mineplex.core.stats.command.GiveStatCommand;
|
||||||
import mineplex.core.stats.command.TimeCommand;
|
import mineplex.core.stats.command.TimeCommand;
|
||||||
import mineplex.core.stats.event.StatChangeEvent;
|
import mineplex.core.stats.event.StatChangeEvent;
|
||||||
|
|
||||||
public class StatsManager extends MiniClientPlugin<PlayerStats>
|
public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||||
{
|
{
|
||||||
private static Object _statSync = new Object();
|
private static Object _statSync = new Object();
|
||||||
|
|
||||||
@ -25,9 +25,9 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
|||||||
private NautHashMap<String, NautHashMap<String, Integer>> _statUploadQueue = new NautHashMap<String, NautHashMap<String, Integer>>();
|
private NautHashMap<String, NautHashMap<String, Integer>> _statUploadQueue = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||||
private Runnable _saveRunnable;
|
private Runnable _saveRunnable;
|
||||||
|
|
||||||
public StatsManager(JavaPlugin plugin)
|
public StatsManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
super("StatsManager", plugin);
|
super("Stats Manager", plugin, clientManager);
|
||||||
|
|
||||||
_repository = new StatsRepository(plugin);
|
_repository = new StatsRepository(plugin);
|
||||||
|
|
||||||
@ -117,20 +117,6 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
|||||||
return new PlayerStats();
|
return new PlayerStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId().toString()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerStats getOfflinePlayerStats(String playerName) throws SQLException
|
public PlayerStats getOfflinePlayerStats(String playerName) throws SQLException
|
||||||
{
|
{
|
||||||
return _repository.loadOfflinePlayerStats(playerName);
|
return _repository.loadOfflinePlayerStats(playerName);
|
||||||
@ -185,4 +171,16 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
|||||||
addCommand(new TimeCommand(this));
|
addCommand(new TimeCommand(this));
|
||||||
addCommand(new GiveStatCommand(this));
|
addCommand(new GiveStatCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package mineplex.core.stats;
|
package mineplex.core.stats;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -14,17 +13,12 @@ import mineplex.core.database.RepositoryBase;
|
|||||||
import mineplex.core.database.ResultSetCallable;
|
import mineplex.core.database.ResultSetCallable;
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
import mineplex.database.Tables;
|
import mineplex.database.Tables;
|
||||||
import mineplex.database.tables.records.AccountStatsRecord;
|
|
||||||
import mineplex.database.tables.records.StatsRecord;
|
|
||||||
import org.jooq.DSLContext;
|
import org.jooq.DSLContext;
|
||||||
import org.jooq.Insert;
|
import org.jooq.Insert;
|
||||||
import org.jooq.InsertQuery;
|
|
||||||
import org.jooq.Query;
|
|
||||||
import org.jooq.Record;
|
|
||||||
import org.jooq.Record2;
|
import org.jooq.Record2;
|
||||||
import org.jooq.Result;
|
import org.jooq.Result;
|
||||||
import org.jooq.Update;
|
import org.jooq.Update;
|
||||||
import org.jooq.UpdateQuery;
|
|
||||||
import org.jooq.impl.DSL;
|
import org.jooq.impl.DSL;
|
||||||
|
|
||||||
public class StatsRepository extends RepositoryBase
|
public class StatsRepository extends RepositoryBase
|
||||||
@ -32,7 +26,6 @@ public class StatsRepository extends RepositoryBase
|
|||||||
private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX nameIndex (name));";
|
private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX nameIndex (name));";
|
||||||
private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));";
|
private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));";
|
||||||
|
|
||||||
private static String RETRIEVE_PLAYER_STATS = "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = ?;";
|
|
||||||
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
||||||
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
||||||
|
|
||||||
@ -81,10 +74,9 @@ public class StatsRepository extends RepositoryBase
|
|||||||
executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name));
|
executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public void saveStats(NautHashMap<String, NautHashMap<Integer, Integer>> uploadQueue)
|
public void saveStats(NautHashMap<String, NautHashMap<Integer, Integer>> uploadQueue)
|
||||||
{
|
{
|
||||||
System.out.println("saving stats.");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DSLContext context = DSL.using(getConnection());
|
DSLContext context = DSL.using(getConnection());
|
||||||
@ -96,8 +88,6 @@ public class StatsRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
for (Integer statId : uploadQueue.get(uuid).keySet())
|
for (Integer statId : uploadQueue.get(uuid).keySet())
|
||||||
{
|
{
|
||||||
System.out.println("saving stat : uuid=" + uuid + " " + statId + "=" + uploadQueue.get(uuid).get(statId));
|
|
||||||
|
|
||||||
Update update = context
|
Update update = context
|
||||||
.update(Tables.accountStats)
|
.update(Tables.accountStats)
|
||||||
.set(Tables.accountStats.value, Tables.accountStats.value.plus(uploadQueue.get(uuid).get(statId)))
|
.set(Tables.accountStats.value, Tables.accountStats.value.plus(uploadQueue.get(uuid).get(statId)))
|
||||||
@ -166,20 +156,14 @@ public class StatsRepository extends RepositoryBase
|
|||||||
return playerStats;
|
return playerStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerStats loadClientInformation(String uuid)
|
public PlayerStats loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final PlayerStats playerStats = new PlayerStats();
|
final PlayerStats playerStats = new PlayerStats();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_PLAYER_STATS, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
playerStats.addStat(resultSet.getString(1), resultSet.getInt(2));
|
playerStats.addStat(resultSet.getString(1), resultSet.getInt(2));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
|
|
||||||
return playerStats;
|
return playerStats;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.task.repository.TaskRepository;
|
import mineplex.core.task.repository.TaskRepository;
|
||||||
import mineplex.core.task.repository.TaskToken;
|
import mineplex.core.task.repository.TaskToken;
|
||||||
|
|
||||||
@ -52,9 +51,4 @@ public class TaskManager extends MiniClientPlugin<TaskClient>
|
|||||||
|
|
||||||
_repository.AddTask(client.Name, taskName);
|
_repository.AddTask(client.Name, taskName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,13 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.reward.Reward;
|
import mineplex.core.reward.Reward;
|
||||||
import mineplex.core.reward.RewardData;
|
import mineplex.core.reward.RewardData;
|
||||||
import mineplex.core.reward.RewardRarity;
|
import mineplex.core.reward.RewardRarity;
|
||||||
@ -56,15 +57,16 @@ public class Treasure
|
|||||||
private LinkedList<Animation> _animations;
|
private LinkedList<Animation> _animations;
|
||||||
|
|
||||||
private TreasureStyle _style;
|
private TreasureStyle _style;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
public Treasure(Player player, Reward[] rewards, BlockRestore blockRestore)
|
public Treasure(Player player, Reward[] rewards, BlockRestore blockRestore, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
this(player, new Random(), rewards);
|
this(player, new Random(), rewards, hologramManager);
|
||||||
|
|
||||||
_blockRestore = blockRestore;
|
_blockRestore = blockRestore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Treasure(Player player, Random seed, Reward[] rewards)
|
public Treasure(Player player, Random seed, Reward[] rewards, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
_player = player;
|
_player = player;
|
||||||
_random = seed;
|
_random = seed;
|
||||||
@ -73,6 +75,7 @@ public class Treasure
|
|||||||
|
|
||||||
_centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
_centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||||
_animations = new LinkedList<Animation>();
|
_animations = new LinkedList<Animation>();
|
||||||
|
_hologramManager = hologramManager;
|
||||||
|
|
||||||
// _animations.add(new ParticleAnimation(this));
|
// _animations.add(new ParticleAnimation(this));
|
||||||
|
|
||||||
@ -288,7 +291,7 @@ public class Treasure
|
|||||||
RewardData rewardData = data.getReward().giveReward("Treasure", _player);
|
RewardData rewardData = data.getReward().giveReward("Treasure", _player);
|
||||||
|
|
||||||
data.setOpened(true);
|
data.setOpened(true);
|
||||||
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData);
|
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData, _hologramManager);
|
||||||
_animations.add(chestOpenTask);
|
_animations.add(chestOpenTask);
|
||||||
|
|
||||||
// Extra effects based off the rarity of the treasure
|
// Extra effects based off the rarity of the treasure
|
||||||
|
@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilPlayer;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.event.StackerEvent;
|
import mineplex.core.event.StackerEvent;
|
||||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.pet.PetManager;
|
import mineplex.core.pet.PetManager;
|
||||||
import mineplex.core.reward.Reward;
|
import mineplex.core.reward.Reward;
|
||||||
@ -55,14 +56,16 @@ public class TreasureManager extends MiniPlugin
|
|||||||
private RewardManager _rewardManager;
|
private RewardManager _rewardManager;
|
||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
private BlockRestore _blockRestore;
|
private BlockRestore _blockRestore;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore)
|
public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
super("Treasure", plugin);
|
super("Treasure", plugin);
|
||||||
|
|
||||||
_playerTreasureMap = new NautHashMap<Player, Treasure>();
|
_playerTreasureMap = new NautHashMap<Player, Treasure>();
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
_blockRestore = blockRestore;
|
_blockRestore = blockRestore;
|
||||||
|
_hologramManager = hologramManager;
|
||||||
_rewardManager = new RewardManager(donationManager, inventoryManager, petManager,
|
_rewardManager = new RewardManager(donationManager, inventoryManager, petManager,
|
||||||
250, 500,
|
250, 500,
|
||||||
750, 1500,
|
750, 1500,
|
||||||
@ -108,7 +111,7 @@ public class TreasureManager extends MiniPlugin
|
|||||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
|
||||||
|
|
||||||
Reward[] rewards = _rewardManager.getRewards(player, true);
|
Reward[] rewards = _rewardManager.getRewards(player, true);
|
||||||
Treasure treasure = new Treasure(player, rewards, _blockRestore);
|
Treasure treasure = new Treasure(player, rewards, _blockRestore, _hologramManager);
|
||||||
_playerTreasureMap.put(player, treasure);
|
_playerTreasureMap.put(player, treasure);
|
||||||
|
|
||||||
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
|
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
package mineplex.core.treasure.animation;
|
package mineplex.core.treasure.animation;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.hologram.Hologram;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
|
import mineplex.core.reward.RewardData;
|
||||||
|
import mineplex.core.treasure.ChestData;
|
||||||
|
import mineplex.core.treasure.Treasure;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -8,13 +16,6 @@ import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
|||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.hologram.Hologram;
|
|
||||||
import mineplex.core.reward.RewardData;
|
|
||||||
import mineplex.core.treasure.ChestData;
|
|
||||||
import mineplex.core.treasure.Treasure;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Shaun on 8/29/2014.
|
* Created by Shaun on 8/29/2014.
|
||||||
@ -23,19 +24,22 @@ public class ChestOpenAnimation extends Animation
|
|||||||
{
|
{
|
||||||
private ChestData _chestData;
|
private ChestData _chestData;
|
||||||
private RewardData _rewardData;
|
private RewardData _rewardData;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
private Item _itemEntity;
|
private Item _itemEntity;
|
||||||
private Hologram _hologram;
|
private Hologram _hologram;
|
||||||
|
|
||||||
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData)
|
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
super(treasure);
|
super(treasure);
|
||||||
|
_hologramManager = hologramManager;
|
||||||
_chestData = chestData;
|
_chestData = chestData;
|
||||||
_rewardData = rewardData;
|
_rewardData = rewardData;
|
||||||
|
|
||||||
// Send chest open packet
|
// Send chest open packet
|
||||||
Block block = chestData.getBlock();
|
Block block = chestData.getBlock();
|
||||||
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(), CraftMagicNumbers.getBlock(block), 1, 1);
|
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(),
|
||||||
|
CraftMagicNumbers.getBlock(block), 1, 1);
|
||||||
for (Player other : UtilServer.getPlayers())
|
for (Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
|
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
|
||||||
@ -55,8 +59,9 @@ public class ChestOpenAnimation extends Animation
|
|||||||
}
|
}
|
||||||
else if (getTicks() == 15)
|
else if (getTicks() == 15)
|
||||||
{
|
{
|
||||||
_hologram = new Hologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _rewardData.getFriendlyName());
|
_hologram = new Hologram(_hologramManager, _chestData.getBlock().getLocation().add(0.5, 1.1, 0.5),
|
||||||
_hologram.sendToPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
|
_rewardData.getFriendlyName());
|
||||||
|
_hologram.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +69,7 @@ public class ChestOpenAnimation extends Animation
|
|||||||
{
|
{
|
||||||
if (_hologram != null)
|
if (_hologram != null)
|
||||||
{
|
{
|
||||||
_hologram.removeForPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
|
_hologram.stop();
|
||||||
_itemEntity.remove();
|
_itemEntity.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,12 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
|||||||
playerUUID = UUIDFetcher.getUUIDOf(name);
|
playerUUID = UUIDFetcher.getUUIDOf(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (playerUUID == null)
|
||||||
|
{
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
|
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
|
||||||
|
|
||||||
if (args.length == 3 && args[0].equalsIgnoreCase("gem"))
|
if (args.length == 3 && args[0].equalsIgnoreCase("gem"))
|
||||||
|
@ -37,6 +37,7 @@ public class ClanInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int _id = -1;
|
||||||
private String _name = "";
|
private String _name = "";
|
||||||
private String _desc = "";
|
private String _desc = "";
|
||||||
private Location _home = null;
|
private Location _home = null;
|
||||||
@ -64,6 +65,7 @@ public class ClanInfo
|
|||||||
{
|
{
|
||||||
Clans = clans;
|
Clans = clans;
|
||||||
|
|
||||||
|
_id = token.Id;
|
||||||
_name = token.Name;
|
_name = token.Name;
|
||||||
_desc = token.Description;
|
_desc = token.Description;
|
||||||
|
|
||||||
@ -370,4 +372,9 @@ public class ClanInfo
|
|||||||
{
|
{
|
||||||
return _admin;
|
return _admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId()
|
||||||
|
{
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,695 @@
|
|||||||
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClient;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilInput;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
|
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||||
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ClansAdmin
|
||||||
|
{
|
||||||
|
private ClansManager Clans;
|
||||||
|
|
||||||
|
public ClansAdmin(ClansManager clans)
|
||||||
|
{
|
||||||
|
Clans = clans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void command(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1)
|
||||||
|
help(caller);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("help") || args[1].equalsIgnoreCase("h"))
|
||||||
|
help(caller);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("set") || args[1].equalsIgnoreCase("mimic"))
|
||||||
|
setMimic(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("create"))
|
||||||
|
create(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("disband") || args[1].equalsIgnoreCase("delete") || args[1].equalsIgnoreCase("d"))
|
||||||
|
delete(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("invite") || args[1].equalsIgnoreCase("i"))
|
||||||
|
invite(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("promote"))
|
||||||
|
promote(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("demote"))
|
||||||
|
demote(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("kick") || args[1].equalsIgnoreCase("k"))
|
||||||
|
kick(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("ally") || args[1].equalsIgnoreCase("a"))
|
||||||
|
ally(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("trust"))
|
||||||
|
trust(caller, args);
|
||||||
|
|
||||||
|
else if (args[0].equalsIgnoreCase("neutral") || args[0].equalsIgnoreCase("neut") || args[0].equalsIgnoreCase("n"))
|
||||||
|
neutral(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("claim") || args[1].equalsIgnoreCase("c"))
|
||||||
|
claim(caller);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("unclaim") || args[1].equalsIgnoreCase("uc"))
|
||||||
|
unclaim(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("home") || args[1].equalsIgnoreCase("h"))
|
||||||
|
home(caller, args);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("safe"))
|
||||||
|
safe(caller);
|
||||||
|
|
||||||
|
else if (args[1].equalsIgnoreCase("autoclaim"))
|
||||||
|
autoclaim(caller);
|
||||||
|
|
||||||
|
else
|
||||||
|
help(caller);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void help(Player caller)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Admin Commands List;"));
|
||||||
|
|
||||||
|
UtilPlayer.message(caller, F.help("/c x create <clan>", "Create Admin Clan", Rank.ADMIN));
|
||||||
|
|
||||||
|
UtilPlayer.message(caller, F.help("/c x set <clan>", "Set Mimic Clan", Rank.ALL));
|
||||||
|
|
||||||
|
UtilPlayer.message(caller, F.help("/c x home (set)", "Teleport to Mimic Home", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x invite <player>", "Invite Player to Mimic", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x promote <player>", "Promote Player in Mimic", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x demote <player>", "Demote Player in Mimic", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x kick <player>", "Kick Player from Mimic", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x ally <clan>", "Send Alliance to Mimic", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x trust <clan>", "Give Trust to Clan", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x neutral <clan>", "Set Neutrality", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x enemy <clan>", "Start Invasion", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x claim", "Claim Territory for Mimic", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.ADMIN));
|
||||||
|
UtilPlayer.message(caller, F.main("Mimic Clan", Clans.Get(caller).getMimic()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void autoclaim(Player caller)
|
||||||
|
{
|
||||||
|
Clans.Get(caller).setAutoClaim(!Clans.Get(caller).isAutoClaim());
|
||||||
|
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", F.oo("Auto Claim", Clans.Get(caller).isAutoClaim())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMimic(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
if (Clans.Get(caller).getMimic().length() > 0)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You are no longer mimicing " + F.elem("Clan " + Clans.Get(caller).getMimic()) + "."));
|
||||||
|
Clans.Get(caller).setMimic("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input a Clan/Player."));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanInfo clan = Clans.getClanUtility().searchClanPlayer(caller, args[2], true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Invalid Clan/Player."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set Mimic
|
||||||
|
Clans.Get(caller).setMimic(clan.getName());
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You are mimicing " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClanInfo getMimic(Player caller, boolean inform)
|
||||||
|
{
|
||||||
|
String mimic = Clans.Get(caller).getMimic();
|
||||||
|
|
||||||
|
if (mimic.length() == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ClanInfo clan = Clans.getClanUtility().searchClanPlayer(caller, mimic, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
{
|
||||||
|
if (inform)
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You are not mimicing a Clan."));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return clan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void create(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input a Clan name."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UtilInput.valid(args[2]))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Invalid characters in Clan name."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[2].length() < Clans.getNameMin())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Clan name too short. Minimum length is " + (Clans.getNameMin()) + "."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[2].length() > Clans.getNameMax())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Clan name too long. Maximum length is + " + (Clans.getNameMax()) + "."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String cur : Clans.CCommand().denyClan)
|
||||||
|
{
|
||||||
|
if (cur.equalsIgnoreCase(args[2]))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Clan name cannot be a Clan command."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String cur : Clans.getAll())
|
||||||
|
{
|
||||||
|
if (cur.equalsIgnoreCase(args[2]))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Clan name cannot be a Player name."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Clans.getClan(args[2]) != null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", F.elem("Clan " + args[2]) + " already exists."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilServer.broadcast(F.main("Clans Admin", caller.getName() + " formed " + F.elem("Admin Clan " + args[2]) + "."));
|
||||||
|
|
||||||
|
// Create and Join
|
||||||
|
Clans.getClanDataAccess().create(caller.getName(), args[2], true);
|
||||||
|
|
||||||
|
// Set Mimic
|
||||||
|
Clans.Get(caller).setMimic(args[2]);
|
||||||
|
|
||||||
|
// Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You are mimicing Clan " + args[2] + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo clan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().delete(clan);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilServer.broadcast(F.main("Clans Admin", caller.getName() + " disbanded " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invite(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo clan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input an invitee."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = UtilPlayer.searchOnline(caller, args[2], true);
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (target.getName().equals(caller.getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot invite yourself."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
clan.inform(caller.getName() + " invited " + target.getName() + " to join Clan " + clan.getName() + ".", caller.getName());
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You invited " + target.getName() + " to join " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
|
UtilPlayer.message(target, F.main("Clans Admin", caller.getName() + " invited you to join " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
|
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().invite(clan, target.getName(), caller.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void promote(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo clan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input player to promote."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String target = UtilPlayer.searchCollection(caller, args[2], clan.getMembers().keySet(), "Clan Member", true);
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (clan.getMembers().get(target) == Role.LEADER)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot promote " + F.name(target) + " any further."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Task
|
||||||
|
String newRank = "?";
|
||||||
|
if (clan.getMembers().get(target) == Role.RECRUIT)
|
||||||
|
{
|
||||||
|
Clans.getClanDataAccess().role(clan, target, Role.MEMBER);
|
||||||
|
newRank = "Member";
|
||||||
|
}
|
||||||
|
else if (clan.getMembers().get(target) == Role.MEMBER)
|
||||||
|
{
|
||||||
|
Clans.getClanDataAccess().role(clan, target, Role.ADMIN);
|
||||||
|
newRank = "Admin";
|
||||||
|
}
|
||||||
|
else if (clan.getMembers().get(target) == Role.ADMIN)
|
||||||
|
{
|
||||||
|
Clans.getClanDataAccess().role(clan, target, Role.LEADER);
|
||||||
|
newRank = "Leader";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You promoted " + target + " to " + newRank + " in Mimic Clan."));
|
||||||
|
clan.inform(caller.getName() + " promoted " + target + " to " + newRank + ".", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void demote(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo clan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input player to demote."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String target = UtilPlayer.searchCollection(caller, args[2], clan.getMembers().keySet(), "Clan Member", true);
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (clan.getMembers().get(target) == Role.RECRUIT)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot demote " + F.name(target) + " any further."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Task
|
||||||
|
String newRank = "?";
|
||||||
|
if (clan.getMembers().get(target) == Role.MEMBER)
|
||||||
|
{
|
||||||
|
Clans.getClanDataAccess().role(clan, target, Role.RECRUIT);
|
||||||
|
newRank = "Recruit";
|
||||||
|
}
|
||||||
|
else if (clan.getMembers().get(target) == Role.ADMIN)
|
||||||
|
{
|
||||||
|
Clans.getClanDataAccess().role(clan, target, Role.MEMBER);
|
||||||
|
newRank = "Member";
|
||||||
|
}
|
||||||
|
else if (clan.getMembers().get(target) == Role.LEADER)
|
||||||
|
{
|
||||||
|
Clans.getClanDataAccess().role(clan, target, Role.ADMIN);
|
||||||
|
newRank = "Admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You demoted " + target + " to " + newRank + " in Mimic Clan."));
|
||||||
|
clan.inform(F.main("Clans Admin", caller.getName() + " demoted " + target + " to " + newRank + "."), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void kick(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo clan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input a Player to kick."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetName = UtilPlayer.searchCollection(caller, args[2], clan.getMembers().keySet(), "Clan Member", true);
|
||||||
|
|
||||||
|
if (targetName == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().leave(clan, targetName);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(UtilPlayer.searchOnline(null, targetName, false), F.main("Clans Admin", caller.getName() + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You kicked " + targetName + " from your Clan."));
|
||||||
|
clan.inform(F.main("Clans Admin", caller.getName() + " kicked " + targetName + " from your Clan."), caller.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ally(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo cA = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (cA == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input a Clan to ally."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanInfo cB = Clans.getClanUtility().searchClanPlayer(caller, args[2], true);
|
||||||
|
|
||||||
|
if (cB == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cA.isSelf(cB.getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot ally with yourself."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cA.isAlly(cB.getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You are already allies with " + F.elem("Clan " + cB.getName()) + "."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cB.isRequested(cA.getName()))
|
||||||
|
{
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().ally(cA, cB, caller.getName());
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You accepted alliance with Clan " + cB.getName() + "."));
|
||||||
|
cA.inform(caller.getName() + " accepted alliance with Clan " + cB.getName() + ".", caller.getName());
|
||||||
|
cB.inform("Clan " + cA.getName() + " has accepted alliance with you.", null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().requestAlly(cA, cB, caller.getName());
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You requested alliance with Clan " + cB.getName() + "."));
|
||||||
|
cA.inform(caller.getName() + " has requested alliance with Clan " + cB.getName() + ".", caller.getName());
|
||||||
|
cB.inform("Clan " + cA.getName() + " has requested alliance with you.", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trust(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo cA = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (cA == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You did not input a Clan to enemy."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanInfo cB = Clans.getClanUtility().searchClanPlayer(caller, args[2], true);
|
||||||
|
|
||||||
|
if (cB == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!cA.isAlly(cB.getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot give trust to enemies."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Task
|
||||||
|
if (Clans.getClanDataAccess().trust(cA, cB, caller.getName()))
|
||||||
|
{
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You gave trust to Clan " + cB.getName() + "."));
|
||||||
|
cA.inform(caller.getName() + " has given trust to Clan " + cB.getName() + ".", caller.getName());
|
||||||
|
cB.inform("Clan " + cA.getName() + " has given trust to you.", null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You revoked trust to Clan " + cB.getName() + "."));
|
||||||
|
cA.inform(caller.getName() + " has revoked trust to Clan " + cB.getName() + ".", caller.getName());
|
||||||
|
cB.inform("Clan " + cA.getName() + " has revoked trust to you.", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void neutral(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
ClanInfo cA = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (cA == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to set neutrality with."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanInfo cB = Clans.getClanUtility().searchClanPlayer(caller, args[1], true);
|
||||||
|
|
||||||
|
if (cB == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cB.isSelf(cA.getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You prefer to think of yourself positively..."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cB.isNeutral(cA.getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + "."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cB.isAlly(cA.getName()))
|
||||||
|
{
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().neutral(cA, cB, caller.getName(), true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + "."));
|
||||||
|
cA.inform(F.name(caller.getName()) + " revoked alliance with " + F.elem("Clan " + cB.getName()) + ".", caller.getName());
|
||||||
|
cB.inform(F.elem("Clan " + cA.getName()) + " has revoked alliance with you.", null);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void claim(Player caller)
|
||||||
|
{
|
||||||
|
ClanInfo clientClan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clientClan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (clientClan.getClaims() >= clientClan.getClaimsMax())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan cannot claim more Territory."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk());
|
||||||
|
ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation());
|
||||||
|
|
||||||
|
//Already Claimed
|
||||||
|
if (ownerClan != null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "This Territory is claimed by " +
|
||||||
|
Clans.getClanUtility().mRel(Clans.getClanUtility().relPC(caller.getName(), ownerClan), ownerClan.getName(), true) + "."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().claim(clientClan.getName(), chunk, caller.getName(), false);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
|
||||||
|
clientClan.inform(caller.getName() + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unclaim(Player caller, String args[])
|
||||||
|
{
|
||||||
|
if (args.length > 2)
|
||||||
|
{
|
||||||
|
if (args[2].equalsIgnoreCase("all") || args[2].equalsIgnoreCase("a"))
|
||||||
|
{
|
||||||
|
unclaimall(caller);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanInfo clientClan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clientClan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk());
|
||||||
|
ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation());
|
||||||
|
|
||||||
|
//Not Claimed
|
||||||
|
if (ownerClan == null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Territory is not claimed."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
|
||||||
|
ownerClan.inform(caller.getName() + " unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unclaimall(Player caller)
|
||||||
|
{
|
||||||
|
ClanInfo clientClan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clientClan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Unclaim
|
||||||
|
ArrayList<String> toUnclaim = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (String chunk : clientClan.getClaimSet())
|
||||||
|
toUnclaim.add(chunk);
|
||||||
|
|
||||||
|
for (String chunk : toUnclaim)
|
||||||
|
Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You unclaimed all your Clans Territory."));
|
||||||
|
clientClan.inform(caller.getName() + " unclaimed all your Clans Territory.", caller.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void home(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length > 2)
|
||||||
|
{
|
||||||
|
if (args[2].equalsIgnoreCase("set") || args[2].equalsIgnoreCase("s"))
|
||||||
|
{
|
||||||
|
homeSet(caller);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanInfo clan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (clan.getHome() == null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan has not set a Home."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk())))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan has lost its Home Territory."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Do
|
||||||
|
Clans.getTeleport().TP(caller, clan.getHome());
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void homeSet(Player caller)
|
||||||
|
{
|
||||||
|
ClanInfo clan = getMimic(caller, true);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Clans.getClanUtility().getOwner(caller.getLocation()) == null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You must set your Clan Home in your own Territory."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Clans.getClanUtility().getOwner(caller.getLocation()).isSelf(clan.getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You must set your Clan Home in your own Territory."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Task
|
||||||
|
Clans.getClanDataAccess().home(clan, caller.getLocation(), caller.getName());
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You set Clan Home to " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
|
||||||
|
clan.inform(caller.getName() + " set Clan Home to " + UtilWorld.locToStrClean(caller.getLocation()) + ".", caller.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void safe(Player caller)
|
||||||
|
{
|
||||||
|
ClanTerritory claim = Clans.getClanUtility().getClaim(caller.getLocation());
|
||||||
|
|
||||||
|
if (claim == null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "You can only Safe Zone on Claimed Territory."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set
|
||||||
|
Clans.getClanDataAccess().safe(claim, caller.getName());
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Territory Safe Zone: " + F.tf(claim.Safe)));
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||||
@ -92,7 +91,7 @@ public class ClansDataAccessLayer
|
|||||||
clan.getInviterMap().remove(player);
|
clan.getInviterMap().remove(player);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_repository.addMember(clan.getName(), player);
|
_repository.addMember(clan.getId(), player, role.toString());
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Added [" + player + "] to [" + clan.getName() + "].");
|
_manager.log("Added [" + player + "] to [" + clan.getName() + "].");
|
||||||
@ -108,7 +107,7 @@ public class ClansDataAccessLayer
|
|||||||
_manager.getClanMemberMap().remove(player);
|
_manager.getClanMemberMap().remove(player);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_repository.removeMember(clan.getName(), player);
|
_repository.removeMember(clan.getId(), player);
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
|
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
|
||||||
@ -120,7 +119,7 @@ public class ClansDataAccessLayer
|
|||||||
clan.getMembers().put(player, role);
|
clan.getMembers().put(player, role);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_repository.updateMember(clan.getName(), player, role);
|
_repository.updateMember(clan.getId(), player, role.toString());
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
|
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
|
||||||
@ -154,8 +153,8 @@ public class ClansDataAccessLayer
|
|||||||
cB.getAllyMap().put(cA.getName(), false);
|
cB.getAllyMap().put(cA.getName(), false);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_manager.CRepo().EditClan(cA.GetToken());
|
_repository.addClanRelationship(cA.getId(), cB.getId(), true);
|
||||||
_manager.CRepo().EditClan(cB.GetToken());
|
_repository.addClanRelationship(cB.getId(), cA.getId(), true);
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "].");
|
_manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "].");
|
||||||
@ -172,16 +171,8 @@ public class ClansDataAccessLayer
|
|||||||
cA.getAllyMap().put(cB.getName(), trust);
|
cA.getAllyMap().put(cB.getName(), trust);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_manager.CRepo().EditClan(cA.GetToken());
|
_repository.updateClanRelationship(cA.getId(), cB.getId(), true);
|
||||||
_manager.CRepo().EditClan(cB.GetToken());
|
_repository.updateClanRelationship(cB.getId(), cA.getId(), true);
|
||||||
|
|
||||||
//Update Relations
|
|
||||||
for (String cur : cA.getMembers().keySet())
|
|
||||||
_manager.getClanUtility().updateRelations(cur);
|
|
||||||
|
|
||||||
//Update Relations
|
|
||||||
for (String cur : cB.getMembers().keySet())
|
|
||||||
_manager.getClanUtility().updateRelations(cur);
|
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Gave Trust [" + trust + "] to [" + cB.getName() + "] for [" + cA.getName() + "] by [" + player + "].");
|
_manager.log("Gave Trust [" + trust + "] to [" + cB.getName() + "] for [" + cA.getName() + "] by [" + player + "].");
|
||||||
@ -196,21 +187,14 @@ public class ClansDataAccessLayer
|
|||||||
cB.getAllyMap().remove(cA.getName());
|
cB.getAllyMap().remove(cA.getName());
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_manager.CRepo().EditClan(cA.GetToken());
|
_repository.removeClanRelationship(cA.getId(), cB.getId());
|
||||||
_manager.CRepo().EditClan(cB.GetToken());
|
_repository.removeClanRelationship(cB.getId(), cA.getId());
|
||||||
|
|
||||||
//Update Relations
|
|
||||||
for (String cur : cA.getMembers().keySet())
|
|
||||||
_manager.getClanUtility().updateRelations(cur);
|
|
||||||
|
|
||||||
//Update Relations
|
|
||||||
for (String cur : cB.getMembers().keySet())
|
|
||||||
_manager.getClanUtility().updateRelations(cur);
|
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Added Neutral between [" + cA.getName() + "] and [" + cB.getName() + "] by [" + player + "].");
|
_manager.log("Added Neutral between [" + cA.getName() + "] and [" + cB.getName() + "] by [" + player + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public boolean claim(String name, String chunk, String player, boolean safe)
|
public boolean claim(String name, String chunk, String player, boolean safe)
|
||||||
{
|
{
|
||||||
if (!_manager.getClanMap().containsKey(name))
|
if (!_manager.getClanMap().containsKey(name))
|
||||||
@ -223,16 +207,18 @@ public class ClansDataAccessLayer
|
|||||||
unclaim(chunk, player, false);
|
unclaim(chunk, player, false);
|
||||||
|
|
||||||
//Memory
|
//Memory
|
||||||
ClanTerritory claim = new ClanTerritory(_manager, name, chunk, safe);
|
ClanTerritory claim = new ClanTerritory();
|
||||||
|
claim.Owner = name;
|
||||||
|
claim.Safe = safe;
|
||||||
clan.getClaimSet().add(chunk);
|
clan.getClaimSet().add(chunk);
|
||||||
_manager.getClaimMap().put(chunk, claim);
|
_manager.getClaimMap().put(chunk, claim);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_manager.CRepo().EditClan(clan.GetToken());
|
_repository.addTerritoryClaim(clan.getId(), chunk, safe);
|
||||||
|
|
||||||
//Visual
|
//Visual
|
||||||
Chunk c = UtilWorld.strToChunk(chunk);
|
Chunk c = UtilWorld.strToChunk(chunk);
|
||||||
if (!clan.IsAdmin())
|
if (!clan.isAdmin())
|
||||||
for (int i = 0 ; i < 3 ; i++)
|
for (int i = 0 ; i < 3 ; i++)
|
||||||
for (int x=0 ; x < 16 ; x++)
|
for (int x=0 ; x < 16 ; x++)
|
||||||
for (int z=0 ; z < 16 ; z++)
|
for (int z=0 ; z < 16 ; z++)
|
||||||
@ -241,7 +227,7 @@ public class ClansDataAccessLayer
|
|||||||
Block down = UtilBlock.getHighest(c.getWorld(), c.getBlock(x, 0, z).getX(), c.getBlock(x, 0, z).getZ()).getRelative(BlockFace.DOWN);
|
Block down = UtilBlock.getHighest(c.getWorld(), c.getBlock(x, 0, z).getX(), c.getBlock(x, 0, z).getZ()).getRelative(BlockFace.DOWN);
|
||||||
|
|
||||||
if (down.getTypeId() == 1 || down.getTypeId() == 2 || down.getTypeId() == 3 || down.getTypeId() == 12 || down.getTypeId() == 8)
|
if (down.getTypeId() == 1 || down.getTypeId() == 2 || down.getTypeId() == 3 || down.getTypeId() == 12 || down.getTypeId() == 8)
|
||||||
_manager.BlockRestore().Add(down, 89, (byte)0, 180000);
|
_manager.getBlockRestore().Add(down, 89, (byte)0, 180000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
@ -272,10 +258,10 @@ public class ClansDataAccessLayer
|
|||||||
clan.getClaimSet().remove(chunk);
|
clan.getClaimSet().remove(chunk);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_manager.CRepo().EditClan(clan.GetToken());
|
_repository.removeTerritoryClaim(clan.getId(), chunk);
|
||||||
|
|
||||||
//Register
|
//Register
|
||||||
_manager.getUnclaimMap().put(chunk, System.currentTimeMillis());
|
// _manager.getUnclaimMap().put(chunk, System.currentTimeMillis());
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [" + player + "].");
|
_manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [" + player + "].");
|
||||||
@ -286,10 +272,10 @@ public class ClansDataAccessLayer
|
|||||||
public void home(ClanInfo clan, Location loc, String player)
|
public void home(ClanInfo clan, Location loc, String player)
|
||||||
{
|
{
|
||||||
//Memory
|
//Memory
|
||||||
clan.SetHome(loc);
|
clan.setHome(loc);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_manager.CRepo().EditClan(clan.GetToken());
|
_repository.updateClan(clan.getId(), clan.getName(), clan.getDesc(), UtilWorld.locToStr(clan.getHome()), clan.isAdmin(), clan.getLastOnline());
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
|
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
|
||||||
@ -301,9 +287,9 @@ public class ClansDataAccessLayer
|
|||||||
claim.Safe = !claim.Safe;
|
claim.Safe = !claim.Safe;
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_manager.CRepo().EditClan(_manager.getClan(claim.Owner).GetToken());
|
_repository.updateTerritoryClaim(claim.Chunk, claim.Safe);
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Safe Zone at [" + claim.chunk + "] set to [" + claim.Safe + "] by [" + player + "].");
|
_manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,251 @@
|
|||||||
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
public class ClansDisplay
|
||||||
|
{
|
||||||
|
private ClansManager Clans;
|
||||||
|
|
||||||
|
public ClansDisplay(ClansManager clans)
|
||||||
|
{
|
||||||
|
Clans = clans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(Player player)
|
||||||
|
{
|
||||||
|
if (player.getWorld().getEnvironment() != Environment.NORMAL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ClientClan client = Clans.Get(player);
|
||||||
|
if (client == null) return;
|
||||||
|
|
||||||
|
//Same Chunk
|
||||||
|
if (client.getTerritory().equals(UtilWorld.chunkToStr(player.getLocation().getChunk())))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Update Territory
|
||||||
|
client.setTerritory(UtilWorld.chunkToStr(player.getLocation().getChunk()));
|
||||||
|
|
||||||
|
//AutoClaim
|
||||||
|
if (client.isAutoClaim())
|
||||||
|
Clans.getClanAdmin().claim(player);
|
||||||
|
|
||||||
|
//Map
|
||||||
|
String owner = "?";
|
||||||
|
ClanInfo ownerClan = Clans.getClanUtility().getOwner(player.getLocation());
|
||||||
|
if (ownerClan != null)
|
||||||
|
owner = ownerClan.getName();
|
||||||
|
|
||||||
|
boolean safe = Clans.getClanUtility().isSafe(player);
|
||||||
|
|
||||||
|
if (!client.isMapOn())
|
||||||
|
{
|
||||||
|
boolean showChange = false;
|
||||||
|
|
||||||
|
//Owner Change
|
||||||
|
if (!client.getOwner().equals(owner))
|
||||||
|
{
|
||||||
|
client.setOwner(owner);
|
||||||
|
showChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Safe Change
|
||||||
|
if (safe != client.isSafe())
|
||||||
|
{
|
||||||
|
client.setSafe(safe);
|
||||||
|
showChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showChange)
|
||||||
|
displayOwner(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displayOwner(player);
|
||||||
|
displayMap(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayOwner(Player player)
|
||||||
|
{
|
||||||
|
//Name
|
||||||
|
String ownerString = C.xWilderness + "Wilderness";
|
||||||
|
|
||||||
|
ClanTerritory claim = Clans.getClanUtility().getClaim(player.getLocation());
|
||||||
|
String append = "";
|
||||||
|
if (claim != null)
|
||||||
|
{
|
||||||
|
//Relation
|
||||||
|
ClanRelation relation = Clans.getClanUtility().relPT(player.getName(), claim.Chunk);
|
||||||
|
|
||||||
|
//Name
|
||||||
|
ownerString = Clans.getClanUtility().mRel(relation, claim.Owner, false);
|
||||||
|
|
||||||
|
//Trust
|
||||||
|
if (relation == ClanRelation.ALLY_TRUST)
|
||||||
|
append = C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Clans", ownerString + " " + append));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int width = 8;
|
||||||
|
public int height = 4;
|
||||||
|
|
||||||
|
public void displayMap(Player player)
|
||||||
|
{
|
||||||
|
if (player.getWorld().getEnvironment().equals(Environment.NETHER))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Get Local
|
||||||
|
LinkedList<String> local = mLocalMap(player, player.getLocation().getChunk(), true);
|
||||||
|
|
||||||
|
//Get Home
|
||||||
|
LinkedList<String> home = null;
|
||||||
|
|
||||||
|
if (player.getItemInHand().getType() == Material.MAP)
|
||||||
|
{
|
||||||
|
ClanInfo clan = Clans.getClanUtility().getClanByPlayer(player);
|
||||||
|
if (clan != null)
|
||||||
|
if (clan.getHome() != null)
|
||||||
|
home = mLocalMap(player, clan.getHome().getChunk(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Display
|
||||||
|
if (home == null || local.size() != home.size())
|
||||||
|
UtilPlayer.message(player, local);
|
||||||
|
|
||||||
|
else
|
||||||
|
for (int i = 0 ; i < local.size() ; i++)
|
||||||
|
UtilPlayer.message(player, local.get(i) + " " + home.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<String> mLocalMap(Player player, Chunk chunk, boolean local)
|
||||||
|
{
|
||||||
|
if (chunk == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
LinkedList<String> localMap = new LinkedList<String>();
|
||||||
|
|
||||||
|
for (int i=(chunk.getX()-height) ; i <= (chunk.getX()+height) ; i++)
|
||||||
|
{
|
||||||
|
String output = C.xNone + "<";
|
||||||
|
|
||||||
|
for (int j=(chunk.getZ()+width) ; j >= (chunk.getZ()-width) ; j--)
|
||||||
|
{
|
||||||
|
Chunk curChunk = player.getWorld().getChunkAt(i, j);
|
||||||
|
|
||||||
|
//Count Players
|
||||||
|
int pCount = 0;
|
||||||
|
if (player.getItemInHand().getType() == Material.MAP)
|
||||||
|
{
|
||||||
|
for (Player cur : UtilServer.getPlayers())
|
||||||
|
if (cur.getLocation().getChunk().toString().equals(curChunk.toString()))
|
||||||
|
pCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get Data
|
||||||
|
ClanInfo curOwner = Clans.getClanUtility().getOwner(UtilWorld.chunkToStr(curChunk));
|
||||||
|
ClanTerritory curClaim = Clans.getClanUtility().getClaim(UtilWorld.chunkToStr(curChunk));
|
||||||
|
|
||||||
|
//Add Icon
|
||||||
|
if (i == chunk.getX() && j == chunk.getZ())
|
||||||
|
output += getMapIcon(Clans.getClanUtility().relPC(player.getName(), curOwner), curClaim, curOwner, curChunk, pCount, true, local);
|
||||||
|
else
|
||||||
|
output += getMapIcon(Clans.getClanUtility().relPC(player.getName(), curOwner), curClaim, curOwner, curChunk, pCount, false, local);
|
||||||
|
}
|
||||||
|
|
||||||
|
output += ">";
|
||||||
|
|
||||||
|
//Send
|
||||||
|
localMap.add(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
return localMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMapIcon(ClanRelation relation, ClanTerritory claim, ClanInfo owner, Chunk chunk, int players, boolean mid, boolean local)
|
||||||
|
{
|
||||||
|
if (players > 9)
|
||||||
|
players = 9;
|
||||||
|
|
||||||
|
if (mid && local)
|
||||||
|
{
|
||||||
|
if (players > 0) return "" + C.cWhite + players;
|
||||||
|
else return "" + C.cWhite + "X";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (owner == null || claim == null)
|
||||||
|
{
|
||||||
|
if (players > 0) return "" + C.xNone + players;
|
||||||
|
else return "" + C.xNone + "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (claim.Safe)
|
||||||
|
{
|
||||||
|
if (players > 0) return "" + C.xSafe + players;
|
||||||
|
else return "" + C.xSafe + "S";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (owner.isAdmin())
|
||||||
|
{
|
||||||
|
if (players > 0) return "" + C.xAdmin + players;
|
||||||
|
else return "" + C.xAdmin + "+";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (relation == ClanRelation.SELF)
|
||||||
|
{
|
||||||
|
if (players > 0) return "" + C.xSelf + players;
|
||||||
|
else if (Clans.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xSelf + "H";
|
||||||
|
else return "" + C.xSelf + "#";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relation == ClanRelation.ALLY)
|
||||||
|
{
|
||||||
|
if (players > 0) return "" + C.xAlly + players;
|
||||||
|
else if (Clans.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xAlly + "H";
|
||||||
|
else return "" + C.xAlly + "#";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relation == ClanRelation.ALLY_TRUST)
|
||||||
|
{
|
||||||
|
if (players > 0) return "" + C.xdAlly + players;
|
||||||
|
else if (Clans.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xdAlly + "H";
|
||||||
|
else return "" + C.xdAlly + "#";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (players > 0) return "" + C.xEnemy + players;
|
||||||
|
else if (Clans.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xEnemy + "H";
|
||||||
|
else return "" + C.xEnemy + "#";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer().getItemInHand().getType() != Material.MAP)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!Recharge.Instance.use(event.getPlayer(), "Clan Map", 500, false, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
displayOwner(event.getPlayer());
|
||||||
|
displayMap(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -24,6 +24,7 @@ import mineplex.core.MiniClientPlugin;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||||
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
@ -33,8 +34,10 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||||
|
import mineplex.core.teleport.Teleport;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
@ -43,6 +46,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
{
|
{
|
||||||
private CombatManager _combatManager;
|
private CombatManager _combatManager;
|
||||||
private ClansUtility _clanUtility;
|
private ClansUtility _clanUtility;
|
||||||
|
private ClansDataAccessLayer _clanDataAccess;
|
||||||
|
private ClansDisplay _clanDisplay;
|
||||||
|
private ClansAdmin _clanAdmin;
|
||||||
|
private BlockRestore _blockRestore;
|
||||||
|
private Teleport _teleport;
|
||||||
|
|
||||||
private int _dominanceLimit = 16;
|
private int _dominanceLimit = 16;
|
||||||
private int _inviteExpire = 2;
|
private int _inviteExpire = 2;
|
||||||
@ -57,12 +65,17 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
|
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
|
||||||
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
|
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
|
||||||
|
|
||||||
public ClansManager(JavaPlugin plugin, CombatManager combatManager)
|
public ClansManager(JavaPlugin plugin, CombatManager combatManager, BlockRestore blockRestore, Teleport teleport)
|
||||||
{
|
{
|
||||||
super("Clans Manager", plugin);
|
super("Clans Manager", plugin);
|
||||||
|
|
||||||
_combatManager = combatManager;
|
_combatManager = combatManager;
|
||||||
_clanUtility = new ClansUtility(this);
|
_clanUtility = new ClansUtility(this);
|
||||||
|
_blockRestore = blockRestore;
|
||||||
|
_teleport = teleport;
|
||||||
|
_clanDataAccess = new ClansDataAccessLayer(this);
|
||||||
|
_clanDisplay = new ClansDisplay(this);
|
||||||
|
_clanAdmin = new ClansAdmin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInviteExpire()
|
public int getInviteExpire()
|
||||||
@ -111,17 +124,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
CCommand().command(caller, args);
|
CCommand().command(caller, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClansClan getClan(String name)
|
|
||||||
{
|
|
||||||
return GetClanMap().get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void Update(UpdateEvent event)
|
public void Update(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() == UpdateType.SEC)
|
|
||||||
Power();
|
|
||||||
|
|
||||||
if (event.getType() == UpdateType.FAST)
|
if (event.getType() == UpdateType.FAST)
|
||||||
CGame().UpdateSafe();
|
CGame().UpdateSafe();
|
||||||
|
|
||||||
@ -177,7 +182,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
|
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
|
||||||
{
|
{
|
||||||
ClansClan clan = Clans().CUtil().getOwner(event.GetLocation());
|
ClansClan clan = _clanUtility.getOwner(event.GetLocation());
|
||||||
|
|
||||||
if (clan != null)
|
if (clan != null)
|
||||||
if (!clan.IsAdmin() && !clan.GetName().equals("Spawn"))
|
if (!clan.IsAdmin() && !clan.GetName().equals("Spawn"))
|
||||||
@ -256,18 +261,18 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
|
|
||||||
public boolean HandleClanChat(AsyncPlayerChatEvent event, String filteredMessage)
|
public boolean HandleClanChat(AsyncPlayerChatEvent event, String filteredMessage)
|
||||||
{
|
{
|
||||||
CoreClient client = Clients().Get(event.getPlayer());
|
ClientClan client = Get(event.getPlayer());
|
||||||
|
|
||||||
if (client == null)
|
if (client == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!client.Clan().IsClanChat())
|
if (!client.isClanChat())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
|
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
||||||
if (clan == null)
|
if (clan == null)
|
||||||
{
|
{
|
||||||
Clients().Get(event.getPlayer()).Clan().SetClanChat(false);
|
Get(event.getPlayer()).setClanChat(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,10 +285,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
if (!Get(event.getPlayer()).isAllyChat())
|
if (!Get(event.getPlayer()).isAllyChat())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
|
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
||||||
if (clan == null)
|
if (clan == null)
|
||||||
{
|
{
|
||||||
Clients().Get(event.getPlayer()).Clan().SetAllyChat(false);
|
Get(event.getPlayer()).setAllyChat(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,57 +329,36 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
return _reclaimTime;
|
return _reclaimTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean canHurt(Player a, Player b)
|
||||||
public boolean CanHurt(Player a, Player b)
|
|
||||||
{
|
{
|
||||||
if (a.equals(b))
|
if (a.equals(b))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return CUtil().canHurt(a, b);
|
return _clanUtility.canHurt(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean canHurt(String a, String b)
|
||||||
public boolean CanHurt(String a, String b)
|
|
||||||
{
|
{
|
||||||
if (a.equals(b))
|
if (a.equals(b))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return CUtil().canHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b));
|
return _clanUtility.canHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean isSafe(Player a)
|
||||||
public boolean IsSafe(Player a)
|
|
||||||
{
|
{
|
||||||
return CUtil().isSafe(a);
|
return _clanUtility.isSafe(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRepository GetRepository() {
|
public ClanRelation getRelation(String playerA, String playerB)
|
||||||
return _repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRepository(IRepository _repository) {
|
|
||||||
this._repository = _repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, ClansClan> GetClanMemberMap()
|
|
||||||
{
|
{
|
||||||
return _clanMemberMap;
|
return Get(playerA).getRelation(playerB);
|
||||||
}
|
|
||||||
|
|
||||||
public ClanRelation GetRelation(String playerA, String playerB)
|
|
||||||
{
|
|
||||||
return Clients().Get(playerA).Clan().GetRelation(playerB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatColor GetColorOfFor(String other, Player player)
|
public ChatColor GetColorOfFor(String other, Player player)
|
||||||
{
|
{
|
||||||
return CUtil().relChatColor(Clients().Get(player).Clan().GetRelation(other), false);
|
return _clanUtility.relChatColor(Get(player).getRelation(other), false);
|
||||||
}
|
|
||||||
|
|
||||||
public String GetServerName()
|
|
||||||
{
|
|
||||||
return _serverName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getOnlineTime()
|
public long getOnlineTime()
|
||||||
@ -402,4 +386,34 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockRestore getBlockRestore()
|
||||||
|
{
|
||||||
|
return _blockRestore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClansDataAccessLayer getClanDataAccess()
|
||||||
|
{
|
||||||
|
return _clanDataAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Teleport getTeleport()
|
||||||
|
{
|
||||||
|
return _teleport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClansDisplay getClanDisplay()
|
||||||
|
{
|
||||||
|
return _clanDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NautHashMap<String, Long> getUnclaimMap()
|
||||||
|
{
|
||||||
|
return _unclaimMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClansAdmin getClanAdmin()
|
||||||
|
{
|
||||||
|
return _clanAdmin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,12 @@ public class ClientClan
|
|||||||
private boolean _canJoin;
|
private boolean _canJoin;
|
||||||
private long _joinDelay;
|
private long _joinDelay;
|
||||||
|
|
||||||
|
private String _territory;
|
||||||
|
private boolean _autoClaim;
|
||||||
|
private String _owner;
|
||||||
|
private boolean _safe;
|
||||||
|
private String _mimic;
|
||||||
|
|
||||||
public boolean isAllyChat()
|
public boolean isAllyChat()
|
||||||
{
|
{
|
||||||
return _allyChat;
|
return _allyChat;
|
||||||
@ -48,4 +54,54 @@ public class ClientClan
|
|||||||
{
|
{
|
||||||
return _joinDelay;
|
return _joinDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTerritory()
|
||||||
|
{
|
||||||
|
return _territory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTerritory(String territory)
|
||||||
|
{
|
||||||
|
_territory = territory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutoClaim()
|
||||||
|
{
|
||||||
|
return _autoClaim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner()
|
||||||
|
{
|
||||||
|
return _owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(String owner)
|
||||||
|
{
|
||||||
|
_owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSafe()
|
||||||
|
{
|
||||||
|
return _safe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSafe(boolean safe)
|
||||||
|
{
|
||||||
|
_safe = safe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoClaim(boolean autoclaim)
|
||||||
|
{
|
||||||
|
_autoClaim = autoclaim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMimic(String mimic)
|
||||||
|
{
|
||||||
|
_mimic = mimic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimic()
|
||||||
|
{
|
||||||
|
return _mimic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import java.util.ArrayList;
|
|||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilInput;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -50,7 +50,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
help(caller);
|
help(caller);
|
||||||
|
|
||||||
else if (args[0].equalsIgnoreCase("admin") || args[0].equalsIgnoreCase("x"))
|
else if (args[0].equalsIgnoreCase("admin") || args[0].equalsIgnoreCase("x"))
|
||||||
Plugin.CAdmin().command(caller, args);
|
Plugin.getClanAdmin().command(caller, args);
|
||||||
|
|
||||||
else if (args[0].equalsIgnoreCase("create"))
|
else if (args[0].equalsIgnoreCase("create"))
|
||||||
create(caller, args);
|
create(caller, args);
|
||||||
@ -204,7 +204,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Plugin.Util().Input().valid(args[1]))
|
if (!UtilInput.valid(args[1]))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
|
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
|
||||||
return;
|
return;
|
||||||
@ -243,8 +243,10 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
//Inform
|
//Inform
|
||||||
UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " formed " + F.elem("Clan " + args[1]) + "."));
|
UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " formed " + F.elem("Clan " + args[1]) + "."));
|
||||||
|
|
||||||
//Create and Join
|
|
||||||
Plugin.CTask().join(Plugin.CTask().create(caller.getName(), args[1], false), caller.getName(), Role.LEADER);
|
ClanInfo clan = Plugin.getClanDataAccess().create(caller.getName(), args[1], false);
|
||||||
|
|
||||||
|
Plugin.getClanDataAccess().join(clan, caller.getName(), Role.LEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Player caller, String[] args)
|
public void delete(Player caller, String[] args)
|
||||||
@ -264,7 +266,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().delete(clan);
|
Plugin.getClanDataAccess().delete(clan);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " disbanded " + F.elem("Clan " + clan.getName()) + "."));
|
UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " disbanded " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
@ -310,7 +312,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
UtilPlayer.message(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
|
UtilPlayer.message(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().invite(clan, target.getName(), caller.getName());
|
Plugin.getClanDataAccess().invite(clan, target.getName(), caller.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void join(Player caller, String[] args)
|
public void join(Player caller, String[] args)
|
||||||
@ -337,7 +339,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Plugin.Util().Input().valid(args[1]))
|
if (!UtilInput.valid(args[1]))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
|
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
|
||||||
return;
|
return;
|
||||||
@ -354,7 +356,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().join(clan, caller.getName(), Role.RECRUIT);
|
Plugin.getClanDataAccess().join(clan, caller.getName(), Role.RECRUIT);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
@ -384,7 +386,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().leave(clan, caller.getName());
|
Plugin.getClanDataAccess().leave(clan, caller.getName());
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
|
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
|
||||||
@ -432,7 +434,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
|
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().leave(clan, target);
|
Plugin.getClanDataAccess().leave(clan, target);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(UtilPlayer.searchOnline(null, target, false), F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
|
UtilPlayer.message(UtilPlayer.searchOnline(null, target, false), F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
@ -477,21 +479,21 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
String newRank = "?";
|
String newRank = "?";
|
||||||
if (clan.getMembers().get(target) == Role.RECRUIT)
|
if (clan.getMembers().get(target) == Role.RECRUIT)
|
||||||
{
|
{
|
||||||
Plugin.CTask().role(clan, target, Role.MEMBER);
|
Plugin.getClanDataAccess().role(clan, target, Role.MEMBER);
|
||||||
newRank = "Member";
|
newRank = "Member";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == Role.MEMBER)
|
else if (clan.getMembers().get(target) == Role.MEMBER)
|
||||||
{
|
{
|
||||||
Plugin.CTask().role(clan, target, Role.ADMIN);
|
Plugin.getClanDataAccess().role(clan, target, Role.ADMIN);
|
||||||
newRank = "Admin";
|
newRank = "Admin";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == Role.ADMIN)
|
else if (clan.getMembers().get(target) == Role.ADMIN)
|
||||||
{
|
{
|
||||||
Plugin.CTask().role(clan, target, Role.LEADER);
|
Plugin.getClanDataAccess().role(clan, target, Role.LEADER);
|
||||||
newRank = "Leader";
|
newRank = "Leader";
|
||||||
|
|
||||||
//Give Leader
|
//Give Leader
|
||||||
Plugin.CTask().role(clan, caller.getName(), Role.ADMIN);
|
Plugin.getClanDataAccess().role(clan, caller.getName(), Role.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
@ -541,12 +543,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
String newRank = "?";
|
String newRank = "?";
|
||||||
if (clan.getMembers().get(target) == Role.MEMBER)
|
if (clan.getMembers().get(target) == Role.MEMBER)
|
||||||
{
|
{
|
||||||
Plugin.CTask().role(clan, target, Role.RECRUIT);
|
Plugin.getClanDataAccess().role(clan, target, Role.RECRUIT);
|
||||||
newRank = "Recruit";
|
newRank = "Recruit";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == Role.ADMIN)
|
else if (clan.getMembers().get(target) == Role.ADMIN)
|
||||||
{
|
{
|
||||||
Plugin.CTask().role(clan, target, Role.MEMBER);
|
Plugin.getClanDataAccess().role(clan, target, Role.MEMBER);
|
||||||
newRank = "Member";
|
newRank = "Member";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +610,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
if (cB.isRequested(cA.getName()))
|
if (cB.isRequested(cA.getName()))
|
||||||
{
|
{
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().ally(cA, cB, caller.getName());
|
Plugin.getClanDataAccess().ally(cA, cB, caller.getName());
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You accepted alliance with " + F.elem("Clan " + cB.getName()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You accepted alliance with " + F.elem("Clan " + cB.getName()) + "."));
|
||||||
@ -618,7 +620,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().requestAlly(cA, cB, caller.getName());
|
Plugin.getClanDataAccess().requestAlly(cA, cB, caller.getName());
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You requested alliance with " + F.elem("Clan " + cB.getName()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You requested alliance with " + F.elem("Clan " + cB.getName()) + "."));
|
||||||
@ -661,7 +663,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
if (Plugin.CTask().trust(cA, cB, caller.getName()))
|
if (Plugin.getClanDataAccess().trust(cA, cB, caller.getName()))
|
||||||
{
|
{
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You gave trust to " + F.elem("Clan " + cB.getName()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You gave trust to " + F.elem("Clan " + cB.getName()) + "."));
|
||||||
@ -719,7 +721,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
if (cB.isAlly(cA.getName()))
|
if (cB.isAlly(cA.getName()))
|
||||||
{
|
{
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().neutral(cA, cB, caller.getName(), true);
|
Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + "."));
|
||||||
@ -864,7 +866,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().claim(clan.getName(), chunk, caller.getName(), false);
|
Plugin.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
|
||||||
@ -936,7 +938,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().unclaim(chunk, caller.getName(), true);
|
Plugin.getClanDataAccess().unclaim(chunk, caller.getName(), true);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
|
||||||
@ -964,7 +966,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
|
F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
|
||||||
|
|
||||||
//Unclaim
|
//Unclaim
|
||||||
Plugin.CTask().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true);
|
Plugin.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -992,7 +994,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
toUnclaim.add(chunk);
|
toUnclaim.add(chunk);
|
||||||
|
|
||||||
for (String chunk : toUnclaim)
|
for (String chunk : toUnclaim)
|
||||||
Plugin.CTask().unclaim(chunk, caller.getName(), true);
|
Plugin.getClanDataAccess().unclaim(chunk, caller.getName(), true);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You unclaimed all your Clans Territory."));
|
UtilPlayer.message(caller, F.main("Clans", "You unclaimed all your Clans Territory."));
|
||||||
@ -1013,8 +1015,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Display
|
//Display
|
||||||
Plugin.CDisplay().displayOwner(caller);
|
Plugin.getClanDisplay().displayOwner(caller);
|
||||||
Plugin.CDisplay().displayMap(caller);
|
Plugin.getClanDisplay().displayMap(caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void home(Player caller, String[] args)
|
public void home(Player caller, String[] args)
|
||||||
@ -1075,7 +1077,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Do
|
//Do
|
||||||
Plugin.Teleport().TP(caller, clan.GetHome());
|
Plugin.getTeleport().TP(caller, clan.getHome());
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
|
||||||
@ -1110,7 +1112,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.CTask().home(clan, caller.getLocation(), caller.getName());
|
Plugin.getClanDataAccess().home(clan, caller.getLocation(), caller.getName());
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You set Clan Home to " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You set Clan Home to " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
|
||||||
|
@ -9,6 +9,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.database.RepositoryBase;
|
import mineplex.core.database.RepositoryBase;
|
||||||
import mineplex.core.database.ResultSetCallable;
|
import mineplex.core.database.ResultSetCallable;
|
||||||
|
import mineplex.core.database.column.ColumnBoolean;
|
||||||
|
import mineplex.core.database.column.ColumnInt;
|
||||||
|
import mineplex.core.database.column.ColumnLong;
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
||||||
@ -26,6 +29,24 @@ public class ClanRepository extends RepositoryBase
|
|||||||
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, role FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId;";
|
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, role FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId;";
|
||||||
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId;";
|
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId;";
|
||||||
|
|
||||||
|
private static String DELETE_CLAN_MEMBER = "DELETE FROM accountClan INNER JOIN accounts ON accounts.id = accountClan.accountId WHERE clans.id = ? AND accounts.name = ?;";
|
||||||
|
private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId WHERE clans.name = ?;";
|
||||||
|
private static String DELETE_CLAN_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ? AND serverName = ? AND chunk = ?;";
|
||||||
|
private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory INNER JOIN clans ON clans.id = clanTerritory.clanId WHERE clans.name = ?;";
|
||||||
|
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
|
||||||
|
private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances INNER JOIN clans ON clans.id = clanAlliances.clanId WHERE clans.name = ?;";
|
||||||
|
private static String DELETE_CLAN = "DELETE FROM clans WHERE name = ?;";
|
||||||
|
|
||||||
|
private static String ADD_CLAN = "INSERT INTO clans (name, description, home, admin, dateCreated, lastOnline) VALUES (?, ?, ?, ?, now(), now());";
|
||||||
|
private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;";
|
||||||
|
private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clandId, otherClanId, trusted) VALUES (?, ?, ?);";
|
||||||
|
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, serverName, chunk, safe) VALUES (?, ?, ?, ?);";
|
||||||
|
|
||||||
|
private static String UPDATE_CLAN = "UPDATE clans SET name = ?, desc = ?, home = ?, admin = ?, lastOnline = ? WHERE id = ?;";
|
||||||
|
private static String UPDATE_CLAN_MEMBER = "UPDATE AC SET clanRole = ? FROM accountClan AS AC INNER JOIN accounts ON accounts.id = accountClan.accountId WHERE clans.id = ? AND accounts.name = ?;";
|
||||||
|
private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;";
|
||||||
|
private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverName = ? AND chunk = ?;";
|
||||||
|
|
||||||
private String _serverName;
|
private String _serverName;
|
||||||
|
|
||||||
public ClanRepository(JavaPlugin plugin, String serverName)
|
public ClanRepository(JavaPlugin plugin, String serverName)
|
||||||
@ -130,4 +151,79 @@ public class ClanRepository extends RepositoryBase
|
|||||||
protected void update()
|
protected void update()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteClan(String name)
|
||||||
|
{
|
||||||
|
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnVarChar("name", 100, name));
|
||||||
|
executeUpdate(DELETE_CLAN_TERRITORIES, new ColumnVarChar("name", 100, name));
|
||||||
|
executeUpdate(DELETE_CLAN_ALLIANCES, new ColumnVarChar("name", 100, name));
|
||||||
|
executeUpdate(DELETE_CLAN, new ColumnVarChar("name", 100, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addClan(final ClanToken token)
|
||||||
|
{
|
||||||
|
executeUpdate(ADD_CLAN, new ResultSetCallable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
executeUpdate(ADD_CLAN_MEMBER, new ColumnInt("clanid", resultSet.getInt(0)), new ColumnVarChar("clanRole", 100, token.Members.get(0).ClanRole), new ColumnVarChar("name", 100, token.Members.get(0).Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, new ColumnVarChar("name", 100, token.Name), new ColumnVarChar("description", 100, token.Description), new ColumnVarChar("home", 100, token.Home), new ColumnBoolean("admin", token.Admin));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMember(int clanId, String playerName, String role)
|
||||||
|
{
|
||||||
|
executeUpdate(ADD_CLAN_MEMBER, new ColumnInt("clanid", clanId), new ColumnVarChar("clanRole", 100, role), new ColumnVarChar("name", 100, playerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMember(int clanId, String playerName)
|
||||||
|
{
|
||||||
|
executeUpdate(DELETE_CLAN_MEMBER, new ColumnInt("clanid", clanId), new ColumnVarChar("name", 100, playerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMember(int clanId, String playerName, String role)
|
||||||
|
{
|
||||||
|
executeUpdate(UPDATE_CLAN_MEMBER, new ColumnInt("clanid", clanId), new ColumnVarChar("clanRole", 100, role), new ColumnVarChar("name", 100, playerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addClanRelationship(int clanId, int otherClanId, boolean trusted)
|
||||||
|
{
|
||||||
|
executeUpdate(ADD_CLAN_ALLIANCE, new ColumnInt("clanid", clanId), new ColumnInt("otherClanId", otherClanId), new ColumnBoolean("trusted", trusted));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateClanRelationship(int clanId, int otherClanId, boolean trusted)
|
||||||
|
{
|
||||||
|
executeUpdate(UPDATE_CLAN_ALLIANCE, new ColumnInt("clanid", clanId), new ColumnInt("otherClanId", otherClanId), new ColumnBoolean("trusted", trusted));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeClanRelationship(int clanId, int otherClanId)
|
||||||
|
{
|
||||||
|
executeUpdate(DELETE_CLAN_ALLIANCE, new ColumnInt("clanid", clanId), new ColumnInt("otherClanId", otherClanId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTerritoryClaim(int clanId, String chunk, boolean safe)
|
||||||
|
{
|
||||||
|
executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTerritoryClaim(int clanId, String chunk)
|
||||||
|
{
|
||||||
|
executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateClan(int clanId, String name, String desc, String home, boolean admin, long lastOnline)
|
||||||
|
{
|
||||||
|
executeUpdate(UPDATE_CLAN, new ColumnVarChar("name", 100, name), new ColumnVarChar("desc", 100, desc), new ColumnVarChar("home", 100, home), new ColumnBoolean("admin", admin), new ColumnLong("lastOnline", lastOnline), new ColumnInt("clanId", clanId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTerritoryClaim(String chunk, boolean safe)
|
||||||
|
{
|
||||||
|
executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,5 @@ public class ClanTerritory
|
|||||||
{
|
{
|
||||||
public boolean Safe;
|
public boolean Safe;
|
||||||
public String Owner;
|
public String Owner;
|
||||||
|
public String Chunk;
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import mineplex.core.CustomTagFix;
|
import mineplex.core.CustomTagFix;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.antistack.AntiStack;
|
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
@ -16,6 +16,7 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.elo.EloManager;
|
import mineplex.core.elo.EloManager;
|
||||||
import mineplex.core.energy.Energy;
|
import mineplex.core.energy.Energy;
|
||||||
import mineplex.core.friend.FriendManager;
|
import mineplex.core.friend.FriendManager;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
import mineplex.core.memory.MemoryFix;
|
import mineplex.core.memory.MemoryFix;
|
||||||
@ -32,6 +33,7 @@ import mineplex.core.punish.Punish;
|
|||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.serverConfig.ServerConfiguration;
|
import mineplex.core.serverConfig.ServerConfiguration;
|
||||||
import mineplex.core.spawn.Spawn;
|
import mineplex.core.spawn.Spawn;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.status.ServerStatusManager;
|
import mineplex.core.status.ServerStatusManager;
|
||||||
import mineplex.core.task.TaskManager;
|
import mineplex.core.task.TaskManager;
|
||||||
import mineplex.core.teleport.Teleport;
|
import mineplex.core.teleport.Teleport;
|
||||||
@ -89,20 +91,20 @@ public class Hub extends JavaPlugin implements IRelation
|
|||||||
Creature creature = new Creature(this);
|
Creature creature = new Creature(this);
|
||||||
NpcManager npcManager = new NpcManager(this, creature);
|
NpcManager npcManager = new NpcManager(this, creature);
|
||||||
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress);
|
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress);
|
||||||
new AntiStack(this);
|
|
||||||
PollManager pollManager = new PollManager(this, donationManager);
|
PollManager pollManager = new PollManager(this, donationManager);
|
||||||
|
|
||||||
//Main Modules
|
//Main Modules
|
||||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
|
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
|
||||||
//new FriendManager(this, packetHandler);
|
|
||||||
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
|
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
|
||||||
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
|
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
|
||||||
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
|
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
|
||||||
PacketHandler packetHandler = new PacketHandler(this);
|
PacketHandler packetHandler = new PacketHandler(this);
|
||||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
||||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
|
StatsManager statsManager = new StatsManager(this, clientManager);
|
||||||
|
AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager);
|
||||||
|
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this));
|
||||||
|
|
||||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
|
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
|
||||||
|
|
||||||
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);
|
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);
|
||||||
new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
|
new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
|
||||||
@ -126,7 +128,7 @@ public class Hub extends JavaPlugin implements IRelation
|
|||||||
SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, disguiseManager, blockRestore, fire, new Movement(this), teleport, energy, webServerAddress);
|
SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, disguiseManager, blockRestore, fire, new Movement(this), teleport, energy, webServerAddress);
|
||||||
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, webServerAddress);
|
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, webServerAddress);
|
||||||
|
|
||||||
ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory);
|
ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory, achievementManager, clientManager);
|
||||||
|
|
||||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Brute", classManager.GetClass("Brute"));
|
new ClassCombatShop(shopManager, clientManager, donationManager, "Brute", classManager.GetClass("Brute"));
|
||||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Mage", classManager.GetClass("Mage"));
|
new ClassCombatShop(shopManager, clientManager, donationManager, "Mage", classManager.GetClass("Mage"));
|
||||||
|
@ -40,12 +40,10 @@ import org.bukkit.scoreboard.Objective;
|
|||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.RankBenefitsGiver9000;
|
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.achievement.Achievement;
|
|
||||||
import mineplex.core.achievement.AchievementManager;
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.benefit.BenefitManager;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -66,6 +64,7 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||||
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.mount.MountManager;
|
import mineplex.core.mount.MountManager;
|
||||||
@ -146,7 +145,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
//Admin
|
//Admin
|
||||||
private boolean _gadgetsEnabled = true;
|
private boolean _gadgetsEnabled = true;
|
||||||
|
|
||||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager)
|
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
super("Hub Manager", plugin);
|
super("Hub Manager", plugin);
|
||||||
|
|
||||||
@ -159,6 +158,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
_portal = portal;
|
_portal = portal;
|
||||||
|
|
||||||
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5);
|
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5);
|
||||||
|
// Disable item merging
|
||||||
|
((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0;
|
||||||
|
|
||||||
_textCreator = new TextManager(this);
|
_textCreator = new TextManager(this);
|
||||||
_parkour = new ParkourManager(this, donationManager, taskManager);
|
_parkour = new ParkourManager(this, donationManager, taskManager);
|
||||||
@ -172,10 +173,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
_news = new NewsManager(this);
|
_news = new NewsManager(this);
|
||||||
|
|
||||||
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
|
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
|
||||||
_inventoryManager = new InventoryManager(plugin);
|
_inventoryManager = new InventoryManager(plugin, clientManager);
|
||||||
new RankBenefitsGiver9000(plugin, clientManager, _inventoryManager);
|
new BenefitManager(plugin, clientManager, _inventoryManager);
|
||||||
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
|
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
|
||||||
_treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore);
|
_treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager);
|
||||||
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false, _treasureManager);
|
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false, _treasureManager);
|
||||||
|
|
||||||
_partyManager = partyManager;
|
_partyManager = partyManager;
|
||||||
@ -186,8 +187,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
_forcefieldManager = new ForcefieldManager(this);
|
_forcefieldManager = new ForcefieldManager(this);
|
||||||
addCommand(new ForcefieldRadius(_forcefieldManager));
|
addCommand(new ForcefieldRadius(_forcefieldManager));
|
||||||
|
|
||||||
_statsManager = new StatsManager(plugin);
|
_statsManager = statsManager;
|
||||||
_achievementManager = new AchievementManager(_statsManager, _clientManager, _donationManager);
|
_achievementManager = achievementManager;
|
||||||
_achievementManager.setGiveInterfaceItem(true);
|
_achievementManager.setGiveInterfaceItem(true);
|
||||||
|
|
||||||
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
||||||
@ -964,12 +965,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
return _news;
|
return _news;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,8 @@ public class PlayerPollData
|
|||||||
private NautHashMap<Integer, Integer> _pollAnswers;
|
private NautHashMap<Integer, Integer> _pollAnswers;
|
||||||
private long _nextPollTime;
|
private long _nextPollTime;
|
||||||
|
|
||||||
|
public boolean Loaded;
|
||||||
|
|
||||||
public PlayerPollData()
|
public PlayerPollData()
|
||||||
{
|
{
|
||||||
_pollAnswers = new NautHashMap<Integer, Integer>();
|
_pollAnswers = new NautHashMap<Integer, Integer>();
|
||||||
@ -40,7 +42,7 @@ public class PlayerPollData
|
|||||||
|
|
||||||
public boolean shouldPoll()
|
public boolean shouldPoll()
|
||||||
{
|
{
|
||||||
return System.currentTimeMillis() > _nextPollTime;
|
return Loaded && System.currentTimeMillis() > _nextPollTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
|
|||||||
import net.minecraft.util.com.google.gson.JsonObject;
|
import net.minecraft.util.com.google.gson.JsonObject;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -24,9 +23,6 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.hub.poll.command.PollCommand;
|
import mineplex.hub.poll.command.PollCommand;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Shaun on 8/16/2014.
|
|
||||||
*/
|
|
||||||
public class PollManager extends MiniClientPlugin<PlayerPollData>
|
public class PollManager extends MiniClientPlugin<PlayerPollData>
|
||||||
{
|
{
|
||||||
private PollRepository _repository;
|
private PollRepository _repository;
|
||||||
@ -57,17 +53,14 @@ public class PollManager extends MiniClientPlugin<PlayerPollData>
|
|||||||
return new PlayerPollData();
|
return new PlayerPollData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void loadClientInformation(final PlayerJoinEvent event)
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
{
|
||||||
event.incrementProcessingCount();
|
|
||||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Set(event.getPlayerName(), _repository.loadPollData(event.getUniqueId()));
|
Set(event.getPlayer().getName(), _repository.loadPollData(event.getPlayer().getUniqueId()));
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,8 @@ public class PollRepository extends RepositoryBase
|
|||||||
}
|
}
|
||||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||||
|
|
||||||
|
pollData.Loaded = true;
|
||||||
|
|
||||||
return pollData;
|
return pollData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,8 @@ public class ServerManager extends MiniPlugin
|
|||||||
long timeUntilPortal = getMillisecondsUntilPortal(player, false);
|
long timeUntilPortal = getMillisecondsUntilPortal(player, false);
|
||||||
if (!_hubManager.CanPortal(player) || timeUntilPortal > 0)
|
if (!_hubManager.CanPortal(player) || timeUntilPortal > 0)
|
||||||
{
|
{
|
||||||
|
player.closeInventory();
|
||||||
|
|
||||||
if (timeUntilPortal > 0)
|
if (timeUntilPortal > 0)
|
||||||
{
|
{
|
||||||
player.playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 2, 2);
|
player.playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 2, 2);
|
||||||
|
@ -29,6 +29,7 @@ public enum GameType
|
|||||||
SurvivalGames("Survival Games"),
|
SurvivalGames("Survival Games"),
|
||||||
SurvivalGamesTeams("Survival Games Teams"),
|
SurvivalGamesTeams("Survival Games Teams"),
|
||||||
Micro("Micro Battle"),
|
Micro("Micro Battle"),
|
||||||
|
MineStrike("MineStrike"),
|
||||||
MineWare("MineWare"),
|
MineWare("MineWare"),
|
||||||
MilkCow("Milk the Cow"),
|
MilkCow("Milk the Cow"),
|
||||||
Paintball("Super Paintball"),
|
Paintball("Super Paintball"),
|
||||||
@ -49,6 +50,7 @@ public enum GameType
|
|||||||
Tug("Tug of Wool"),
|
Tug("Tug of Wool"),
|
||||||
TurfWars("Turf Wars"),
|
TurfWars("Turf Wars"),
|
||||||
UHC("Ultra Hardcore"),
|
UHC("Ultra Hardcore"),
|
||||||
|
WitherAssault("Wither Assault"),
|
||||||
ZombieSurvival("Zombie Survival"),
|
ZombieSurvival("Zombie Survival"),
|
||||||
None("None");
|
None("None");
|
||||||
|
|
||||||
|
@ -9,12 +9,10 @@ import mineplex.minecraft.game.classcombat.Class.repository.token.ClientClassTok
|
|||||||
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType;
|
|
||||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -309,9 +307,4 @@ public class ClassManager extends MiniClientPlugin<ClientClass> implements IClas
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,6 @@ public class ClientClass
|
|||||||
skillTokenUsage += swordSkill.GetTokenCost() * buildToken.SwordSkillLevel;
|
skillTokenUsage += swordSkill.GetTokenCost() * buildToken.SwordSkillLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!buildToken.AxeSkill.isEmpty())
|
if (!buildToken.AxeSkill.isEmpty())
|
||||||
{
|
{
|
||||||
if (!ValidSkill(buildToken.AxeSkill, axeSkill, SkillType.Axe))
|
if (!ValidSkill(buildToken.AxeSkill, axeSkill, SkillType.Axe))
|
||||||
@ -140,8 +139,6 @@ public class ClientClass
|
|||||||
skillTokenUsage += globalPassive.GetTokenCost() * buildToken.GlobalPassiveSkillLevel;
|
skillTokenUsage += globalPassive.GetTokenCost() * buildToken.GlobalPassiveSkillLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean allEmpty = true;
|
|
||||||
|
|
||||||
for (SlotToken slotToken : buildToken.Slots)
|
for (SlotToken slotToken : buildToken.Slots)
|
||||||
{
|
{
|
||||||
if (slotToken == null)
|
if (slotToken == null)
|
||||||
@ -153,45 +150,43 @@ public class ClientClass
|
|||||||
if (slotToken.Material.isEmpty())
|
if (slotToken.Material.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
allEmpty = false;
|
itemTokenUsage += _itemFactory.GetItem(slotToken.Name.equalsIgnoreCase("Cobweb") ? "Web" : slotToken.Name).getTokenCost();
|
||||||
|
|
||||||
//itemTokenUsage += _itemFactory.GetItem(slotToken.Name).getTokenCost();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//itemTokenUsage += buildToken.ItemTokens;
|
itemTokenUsage += buildToken.ItemTokens;
|
||||||
//skillTokenUsage += buildToken.SkillTokens;
|
skillTokenUsage += buildToken.SkillTokens;
|
||||||
|
|
||||||
/*
|
|
||||||
if (itemTokenUsage > CustomBuildToken.MAX_ITEM_TOKENS || skillTokenUsage > CustomBuildToken.MAX_SKILL_TOKENS)
|
if (itemTokenUsage > CustomBuildToken.MAX_ITEM_TOKENS || skillTokenUsage > CustomBuildToken.MAX_SKILL_TOKENS)
|
||||||
{
|
{
|
||||||
System.out.println(buildToken.PvpClass + " " + buildToken.CustomBuildId + "'s item tokens :" + itemTokenUsage + " skill tokens :" + skillTokenUsage);
|
System.out.println(buildToken.PvpClass + " " + buildToken.CustomBuildId + "'s item tokens :" + itemTokenUsage + " skill tokens :" + skillTokenUsage);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
/*
|
||||||
if (allEmpty)
|
if (allEmpty)
|
||||||
{
|
{
|
||||||
buildToken.SkillTokens = CustomBuildToken.MAX_SKILL_TOKENS;
|
buildToken.SkillTokens = CustomBuildToken.MAX_SKILL_TOKENS;
|
||||||
buildToken.ItemTokens = CustomBuildToken.MAX_ITEM_TOKENS;
|
buildToken.ItemTokens = CustomBuildToken.MAX_ITEM_TOKENS;
|
||||||
|
|
||||||
if (!buildToken.SwordSkill.isEmpty() && !ValidSkill(buildToken.SwordSkill, swordSkill, SkillType.Sword))
|
if (!buildToken.SwordSkill.isEmpty() && ValidSkill(buildToken.SwordSkill, swordSkill, SkillType.Sword))
|
||||||
buildToken.SkillTokens -= swordSkill.GetTokenCost();
|
buildToken.SkillTokens -= swordSkill.GetTokenCost();
|
||||||
|
|
||||||
if (!buildToken.AxeSkill.isEmpty() && !ValidSkill(buildToken.AxeSkill, axeSkill, SkillType.Axe))
|
if (!buildToken.AxeSkill.isEmpty() && ValidSkill(buildToken.AxeSkill, axeSkill, SkillType.Axe))
|
||||||
buildToken.SkillTokens -= axeSkill.GetTokenCost();
|
buildToken.SkillTokens -= axeSkill.GetTokenCost();
|
||||||
|
|
||||||
if (!buildToken.BowSkill.isEmpty() && !ValidSkill(buildToken.BowSkill, bowSkill, SkillType.Bow))
|
if (!buildToken.BowSkill.isEmpty() && ValidSkill(buildToken.BowSkill, bowSkill, SkillType.Bow))
|
||||||
buildToken.SkillTokens -= bowSkill.GetTokenCost();
|
buildToken.SkillTokens -= bowSkill.GetTokenCost();
|
||||||
|
|
||||||
if (!buildToken.ClassPassiveASkill.isEmpty() && !ValidSkill(buildToken.ClassPassiveASkill, classPassiveASkill, SkillType.PassiveA))
|
if (!buildToken.ClassPassiveASkill.isEmpty() && ValidSkill(buildToken.ClassPassiveASkill, classPassiveASkill, SkillType.PassiveA))
|
||||||
buildToken.SkillTokens -= classPassiveASkill.GetTokenCost();
|
buildToken.SkillTokens -= classPassiveASkill.GetTokenCost();
|
||||||
|
|
||||||
if (!buildToken.ClassPassiveBSkill.isEmpty() && !ValidSkill(buildToken.ClassPassiveBSkill, classPassiveBSkill, SkillType.PassiveB))
|
if (!buildToken.ClassPassiveBSkill.isEmpty() && ValidSkill(buildToken.ClassPassiveBSkill, classPassiveBSkill, SkillType.PassiveB))
|
||||||
buildToken.SkillTokens -= classPassiveBSkill.GetTokenCost();
|
buildToken.SkillTokens -= classPassiveBSkill.GetTokenCost();
|
||||||
|
|
||||||
if (!buildToken.GlobalPassiveSkill.isEmpty() && !ValidSkill(buildToken.GlobalPassiveSkill, globalPassive, SkillType.GlobalPassive))
|
if (!buildToken.GlobalPassiveSkill.isEmpty() && ValidSkill(buildToken.GlobalPassiveSkill, globalPassive, SkillType.GlobalPassive))
|
||||||
buildToken.SkillTokens -= globalPassive.GetTokenCost();
|
buildToken.SkillTokens -= globalPassive.GetTokenCost();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
_customBuilds.get(pvpClass).put(buildToken.CustomBuildNumber, buildToken);
|
_customBuilds.get(pvpClass).put(buildToken.CustomBuildNumber, buildToken);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class CustomBuildToken
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Slots.set(7, new SlotToken("Cobweb", Material.WEB, 3));
|
Slots.set(7, new SlotToken("Web", Material.WEB, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
Slots.set(8, new SlotToken());
|
Slots.set(8, new SlotToken());
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
package mineplex.minecraft.game.classcombat.Skill.Assassin;
|
package mineplex.minecraft.game.classcombat.Skill.Assassin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.entity.Skeleton;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
@ -19,12 +25,15 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilAction;
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.SkillActive;
|
import mineplex.minecraft.game.classcombat.Skill.SkillActive;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
@ -51,21 +60,26 @@ public class Illusion extends SkillActive
|
|||||||
|
|
||||||
SetDesc(new String[]
|
SetDesc(new String[]
|
||||||
{
|
{
|
||||||
"Block to go invisible, and create an",
|
"Hold Block to go invisible and create an",
|
||||||
"illusion of yourself that runs towards",
|
"illusion of yourself that runs towards",
|
||||||
"your target location.",
|
"your target location.",
|
||||||
"",
|
"",
|
||||||
"Invisibility ends if you release Block",
|
"Invisibility ends if you release Block",
|
||||||
"or your Illusion is killed.",
|
"or your Illusion is killed.",
|
||||||
"",
|
"",
|
||||||
"Lasts up to #2#2 seconds.",
|
"Illusion lasts up to #2#1 seconds.",
|
||||||
|
"",
|
||||||
|
"Gives Slow 2 for up to 4 seconds",
|
||||||
|
"to nearby players upon ending."
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setAchievementSkill(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetEnergyString()
|
public String GetEnergyString()
|
||||||
{
|
{
|
||||||
return "Energy: #30#-5 and #10#-2 per Second";
|
return "Energy: #40#-3 and #12.5#-0.5 per Second";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,12 +115,22 @@ public class Illusion extends SkillActive
|
|||||||
skel.getEquipment().setBoots(player.getInventory().getBoots());
|
skel.getEquipment().setBoots(player.getInventory().getBoots());
|
||||||
skel.getEquipment().setItemInHand(Math.random() > 0.5 ? player.getItemInHand() : new ItemStack(Material.IRON_AXE));
|
skel.getEquipment().setItemInHand(Math.random() > 0.5 ? player.getItemInHand() : new ItemStack(Material.IRON_AXE));
|
||||||
|
|
||||||
|
//Get in range
|
||||||
|
ArrayList<Player> inRange = new ArrayList<Player>();
|
||||||
|
for (Player other : UtilServer.getPlayers())
|
||||||
|
if (UtilMath.offset2d(skel, other) < 70)
|
||||||
|
inRange.add(other);
|
||||||
|
|
||||||
|
Player[] disguiseList = new Player[inRange.size()];
|
||||||
|
for (int i=0 ; i<inRange.size() ; i++)
|
||||||
|
disguiseList[i] = inRange.get(i);
|
||||||
|
|
||||||
//Disguise
|
//Disguise
|
||||||
DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer)player).getHandle().getProfile());
|
DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer)player).getHandle().getProfile());
|
||||||
Factory.Disguise().disguise(disguise);
|
Factory.Disguise().disguise(disguise, disguiseList);
|
||||||
|
|
||||||
//Invis
|
//Invis
|
||||||
Factory.Condition().Factory().Cloak(GetName(), player, player, 2 + 2*level, false, true);
|
Factory.Condition().Factory().Cloak(GetName(), player, player, 2 + 1*level, false, true);
|
||||||
|
|
||||||
_active.put(player, skel);
|
_active.put(player, skel);
|
||||||
|
|
||||||
@ -115,7 +139,7 @@ public class Illusion extends SkillActive
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void Energy(UpdateEvent event)
|
public void update(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.TICK)
|
if (event.getType() != UpdateType.TICK)
|
||||||
return;
|
return;
|
||||||
@ -129,7 +153,7 @@ public class Illusion extends SkillActive
|
|||||||
|
|
||||||
if (Factory.Condition().GetActiveCondition(cur, ConditionType.CLOAK) == null ||
|
if (Factory.Condition().GetActiveCondition(cur, ConditionType.CLOAK) == null ||
|
||||||
!cur.isBlocking() ||
|
!cur.isBlocking() ||
|
||||||
!Factory.Energy().Use(cur, GetName(), 0.5 - (getLevel(cur) * 0.1), true, true) ||
|
!Factory.Energy().Use(cur, GetName(), 0.625 - (getLevel(cur) * 0.025), true, true) ||
|
||||||
skel == null ||
|
skel == null ||
|
||||||
!skel.isValid())
|
!skel.isValid())
|
||||||
{
|
{
|
||||||
@ -150,7 +174,7 @@ public class Illusion extends SkillActive
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void illusionDeath(EntityDeathEvent event)
|
public void illusionDeath(EntityDeathEvent event)
|
||||||
{
|
{
|
||||||
if (_active.containsValue(event.getEntity()))
|
if (_active.containsValue(event.getEntity()))
|
||||||
@ -160,20 +184,35 @@ public class Illusion extends SkillActive
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void end(Player cur)
|
private void end(Player player)
|
||||||
{
|
{
|
||||||
Factory.Condition().EndCondition(cur, null, GetName());
|
Factory.Condition().EndCondition(player, null, GetName());
|
||||||
|
|
||||||
Skeleton skel = _active.remove(cur);
|
Skeleton skel = _active.remove(player);
|
||||||
if (skel == null)
|
if (skel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Ploop
|
//Level
|
||||||
|
int level = getLevel(player);
|
||||||
|
|
||||||
|
//Blind
|
||||||
|
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(skel.getLocation(), 6d + 0.5 * level);
|
||||||
|
for (LivingEntity cur : targets.keySet())
|
||||||
|
{
|
||||||
|
if (cur.equals(player))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Condition
|
||||||
|
Factory.Condition().Factory().Slow(GetName(), cur, player, 4 * targets.get(cur), 1, false, false, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Effect
|
||||||
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, skel.getLocation().add(0, 1, 0), 0.3f, 0.3f, 0.3f, 0.06f, 30);
|
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, skel.getLocation().add(0, 1, 0), 0.3f, 0.3f, 0.3f, 0.06f, 30);
|
||||||
|
|
||||||
for (int i=0 ; i<2 ; i++)
|
for (int i=0 ; i<2 ; i++)
|
||||||
skel.getWorld().playSound(skel.getLocation(), Sound.FIZZ, 2f, 0.4f);
|
skel.getWorld().playSound(skel.getLocation(), Sound.FIZZ, 2f, 0.4f);
|
||||||
|
|
||||||
|
skel.getEquipment().clear();
|
||||||
skel.remove();
|
skel.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class CripplingBlow extends Skill
|
|||||||
|
|
||||||
SetDesc(new String[]
|
SetDesc(new String[]
|
||||||
{
|
{
|
||||||
"Your powerflow axe blows give",
|
"Your powerful axe attacks give",
|
||||||
"targets Slow 1 for 1.5 second,",
|
"targets Slow 1 for 1.5 second,",
|
||||||
"as well as no knockback."
|
"as well as no knockback."
|
||||||
});
|
});
|
||||||
|
@ -80,8 +80,8 @@ public class SeismicSlam extends SkillActive
|
|||||||
SetDesc(new String[]
|
SetDesc(new String[]
|
||||||
{
|
{
|
||||||
"Jump up and slam back into the ground.",
|
"Jump up and slam back into the ground.",
|
||||||
"Players within #6#0.5 Blocks take up to",
|
"Players within #5.5#0.5 Blocks take up to",
|
||||||
"#2#1 damage and are thrown into the air.",
|
"#1#1 damage and are thrown into the air.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class SeismicSlam extends SkillActive
|
|||||||
_live.remove(player);
|
_live.remove(player);
|
||||||
|
|
||||||
//Action
|
//Action
|
||||||
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), 6d + 0.5 * level);
|
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), 5.5d + 0.5 * level);
|
||||||
for (LivingEntity cur : targets.keySet())
|
for (LivingEntity cur : targets.keySet())
|
||||||
{
|
{
|
||||||
if (cur.equals(player))
|
if (cur.equals(player))
|
||||||
@ -145,13 +145,13 @@ public class SeismicSlam extends SkillActive
|
|||||||
|
|
||||||
//Damage Event
|
//Damage Event
|
||||||
Factory.Damage().NewDamageEvent(cur, player, null,
|
Factory.Damage().NewDamageEvent(cur, player, null,
|
||||||
DamageCause.CUSTOM, (2+level) * targets.get(cur) + 0.5, false, true, false,
|
DamageCause.CUSTOM, (1+level) * targets.get(cur) + 0.5, false, true, false,
|
||||||
player.getName(), GetName());
|
player.getName(), GetName());
|
||||||
|
|
||||||
//Velocity
|
//Velocity
|
||||||
UtilAction.velocity(cur,
|
UtilAction.velocity(cur,
|
||||||
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
|
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
|
||||||
1.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.6, true);
|
0.2 + 1.6 * targets.get(cur), true, 0, 0.2 + 1.2 * targets.get(cur), 1.6, true);
|
||||||
|
|
||||||
//Condition
|
//Condition
|
||||||
Factory.Condition().Factory().Falling(GetName(), cur, player, 10, false, true);
|
Factory.Condition().Factory().Falling(GetName(), cur, player, 10, false, true);
|
||||||
|
@ -37,4 +37,6 @@ public interface ISkill
|
|||||||
|
|
||||||
Integer GetSalesPackageId();
|
Integer GetSalesPackageId();
|
||||||
int getMaxLevel();
|
int getMaxLevel();
|
||||||
|
|
||||||
|
boolean isAchievementSkill();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,233 @@
|
|||||||
|
package mineplex.minecraft.game.classcombat.Skill.Knight;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.projectile.IThrown;
|
||||||
|
import mineplex.core.projectile.ProjectileUser;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillActive;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
|
|
||||||
|
public class AxeThrow extends SkillActive implements IThrown
|
||||||
|
{
|
||||||
|
private HashMap<Item, Player> _thrown = new HashMap<Item, Player>();
|
||||||
|
|
||||||
|
public AxeThrow(SkillFactory skills, String name, ClassType classType, SkillType skillType,
|
||||||
|
int cost, int levels,
|
||||||
|
int energy, int energyMod,
|
||||||
|
long recharge, long rechargeMod, boolean rechargeInform,
|
||||||
|
Material[] itemArray,
|
||||||
|
Action[] actionArray)
|
||||||
|
{
|
||||||
|
super(skills, name, classType, skillType,
|
||||||
|
cost, levels,
|
||||||
|
energy, energyMod,
|
||||||
|
recharge, rechargeMod, rechargeInform,
|
||||||
|
itemArray,
|
||||||
|
actionArray);
|
||||||
|
|
||||||
|
SetDesc(new String[]
|
||||||
|
{
|
||||||
|
"Throw your axe with #0.7#0.1 velocity, ",
|
||||||
|
"dealing #6.5#0.5 damage.",
|
||||||
|
"",
|
||||||
|
"You pull your axe back to you when it",
|
||||||
|
"collides with anything.",
|
||||||
|
"",
|
||||||
|
"Your axe is returned to you if you do",
|
||||||
|
"not pick it up within #20#-2 seconds."
|
||||||
|
});
|
||||||
|
|
||||||
|
setAchievementSkill(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean CustomCheck(Player player, int level)
|
||||||
|
{
|
||||||
|
if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getTypeId() == 9)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Skill(Player player, int level)
|
||||||
|
{
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
|
||||||
|
|
||||||
|
//Throw
|
||||||
|
Item item = player.getWorld().dropItem(player.getEyeLocation(), player.getItemInHand());
|
||||||
|
UtilAction.velocity(item, player.getLocation().getDirection(), 0.7 + 0.1 * level, false, 0, 0.2, 10, true);
|
||||||
|
|
||||||
|
player.setItemInHand(null);
|
||||||
|
|
||||||
|
//Projectile
|
||||||
|
Factory.Projectile().AddThrow(item, player, this, -1, true, true, true, false, 2.5d);
|
||||||
|
|
||||||
|
//Store
|
||||||
|
_thrown.put(item, player);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
||||||
|
{
|
||||||
|
Rebound(data.GetThrower(), data.GetThrown());
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int level = getLevel(data.GetThrower());
|
||||||
|
if (level <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double damage = 6.5 + 0.5 * level;
|
||||||
|
|
||||||
|
//Damage Event
|
||||||
|
Factory.Damage().NewDamageEvent(target, data.GetThrower(), null,
|
||||||
|
DamageCause.CUSTOM, damage, true, true, false,
|
||||||
|
UtilEnt.getName(data.GetThrower()), GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Idle(ProjectileUser data)
|
||||||
|
{
|
||||||
|
Rebound(data.GetThrower(), data.GetThrown());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Expire(ProjectileUser data)
|
||||||
|
{
|
||||||
|
Rebound(data.GetThrower(), data.GetThrown());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Rebound(LivingEntity player, Entity ent)
|
||||||
|
{
|
||||||
|
ent.getWorld().playSound(ent.getLocation(), Sound.ZOMBIE_WOOD, 0.6f, 0.5f);
|
||||||
|
|
||||||
|
double mult = 0.5 + (0.6 * (UtilMath.offset(player.getLocation(), ent.getLocation())/16d));
|
||||||
|
|
||||||
|
//Velocity
|
||||||
|
ent.setVelocity(player.getLocation().toVector().subtract(ent.getLocation().toVector()).normalize().add(new Vector(0, 0.4, 0)).multiply(mult));
|
||||||
|
|
||||||
|
//Ticks
|
||||||
|
if (ent instanceof Item)
|
||||||
|
((Item)ent).setPickupDelay(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void pickup(PlayerPickupItemEvent event)
|
||||||
|
{
|
||||||
|
if (!_thrown.containsKey(event.getItem()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
Player player = _thrown.remove(event.getItem());
|
||||||
|
|
||||||
|
player.getInventory().addItem(event.getItem().getItemStack());
|
||||||
|
|
||||||
|
UtilInv.Update(event.getPlayer());
|
||||||
|
|
||||||
|
event.getItem().remove();
|
||||||
|
|
||||||
|
player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1f, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void timeout(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Iterator<Item> itemIterator = _thrown.keySet().iterator();
|
||||||
|
|
||||||
|
while (itemIterator.hasNext())
|
||||||
|
{
|
||||||
|
Item item = itemIterator.next();
|
||||||
|
|
||||||
|
Player player = _thrown.get(item);
|
||||||
|
if (!player.isOnline())
|
||||||
|
{
|
||||||
|
item.remove();
|
||||||
|
itemIterator.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int level = getLevel(player);
|
||||||
|
|
||||||
|
if (item.getTicksLived() > 400 - level * 40)
|
||||||
|
{
|
||||||
|
_thrown.get(item).getInventory().addItem(item.getItemStack());
|
||||||
|
item.remove();
|
||||||
|
itemIterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void death(PlayerDeathEvent event)
|
||||||
|
{
|
||||||
|
Iterator<Item> i = _thrown.keySet().iterator();
|
||||||
|
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
Item item = i.next();
|
||||||
|
Player player = _thrown.get(item);
|
||||||
|
|
||||||
|
if (player.equals(event.getEntity()))
|
||||||
|
{
|
||||||
|
i.remove();
|
||||||
|
item.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Reset(Player player)
|
||||||
|
{
|
||||||
|
Iterator<Item> i = _thrown.keySet().iterator();
|
||||||
|
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
Item item = i.next();
|
||||||
|
Player thrower = _thrown.get(item);
|
||||||
|
|
||||||
|
if (player.equals(thrower))
|
||||||
|
{
|
||||||
|
i.remove();
|
||||||
|
item.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,146 @@
|
|||||||
|
package mineplex.minecraft.game.classcombat.Skill.Mage;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillChargeSword;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
|
public class StaticLazer extends SkillChargeSword
|
||||||
|
{
|
||||||
|
public StaticLazer(SkillFactory skills, String name,
|
||||||
|
ClassType classType, SkillType skillType,
|
||||||
|
int cost, int maxLevel)
|
||||||
|
{
|
||||||
|
super(skills, name, classType, skillType, cost, maxLevel,
|
||||||
|
0.012f, 0.008f,
|
||||||
|
12000, -1000, true, true,
|
||||||
|
false, true);
|
||||||
|
|
||||||
|
SetDesc(new String[]
|
||||||
|
{
|
||||||
|
"Hold Block to charge static electricity.",
|
||||||
|
"Release Block to fire static lazer.",
|
||||||
|
"",
|
||||||
|
GetChargeString(),
|
||||||
|
"Taking damage cancels charge.",
|
||||||
|
"",
|
||||||
|
"Deals up to #7#1 damage and travels",
|
||||||
|
"up to #20#10 blocks.",
|
||||||
|
});
|
||||||
|
|
||||||
|
_fireOnFull = true;
|
||||||
|
setAchievementSkill(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String GetRechargeString()
|
||||||
|
{
|
||||||
|
return "Recharge: " + "#12#-1 Seconds";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void DoSkillCustom(Player player, float charge)
|
||||||
|
{
|
||||||
|
int level = getLevel(player);
|
||||||
|
if (level <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Action
|
||||||
|
double curRange = 0;
|
||||||
|
while (curRange <= 20 + 10 * level)
|
||||||
|
{
|
||||||
|
Location newTarget = player.getEyeLocation().add(player.getLocation().getDirection().multiply(curRange));
|
||||||
|
|
||||||
|
//Hit Player
|
||||||
|
HashMap<LivingEntity, Double> hits = UtilEnt.getInRadius(newTarget, 2);
|
||||||
|
hits.remove(player);
|
||||||
|
if (!hits.isEmpty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Hit Block
|
||||||
|
if (!UtilBlock.airFoliage(newTarget.getBlock()))
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Progress Forwards
|
||||||
|
curRange += 0.2;
|
||||||
|
|
||||||
|
//Smoke Trail
|
||||||
|
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget, 0, 0, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Destination
|
||||||
|
Location target = player.getLocation().add(player.getLocation().getDirection().multiply(curRange));
|
||||||
|
|
||||||
|
UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1);
|
||||||
|
|
||||||
|
//Firework
|
||||||
|
UtilFirework.playFirework(player.getLocation().add(player.getLocation().getDirection().multiply(Math.max(0, curRange - 0.6))), Type.BURST, Color.WHITE, false, false);
|
||||||
|
|
||||||
|
HashMap<LivingEntity, Double> hit = UtilEnt.getInRadius(target.subtract(0, 1, 0), 6);
|
||||||
|
for (LivingEntity other : hit.keySet())
|
||||||
|
{
|
||||||
|
if (other.equals(player))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Damage Event
|
||||||
|
Factory.Damage().NewDamageEvent(other, player, null,
|
||||||
|
DamageCause.CUSTOM, (2 + (5 + level) * hit.get(other)) * charge, true, true, false,
|
||||||
|
player.getName(), GetName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName(getLevel(player))) + "."));
|
||||||
|
|
||||||
|
//Effect
|
||||||
|
player.getWorld().playSound(player.getEyeLocation(), Sound.ZOMBIE_REMEDY, 0.5f + player.getExp(), 1.75f - charge);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void damageCancelCharge(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
if (event.IsCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Damagee
|
||||||
|
Player damagee = event.GetDamageePlayer();
|
||||||
|
if (damagee == null) return;
|
||||||
|
|
||||||
|
if (_charge.remove(damagee) == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(damagee, F.main(GetClassType().name(), F.skill(GetName()) + " was interrupted."));
|
||||||
|
|
||||||
|
//Effect
|
||||||
|
damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_REMEDY, 0.5f, 3f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Reset(Player player)
|
||||||
|
{
|
||||||
|
_charge.remove(player);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,254 @@
|
|||||||
|
package mineplex.minecraft.game.classcombat.Skill.Ranger;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
|
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillActive;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
|
public class ExplosiveShot extends SkillActive
|
||||||
|
{
|
||||||
|
private HashSet<Arrow> _arrows = new HashSet<Arrow>();
|
||||||
|
private HashSet<Player> _active = new HashSet<Player>();
|
||||||
|
|
||||||
|
public ExplosiveShot(SkillFactory skills, String name, ClassType classType, SkillType skillType,
|
||||||
|
int cost, int levels,
|
||||||
|
int energy, int energyMod,
|
||||||
|
long recharge, long rechargeMod, boolean rechargeInform,
|
||||||
|
Material[] itemArray,
|
||||||
|
Action[] actionArray)
|
||||||
|
{
|
||||||
|
super(skills, name, classType, skillType,
|
||||||
|
cost, levels,
|
||||||
|
energy, energyMod,
|
||||||
|
recharge, rechargeMod, rechargeInform,
|
||||||
|
itemArray,
|
||||||
|
actionArray);
|
||||||
|
|
||||||
|
SetDesc(new String[]
|
||||||
|
{
|
||||||
|
"Prepare an explosive shot;",
|
||||||
|
"Your next arrow will explode on",
|
||||||
|
"impact, dealing up to 10 damage",
|
||||||
|
"and knockback. ",
|
||||||
|
" ",
|
||||||
|
"Explosion radius of #4.5#0.5",
|
||||||
|
});
|
||||||
|
|
||||||
|
setAchievementSkill(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean CustomCheck(Player player, int level)
|
||||||
|
{
|
||||||
|
if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getTypeId() == 9)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Skill(Player player, int level)
|
||||||
|
{
|
||||||
|
//Action
|
||||||
|
_active.add(player);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main(GetClassType().name(), "You prepared " + F.skill(GetName(level)) + "."));
|
||||||
|
|
||||||
|
//Effect
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 2.5f, 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void BowShoot(EntityShootBowEvent event)
|
||||||
|
{
|
||||||
|
if (!(event.getEntity() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getProjectile() instanceof Arrow))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = (Player)event.getEntity();
|
||||||
|
|
||||||
|
if (!_active.remove(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main(GetClassType().name(), "You fired " + F.skill(GetName(getLevel(player))) + "."));
|
||||||
|
|
||||||
|
_arrows.add((Arrow)event.getProjectile());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void hitEntityTrigger(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
if (event.IsCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.GetCause() != DamageCause.PROJECTILE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Projectile projectile = event.GetProjectile();
|
||||||
|
if (projectile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_arrows.remove(event.GetProjectile()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.SetCancelled(GetName());
|
||||||
|
|
||||||
|
Location loc = event.GetDamageeEntity().getLocation().subtract(event.GetProjectile().getVelocity().normalize().multiply(0.1));
|
||||||
|
|
||||||
|
trigger((Arrow)event.GetProjectile(), loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void hitBlockTrigger(ProjectileHitEvent event)
|
||||||
|
{
|
||||||
|
Projectile proj = event.getEntity();
|
||||||
|
|
||||||
|
if (!_arrows.contains(proj))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (proj.getShooter() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(proj.getShooter() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player damager = (Player)proj.getShooter();
|
||||||
|
int level = getLevel(damager);
|
||||||
|
if (level == 0) return;
|
||||||
|
|
||||||
|
final Arrow arrow = (Arrow)proj;
|
||||||
|
|
||||||
|
Factory.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Factory.GetPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//If it hasnt already triggered (via damage)
|
||||||
|
if (_arrows.remove(arrow))
|
||||||
|
trigger(arrow, arrow.getLocation());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
//Remove
|
||||||
|
proj.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void cleanTrigger(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SEC)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Iterator<Arrow> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();)
|
||||||
|
{
|
||||||
|
Arrow arrow = arrowIterator.next();
|
||||||
|
|
||||||
|
if (arrow.isDead() || !arrow.isValid() || arrow.isOnGround() || arrow.getTicksLived() > 60)
|
||||||
|
{
|
||||||
|
arrowIterator.remove();
|
||||||
|
trigger(arrow, arrow.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trigger(Arrow arrow, Location loc)
|
||||||
|
{
|
||||||
|
if (arrow == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (arrow.getShooter() == null || !(arrow.getShooter() instanceof Player))
|
||||||
|
{
|
||||||
|
arrow.remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player)arrow.getShooter();
|
||||||
|
|
||||||
|
//Level
|
||||||
|
int level = getLevel(player);
|
||||||
|
if (level == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Velocity Players
|
||||||
|
HashMap<Player,Double> hitMap = UtilPlayer.getInRadius(loc, 4.5 + (level * 0.5));
|
||||||
|
for (Player cur : hitMap.keySet())
|
||||||
|
{
|
||||||
|
double range = hitMap.get(cur);
|
||||||
|
|
||||||
|
//Condition
|
||||||
|
Factory.Condition().Factory().Falling(GetName(), cur, player, 6, false, true);
|
||||||
|
|
||||||
|
//Damage Event
|
||||||
|
Factory.Damage().NewDamageEvent(cur, player, null,
|
||||||
|
DamageCause.CUSTOM, 10 * range, false, true, false,
|
||||||
|
player.getName(), GetName());
|
||||||
|
|
||||||
|
//Velocity
|
||||||
|
UtilAction.velocity(cur, UtilAlg.getTrajectory2d(loc, cur.getLocation().add(0, 1, 0)),
|
||||||
|
0.4 + 1 * range, false, 0, 0.2 + 0.6 * range, 1.2, true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
if (cur instanceof Player)
|
||||||
|
UtilPlayer.message((Player)cur, F.main(GetClassType().name(), F.name(player.getName()) +" hit you with " + F.skill(GetName(level)) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1);
|
||||||
|
loc.getWorld().playSound(loc, Sound.EXPLODE, 2f, 0.75f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void particle(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Entity ent : _arrows)
|
||||||
|
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, ent.getLocation(), 0, 0, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Reset(Player player)
|
||||||
|
{
|
||||||
|
_active.remove(player);
|
||||||
|
}
|
||||||
|
}
|
@ -50,8 +50,6 @@ public class Longshot extends Skill
|
|||||||
|
|
||||||
//Save
|
//Save
|
||||||
_arrows.put(event.getProjectile(), event.getProjectile().getLocation());
|
_arrows.put(event.getProjectile(), event.getProjectile().getLocation());
|
||||||
|
|
||||||
System.out.println("FIRING!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
@ -48,8 +48,8 @@ public class NapalmShot extends SkillActive
|
|||||||
SetDesc(new String[]
|
SetDesc(new String[]
|
||||||
{
|
{
|
||||||
"Prepare a napalm shot;",
|
"Prepare a napalm shot;",
|
||||||
"Your next arrow will explode on",
|
"Your next arrow will burst into",
|
||||||
"impact, releasing #8#8 flames."
|
"#8#8 flames on impact."
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ public abstract class Skill implements ISkill, Listener
|
|||||||
private boolean _free;
|
private boolean _free;
|
||||||
private NautHashMap<Player, Integer> _users;
|
private NautHashMap<Player, Integer> _users;
|
||||||
|
|
||||||
|
private boolean _isAchievementSkill = false;
|
||||||
|
|
||||||
public SkillFactory Factory;
|
public SkillFactory Factory;
|
||||||
|
|
||||||
public Skill(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int maxLevel)
|
public Skill(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int maxLevel)
|
||||||
@ -327,4 +329,15 @@ public abstract class Skill implements ISkill, Listener
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAchievementSkill(boolean var)
|
||||||
|
{
|
||||||
|
_isAchievementSkill = var;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAchievementSkill()
|
||||||
|
{
|
||||||
|
return _isAchievementSkill;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@ import mineplex.core.recharge.Recharge;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -21,6 +23,8 @@ public abstract class SkillChargeSword extends SkillCharge implements Listener
|
|||||||
protected boolean _rechargeInform = false;
|
protected boolean _rechargeInform = false;
|
||||||
protected boolean _rechargeAttach = false;
|
protected boolean _rechargeAttach = false;
|
||||||
|
|
||||||
|
protected boolean _fireOnFull = false;
|
||||||
|
|
||||||
public SkillChargeSword(SkillFactory skills, String name, ClassType classType,
|
public SkillChargeSword(SkillFactory skills, String name, ClassType classType,
|
||||||
SkillType skillType, int cost, int maxLevel,
|
SkillType skillType, int cost, int maxLevel,
|
||||||
float base, float boost,
|
float base, float boost,
|
||||||
@ -56,13 +60,31 @@ public abstract class SkillChargeSword extends SkillCharge implements Listener
|
|||||||
if (!_canChargeInWater && cur.getLocation().getBlock().isLiquid())
|
if (!_canChargeInWater && cur.getLocation().getBlock().isLiquid())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
//Check Allowed
|
||||||
|
SkillTriggerEvent triggerEvent = new SkillTriggerEvent(cur, GetName(), GetClassType());
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(triggerEvent);
|
||||||
|
|
||||||
|
if (triggerEvent.IsCancelled())
|
||||||
|
continue;
|
||||||
|
|
||||||
//Recharged Check (uses recharge upon activation)
|
//Recharged Check (uses recharge upon activation)
|
||||||
if (!_charge.containsKey(cur))
|
if (!_charge.containsKey(cur))
|
||||||
if (!Recharge.Instance.usable(cur, GetName()))
|
if (!Recharge.Instance.usable(cur, GetName()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Charge
|
//Charge
|
||||||
Charge(cur);
|
if (Charge(cur) && _fireOnFull)
|
||||||
|
{
|
||||||
|
//Action
|
||||||
|
float charge = _charge.remove(cur);
|
||||||
|
|
||||||
|
//Set Recharge
|
||||||
|
Recharge.Instance.recharge(cur, GetName());
|
||||||
|
Recharge.Instance.use(cur, GetName(), _recharge + (getLevel(cur) * _rechargePerLevel), true, true);
|
||||||
|
|
||||||
|
DoSkill(cur, charge);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//Release Charge
|
//Release Charge
|
||||||
else if (_charge.containsKey(cur))
|
else if (_charge.containsKey(cur))
|
||||||
|
@ -167,13 +167,13 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
|||||||
0, 0, true,
|
0, 0, true,
|
||||||
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
||||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
//
|
|
||||||
// AddSkill(new Illusion(this, "Illusion", ClassType.Assassin, SkillType.Sword,
|
AddSkill(new Illusion(this, "Illusion", ClassType.Assassin, SkillType.Sword,
|
||||||
// 1, 4,
|
1, 4,
|
||||||
// 30, -5,
|
50, -4,
|
||||||
// 0, 0, true,
|
20000, -1000, true,
|
||||||
// new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
||||||
// new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
|
|
||||||
//Axe
|
//Axe
|
||||||
AddSkill(new Blink(this, "Blink", ClassType.Assassin, SkillType.Axe,
|
AddSkill(new Blink(this, "Blink", ClassType.Assassin, SkillType.Axe,
|
||||||
@ -257,7 +257,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
|||||||
AddSkill(new SeismicSlam(this, "Seismic Slam", ClassType.Brute, SkillType.Axe,
|
AddSkill(new SeismicSlam(this, "Seismic Slam", ClassType.Brute, SkillType.Axe,
|
||||||
1, 5,
|
1, 5,
|
||||||
0, 0,
|
0, 0,
|
||||||
30000, -3000, true,
|
30000, -2000, true,
|
||||||
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
|
|
||||||
@ -328,6 +328,13 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
|||||||
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
|
|
||||||
|
AddSkill(new AxeThrow(this, "Roped Axe Throw", ClassType.Knight, SkillType.Axe,
|
||||||
|
1, 5,
|
||||||
|
0, 0,
|
||||||
|
3000, -450, true,
|
||||||
|
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||||
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
|
|
||||||
|
|
||||||
//Passive A
|
//Passive A
|
||||||
AddSkill(new Cleave(this, "Cleave", ClassType.Knight, SkillType.PassiveA, 1, 3));
|
AddSkill(new Cleave(this, "Cleave", ClassType.Knight, SkillType.PassiveA, 1, 3));
|
||||||
@ -366,6 +373,8 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
|||||||
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
||||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
|
|
||||||
|
AddSkill(new StaticLazer(this, "Static Lazer", ClassType.Mage, SkillType.Sword, 1, 5));
|
||||||
|
|
||||||
//Axe
|
//Axe
|
||||||
AddSkill(new FireBlast(this, "Fire Blast", ClassType.Mage, SkillType.Axe,
|
AddSkill(new FireBlast(this, "Fire Blast", ClassType.Mage, SkillType.Axe,
|
||||||
1, 5,
|
1, 5,
|
||||||
@ -492,6 +501,13 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
|||||||
new Material[] {Material.BOW},
|
new Material[] {Material.BOW},
|
||||||
new Action[] {Action.LEFT_CLICK_AIR, Action.LEFT_CLICK_BLOCK}));
|
new Action[] {Action.LEFT_CLICK_AIR, Action.LEFT_CLICK_BLOCK}));
|
||||||
|
|
||||||
|
AddSkill(new ExplosiveShot(this, "Explosive Arrow", ClassType.Ranger, SkillType.Bow,
|
||||||
|
1, 4,
|
||||||
|
0, 0,
|
||||||
|
20000, -2000, false,
|
||||||
|
new Material[] {Material.BOW},
|
||||||
|
new Action[] {Action.LEFT_CLICK_AIR, Action.LEFT_CLICK_BLOCK}));
|
||||||
|
|
||||||
//Passive A
|
//Passive A
|
||||||
AddSkill(new Barrage(this, "Barrage", ClassType.Ranger, SkillType.PassiveA, 1, 3));
|
AddSkill(new Barrage(this, "Barrage", ClassType.Ranger, SkillType.PassiveA, 1, 3));
|
||||||
AddSkill(new Overcharge(this, "Overcharge", ClassType.Ranger, SkillType.PassiveA, 1, 3));
|
AddSkill(new Overcharge(this, "Overcharge", ClassType.Ranger, SkillType.PassiveA, 1, 3));
|
||||||
|
@ -4,8 +4,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.achievement.Achievement;
|
import mineplex.core.achievement.Achievement;
|
||||||
import mineplex.core.achievement.AchievementManager;
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||||
@ -16,15 +18,17 @@ public class ClassShopManager extends MiniPlugin
|
|||||||
private SkillFactory _skillFactory;
|
private SkillFactory _skillFactory;
|
||||||
private ItemFactory _itemFactory;
|
private ItemFactory _itemFactory;
|
||||||
private AchievementManager _achievementManager;
|
private AchievementManager _achievementManager;
|
||||||
|
private CoreClientManager _clientManager;
|
||||||
|
|
||||||
public ClassShopManager(JavaPlugin plugin, ClassManager classManager, SkillFactory skillFactory, ItemFactory itemFactory)
|
public ClassShopManager(JavaPlugin plugin, ClassManager classManager, SkillFactory skillFactory, ItemFactory itemFactory, AchievementManager achievementManager, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
super("Class Shop Manager", plugin);
|
super("Class Shop Manager", plugin);
|
||||||
|
|
||||||
_classManager = classManager;
|
_classManager = classManager;
|
||||||
_skillFactory = skillFactory;
|
_skillFactory = skillFactory;
|
||||||
_itemFactory = itemFactory;
|
_itemFactory = itemFactory;
|
||||||
//_achievementManager = achievementManager;
|
_achievementManager = achievementManager;
|
||||||
|
_clientManager = clientManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassManager GetClassManager()
|
public ClassManager GetClassManager()
|
||||||
@ -44,6 +48,9 @@ public class ClassShopManager extends MiniPlugin
|
|||||||
|
|
||||||
public boolean hasAchievements(Player player)
|
public boolean hasAchievements(Player player)
|
||||||
{
|
{
|
||||||
|
if (_clientManager.Get(player).GetRank().Has(Rank.MODERATOR))
|
||||||
|
return true;
|
||||||
|
|
||||||
return _achievementManager.hasCategory(player, new Achievement[]
|
return _achievementManager.hasCategory(player, new Achievement[]
|
||||||
{
|
{
|
||||||
Achievement.CHAMPIONS_ACE,
|
Achievement.CHAMPIONS_ACE,
|
||||||
|
@ -216,7 +216,8 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
|
|||||||
{
|
{
|
||||||
List<String> skillLore = new ArrayList<String>();
|
List<String> skillLore = new ArrayList<String>();
|
||||||
|
|
||||||
boolean locked = isSkillLocked(skill);
|
boolean achievementLocked = skill.isAchievementSkill() && !Plugin.hasAchievements(Player);
|
||||||
|
boolean locked = isSkillLocked(skill) || achievementLocked;
|
||||||
Material material = locked ? Material.EMERALD : (clientClass.GetSavingCustomBuild().hasSkill(skill) ? Material.WRITTEN_BOOK : Material.BOOK);
|
Material material = locked ? Material.EMERALD : (clientClass.GetSavingCustomBuild().hasSkill(skill) ? Material.WRITTEN_BOOK : Material.BOOK);
|
||||||
boolean hasSkill = clientClass.GetSavingCustomBuild().hasSkill(skill);
|
boolean hasSkill = clientClass.GetSavingCustomBuild().hasSkill(skill);
|
||||||
int level = hasSkill ? clientClass.GetSavingCustomBuild().getLevel(skill) : 1;
|
int level = hasSkill ? clientClass.GetSavingCustomBuild().getLevel(skill) : 1;
|
||||||
@ -224,7 +225,7 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
|
|||||||
ChatColor.RESET + C.Bold + " - " + ChatColor.GREEN + C.Bold + "Level " + (hasSkill ? level : 0) + "/" + skill.getMaxLevel());
|
ChatColor.RESET + C.Bold + " - " + ChatColor.GREEN + C.Bold + "Level " + (hasSkill ? level : 0) + "/" + skill.getMaxLevel());
|
||||||
|
|
||||||
|
|
||||||
if (locked)
|
if (locked && !skill.isAchievementSkill())
|
||||||
{
|
{
|
||||||
skillLore.add(C.cYellow + skill.GetGemCost() + " Gems");
|
skillLore.add(C.cYellow + skill.GetGemCost() + " Gems");
|
||||||
skillLore.add(C.cBlack);
|
skillLore.add(C.cBlack);
|
||||||
@ -247,7 +248,7 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
|
|||||||
if (hasSkill)
|
if (hasSkill)
|
||||||
skillLore.add(C.cGreen + "Left-Click to Upgrade to Level " + (level + 1));
|
skillLore.add(C.cGreen + "Left-Click to Upgrade to Level " + (level + 1));
|
||||||
else
|
else
|
||||||
skillLore.add(C.cGreen + "Left-Click to Select");
|
skillLore.add(C.cGreen + "Left-Click to " + (locked && !achievementLocked ? "Purchase" : "Select"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -266,9 +267,21 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ShopItem skillItem = new ShopItem(material, name, skillLore.toArray(new String[skillLore.size()]), level, locked, true);
|
ShopItem skillItem = null;
|
||||||
|
|
||||||
if (locked)
|
if (achievementLocked)
|
||||||
|
{
|
||||||
|
skillLore.add(C.cGray + " ");
|
||||||
|
skillLore.add(C.cPurple + "To use this skill, you must have all");
|
||||||
|
skillLore.add(C.cPurple + "Champions Achievements unlocked!");
|
||||||
|
skillItem = new ShopItem(Material.DIAMOND, (byte)0, name, skillLore.toArray(new String[skillLore.size()]), level, achievementLocked, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
skillItem = new ShopItem(material, name, skillLore.toArray(new String[skillLore.size()]), level, locked, true);
|
||||||
|
|
||||||
|
if (achievementLocked)
|
||||||
|
AddItem(slotNumber, skillItem);
|
||||||
|
else if (locked)
|
||||||
AddButton(slotNumber, skillItem, new PurchaseSkillButton(this, skill));
|
AddButton(slotNumber, skillItem, new PurchaseSkillButton(this, skill));
|
||||||
else
|
else
|
||||||
AddButton(slotNumber, skillItem, new SelectSkillButton(this, skill, Math.min((hasSkill ? level + 1 : level), skill.getMaxLevel()), clientClass.GetSavingCustomBuild().SkillTokens >= skill.GetTokenCost()));
|
AddButton(slotNumber, skillItem, new SelectSkillButton(this, skill, Math.min((hasSkill ? level + 1 : level), skill.getMaxLevel()), clientClass.GetSavingCustomBuild().SkillTokens >= skill.GetTokenCost()));
|
||||||
|
@ -44,6 +44,7 @@ public class ServerCommandManager
|
|||||||
*/
|
*/
|
||||||
private void initialize()
|
private void initialize()
|
||||||
{
|
{
|
||||||
|
/* CAUSING STUTTER LAG IN HUBS
|
||||||
final Jedis jedis = _jedisPool.getResource();
|
final Jedis jedis = _jedisPool.getResource();
|
||||||
|
|
||||||
// Spin up a new thread and subscribe to the Redis pubsub network
|
// Spin up a new thread and subscribe to the Redis pubsub network
|
||||||
@ -67,13 +68,18 @@ public class ServerCommandManager
|
|||||||
});
|
});
|
||||||
|
|
||||||
thread.start();
|
thread.start();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish a {@link ServerCommand} across the network to all live servers.
|
* Publish a {@link ServerCommand} across the network to all live servers.
|
||||||
* @param serverCommand - the {@link ServerCommand} to issue to all servers.
|
* @param serverCommand - the {@link ServerCommand} to issue to all servers.
|
||||||
*/
|
*/
|
||||||
public void publishCommand(ServerCommand serverCommand)
|
public void publishCommand(final ServerCommand serverCommand)
|
||||||
|
{
|
||||||
|
new Thread(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
{
|
{
|
||||||
Jedis jedis = _jedisPool.getResource();
|
Jedis jedis = _jedisPool.getResource();
|
||||||
|
|
||||||
@ -92,6 +98,8 @@ public class ServerCommandManager
|
|||||||
_jedisPool.returnResource(jedis);
|
_jedisPool.returnResource(jedis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming (serialized) {@link ServerCommand}.
|
* Handle an incoming (serialized) {@link ServerCommand}.
|
||||||
|
@ -186,6 +186,9 @@ public class ServerMonitor
|
|||||||
|
|
||||||
for (ServerGroup serverGroup : serverGroups)
|
for (ServerGroup serverGroup : serverGroups)
|
||||||
{
|
{
|
||||||
|
if (serverGroup.getName().equals("Testing"))
|
||||||
|
continue;
|
||||||
|
|
||||||
handleGroupChanges(dedicatedServers, serverTracker, serverGroup, false);
|
handleGroupChanges(dedicatedServers, serverTracker, serverGroup, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class StaffServer extends JavaPlugin
|
|||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
new FileUpdater(this, portal);
|
new FileUpdater(this, portal);
|
||||||
|
|
||||||
new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this), new StatsManager(this)));
|
new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), new StatsManager(this, clientManager)));
|
||||||
new Password(this, serverStatusManager.getCurrentServerName());
|
new Password(this, serverStatusManager.getCurrentServerName());
|
||||||
|
|
||||||
//Updates
|
//Updates
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||||
@ -18,18 +19,26 @@ public class BoosterCommand extends CommandBase<SalesPackageManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(final Player caller, String[] args)
|
||||||
{
|
{
|
||||||
if (args == null || args.length != 2)
|
if (args == null || args.length != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String playerName = args[0];
|
final String playerName = args[0];
|
||||||
int amount = Integer.parseInt(args[1]);
|
final int amount = Integer.parseInt(args[1]);
|
||||||
|
|
||||||
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
|
|
||||||
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Booster " + amount, false, 0, false);
|
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Booster " + amount, false, 0, false);
|
||||||
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Gem Booster", amount);
|
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " boosters to " + playerName + "'s account!"));
|
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " boosters to " + playerName + "'s account!"));
|
||||||
|
else
|
||||||
|
caller.sendMessage(F.main(Plugin.getName(), "There was an error adding " + amount + " boosters to " + playerName + "'s account!"));
|
||||||
|
}
|
||||||
|
}, uuid.toString(), "Utility", "Gem Booster", amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||||
@ -18,18 +19,27 @@ public class TreasureChestCommand extends CommandBase<SalesPackageManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(final Player caller, String[] args)
|
||||||
{
|
{
|
||||||
if (args == null || args.length != 2)
|
if (args == null || args.length != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String playerName = args[0];
|
final String playerName = args[0];
|
||||||
int amount = Integer.parseInt(args[1]);
|
final int amount = Integer.parseInt(args[1]);
|
||||||
|
|
||||||
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
|
|
||||||
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Chest " + amount, false, 0, false);
|
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Chest " + amount, false, 0, false);
|
||||||
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Treasure Chest", amount);
|
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure chests to " + playerName + "'s account!"));
|
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure chests to " + playerName + "'s account!"));
|
||||||
|
else
|
||||||
|
caller.sendMessage(F.main(Plugin.getName(), "There was an error adding " + amount + " treasure chests to " + playerName + "'s account!"));
|
||||||
|
}
|
||||||
|
}, uuid.toString(), "Utility", "Treasure Chest", amount);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||||
@ -18,18 +19,26 @@ public class TreasureKeyCommand extends CommandBase<SalesPackageManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(final Player caller, String[] args)
|
||||||
{
|
{
|
||||||
if (args == null || args.length != 2)
|
if (args == null || args.length != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String playerName = args[0];
|
final String playerName = args[0];
|
||||||
int amount = Integer.parseInt(args[1]);
|
final int amount = Integer.parseInt(args[1]);
|
||||||
|
|
||||||
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
|
|
||||||
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Key " + amount, false, 0, false);
|
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Key " + amount, false, 0, false);
|
||||||
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Treasure", "Treasure Key", amount);
|
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!"));
|
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!"));
|
||||||
|
else
|
||||||
|
caller.sendMessage(F.main(Plugin.getName(), "There was an error adding " + amount + " treasure Keys to " + playerName + "'s account!"));
|
||||||
|
}
|
||||||
|
}, uuid.toString(), "Treasure", "Treasure Key", amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import net.minecraft.server.v1_7_R4.MinecraftServer;
|
|||||||
import mineplex.core.CustomTagFix;
|
import mineplex.core.CustomTagFix;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.antistack.AntiStack;
|
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.blood.Blood;
|
import mineplex.core.blood.Blood;
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
@ -21,6 +20,7 @@ import mineplex.core.disguise.DisguiseManager;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.friend.FriendManager;
|
import mineplex.core.friend.FriendManager;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
@ -89,7 +89,6 @@ public class Arcade extends JavaPlugin
|
|||||||
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
||||||
new MessageManager(this, _clientManager, preferenceManager);
|
new MessageManager(this, _clientManager, preferenceManager);
|
||||||
|
|
||||||
AntiStack antistack = new AntiStack(this);
|
|
||||||
Creature creature = new Creature(this);
|
Creature creature = new Creature(this);
|
||||||
Spawn spawn = new Spawn(this);
|
Spawn spawn = new Spawn(this);
|
||||||
Teleport teleport = new Teleport(this, _clientManager, spawn);
|
Teleport teleport = new Teleport(this, _clientManager, spawn);
|
||||||
@ -109,9 +108,10 @@ public class Arcade extends JavaPlugin
|
|||||||
BlockRestore blockRestore = new BlockRestore(this);
|
BlockRestore blockRestore = new BlockRestore(this);
|
||||||
|
|
||||||
ProjectileManager projectileManager = new ProjectileManager(this);
|
ProjectileManager projectileManager = new ProjectileManager(this);
|
||||||
|
HologramManager hologramManager = new HologramManager(this);
|
||||||
|
|
||||||
//Inventory
|
//Inventory
|
||||||
InventoryManager inventoryManager = new InventoryManager(this);
|
InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
|
||||||
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
|
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
|
||||||
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
||||||
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
|
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
|
||||||
@ -119,7 +119,7 @@ public class Arcade extends JavaPlugin
|
|||||||
cosmeticManager.setInterfaceSlot(7);
|
cosmeticManager.setInterfaceSlot(7);
|
||||||
|
|
||||||
//Arcade Manager
|
//Arcade Manager
|
||||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, webServerAddress);
|
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress);
|
||||||
|
|
||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
new CustomTagFix(this, packetHandler);
|
new CustomTagFix(this, packetHandler);
|
||||||
|
@ -36,7 +36,6 @@ import org.bukkit.event.server.ServerListPingEvent;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.achievement.AchievementManager;
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.antistack.AntiStack;
|
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.blood.Blood;
|
import mineplex.core.blood.Blood;
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
@ -55,6 +54,7 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.elo.EloManager;
|
import mineplex.core.elo.EloManager;
|
||||||
import mineplex.core.energy.Energy;
|
import mineplex.core.energy.Energy;
|
||||||
import mineplex.core.explosion.Explosion;
|
import mineplex.core.explosion.Explosion;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.movement.Movement;
|
import mineplex.core.movement.Movement;
|
||||||
@ -116,7 +116,6 @@ import nautilus.game.arcade.shop.ArcadeShop;
|
|||||||
public class ArcadeManager extends MiniPlugin implements IRelation
|
public class ArcadeManager extends MiniPlugin implements IRelation
|
||||||
{
|
{
|
||||||
// Modules
|
// Modules
|
||||||
private AntiStack _antistack;
|
|
||||||
private BlockRestore _blockRestore;
|
private BlockRestore _blockRestore;
|
||||||
private Blood _blood;
|
private Blood _blood;
|
||||||
private Chat _chat;
|
private Chat _chat;
|
||||||
@ -147,7 +146,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
private CosmeticManager _cosmeticManager;
|
private CosmeticManager _cosmeticManager;
|
||||||
private final IdleManager _idleManager;
|
private final IdleManager _idleManager;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
private AchievementManager _achievementManager;
|
private AchievementManager _achievementManager;
|
||||||
private StatsManager _statsManager;
|
private StatsManager _statsManager;
|
||||||
private ClassManager _classManager;
|
private ClassManager _classManager;
|
||||||
@ -173,17 +172,15 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
|
|
||||||
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
|
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
|
||||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||||
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack,
|
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood,
|
||||||
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
||||||
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, String webAddress)
|
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress)
|
||||||
{
|
{
|
||||||
super("Game Manager", plugin);
|
super("Game Manager", plugin);
|
||||||
|
|
||||||
_serverConfig = serverConfig;
|
_serverConfig = serverConfig;
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
_antistack = antistack;
|
|
||||||
|
|
||||||
_blockRestore = new BlockRestore(plugin);
|
_blockRestore = new BlockRestore(plugin);
|
||||||
|
|
||||||
_blood = blood;
|
_blood = blood;
|
||||||
@ -219,26 +216,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
|
|
||||||
_projectileManager = projectileManager;
|
_projectileManager = projectileManager;
|
||||||
|
|
||||||
if (serverConfig.GameList.contains(GameType.ChampionsDominate)
|
_statsManager = new StatsManager(plugin, clientManager);
|
||||||
|| serverConfig.GameList.contains(GameType.ChampionsTDM)
|
|
||||||
|| serverConfig.GameList.contains(GameType.ChampionsMOBA))
|
|
||||||
{
|
|
||||||
Energy energy = new Energy(plugin);
|
|
||||||
ItemFactory itemFactory = new ItemFactory(_plugin, _blockRestore, _conditionManager, damageManager, energy,
|
|
||||||
_fire, _projectileManager, webAddress);
|
|
||||||
_skillFactory = new SkillFactory(plugin, damageManager, this, _damageManager.GetCombatManager(),
|
|
||||||
_conditionManager, _projectileManager, _disguiseManager, _blockRestore, _fire, new Movement(plugin), teleport,
|
|
||||||
energy, webAddress);
|
|
||||||
_classManager = new ClassManager(plugin, clientManager, donationManager, _skillFactory, itemFactory,
|
|
||||||
webAddress);
|
|
||||||
|
|
||||||
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, itemFactory);
|
|
||||||
_classShop = new ClassCombatShop(_classShopManager, clientManager, donationManager, webAddress);
|
|
||||||
|
|
||||||
_eloManager = new EloManager(_plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
_statsManager = new StatsManager(plugin);
|
|
||||||
_taskManager = new TaskManager(plugin, webAddress);
|
_taskManager = new TaskManager(plugin, webAddress);
|
||||||
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
@ -267,6 +245,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
new GameSpectatorManager(this);
|
new GameSpectatorManager(this);
|
||||||
_gameWorldManager = new GameWorldManager(this);
|
_gameWorldManager = new GameWorldManager(this);
|
||||||
new MiscManager(this);
|
new MiscManager(this);
|
||||||
|
_hologramManager = hologramManager;
|
||||||
_idleManager = new IdleManager(this);
|
_idleManager = new IdleManager(this);
|
||||||
//new HalloweenManager(this);
|
//new HalloweenManager(this);
|
||||||
|
|
||||||
@ -275,6 +254,25 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
new CompassAddon(plugin, this);
|
new CompassAddon(plugin, this);
|
||||||
new SoupAddon(plugin, this);
|
new SoupAddon(plugin, this);
|
||||||
new TeamArmorAddon(plugin, this);
|
new TeamArmorAddon(plugin, this);
|
||||||
|
|
||||||
|
if (serverConfig.GameList.contains(GameType.ChampionsDominate)
|
||||||
|
|| serverConfig.GameList.contains(GameType.ChampionsTDM)
|
||||||
|
|| serverConfig.GameList.contains(GameType.ChampionsMOBA))
|
||||||
|
{
|
||||||
|
Energy energy = new Energy(plugin);
|
||||||
|
ItemFactory itemFactory = new ItemFactory(_plugin, _blockRestore, _conditionManager, damageManager, energy,
|
||||||
|
_fire, _projectileManager, webAddress);
|
||||||
|
_skillFactory = new SkillFactory(plugin, damageManager, this, _damageManager.GetCombatManager(),
|
||||||
|
_conditionManager, _projectileManager, _disguiseManager, _blockRestore, _fire, new Movement(plugin), teleport,
|
||||||
|
energy, webAddress);
|
||||||
|
_classManager = new ClassManager(plugin, clientManager, donationManager, _skillFactory, itemFactory,
|
||||||
|
webAddress);
|
||||||
|
|
||||||
|
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, itemFactory, _achievementManager, clientManager);
|
||||||
|
_classShop = new ClassCombatShop(_classShopManager, clientManager, donationManager, webAddress);
|
||||||
|
|
||||||
|
_eloManager = new EloManager(_plugin, clientManager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -300,11 +298,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
return _achievementManager;
|
return _achievementManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AntiStack GetAntiStack()
|
|
||||||
{
|
|
||||||
return _antistack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Blood GetBlood()
|
public Blood GetBlood()
|
||||||
{
|
{
|
||||||
return _blood;
|
return _blood;
|
||||||
@ -345,6 +338,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
return _disguiseManager;
|
return _disguiseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HologramManager getHologramManager()
|
||||||
|
{
|
||||||
|
return _hologramManager;
|
||||||
|
}
|
||||||
|
|
||||||
public DamageManager GetDamage()
|
public DamageManager GetDamage()
|
||||||
{
|
{
|
||||||
return _damageManager;
|
return _damageManager;
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Hanging;
|
import org.bukkit.entity.Hanging;
|
||||||
@ -33,6 +34,7 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -203,6 +205,7 @@ public abstract class Game implements Listener
|
|||||||
|
|
||||||
public boolean RepairWeapons = true;
|
public boolean RepairWeapons = true;
|
||||||
|
|
||||||
|
private double _itemMergeRadius = 0;
|
||||||
|
|
||||||
public boolean AnnounceStay = true;
|
public boolean AnnounceStay = true;
|
||||||
public boolean AnnounceJoinQuit = true;
|
public boolean AnnounceJoinQuit = true;
|
||||||
@ -1287,7 +1290,33 @@ public abstract class Game implements Listener
|
|||||||
loc.getY() <= WorldData.MinY);
|
loc.getY() <= WorldData.MinY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItemMerge(boolean itemMerge)
|
||||||
|
{
|
||||||
|
setItemMergeRadius(itemMerge ? 3.5 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemMergeRadius(double mergeRadius)
|
||||||
|
{
|
||||||
|
_itemMergeRadius = mergeRadius;
|
||||||
|
|
||||||
|
if (WorldData.World != null)
|
||||||
|
{
|
||||||
|
((CraftWorld) WorldData.World).getHandle().spigotConfig.itemMerge = _itemMergeRadius;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getItemMergeRadius()
|
||||||
|
{
|
||||||
|
return _itemMergeRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void applyItemMerge(WorldLoadEvent event)
|
||||||
|
{
|
||||||
|
if (event.getWorld().getName().equals(WorldData.GetFolder()))
|
||||||
|
{
|
||||||
|
System.out.println("Setting item merge radius for game to " + _itemMergeRadius);
|
||||||
|
((CraftWorld) event.getWorld()).getHandle().spigotConfig.itemMerge = _itemMergeRadius;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
@ -1012,20 +1012,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Under Water
|
|
||||||
if (event.getBlock().getRelative(BlockFace.UP).isLiquid())
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Game",
|
|
||||||
"Cannot place blocks under liquids."));
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_bridgesDown)
|
if (_bridgesDown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//In Liquid
|
//In Liquid
|
||||||
if (event.getBlockReplacedState().getTypeId() == 8 ||
|
if (event.getBlock().getRelative(BlockFace.UP).isLiquid() ||
|
||||||
|
event.getBlockReplacedState().getTypeId() == 8 ||
|
||||||
event.getBlockReplacedState().getTypeId() == 9 ||
|
event.getBlockReplacedState().getTypeId() == 9 ||
|
||||||
event.getBlockReplacedState().getTypeId() == 10 ||
|
event.getBlockReplacedState().getTypeId() == 10 ||
|
||||||
event.getBlockReplacedState().getTypeId() == 11)
|
event.getBlockReplacedState().getTypeId() == 11)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user