Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f48085d5ca
@ -85,6 +85,48 @@
|
|||||||
</jar>
|
</jar>
|
||||||
<copy file="../bin/Hub.jar" todir="../../Testing/Hub/plugins"/>
|
<copy file="../bin/Hub.jar" todir="../../Testing/Hub/plugins"/>
|
||||||
</target>
|
</target>
|
||||||
|
<target name ="Clans" description="Clans">
|
||||||
|
<jar jarfile="../bin/Clans.jar">
|
||||||
|
<fileset dir="../Mineplex.Game.Clans/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="../Mineplex.Core/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="../Mineplex.Core.Common/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="../Mineplex.Minecraft.Game.Core/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="../Mineplex.Database/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="../Mineplex.Game.Clans">
|
||||||
|
<include name="*.yml"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="../Mineplex.ServerData/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
|
||||||
|
<zipfileset src="../Libraries/jooq-3.4.2.jar" />
|
||||||
|
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||||
|
<zipfileset src="../Libraries/httpcore-4.2.jar" />
|
||||||
|
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" />
|
||||||
|
<zipfileset src="../Libraries/httpmime-4.2.jar" />
|
||||||
|
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||||
|
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||||
|
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||||
|
<zipfileset src="../Libraries/commons-dbcp2-2.0.1.jar" />
|
||||||
|
<zipfileset src="../Libraries/jedis-2.4.2.jar" />
|
||||||
|
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||||
|
<zipfileset src="../Libraries/commons-dbcp2-2.0.1.jar" />
|
||||||
|
</jar>
|
||||||
|
<copy file="../bin/Clans.jar" todir="../../Testing/Clans/plugins"/>
|
||||||
|
</target>
|
||||||
<target name ="StaffServer" description="StaffServer">
|
<target name ="StaffServer" description="StaffServer">
|
||||||
<jar jarfile="../bin/StaffServer.jar">
|
<jar jarfile="../bin/StaffServer.jar">
|
||||||
<fileset dir="../Mineplex.StaffServer/bin">
|
<fileset dir="../Mineplex.StaffServer/bin">
|
||||||
|
@ -137,7 +137,7 @@ public class Fix extends AModule
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Teleport
|
//Teleport
|
||||||
Teleport().TP(event.getPlayer(), UtilWorld.locMerge(event.getPlayer().getLocation(), block.getLocation().add(0.5, 0, 0.5)));
|
event.getPlayer().teleport(UtilWorld.locMerge(event.getPlayer().getLocation(), block.getLocation().add(0.5, 0, 0.5)));
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(event.getPlayer(), F.main(_moduleName, "Block Climb Prevented."));
|
UtilPlayer.message(event.getPlayer(), F.main(_moduleName, "Block Climb Prevented."));
|
||||||
|
@ -60,7 +60,7 @@ public class Ignore extends AModule
|
|||||||
if (!Recharge().use(caller, "Ignore Command", 2000, true))
|
if (!Recharge().use(caller, "Ignore Command", 2000, true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GetRepository().MatchPlayerName(new Callback<List<String>>()
|
GetRepository().matchPlayerName(new Callback<List<String>>()
|
||||||
{
|
{
|
||||||
public void run(List<String> matches)
|
public void run(List<String> matches)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ public class Quit extends AModule
|
|||||||
boolean clear = false;
|
boolean clear = false;
|
||||||
for (Player other : event.getPlayer().getWorld().getPlayers())
|
for (Player other : event.getPlayer().getWorld().getPlayers())
|
||||||
if (UtilMath.offset(event.getPlayer(), other) < 32)
|
if (UtilMath.offset(event.getPlayer(), other) < 32)
|
||||||
if (Clans().CanHurt(event.getPlayer(), other))
|
if (Clans().canHurt(event.getPlayer(), other))
|
||||||
clear = true;
|
clear = true;
|
||||||
|
|
||||||
if (!clear)
|
if (!clear)
|
||||||
@ -200,7 +200,7 @@ public class Quit extends AModule
|
|||||||
boolean clear = false;
|
boolean clear = false;
|
||||||
for (Player other : player.getWorld().getPlayers())
|
for (Player other : player.getWorld().getPlayers())
|
||||||
if (UtilMath.offset(player, other) < 32)
|
if (UtilMath.offset(player, other) < 32)
|
||||||
if (Clans().CanHurt(player, other))
|
if (Clans().canHurt(player, other))
|
||||||
clear = true;
|
clear = true;
|
||||||
|
|
||||||
if (!clear)
|
if (!clear)
|
||||||
|
@ -21,6 +21,8 @@ public class PlayerTracker implements Listener
|
|||||||
|
|
||||||
_repository = new PlayerTrackerRepository();
|
_repository = new PlayerTrackerRepository();
|
||||||
_repository.initialize(!new File("eu.dat").exists());
|
_repository.initialize(!new File("eu.dat").exists());
|
||||||
|
|
||||||
|
System.out.println("Initialized PlayerTracker.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -25,6 +25,8 @@ public class InternetStatus implements Runnable
|
|||||||
_repository.initialize();
|
_repository.initialize();
|
||||||
|
|
||||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES);
|
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
System.out.println("Initialized InternetStatus.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,7 +6,7 @@ public enum CurrencyType
|
|||||||
{
|
{
|
||||||
Tokens(" Tokens", Material.EMERALD),
|
Tokens(" Tokens", Material.EMERALD),
|
||||||
Coins(" Coins", Material.DOUBLE_PLANT),
|
Coins(" Coins", Material.DOUBLE_PLANT),
|
||||||
Gems("Gems", Material.DIAMOND);
|
Gems(" Gems", Material.EMERALD);
|
||||||
|
|
||||||
private String _prefix;
|
private String _prefix;
|
||||||
private Material _displayMaterial;
|
private Material _displayMaterial;
|
||||||
|
@ -33,7 +33,6 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
|||||||
|
|
||||||
public class UtilEnt
|
public class UtilEnt
|
||||||
{
|
{
|
||||||
private static int entityIdCount = 455000;
|
|
||||||
|
|
||||||
//Custom Entity Names
|
//Custom Entity Names
|
||||||
private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>();
|
private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>();
|
||||||
@ -574,6 +573,30 @@ public class UtilEnt
|
|||||||
|
|
||||||
public static int getNewEntityId()
|
public static int getNewEntityId()
|
||||||
{
|
{
|
||||||
return entityIdCount++;
|
return getNewEntityId(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use false if you don't want to modify the next entityid to be used.
|
||||||
|
*
|
||||||
|
* Normally you want true if you want a unique entityid to use.
|
||||||
|
**/
|
||||||
|
public static int getNewEntityId(boolean modifynumber)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Field field = net.minecraft.server.v1_7_R4.Entity.class.getDeclaredField("entityCount");
|
||||||
|
field.setAccessible(true);
|
||||||
|
int entityId = field.getInt(null);
|
||||||
|
if (modifynumber) {
|
||||||
|
field.set(null, entityId+1);
|
||||||
|
}
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ public class UtilGear
|
|||||||
return _maulSet.contains(item.getType());
|
return _maulSet.contains(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<Material> scytheSet = new HashSet<Material>();
|
public static HashSet<Material> scytheSet = new HashSet<Material>();
|
||||||
public boolean isHoe(ItemStack item)
|
public static boolean isHoe(ItemStack item)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return false;
|
return false;
|
||||||
@ -84,7 +84,7 @@ public class UtilGear
|
|||||||
return scytheSet.contains(item.getType());
|
return scytheSet.contains(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPickaxe(ItemStack item)
|
public static boolean isPickaxe(ItemStack item)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return false;
|
return false;
|
||||||
@ -101,7 +101,7 @@ public class UtilGear
|
|||||||
return pickSet.contains(item.getType());
|
return pickSet.contains(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDiamond(ItemStack item)
|
public static boolean isDiamond(ItemStack item)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,10 +55,10 @@ public class UtilTextBottom
|
|||||||
//Send to Player
|
//Send to Player
|
||||||
for (Player player : players)
|
for (Player player : players)
|
||||||
{
|
{
|
||||||
//1.7
|
//1.7 - Add Color
|
||||||
if (!UtilPlayer.is1_8(player))
|
if (!UtilPlayer.is1_8(player))
|
||||||
{
|
{
|
||||||
UtilTextTop.displayProgress((prefix == null ? "" : prefix) + (suffix == null ? "" : ChatColor.RESET + C.Bold + " - " + ChatColor.RESET + suffix),
|
UtilTextTop.displayProgress((prefix == null ? "" : C.cYellow + C.Bold + prefix) + (suffix == null ? "" : ChatColor.RESET + C.Bold + " - " + C.cGreen + C.Bold + suffix),
|
||||||
amount, player);
|
amount, player);
|
||||||
}
|
}
|
||||||
//1.8
|
//1.8
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Arcade,Hub,StaffServer,"/>
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Arcade,Hub,StaffServer,Clans,"/>
|
||||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Arcade,Hub,StaffServer,"/>
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Arcade,Hub,StaffServer,Clans,"/>
|
||||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Arcade,Hub,StaffServer,"/>
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Arcade,Hub,StaffServer,Clans,"/>
|
||||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package mineplex.core.account;
|
package mineplex.core.account;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -174,7 +172,6 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
public void loadClientByName(final String playerName, final Runnable runnable)
|
public void loadClientByName(final String playerName, final Runnable runnable)
|
||||||
{
|
{
|
||||||
final CoreClient client = Add(playerName);
|
final CoreClient client = Add(playerName);
|
||||||
final UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@ -183,6 +180,12 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
ClientToken token = null;
|
ClientToken token = null;
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
|
// Fails if not in DB and if duplicate.
|
||||||
|
UUID uuid = loadUUIDFromDB(playerName);
|
||||||
|
|
||||||
|
if (uuid == null)
|
||||||
|
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
|
|
||||||
String response = _repository.getClientByUUID(uuid);
|
String response = _repository.getClientByUUID(uuid);
|
||||||
token = gson.fromJson(response, ClientToken.class);
|
token = gson.fromJson(response, ClientToken.class);
|
||||||
|
|
||||||
@ -330,23 +333,45 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}, name, rank, perm);
|
}, name, rank, perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPlayerName(final Player caller, final String playerName, final Callback<Boolean> callback)
|
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
||||||
{
|
{
|
||||||
_repository.MatchPlayerName(new Callback<List<String>>()
|
_repository.matchPlayerName(new Callback<List<String>>()
|
||||||
{
|
{
|
||||||
public void run(List<String> matches)
|
public void run(List<String> matches)
|
||||||
{
|
{
|
||||||
boolean matchedExact = false;
|
for (String match : matches)
|
||||||
|
{
|
||||||
|
if (match.equalsIgnoreCase(playerName))
|
||||||
|
{
|
||||||
|
callback.run(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback.run(false);
|
||||||
|
}
|
||||||
|
}, playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkPlayerName(final Player caller, final String playerName, final Callback<String> callback)
|
||||||
|
{
|
||||||
|
_repository.matchPlayerName(new Callback<List<String>>()
|
||||||
|
{
|
||||||
|
public void run(List<String> matches)
|
||||||
|
{
|
||||||
|
String tempName = null;
|
||||||
|
|
||||||
for (String match : matches)
|
for (String match : matches)
|
||||||
{
|
{
|
||||||
if (match.equalsIgnoreCase(playerName))
|
if (match.equalsIgnoreCase(playerName))
|
||||||
{
|
{
|
||||||
matchedExact = true;
|
tempName = match;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedExact)
|
final String matchedName = tempName;
|
||||||
|
|
||||||
|
if (matchedName != null)
|
||||||
{
|
{
|
||||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
||||||
{
|
{
|
||||||
@ -363,11 +388,11 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
callback.run(false);
|
callback.run(matchedName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.run(true);
|
callback.run(matchedName);
|
||||||
}
|
}
|
||||||
}, caller, playerName, true);
|
}, caller, playerName, true);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
|||||||
|
|
||||||
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)
|
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>>()
|
||||||
{
|
{
|
||||||
public void run(List<String> matches)
|
public void run(List<String> matches)
|
||||||
{
|
{
|
||||||
|
@ -264,7 +264,7 @@ public class AccountRepository extends RepositoryBase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MatchPlayerName(final Callback<List<String>> callback, final String userName)
|
public void matchPlayerName(final Callback<List<String>> callback, final String userName)
|
||||||
{
|
{
|
||||||
Thread asyncThread = new Thread(new Runnable()
|
Thread asyncThread = new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
|
@ -297,8 +297,10 @@ public class AntiHack extends MiniPlugin
|
|||||||
|
|
||||||
synchronized (_antiHackLock)
|
synchronized (_antiHackLock)
|
||||||
{
|
{
|
||||||
for (Player player : _offense.keySet())
|
for (Iterator<Player> playerIterator = _offense.keySet().iterator(); playerIterator.hasNext();)
|
||||||
{
|
{
|
||||||
|
Player player = playerIterator.next();
|
||||||
|
|
||||||
String out = "";
|
String out = "";
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
@ -332,6 +334,9 @@ public class AntiHack extends MiniPlugin
|
|||||||
|
|
||||||
//Send Report
|
//Send Report
|
||||||
sendReport(player, out, severity);
|
sendReport(player, out, severity);
|
||||||
|
|
||||||
|
if (severity.equalsIgnoreCase("Extreme"))
|
||||||
|
playerIterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,7 +345,7 @@ public class AntiHack extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (severity.equals("Extreme"))
|
if (severity.equals("Extreme"))
|
||||||
{
|
{
|
||||||
ResetAll(player);
|
ResetAll(player, false);
|
||||||
|
|
||||||
//Staff
|
//Staff
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
@ -416,6 +421,11 @@ public class AntiHack extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ResetAll(Player player)
|
private void ResetAll(Player player)
|
||||||
|
{
|
||||||
|
ResetAll(player, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetAll(Player player, boolean removeOffenses)
|
||||||
{
|
{
|
||||||
synchronized (_antiHackLock)
|
synchronized (_antiHackLock)
|
||||||
{
|
{
|
||||||
@ -423,7 +433,7 @@ public class AntiHack extends MiniPlugin
|
|||||||
_velocityEvent.remove(player);
|
_velocityEvent.remove(player);
|
||||||
_lastMoveEvent.remove(player);
|
_lastMoveEvent.remove(player);
|
||||||
|
|
||||||
|
if (removeOffenses)
|
||||||
_offense.remove(player);
|
_offense.remove(player);
|
||||||
|
|
||||||
for (Detector detector : _movementDetectors)
|
for (Detector detector : _movementDetectors)
|
||||||
|
@ -89,6 +89,7 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<String> getMatches(String start, Enum[] numerators)
|
protected List<String> getMatches(String start, Enum[] numerators)
|
||||||
{
|
{
|
||||||
List<String> matches = new ArrayList<String>();
|
List<String> matches = new ArrayList<String>();
|
||||||
|
@ -38,12 +38,7 @@ public class CosmeticManager extends MiniPlugin
|
|||||||
private boolean _showInterface = true;
|
private boolean _showInterface = true;
|
||||||
private int _interfaceSlot = 4;
|
private int _interfaceSlot = 4;
|
||||||
|
|
||||||
public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, boolean useBooster)
|
public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, TreasureManager treasureManager)
|
||||||
{
|
|
||||||
this(plugin, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, useBooster, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, boolean useBooster, TreasureManager treasureManager)
|
|
||||||
{
|
{
|
||||||
super("Cosmetic Manager", plugin);
|
super("Cosmetic Manager", plugin);
|
||||||
|
|
||||||
@ -53,7 +48,7 @@ public class CosmeticManager extends MiniPlugin
|
|||||||
_petManager = petManager;
|
_petManager = petManager;
|
||||||
_treasureManager = treasureManager;
|
_treasureManager = treasureManager;
|
||||||
|
|
||||||
_shop = new CosmeticShop(this, clientManager, donationManager, _moduleName, useBooster);
|
_shop = new CosmeticShop(this, clientManager, donationManager, _moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showInterface(boolean showInterface)
|
public void showInterface(boolean showInterface)
|
||||||
|
@ -20,13 +20,10 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
|
|
||||||
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
||||||
{
|
{
|
||||||
private boolean _useBooster;
|
public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||||
|
|
||||||
public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name, boolean useBooster)
|
|
||||||
{
|
{
|
||||||
super(plugin, clientManager, donationManager, name, CurrencyType.Gems, CurrencyType.Coins);
|
super(plugin, clientManager, donationManager, name, CurrencyType.Gems, CurrencyType.Coins);
|
||||||
|
|
||||||
_useBooster = useBooster;
|
|
||||||
plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this);
|
plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +68,4 @@ public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMes
|
|||||||
((TreasurePage) shop).update();
|
((TreasurePage) shop).update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getBoosterEnabled()
|
|
||||||
{
|
|
||||||
return _useBooster;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.ComplexButton;
|
||||||
|
|
||||||
public class ActivateGadgetButton implements IButton
|
public class ActivateGadgetButton extends ComplexButton
|
||||||
{
|
{
|
||||||
private Gadget _gadget;
|
private Gadget _gadget;
|
||||||
private GadgetPage _page;
|
private GadgetPage _page;
|
||||||
@ -28,4 +28,16 @@ public class ActivateGadgetButton implements IButton
|
|||||||
{
|
{
|
||||||
_page.handleRightClick(player, _gadget);
|
_page.handleRightClick(player, _gadget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftLeft(Player player)
|
||||||
|
{
|
||||||
|
_page.activateGadget(player, _gadget);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftRight(Player player)
|
||||||
|
{
|
||||||
|
_page.handleRightClick(player, _gadget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.cosmetic.ui.page.MountPage;
|
import mineplex.core.cosmetic.ui.page.MountPage;
|
||||||
import mineplex.core.mount.Mount;
|
import mineplex.core.mount.Mount;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class ActivateMountButton implements IButton
|
public class ActivateMountButton extends SingleButton
|
||||||
{
|
{
|
||||||
private Mount<?> _mount;
|
private Mount<?> _mount;
|
||||||
private MountPage _page;
|
private MountPage _page;
|
||||||
@ -19,14 +19,10 @@ public class ActivateMountButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.activateMount(player, _mount);
|
_page.PlayAcceptSound(player);
|
||||||
}
|
_mount.Enable(player);
|
||||||
|
_page.getShop().OpenPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.activateMount(player, _mount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,12 @@ package mineplex.core.cosmetic.ui.button;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.cosmetic.ui.page.PetPage;
|
import mineplex.core.cosmetic.ui.page.PetPage;
|
||||||
import mineplex.core.pet.Pet;
|
import mineplex.core.pet.Pet;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class ActivatePetButton implements IButton
|
public class ActivatePetButton extends SingleButton
|
||||||
{
|
{
|
||||||
private Pet _pet;
|
private Pet _pet;
|
||||||
private PetPage _page;
|
private PetPage _page;
|
||||||
@ -18,14 +19,10 @@ public class ActivatePetButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.activatePet(player, _pet);
|
_page.PlayAcceptSound(player);
|
||||||
}
|
_page.getPlugin().getPetManager().AddPetOwner(player, _pet.GetPetType(), player.getLocation());
|
||||||
|
_page.getShop().OpenPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.activatePet(player, _pet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,12 @@ package mineplex.core.cosmetic.ui.button;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class CloseButton implements IButton
|
public class CloseButton extends SingleButton
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
|
||||||
player.closeInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
{
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.ComplexButton;
|
||||||
|
|
||||||
public class DeactivateGadgetButton implements IButton
|
public class DeactivateGadgetButton extends ComplexButton
|
||||||
{
|
{
|
||||||
private Gadget _gadget;
|
private Gadget _gadget;
|
||||||
private GadgetPage _page;
|
private GadgetPage _page;
|
||||||
@ -28,4 +28,16 @@ public class DeactivateGadgetButton implements IButton
|
|||||||
{
|
{
|
||||||
_page.handleRightClick(player, _gadget);
|
_page.handleRightClick(player, _gadget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftLeft(Player player)
|
||||||
|
{
|
||||||
|
_page.deactivateGadget(player, _gadget);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftRight(Player player)
|
||||||
|
{
|
||||||
|
_page.handleRightClick(player, _gadget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ package mineplex.core.cosmetic.ui.button;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.core.mount.Mount;
|
import mineplex.core.mount.Mount;
|
||||||
|
|
||||||
public class DeactivateMountButton implements IButton
|
public class DeactivateMountButton extends SingleButton
|
||||||
{
|
{
|
||||||
private Mount<?> _mount;
|
private Mount<?> _mount;
|
||||||
private ShopPageBase<?,?> _page;
|
private ShopPageBase<?,?> _page;
|
||||||
@ -18,15 +18,7 @@ public class DeactivateMountButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
|
||||||
_page.PlayAcceptSound(player);
|
|
||||||
_mount.Disable(player);
|
|
||||||
_page.Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
{
|
||||||
_page.PlayAcceptSound(player);
|
_page.PlayAcceptSound(player);
|
||||||
_mount.Disable(player);
|
_mount.Disable(player);
|
||||||
|
@ -3,10 +3,10 @@ package mineplex.core.cosmetic.ui.button;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.pet.PetManager;
|
import mineplex.core.pet.PetManager;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
|
||||||
public class DeactivatePetButton implements IButton
|
public class DeactivatePetButton extends SingleButton
|
||||||
{
|
{
|
||||||
private ShopPageBase<?,?> _page;
|
private ShopPageBase<?,?> _page;
|
||||||
private PetManager _petManager;
|
private PetManager _petManager;
|
||||||
@ -18,15 +18,7 @@ public class DeactivatePetButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
|
||||||
_page.PlayAcceptSound(player);
|
|
||||||
_petManager.RemovePet(player, true);
|
|
||||||
_page.Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
{
|
||||||
_page.PlayAcceptSound(player);
|
_page.PlayAcceptSound(player);
|
||||||
_petManager.RemovePet(player, true);
|
_petManager.RemovePet(player, true);
|
||||||
|
@ -4,9 +4,9 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class GadgetButton implements IButton
|
public class GadgetButton extends SingleButton
|
||||||
{
|
{
|
||||||
private Gadget _gadget;
|
private Gadget _gadget;
|
||||||
private GadgetPage _page;
|
private GadgetPage _page;
|
||||||
@ -18,13 +18,7 @@ public class GadgetButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
|
||||||
_page.purchaseGadget(player, _gadget);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
{
|
||||||
_page.purchaseGadget(player, _gadget);
|
_page.purchaseGadget(player, _gadget);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,15 @@ package mineplex.core.cosmetic.ui.button;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
import mineplex.core.shop.page.ConfirmationPage;
|
||||||
|
import mineplex.core.common.CurrencyType;
|
||||||
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
|
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||||
import mineplex.core.cosmetic.ui.page.MountPage;
|
import mineplex.core.cosmetic.ui.page.MountPage;
|
||||||
import mineplex.core.mount.Mount;
|
import mineplex.core.mount.Mount;
|
||||||
|
|
||||||
public class MountButton implements IButton
|
public class MountButton extends SingleButton
|
||||||
{
|
{
|
||||||
private Mount<?> _mount;
|
private Mount<?> _mount;
|
||||||
private MountPage _page;
|
private MountPage _page;
|
||||||
@ -18,14 +22,15 @@ public class MountButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(final Player player)
|
||||||
{
|
{
|
||||||
_page.purchaseMount(player, _mount);
|
_page.getShop().OpenPageForPlayer(player, new ConfirmationPage<CosmeticManager, CosmeticShop>(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
_page.getPlugin().getInventoryManager().addItemToInventory(null, player, "Mount", _mount.GetName(), 1);
|
||||||
|
_page.Refresh();
|
||||||
}
|
}
|
||||||
|
}, _page, _mount, CurrencyType.Coins, player));
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.purchaseMount(player, _mount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,6 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.shop.item.SingleButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by shaun on 14-09-15.
|
|
||||||
*/
|
|
||||||
public class OpenCostumes extends SingleButton
|
public class OpenCostumes extends SingleButton
|
||||||
{
|
{
|
||||||
private Menu _menu;
|
private Menu _menu;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
|
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
public class OpenGadgets implements IButton
|
public class OpenGadgets implements IButton
|
||||||
{
|
{
|
||||||
@ -15,14 +17,8 @@ public class OpenGadgets implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
_page.openGadgets(player);
|
_page.getShop().OpenPageForPlayer((Player)event.getWhoClicked(), new GadgetPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Gadgets", (Player)event.getWhoClicked()));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.openGadgets(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,12 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.cosmetic.ui.page.MorphPage;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class OpenMorphs implements IButton
|
public class OpenMorphs extends SingleButton
|
||||||
{
|
{
|
||||||
private Menu _page;
|
private Menu _page;
|
||||||
|
|
||||||
@ -15,14 +16,8 @@ public class OpenMorphs implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.openMorphs(player);
|
_page.getShop().OpenPageForPlayer(player, new MorphPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Morphs", player));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.openMorphs(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,12 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.cosmetic.ui.page.MorphPage;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class OpenMounts implements IButton
|
public class OpenMounts extends SingleButton
|
||||||
{
|
{
|
||||||
private Menu _page;
|
private Menu _page;
|
||||||
|
|
||||||
@ -15,14 +16,8 @@ public class OpenMounts implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.openMounts(player);
|
_page.getShop().OpenPageForPlayer(player, new MorphPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Mounts", player));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.openMounts(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,12 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.cosmetic.ui.page.MorphPage;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class OpenParticles implements IButton
|
public class OpenParticles extends SingleButton
|
||||||
{
|
{
|
||||||
private Menu _page;
|
private Menu _page;
|
||||||
|
|
||||||
@ -15,14 +16,8 @@ public class OpenParticles implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.openParticles(player);
|
_page.getShop().OpenPageForPlayer(player, new MorphPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Particles", player));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.openParticles(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,12 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.cosmetic.ui.page.MorphPage;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class OpenPets implements IButton
|
public class OpenPets extends SingleButton
|
||||||
{
|
{
|
||||||
private Menu _page;
|
private Menu _page;
|
||||||
|
|
||||||
@ -13,16 +14,9 @@ public class OpenPets implements IButton
|
|||||||
{
|
{
|
||||||
_page = page;
|
_page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.openPets(player);
|
_page.getShop().OpenPageForPlayer(player, new MorphPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Pets", player));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.openPets(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,9 +4,9 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.pet.Pet;
|
import mineplex.core.pet.Pet;
|
||||||
import mineplex.core.cosmetic.ui.page.PetPage;
|
import mineplex.core.cosmetic.ui.page.PetPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class PetButton implements IButton
|
public class PetButton extends SingleButton
|
||||||
{
|
{
|
||||||
private Pet _pet;
|
private Pet _pet;
|
||||||
private PetPage _page;
|
private PetPage _page;
|
||||||
@ -18,13 +18,7 @@ public class PetButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
|
||||||
_page.purchasePet(player, _pet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
{
|
||||||
_page.purchasePet(player, _pet);
|
_page.purchasePet(player, _pet);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.PetPage;
|
import mineplex.core.cosmetic.ui.page.PetPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.pet.Pet;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class RenamePetButton implements IButton
|
public class RenamePetButton extends SingleButton
|
||||||
{
|
{
|
||||||
private PetPage _page;
|
private PetPage _page;
|
||||||
|
|
||||||
@ -15,14 +17,10 @@ public class RenamePetButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.renameCurrentPet(player);
|
_page.PlayAcceptSound(player);
|
||||||
}
|
Creature currentPet = _page.getPlugin().getPetManager().getActivePet(player.getName());
|
||||||
|
_page.renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false);
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
_page.renameCurrentPet(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package mineplex.core.cosmetic.ui.button;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.PetTagPage;
|
import mineplex.core.cosmetic.ui.page.PetTagPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class SelectTagButton implements IButton
|
public class SelectTagButton extends SingleButton
|
||||||
{
|
{
|
||||||
private PetTagPage _page;
|
private PetTagPage _page;
|
||||||
|
|
||||||
@ -15,13 +15,7 @@ public class SelectTagButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
|
||||||
_page.SelectTag();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
{
|
||||||
_page.SelectTag();
|
_page.SelectTag();
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package mineplex.core.cosmetic.ui.button;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.ComplexButton;
|
||||||
|
|
||||||
public class TreasureButton implements IButton
|
public class TreasureButton extends ComplexButton
|
||||||
{
|
{
|
||||||
private Menu _menu;
|
private Menu _menu;
|
||||||
private boolean _hasEnoughChests;
|
private boolean _hasEnoughChests;
|
||||||
@ -40,4 +40,16 @@ public class TreasureButton implements IButton
|
|||||||
if (_canPurchaseKey)
|
if (_canPurchaseKey)
|
||||||
_menu.attemptPurchaseKey(player);
|
_menu.attemptPurchaseKey(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftLeft(Player player)
|
||||||
|
{
|
||||||
|
ClickedLeft(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftRight(Player player)
|
||||||
|
{
|
||||||
|
ClickedRight(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package mineplex.core.cosmetic.ui.page;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
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;
|
||||||
@ -13,7 +12,6 @@ import mineplex.core.common.util.C;
|
|||||||
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.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
|
||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||||
import mineplex.core.cosmetic.ui.button.OpenCostumes;
|
import mineplex.core.cosmetic.ui.button.OpenCostumes;
|
||||||
import mineplex.core.cosmetic.ui.button.OpenGadgets;
|
import mineplex.core.cosmetic.ui.button.OpenGadgets;
|
||||||
@ -26,9 +24,7 @@ import mineplex.core.cosmetic.ui.button.TreasureButton;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.inventory.GemBooster;
|
|
||||||
import mineplex.core.mount.Mount;
|
import mineplex.core.mount.Mount;
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.item.SingleButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
import mineplex.core.shop.page.ConfirmationPage;
|
||||||
@ -109,56 +105,6 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddButton(4, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGreen + C.Bold + "Treasure Chest", lore.toArray(new String[0]), 1, false), new TreasureButton(this, treasureChestCount > 0, treasureKeyCount > 0, canPurchaseKey));
|
AddButton(4, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGreen + C.Bold + "Treasure Chest", lore.toArray(new String[0]), 1, false), new TreasureButton(this, treasureChestCount > 0, treasureKeyCount > 0, canPurchaseKey));
|
||||||
|
|
||||||
final GemBooster gemBoosterItem = new GemBooster(Shop.getBoosterEnabled(), Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
|
|
||||||
|
|
||||||
|
|
||||||
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gemBoosterItem.GetCost(CurrencyType.Coins)
|
|
||||||
|| (Shop.getBoosterEnabled() && Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster") > 0))
|
|
||||||
{
|
|
||||||
AddButton(6, new ShopItem(
|
|
||||||
gemBoosterItem.GetDisplayMaterial(),
|
|
||||||
gemBoosterItem.GetDisplayName(),
|
|
||||||
gemBoosterItem.GetDescription(),
|
|
||||||
1,
|
|
||||||
false),
|
|
||||||
new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void ClickedLeft(Player player)
|
|
||||||
{
|
|
||||||
if (Shop.getBoosterEnabled() && Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster") > 0)
|
|
||||||
{
|
|
||||||
ActivateGemBoosterEvent boosterEvent = new ActivateGemBoosterEvent(player);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(boosterEvent);
|
|
||||||
|
|
||||||
if (!boosterEvent.isCancelled())
|
|
||||||
Plugin.getInventoryManager().addItemToInventory(null, Player, "Utility", "Gem Booster", -1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
purchaseGemBooster(gemBoosterItem, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
purchaseGemBooster(gemBoosterItem, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddItem(6, new ShopItem(
|
|
||||||
gemBoosterItem.GetDisplayMaterial(),
|
|
||||||
gemBoosterItem.GetDisplayName(),
|
|
||||||
gemBoosterItem.GetDescription(),
|
|
||||||
1,
|
|
||||||
false));
|
|
||||||
}
|
|
||||||
|
|
||||||
AddButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
|
AddButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
|
||||||
AddButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
|
AddButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
|
||||||
AddButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
|
AddButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
|
||||||
@ -256,43 +202,6 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void purchaseGemBooster(GemBooster gemBoosterItem, Player player)
|
|
||||||
{
|
|
||||||
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Plugin.getInventoryManager().addItemToInventory(null, Player, "Utility", "Gem Booster", 20);
|
|
||||||
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, Player));
|
|
||||||
}
|
|
||||||
}, null, gemBoosterItem, CurrencyType.Coins, Player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openParticles(Player player)
|
|
||||||
{
|
|
||||||
Shop.OpenPageForPlayer(player, new ParticlePage(Plugin, Shop, ClientManager, DonationManager, "Particles", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openGadgets(Player player)
|
|
||||||
{
|
|
||||||
Shop.OpenPageForPlayer(player, new GadgetPage(Plugin, Shop, ClientManager, DonationManager, "Gadgets", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openMorphs(Player player)
|
|
||||||
{
|
|
||||||
Shop.OpenPageForPlayer(player, new MorphPage(Plugin, Shop, ClientManager, DonationManager, "Morphs", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openMounts(Player player)
|
|
||||||
{
|
|
||||||
Shop.OpenPageForPlayer(player, new MountPage(Plugin, Shop, ClientManager, DonationManager, "Mounts", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openPets(Player player)
|
|
||||||
{
|
|
||||||
Shop.OpenPageForPlayer(player, new PetPage(Plugin, Shop, ClientManager, DonationManager, "Pets", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openCostumes(Player player)
|
public void openCostumes(Player player)
|
||||||
{
|
{
|
||||||
Shop.OpenPageForPlayer(player, new CostumePage(Plugin, Shop, ClientManager, DonationManager, "Costumes", player));
|
Shop.OpenPageForPlayer(player, new CostumePage(Plugin, Shop, ClientManager, DonationManager, "Costumes", player));
|
||||||
@ -322,7 +231,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Plugin.getInventoryManager().addItemToInventory(null, Player, "Treasure", "Treasure Key", 1);
|
Plugin.getInventoryManager().addItemToInventory(Player, "Treasure", "Treasure Key", 1);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
}, this, new TreasureKey(), CurrencyType.Coins, Player));
|
}, this, new TreasureKey(), CurrencyType.Coins, Player));
|
||||||
|
@ -17,6 +17,7 @@ import mineplex.core.cosmetic.ui.button.DeactivateMountButton;
|
|||||||
import mineplex.core.cosmetic.ui.button.MountButton;
|
import mineplex.core.cosmetic.ui.button.MountButton;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.mount.Mount;
|
import mineplex.core.mount.Mount;
|
||||||
|
import mineplex.core.shop.ShopBase;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.item.SingleButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
import mineplex.core.shop.page.ConfirmationPage;
|
||||||
@ -85,23 +86,4 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purchaseMount(final Player player, final Mount<?> mount)
|
|
||||||
{
|
|
||||||
Shop.OpenPageForPlayer(Player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Plugin.getInventoryManager().addItemToInventory(null, Player, "Mount", mount.GetName(), 1);
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
}, this, mount, CurrencyType.Coins, Player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void activateMount(Player player, Mount<?> _mount)
|
|
||||||
{
|
|
||||||
PlayAcceptSound(player);
|
|
||||||
_mount.Enable(player);
|
|
||||||
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -138,13 +138,6 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
renamePet(player, pet, true);
|
renamePet(player, pet, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renameCurrentPet(Player player)
|
|
||||||
{
|
|
||||||
PlayAcceptSound(player);
|
|
||||||
Creature currentPet = Plugin.getPetManager().getActivePet(player.getName());
|
|
||||||
renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renamePet(Player player, Pet pet, boolean petPurchase)
|
public void renamePet(Player player, Pet pet, boolean petPurchase)
|
||||||
{
|
{
|
||||||
PlayAcceptSound(player);
|
PlayAcceptSound(player);
|
||||||
@ -161,13 +154,6 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
Shop.SetCurrentPageForPlayer(Player, petTagPage);
|
Shop.SetCurrentPageForPlayer(Player, petTagPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activatePet(Player player, Pet pet)
|
|
||||||
{
|
|
||||||
PlayAcceptSound(player);
|
|
||||||
Plugin.getPetManager().AddPetOwner(player, pet.GetPetType(), player.getLocation());
|
|
||||||
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deactivatePet(Player player)
|
public void deactivatePet(Player player)
|
||||||
{
|
{
|
||||||
PlayAcceptSound(player);
|
PlayAcceptSound(player);
|
||||||
|
@ -5,6 +5,7 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
@ -79,10 +80,10 @@ 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);
|
return executeInsert(query, null, columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int executeUpdate(String query, ResultSetCallable callable, Column<?>...columns)
|
protected int executeInsert(String query, ResultSetCallable callable, Column<?>...columns)
|
||||||
{
|
{
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ public abstract class RepositoryBase implements Listener
|
|||||||
if (_connection == null || !_connection.isValid(1))
|
if (_connection == null || !_connection.isValid(1))
|
||||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||||
|
|
||||||
preparedStatement = _connection.prepareStatement(query);
|
preparedStatement = _connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
for (int i=0; i < columns.length; i++)
|
for (int i=0; i < columns.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
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;
|
||||||
import mineplex.core.database.column.ColumnInt;
|
import mineplex.core.database.column.ColumnInt;
|
||||||
@ -23,9 +22,7 @@ public class DonationRepository extends RepositoryBase
|
|||||||
private static String CREATE_COIN_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountCoinTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), coins INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX coinUuidIndex (accounts_uuid));";
|
private static String CREATE_COIN_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountCoinTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), coins INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX coinUuidIndex (accounts_uuid));";
|
||||||
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX gemUuidIndex (accounts_uuid));";
|
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX gemUuidIndex (accounts_uuid));";
|
||||||
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accounts_uuid, reason, coins) VALUES(?, ?, ?);";
|
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accounts_uuid, reason, coins) VALUES(?, ?, ?);";
|
||||||
private static String INSERT_GEM_TRANSACTION = "INSERT INTO accountGemTransactions(accounts_uuid, reason, gems) VALUES(?, ?, ?);";
|
|
||||||
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE uuid = ?;";
|
||||||
private static String UPDATE_ACCOUNT_GEMS = "UPDATE accounts SET gems = gems + ? WHERE uuid = ?;";
|
|
||||||
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE uuid = ? AND gems IS NULL AND coins IS NULL;";
|
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE uuid = ? AND gems IS NULL AND coins IS NULL;";
|
||||||
|
|
||||||
private String _webAddress;
|
private String _webAddress;
|
||||||
@ -48,9 +45,6 @@ public class DonationRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
public void run(final TransactionResponse response)
|
public void run(final TransactionResponse response)
|
||||||
{
|
{
|
||||||
if (response == TransactionResponse.Success)
|
|
||||||
executeUpdate(UPDATE_ACCOUNT_GEMS, new ColumnInt("gems", cost), new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -91,11 +85,6 @@ public class DonationRepository extends RepositoryBase
|
|||||||
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnVarChar("uuid", 100, uuid));
|
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnVarChar("uuid", 100, uuid));
|
||||||
executeUpdate(INSERT_COIN_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost));
|
executeUpdate(INSERT_COIN_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
executeUpdate(UPDATE_ACCOUNT_GEMS, new ColumnInt("gems", -cost), new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
executeUpdate(INSERT_GEM_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("gems", -cost));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||||
@ -129,12 +118,6 @@ public class DonationRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
public void run(final Boolean response)
|
public void run(final Boolean response)
|
||||||
{
|
{
|
||||||
if (response)
|
|
||||||
{
|
|
||||||
executeUpdate(UPDATE_ACCOUNT_GEMS, new ColumnInt("gems", greenGems), new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
executeUpdate(INSERT_GEM_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Given by " + giver), new ColumnInt("gems", greenGems));
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,13 +24,13 @@ public class AddFriend extends CommandBase<FriendManager>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<Boolean>()
|
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
|
||||||
{
|
{
|
||||||
public void run(Boolean result)
|
public void run(String result)
|
||||||
{
|
{
|
||||||
if (result)
|
if (result != null)
|
||||||
{
|
{
|
||||||
Plugin.addFriend(caller, args[0]);
|
Plugin.addFriend(caller, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -22,13 +22,13 @@ public class DeleteFriend extends CommandBase<FriendManager>
|
|||||||
F.main(Plugin.getName(), "You need to include a player's name.");
|
F.main(Plugin.getName(), "You need to include a player's name.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<Boolean>()
|
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
|
||||||
{
|
{
|
||||||
public void run(Boolean result)
|
public void run(String result)
|
||||||
{
|
{
|
||||||
if (result)
|
if (result != null)
|
||||||
{
|
{
|
||||||
Plugin.removeFriend(caller, args[0]);
|
Plugin.removeFriend(caller, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -19,6 +19,7 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
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.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -40,6 +41,8 @@ public class Hologram
|
|||||||
* 1.7 packets uses both EntityIDs while 1.8 uses only the first.
|
* 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 ArrayList<Entry<Integer, Integer>> _entityIds = new ArrayList<Entry<Integer, Integer>>();
|
||||||
|
private Entity _followEntity;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
private boolean _isWitherSkull;
|
private boolean _isWitherSkull;
|
||||||
/**
|
/**
|
||||||
* Keeps track of the holograms movements. This fixes offset that occasionally happens when moving a hologram around.
|
* Keeps track of the holograms movements. This fixes offset that occasionally happens when moving a hologram around.
|
||||||
@ -54,7 +57,7 @@ public class Hologram
|
|||||||
private HologramTarget _target = HologramTarget.BLACKLIST;
|
private HologramTarget _target = HologramTarget.BLACKLIST;
|
||||||
private String[] _text = new String[0];
|
private String[] _text = new String[0];
|
||||||
private int _viewDistance = 70;
|
private int _viewDistance = 70;
|
||||||
private HologramManager _hologramManager;
|
protected Vector relativeToEntity;
|
||||||
|
|
||||||
public Hologram(HologramManager hologramManager, Location location, String... text)
|
public Hologram(HologramManager hologramManager, Location location, String... text)
|
||||||
{
|
{
|
||||||
@ -106,6 +109,11 @@ public class Hologram
|
|||||||
return UtilPlayer.is1_8(player) ? _destroy1_8 : _destroy1_7;
|
return UtilPlayer.is1_8(player) ? _destroy1_8 : _destroy1_7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Entity getEntityFollowing()
|
||||||
|
{
|
||||||
|
return _followEntity;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get who can see the hologram
|
* Get who can see the hologram
|
||||||
*
|
*
|
||||||
@ -138,6 +146,11 @@ public class Hologram
|
|||||||
return nearbyPlayers;
|
return nearbyPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ArrayList<Player> getPlayersTracking()
|
||||||
|
{
|
||||||
|
return _playersTracking;
|
||||||
|
}
|
||||||
|
|
||||||
protected Packet[] getSpawnPackets(Player player)
|
protected Packet[] getSpawnPackets(Player player)
|
||||||
{
|
{
|
||||||
if (_makePackets)
|
if (_makePackets)
|
||||||
@ -348,6 +361,19 @@ public class Hologram
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the entity moves, the hologram will update its position to appear relative to the movement.
|
||||||
|
*
|
||||||
|
* @Please note the hologram updates every tick.
|
||||||
|
*/
|
||||||
|
public Hologram setFollowEntity(Entity entityToFollow)
|
||||||
|
{
|
||||||
|
_followEntity = entityToFollow;
|
||||||
|
relativeToEntity = entityToFollow == null ? null : this._location.clone().subtract(entityToFollow.getLocation())
|
||||||
|
.toVector();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set who can see the hologram
|
* Set who can see the hologram
|
||||||
*
|
*
|
||||||
@ -368,6 +394,11 @@ public class Hologram
|
|||||||
_makePackets = true;
|
_makePackets = true;
|
||||||
Location oldLocation = getLocation();
|
Location oldLocation = getLocation();
|
||||||
_location = newLocation.clone();
|
_location = newLocation.clone();
|
||||||
|
// TODO Needs to set the new relativeToEntity
|
||||||
|
if (getEntityFollowing() != null)
|
||||||
|
{
|
||||||
|
relativeToEntity = _location.clone().subtract(getEntityFollowing().getLocation()).toVector();
|
||||||
|
}
|
||||||
if (isInUse())
|
if (isInUse())
|
||||||
{
|
{
|
||||||
ArrayList<Player> canSee = getNearbyPlayers();
|
ArrayList<Player> canSee = getNearbyPlayers();
|
||||||
@ -571,11 +602,6 @@ public class Hologram
|
|||||||
return setLocation(getLocation());
|
return setLocation(getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayList<Player> getPlayersTracking()
|
|
||||||
{
|
|
||||||
return _playersTracking;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the hologram
|
* Start the hologram
|
||||||
*/
|
*/
|
||||||
|
@ -11,11 +11,13 @@ import net.minecraft.server.v1_7_R4.Packet;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
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.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;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class HologramManager implements Listener
|
public class HologramManager implements Listener
|
||||||
{
|
{
|
||||||
@ -53,6 +55,18 @@ public class HologramManager implements Listener
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (hologram.getEntityFollowing() != null)
|
||||||
|
{
|
||||||
|
Entity following = hologram.getEntityFollowing();
|
||||||
|
if (!hologram.relativeToEntity.equals(following.getLocation().subtract(hologram.getLocation()).toVector()))
|
||||||
|
{
|
||||||
|
// And we do this so in the rare offchance it changes by a decimal. It doesn't start turning wonky.
|
||||||
|
Vector vec = hologram.relativeToEntity.clone();
|
||||||
|
hologram.setLocation(following.getLocation().add(hologram.relativeToEntity));
|
||||||
|
hologram.relativeToEntity = vec;
|
||||||
|
continue; // No need to do the rest of the code as setLocation does it.
|
||||||
|
}
|
||||||
|
}
|
||||||
ArrayList<Player> canSee = hologram.getNearbyPlayers();
|
ArrayList<Player> canSee = hologram.getNearbyPlayers();
|
||||||
Iterator<Player> itel2 = hologram.getPlayersTracking().iterator();
|
Iterator<Player> itel2 = hologram.getPlayersTracking().iterator();
|
||||||
while (itel2.hasNext())
|
while (itel2.hasNext())
|
||||||
|
@ -0,0 +1,360 @@
|
|||||||
|
package mineplex.core.itemstack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
|
import org.bukkit.potion.Potion;
|
||||||
|
|
||||||
|
public class ItemBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
private static ArrayList<String> split(String string, int maxLength)
|
||||||
|
{
|
||||||
|
String[] split = string.split(" ");
|
||||||
|
string = "";
|
||||||
|
ArrayList<String> newString = new ArrayList<String>();
|
||||||
|
for (int i = 0; i < split.length; i++)
|
||||||
|
{
|
||||||
|
string += (string.length() == 0 ? "" : " ") + split[i];
|
||||||
|
if (ChatColor.stripColor(string).length() > maxLength)
|
||||||
|
{
|
||||||
|
newString
|
||||||
|
.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
|
||||||
|
string = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (string.length() > 0)
|
||||||
|
newString.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
|
||||||
|
return newString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _amount;
|
||||||
|
private Color _color;
|
||||||
|
private short _data;
|
||||||
|
private final HashMap<Enchantment, Integer> _enchants = new HashMap<Enchantment, Integer>();
|
||||||
|
private final List<String> _lore = new ArrayList<String>();
|
||||||
|
private Material _mat;
|
||||||
|
// private Potion potion;
|
||||||
|
private String _title = null;
|
||||||
|
private boolean _unbreakable;
|
||||||
|
|
||||||
|
public ItemBuilder(ItemStack item)
|
||||||
|
{
|
||||||
|
this(item.getType(), item.getDurability());
|
||||||
|
this._amount = item.getAmount();
|
||||||
|
this._enchants.putAll(item.getEnchantments());
|
||||||
|
if (item.getType() == Material.POTION)
|
||||||
|
{
|
||||||
|
// setPotion(Potion.fromItemStack(item));
|
||||||
|
}
|
||||||
|
if (item.hasItemMeta())
|
||||||
|
{
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta.hasDisplayName())
|
||||||
|
{
|
||||||
|
this._title = meta.getDisplayName();
|
||||||
|
}
|
||||||
|
if (meta.hasLore())
|
||||||
|
{
|
||||||
|
this._lore.addAll(meta.getLore());
|
||||||
|
}
|
||||||
|
if (meta instanceof LeatherArmorMeta)
|
||||||
|
{
|
||||||
|
this.setColor(((LeatherArmorMeta) meta).getColor());
|
||||||
|
}
|
||||||
|
this._unbreakable = meta.spigot().isUnbreakable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(Material mat)
|
||||||
|
{
|
||||||
|
this(mat, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(Material mat, int amount)
|
||||||
|
{
|
||||||
|
this(mat, amount, (short) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(Material mat, int amount, short data)
|
||||||
|
{
|
||||||
|
this._mat = mat;
|
||||||
|
this._amount = amount;
|
||||||
|
this._data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(Material mat, short data)
|
||||||
|
{
|
||||||
|
this(mat, 1, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder addEnchantment(Enchantment enchant, int level)
|
||||||
|
{
|
||||||
|
if (_enchants.containsKey(enchant))
|
||||||
|
{
|
||||||
|
_enchants.remove(enchant);
|
||||||
|
}
|
||||||
|
_enchants.put(enchant, level);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder addLore(String... lores)
|
||||||
|
{
|
||||||
|
for (String lore : lores)
|
||||||
|
{
|
||||||
|
this._lore.add(ChatColor.GRAY + lore);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder addLore(String lore, int maxLength)
|
||||||
|
{
|
||||||
|
this._lore.addAll(split(lore, maxLength));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder addLores(List<String> lores)
|
||||||
|
{
|
||||||
|
this._lore.addAll(lores);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder addLores(List<String> lores, int maxLength)
|
||||||
|
{
|
||||||
|
for (String lore : lores)
|
||||||
|
{
|
||||||
|
addLore(lore, maxLength);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder addLores(String[] description, int maxLength)
|
||||||
|
{
|
||||||
|
return addLores(Arrays.asList(description), maxLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack build()
|
||||||
|
{
|
||||||
|
Material mat = this._mat;
|
||||||
|
if (mat == null)
|
||||||
|
{
|
||||||
|
mat = Material.AIR;
|
||||||
|
Bukkit.getLogger().warning("Null material!");
|
||||||
|
}
|
||||||
|
else if (mat == Material.AIR)
|
||||||
|
{
|
||||||
|
Bukkit.getLogger().warning("Air material!");
|
||||||
|
}
|
||||||
|
ItemStack item = new ItemStack(mat, this._amount, this._data);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null)
|
||||||
|
{
|
||||||
|
if (this._title != null)
|
||||||
|
{
|
||||||
|
meta.setDisplayName(this._title);
|
||||||
|
}
|
||||||
|
if (!this._lore.isEmpty())
|
||||||
|
{
|
||||||
|
meta.setLore(this._lore);
|
||||||
|
}
|
||||||
|
if (meta instanceof LeatherArmorMeta)
|
||||||
|
{
|
||||||
|
((LeatherArmorMeta) meta).setColor(this._color);
|
||||||
|
}
|
||||||
|
meta.spigot().setUnbreakable(isUnbreakable());
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
item.addUnsafeEnchantments(this._enchants);
|
||||||
|
// if (this.potion != null) {
|
||||||
|
// this.potion.apply(item);
|
||||||
|
// }
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemBuilder clone()
|
||||||
|
{
|
||||||
|
ItemBuilder newBuilder = new ItemBuilder(this._mat);
|
||||||
|
|
||||||
|
newBuilder.setTitle(this._title);
|
||||||
|
for (String lore : this._lore)
|
||||||
|
{
|
||||||
|
newBuilder.addLore(lore);
|
||||||
|
}
|
||||||
|
for (Map.Entry<Enchantment, Integer> entry : this._enchants.entrySet())
|
||||||
|
{
|
||||||
|
newBuilder.addEnchantment(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
newBuilder.setColor(this._color);
|
||||||
|
// newBuilder.potion = this.potion;
|
||||||
|
|
||||||
|
return newBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Enchantment, Integer> getAllEnchantments()
|
||||||
|
{
|
||||||
|
return this._enchants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getColor()
|
||||||
|
{
|
||||||
|
return this._color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getData()
|
||||||
|
{
|
||||||
|
return this._data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnchantmentLevel(Enchantment enchant)
|
||||||
|
{
|
||||||
|
return this._enchants.get(enchant);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getLore()
|
||||||
|
{
|
||||||
|
return this._lore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return this._title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getType()
|
||||||
|
{
|
||||||
|
return this._mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEnchantment(Enchantment enchant)
|
||||||
|
{
|
||||||
|
return this._enchants.containsKey(enchant);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItem(ItemStack item)
|
||||||
|
{
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (item.getType() != this.getType())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!meta.hasDisplayName() && this.getTitle() != null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!meta.getDisplayName().equals(this.getTitle()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!meta.hasLore() && !this.getLore().isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (meta.hasLore())
|
||||||
|
{
|
||||||
|
for (String lore : meta.getLore())
|
||||||
|
{
|
||||||
|
if (!this.getLore().contains(lore))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Enchantment enchant : item.getEnchantments().keySet())
|
||||||
|
{
|
||||||
|
if (!this.hasEnchantment(enchant))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnbreakable()
|
||||||
|
{
|
||||||
|
return this._unbreakable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setAmount(int amount)
|
||||||
|
{
|
||||||
|
this._amount = amount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setColor(Color color)
|
||||||
|
{
|
||||||
|
if (!this._mat.name().contains("LEATHER_"))
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Can only dye leather armor!");
|
||||||
|
}
|
||||||
|
this._color = color;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(short newData)
|
||||||
|
{
|
||||||
|
this._data = newData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setPotion(Potion potion)
|
||||||
|
{
|
||||||
|
if (this._mat != Material.POTION)
|
||||||
|
{
|
||||||
|
this._mat = Material.POTION;
|
||||||
|
}
|
||||||
|
// this.potion = potion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setRawTitle(String title)
|
||||||
|
{
|
||||||
|
this._title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setTitle(String title)
|
||||||
|
{
|
||||||
|
this._title = (title == null ? null
|
||||||
|
: (title.length() > 2 && ChatColor.getLastColors(title.substring(0, 2)).length() == 0 ? ChatColor.WHITE : ""))
|
||||||
|
+ title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setTitle(String title, int maxLength)
|
||||||
|
{
|
||||||
|
if (title != null && ChatColor.stripColor(title).length() > maxLength)
|
||||||
|
{
|
||||||
|
ArrayList<String> lores = split(title, maxLength);
|
||||||
|
for (int i = 1; i < lores.size(); i++)
|
||||||
|
{
|
||||||
|
this._lore.add(lores.get(i));
|
||||||
|
}
|
||||||
|
title = lores.get(0);
|
||||||
|
}
|
||||||
|
setTitle(title);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setType(Material mat)
|
||||||
|
{
|
||||||
|
this._mat = mat;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder setUnbreakable(boolean setUnbreakable)
|
||||||
|
{
|
||||||
|
this._unbreakable = setUnbreakable;return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package mineplex.core.itemstack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class ItemLayout
|
||||||
|
{
|
||||||
|
|
||||||
|
private int _invSize = 0;
|
||||||
|
private ArrayList<Integer> _size = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
public ItemLayout(String... strings)
|
||||||
|
{
|
||||||
|
_invSize = strings.length * 9;
|
||||||
|
for (int row = 0; row < strings.length; row++)
|
||||||
|
{
|
||||||
|
String string = strings[row];
|
||||||
|
if (string.length() != 9)
|
||||||
|
throw new IllegalArgumentException("String '" + string + "' does not a length of 9 but instead has a length of "
|
||||||
|
+ string.length());
|
||||||
|
char[] cArray = string.toCharArray();
|
||||||
|
for (int slot = 0; slot < 9; slot++)
|
||||||
|
{
|
||||||
|
char letter = cArray[slot];
|
||||||
|
if ('x' == Character.toLowerCase(letter))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if ('o' == Character.toLowerCase(letter))
|
||||||
|
{
|
||||||
|
_size.add((row * 9) + slot);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException("Unrecognised character " + letter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] generate(ArrayList<ItemStack> items)
|
||||||
|
{
|
||||||
|
return generate(items.toArray(new ItemStack[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] generate(ItemStack... items)
|
||||||
|
{
|
||||||
|
return generate(true, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] generate(boolean doRepeats, ItemStack... items)
|
||||||
|
{
|
||||||
|
ItemStack[] itemArray = new ItemStack[_invSize];
|
||||||
|
if (items.length == 0)
|
||||||
|
return itemArray;
|
||||||
|
int i = 0;
|
||||||
|
for (int slot : _size)
|
||||||
|
{
|
||||||
|
if (i < items.length)
|
||||||
|
{
|
||||||
|
if (doRepeats)
|
||||||
|
i = 0;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
itemArray[slot] = items[i];
|
||||||
|
|
||||||
|
}
|
||||||
|
return itemArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -51,4 +51,14 @@ public class PacketHandler extends MiniPlugin
|
|||||||
verifier.addPacketHandler(packetHandler);
|
verifier.addPacketHandler(packetHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removePacketHandler(IPacketHandler packetHandler)
|
||||||
|
{
|
||||||
|
_packetHandlers.remove(packetHandler);
|
||||||
|
|
||||||
|
for (PacketVerifier verifier : _playerVerifierMap.values())
|
||||||
|
{
|
||||||
|
verifier.removePacketHandler(packetHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,4 +88,9 @@ public class PacketVerifier implements IPacketVerifier
|
|||||||
{
|
{
|
||||||
_packetHandlers.add(packetHandler);
|
_packetHandlers.add(packetHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removePacketHandler(IPacketHandler packetHandler)
|
||||||
|
{
|
||||||
|
_packetHandlers.remove(packetHandler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,11 @@ public class SendCommand extends CommandBase<Portal>
|
|||||||
final String playerTarget = args[0];
|
final String playerTarget = args[0];
|
||||||
final String serverTarget = args[1];
|
final String serverTarget = args[1];
|
||||||
|
|
||||||
CommandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback<Boolean>()
|
CommandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback<String>()
|
||||||
{
|
{
|
||||||
public void run(Boolean playerExists)
|
public void run(final String playerName)
|
||||||
{
|
{
|
||||||
if (!playerExists)
|
if (playerName == null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Player " + C.cGold + playerTarget + C.cGray + " does not exist!"));
|
UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Player " + C.cGold + playerTarget + C.cGray + " does not exist!"));
|
||||||
return;
|
return;
|
||||||
@ -50,9 +50,9 @@ public class SendCommand extends CommandBase<Portal>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Portal.transferPlayer(playerTarget, serverTarget);
|
Portal.transferPlayer(playerName, serverTarget);
|
||||||
|
|
||||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "You have sent player: " + C.cGold + playerTarget + C.cGray + " to server: " + C.cGold + serverTarget + C.cGray + "!"));
|
UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "You have sent player: " + C.cGold + playerName + C.cGray + " to server: " + C.cGold + serverTarget + C.cGray + "!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ package mineplex.core.preferences.ui;
|
|||||||
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;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
@ -50,150 +51,90 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
|||||||
_toggleHubGames = new IButton()
|
_toggleHubGames = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleHubGames(player);
|
toggleHubGames((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleHubGames(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleHubPlayers = new IButton()
|
_toggleHubPlayers = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleHubPlayers(player);
|
toggleHubPlayers((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleHubPlayers(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleChat = new IButton()
|
_toggleChat = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleChat(player);
|
toggleChat((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleChat(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_togglePrivateChat = new IButton()
|
_togglePrivateChat = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
togglePrivateChat(player);
|
togglePrivateChat((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
togglePrivateChat(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleHubPartyRequests = new IButton()
|
_toggleHubPartyRequests = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleHubPartyRequests(player);
|
toggleHubPartyRequests((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleHubPartyRequests(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_togglePendingFriendRequests = new IButton()
|
_togglePendingFriendRequests = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
togglePendingFriendRequests(player);
|
togglePendingFriendRequests((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
togglePendingFriendRequests(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleHubInvisibility = new IButton()
|
_toggleHubInvisibility = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleHubInvisibility(player);
|
toggleHubInvisibility((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleHubInvisibility(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleHubForcefield = new IButton()
|
_toggleHubForcefield = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleHubForcefield(player);
|
toggleHubForcefield((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleHubForcefield(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleMacReports = new IButton()
|
_toggleMacReports = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleMacReports(player);
|
toggleMacReports((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleMacReports(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleHubIgnoreVelocity = new IButton()
|
_toggleHubIgnoreVelocity = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
toggleHubIgnoreVelocity(player);
|
toggleHubIgnoreVelocity((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
toggleHubIgnoreVelocity(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,9 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.punish.Category;
|
import mineplex.core.punish.Category;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class PunishButton implements IButton
|
public class PunishButton extends SingleButton
|
||||||
{
|
{
|
||||||
private PunishPage _punishPage;
|
private PunishPage _punishPage;
|
||||||
private Category _category;
|
private Category _category;
|
||||||
@ -23,14 +24,8 @@ public class PunishButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_punishPage.AddInfraction(_category, _severity, _ban, _time);
|
_punishPage.AddInfraction(_category, _severity, _ban, _time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
ClickedLeft(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -416,13 +416,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener
|
|||||||
{
|
{
|
||||||
if (_buttonMap.containsKey(event.getRawSlot()))
|
if (_buttonMap.containsKey(event.getRawSlot()))
|
||||||
{
|
{
|
||||||
if (event.getWhoClicked() instanceof Player)
|
_buttonMap.get(event.getRawSlot()).Clicked(event);
|
||||||
{
|
|
||||||
if (event.isLeftClick())
|
|
||||||
_buttonMap.get(event.getRawSlot()).ClickedLeft((Player)event.getWhoClicked());
|
|
||||||
else if (event.isRightClick())
|
|
||||||
_buttonMap.get(event.getRawSlot()).ClickedRight((Player)event.getWhoClicked());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -3,10 +3,10 @@ package mineplex.core.punish.UI;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.punish.Punishment;
|
import mineplex.core.punish.Punishment;
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
public class RemovePunishmentButton implements IButton
|
public class RemovePunishmentButton extends SingleButton
|
||||||
{
|
{
|
||||||
private PunishPage _punishPage;
|
private PunishPage _punishPage;
|
||||||
private Punishment _punishment;
|
private Punishment _punishment;
|
||||||
@ -20,13 +20,8 @@ public class RemovePunishmentButton implements IButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_punishPage.RemovePunishment(_punishment, _item);
|
_punishPage.RemovePunishment(_punishment, _item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
ClickedLeft(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,24 +11,18 @@ public abstract class Reward
|
|||||||
{
|
{
|
||||||
protected static final Random RANDOM = new Random();
|
protected static final Random RANDOM = new Random();
|
||||||
|
|
||||||
// Reward Manager used to log rewards given to players.
|
|
||||||
private RewardManager _rewardManager;
|
|
||||||
|
|
||||||
private RewardRarity _rarity;
|
private RewardRarity _rarity;
|
||||||
private int _weight;
|
private int _weight;
|
||||||
|
|
||||||
public Reward(RewardManager rewardManager, RewardRarity rarity, int weight)
|
public Reward(RewardRarity rarity, int weight)
|
||||||
{
|
{
|
||||||
_rewardManager = rewardManager;
|
|
||||||
_rarity = rarity;
|
_rarity = rarity;
|
||||||
_weight = weight;
|
_weight = weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final RewardData giveReward(String type, Player player)
|
public final RewardData giveReward(String type, Player player)
|
||||||
{
|
{
|
||||||
RewardData rewardData = giveRewardCustom(player);
|
return giveRewardCustom(player);
|
||||||
_rewardManager.logReward(player, type, getRarity().name(), rewardData.getFriendlyName());
|
|
||||||
return rewardData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract RewardData giveRewardCustom(Player player);
|
protected abstract RewardData giveRewardCustom(Player player);
|
||||||
|
@ -20,13 +20,9 @@ import mineplex.core.reward.rewards.InventoryReward;
|
|||||||
import mineplex.core.reward.rewards.PetReward;
|
import mineplex.core.reward.rewards.PetReward;
|
||||||
import mineplex.core.reward.rewards.UnknownPackageReward;
|
import mineplex.core.reward.rewards.UnknownPackageReward;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by shaun on 2014-09-04.
|
|
||||||
*/
|
|
||||||
public class RewardManager
|
public class RewardManager
|
||||||
{
|
{
|
||||||
private JavaPlugin _plugin;
|
private JavaPlugin _plugin;
|
||||||
private RewardRepository _repository;
|
|
||||||
private HashMap<RewardRarity, List<Reward>> _treasureMap;
|
private HashMap<RewardRarity, List<Reward>> _treasureMap;
|
||||||
private Random _random;
|
private Random _random;
|
||||||
|
|
||||||
@ -40,7 +36,6 @@ public class RewardManager
|
|||||||
boolean doubleGadgetValue)
|
boolean doubleGadgetValue)
|
||||||
{
|
{
|
||||||
_plugin = donationManager.GetPlugin();
|
_plugin = donationManager.GetPlugin();
|
||||||
_repository = new RewardRepository(_plugin);
|
|
||||||
_treasureMap = new HashMap<RewardRarity, List<Reward>>();
|
_treasureMap = new HashMap<RewardRarity, List<Reward>>();
|
||||||
_random = new Random();
|
_random = new Random();
|
||||||
|
|
||||||
@ -62,7 +57,7 @@ public class RewardManager
|
|||||||
RewardRarity rarity = RewardRarity.COMMON;
|
RewardRarity rarity = RewardRarity.COMMON;
|
||||||
|
|
||||||
// Coins
|
// Coins
|
||||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 1, rarity));
|
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1, rarity));
|
||||||
|
|
||||||
//Increase Value
|
//Increase Value
|
||||||
if (_doubleGadgetValue)
|
if (_doubleGadgetValue)
|
||||||
@ -72,31 +67,31 @@ public class RewardManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gadgets
|
// Gadgets
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
||||||
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
||||||
new ItemStack(Material.GOLD_BARDING), rarity, 1));
|
new ItemStack(Material.GOLD_BARDING), rarity, 1));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Fireworks", "Fireworks",
|
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
|
||||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||||
new ItemStack(Material.FIREWORK), rarity, 1));
|
new ItemStack(Material.FIREWORK), rarity, 1));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
||||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||||
new ItemStack(Material.MELON_BLOCK), rarity, 1));
|
new ItemStack(Material.MELON_BLOCK), rarity, 1));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Flesh Hooks", "Flesh Hook",
|
addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook",
|
||||||
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
||||||
new ItemStack(Material.getMaterial(131)), rarity, 1));
|
new ItemStack(Material.getMaterial(131)), rarity, 1));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
||||||
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
||||||
new ItemStack(Material.ENDER_PEARL), rarity, 1));
|
new ItemStack(Material.ENDER_PEARL), rarity, 1));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
||||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||||
new ItemStack(Material.IRON_BARDING), rarity, 1));
|
new ItemStack(Material.IRON_BARDING), rarity, 1));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "TNT", "TNT",
|
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
|
||||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||||
new ItemStack(Material.TNT), rarity, 1));
|
new ItemStack(Material.TNT), rarity, 1));
|
||||||
}
|
}
|
||||||
@ -106,7 +101,7 @@ public class RewardManager
|
|||||||
RewardRarity rarity = RewardRarity.UNCOMMON;
|
RewardRarity rarity = RewardRarity.UNCOMMON;
|
||||||
|
|
||||||
// Coins
|
// Coins
|
||||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
|
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
|
||||||
|
|
||||||
//Increase Value
|
//Increase Value
|
||||||
if (_doubleGadgetValue)
|
if (_doubleGadgetValue)
|
||||||
@ -116,74 +111,74 @@ public class RewardManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gadgets
|
// Gadgets
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
||||||
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
||||||
new ItemStack(Material.GOLD_BARDING), rarity, 250));
|
new ItemStack(Material.GOLD_BARDING), rarity, 250));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Fireworks", "Fireworks",
|
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
|
||||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||||
new ItemStack(Material.FIREWORK), rarity, 250));
|
new ItemStack(Material.FIREWORK), rarity, 250));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
||||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||||
new ItemStack(Material.MELON_BLOCK), rarity, 250));
|
new ItemStack(Material.MELON_BLOCK), rarity, 250));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Flesh Hook Ammo", "Flesh Hook",
|
addReward(new InventoryReward(inventoryManager, "Flesh Hook Ammo", "Flesh Hook",
|
||||||
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
||||||
new ItemStack(Material.getMaterial(131)), rarity, 250));
|
new ItemStack(Material.getMaterial(131)), rarity, 250));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
||||||
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
||||||
new ItemStack(Material.ENDER_PEARL), rarity, 250));
|
new ItemStack(Material.ENDER_PEARL), rarity, 250));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
||||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||||
new ItemStack(Material.IRON_BARDING), rarity, 250));
|
new ItemStack(Material.IRON_BARDING), rarity, 250));
|
||||||
|
|
||||||
addReward(new InventoryReward(this, inventoryManager, "TNT", "TNT",
|
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
|
||||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||||
new ItemStack(Material.TNT), rarity, 250));
|
new ItemStack(Material.TNT), rarity, 250));
|
||||||
|
|
||||||
// Pets
|
// Pets
|
||||||
addReward(new PetReward(petManager, inventoryManager, this, donationManager, "Cow Pet", "Cow",
|
addReward(new PetReward(petManager, inventoryManager, donationManager, "Cow Pet", "Cow",
|
||||||
EntityType.COW, rarity, 500));
|
EntityType.COW, rarity, 500));
|
||||||
addReward(new PetReward(petManager, inventoryManager, this, donationManager, "Sheep Pet", "Sheep",
|
addReward(new PetReward(petManager, inventoryManager, donationManager, "Sheep Pet", "Sheep",
|
||||||
EntityType.SHEEP, rarity, 333));
|
EntityType.SHEEP, rarity, 333));
|
||||||
addReward(new PetReward(petManager, inventoryManager, this, donationManager, "Mooshroom Pet", "Mooshroom",
|
addReward(new PetReward(petManager, inventoryManager, donationManager, "Mooshroom Pet", "Mooshroom",
|
||||||
EntityType.MUSHROOM_COW, rarity, 200));
|
EntityType.MUSHROOM_COW, rarity, 200));
|
||||||
addReward(new PetReward(petManager, inventoryManager, this, donationManager, "Pig Pet", "Pig",
|
addReward(new PetReward(petManager, inventoryManager, donationManager, "Pig Pet", "Pig",
|
||||||
EntityType.PIG, rarity, 200));
|
EntityType.PIG, rarity, 200));
|
||||||
addReward(new PetReward(petManager, inventoryManager, this, donationManager, "Ocelot Pet", "Cat",
|
addReward(new PetReward(petManager, inventoryManager, donationManager, "Ocelot Pet", "Cat",
|
||||||
EntityType.OCELOT, rarity, 167));
|
EntityType.OCELOT, rarity, 167));
|
||||||
addReward(new PetReward(petManager, inventoryManager, this, donationManager, "Chicken Pet", "Chicken",
|
addReward(new PetReward(petManager, inventoryManager, donationManager, "Chicken Pet", "Chicken",
|
||||||
EntityType.CHICKEN, rarity, 143));
|
EntityType.CHICKEN, rarity, 143));
|
||||||
addReward(new PetReward(petManager, inventoryManager, this, donationManager, "Wolf Pet", "Dog",
|
addReward(new PetReward(petManager, inventoryManager, donationManager, "Wolf Pet", "Dog",
|
||||||
EntityType.WOLF, rarity, 125));
|
EntityType.WOLF, rarity, 125));
|
||||||
|
|
||||||
// Music Discs
|
// Music Discs
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "13 Disc", "13 Disc",
|
addReward(new UnknownPackageReward(donationManager, "13 Disc", "13 Disc",
|
||||||
new ItemStack(2256), rarity, 25));
|
new ItemStack(2256), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Cat Disc", "Cat Disc",
|
addReward(new UnknownPackageReward(donationManager, "Cat Disc", "Cat Disc",
|
||||||
new ItemStack(2257), rarity, 25));
|
new ItemStack(2257), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Blocks Disc", "Blocks Disc",
|
addReward(new UnknownPackageReward(donationManager, "Blocks Disc", "Blocks Disc",
|
||||||
new ItemStack(2258), rarity, 25));
|
new ItemStack(2258), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Chirp Disc", "Chirp Disc",
|
addReward(new UnknownPackageReward(donationManager, "Chirp Disc", "Chirp Disc",
|
||||||
new ItemStack(2259), rarity, 25));
|
new ItemStack(2259), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Far Disc", "Far Disc",
|
addReward(new UnknownPackageReward(donationManager, "Far Disc", "Far Disc",
|
||||||
new ItemStack(2260), rarity, 25));
|
new ItemStack(2260), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Mall Disc", "Mall Disc",
|
addReward(new UnknownPackageReward(donationManager, "Mall Disc", "Mall Disc",
|
||||||
new ItemStack(2261), rarity, 25));
|
new ItemStack(2261), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Mellohi Disc", "Mellohi Disc",
|
addReward(new UnknownPackageReward(donationManager, "Mellohi Disc", "Mellohi Disc",
|
||||||
new ItemStack(2262), rarity, 25));
|
new ItemStack(2262), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Stal Disc", "Stal Disc",
|
addReward(new UnknownPackageReward(donationManager, "Stal Disc", "Stal Disc",
|
||||||
new ItemStack(2263), rarity, 25));
|
new ItemStack(2263), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Strad Disc", "Strad Disc",
|
addReward(new UnknownPackageReward(donationManager, "Strad Disc", "Strad Disc",
|
||||||
new ItemStack(2264), rarity, 25));
|
new ItemStack(2264), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Ward Disc", "Ward Disc",
|
addReward(new UnknownPackageReward(donationManager, "Ward Disc", "Ward Disc",
|
||||||
new ItemStack(2265), rarity, 25));
|
new ItemStack(2265), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "11 Disc", "11 Disc",
|
addReward(new UnknownPackageReward(donationManager, "11 Disc", "11 Disc",
|
||||||
new ItemStack(2266), rarity, 25));
|
new ItemStack(2266), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Wait Disc", "Wait Disc",
|
addReward(new UnknownPackageReward(donationManager, "Wait Disc", "Wait Disc",
|
||||||
new ItemStack(2267), rarity, 25));
|
new ItemStack(2267), rarity, 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,49 +187,49 @@ public class RewardManager
|
|||||||
RewardRarity rarity = RewardRarity.RARE;
|
RewardRarity rarity = RewardRarity.RARE;
|
||||||
|
|
||||||
// Coins
|
// Coins
|
||||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
|
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
|
||||||
|
|
||||||
// Mounts
|
// Mounts
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Mount Mule", "Mount Mule",
|
addReward(new UnknownPackageReward(donationManager, "Mount Mule", "Mount Mule",
|
||||||
new ItemStack(Material.HAY_BLOCK), rarity, 200));
|
new ItemStack(Material.HAY_BLOCK), rarity, 200));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Minecart Mount", "Minecart",
|
addReward(new UnknownPackageReward(donationManager, "Minecart Mount", "Minecart",
|
||||||
new ItemStack(Material.MINECART), rarity, 100));
|
new ItemStack(Material.MINECART), rarity, 100));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Slime Mount", "Slime Mount",
|
addReward(new UnknownPackageReward(donationManager, "Slime Mount", "Slime Mount",
|
||||||
new ItemStack(Material.SLIME_BALL), rarity, 67));
|
new ItemStack(Material.SLIME_BALL), rarity, 67));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Glacial Steed", "Glacial Steed",
|
addReward(new UnknownPackageReward(donationManager, "Glacial Steed", "Glacial Steed",
|
||||||
new ItemStack(Material.SNOW_BALL), rarity, 50));
|
new ItemStack(Material.SNOW_BALL), rarity, 50));
|
||||||
|
|
||||||
// Morphs
|
// Morphs
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Cow Morph", "Cow Morph",
|
addReward(new UnknownPackageReward(donationManager, "Cow Morph", "Cow Morph",
|
||||||
new ItemStack(Material.LEATHER), rarity, 167));
|
new ItemStack(Material.LEATHER), rarity, 167));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Villager Morph", "Villager Morph",
|
addReward(new UnknownPackageReward(donationManager, "Villager Morph", "Villager Morph",
|
||||||
new ItemStack(Material.EMERALD), rarity, 83));
|
new ItemStack(Material.EMERALD), rarity, 83));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Chicken Morph", "Chicken Morph",
|
addReward(new UnknownPackageReward(donationManager, "Chicken Morph", "Chicken Morph",
|
||||||
new ItemStack(Material.FEATHER), rarity, 50));
|
new ItemStack(Material.FEATHER), rarity, 50));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Enderman Morph", "Enderman Morph",
|
addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph",
|
||||||
new ItemStack(Material.ENDER_PEARL), rarity, 33));
|
new ItemStack(Material.ENDER_PEARL), rarity, 33));
|
||||||
|
|
||||||
|
|
||||||
// Gadgets
|
// Gadgets
|
||||||
addReward(new InventoryReward(this, inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1,
|
addReward(new InventoryReward(inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1,
|
||||||
new ItemStack(Material.getMaterial(175)), rarity, 100));
|
new ItemStack(Material.getMaterial(175)), rarity, 100));
|
||||||
|
|
||||||
// Costumes
|
// Costumes
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Rave Hat", "Rave Hat",
|
addReward(new UnknownPackageReward(donationManager, "Rave Hat", "Rave Hat",
|
||||||
new ItemStack(Material.LEATHER_HELMET), rarity, 30));
|
new ItemStack(Material.LEATHER_HELMET), rarity, 30));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Rave Shirt", "Rave Shirt",
|
addReward(new UnknownPackageReward(donationManager, "Rave Shirt", "Rave Shirt",
|
||||||
new ItemStack(Material.LEATHER_CHESTPLATE), rarity, 30));
|
new ItemStack(Material.LEATHER_CHESTPLATE), rarity, 30));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Rave Pants", "Rave Pants",
|
addReward(new UnknownPackageReward(donationManager, "Rave Pants", "Rave Pants",
|
||||||
new ItemStack(Material.LEATHER_LEGGINGS), rarity, 30));
|
new ItemStack(Material.LEATHER_LEGGINGS), rarity, 30));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Rave Boots", "Rave Boots",
|
addReward(new UnknownPackageReward(donationManager, "Rave Boots", "Rave Boots",
|
||||||
new ItemStack(Material.LEATHER_BOOTS), rarity, 30));
|
new ItemStack(Material.LEATHER_BOOTS), rarity, 30));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Space Helmet", "Space Helmet",
|
addReward(new UnknownPackageReward(donationManager, "Space Helmet", "Space Helmet",
|
||||||
new ItemStack(Material.GLASS), rarity, 50));
|
new ItemStack(Material.GLASS), rarity, 50));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Space Jacket", "Space Jacket",
|
addReward(new UnknownPackageReward(donationManager, "Space Jacket", "Space Jacket",
|
||||||
new ItemStack(Material.GOLD_CHESTPLATE), rarity, 50));
|
new ItemStack(Material.GOLD_CHESTPLATE), rarity, 50));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Space Pants", "Space Pants",
|
addReward(new UnknownPackageReward(donationManager, "Space Pants", "Space Pants",
|
||||||
new ItemStack(Material.GOLD_LEGGINGS), rarity, 50));
|
new ItemStack(Material.GOLD_LEGGINGS), rarity, 50));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Space Boots", "Space Boots",
|
addReward(new UnknownPackageReward(donationManager, "Space Boots", "Space Boots",
|
||||||
new ItemStack(Material.GOLD_BOOTS), rarity, 50));
|
new ItemStack(Material.GOLD_BOOTS), rarity, 50));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -244,34 +239,34 @@ public class RewardManager
|
|||||||
RewardRarity rarity = RewardRarity.LEGENDARY;
|
RewardRarity rarity = RewardRarity.LEGENDARY;
|
||||||
|
|
||||||
// Coins
|
// Coins
|
||||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY));
|
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY));
|
||||||
|
|
||||||
// Mounts
|
// Mounts
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Infernal Horror", "Infernal Horror",
|
addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror",
|
||||||
new ItemStack(Material.BONE), rarity, 33));
|
new ItemStack(Material.BONE), rarity, 33));
|
||||||
|
|
||||||
// Morphs
|
// Morphs
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Bat Morph", "Bat Morph",
|
addReward(new UnknownPackageReward(donationManager, "Bat Morph", "Bat Morph",
|
||||||
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), rarity, 25));
|
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Block Morph", "Block Morph",
|
addReward(new UnknownPackageReward(donationManager, "Block Morph", "Block Morph",
|
||||||
new ItemStack(Material.EMERALD_BLOCK), rarity, 20));
|
new ItemStack(Material.EMERALD_BLOCK), rarity, 20));
|
||||||
|
|
||||||
// Particles
|
// Particles
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Shadow Walk Particles", "Shadow Walk",
|
addReward(new UnknownPackageReward(donationManager, "Shadow Walk Particles", "Shadow Walk",
|
||||||
new ItemStack(Material.LEATHER_BOOTS), rarity, 33));
|
new ItemStack(Material.LEATHER_BOOTS), rarity, 33));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Enchanted Particles", "Enchanted",
|
addReward(new UnknownPackageReward(donationManager, "Enchanted Particles", "Enchanted",
|
||||||
new ItemStack(Material.BOOK), rarity, 25));
|
new ItemStack(Material.BOOK), rarity, 25));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Flame Rings Particles", "Flame Rings",
|
addReward(new UnknownPackageReward(donationManager, "Flame Rings Particles", "Flame Rings",
|
||||||
new ItemStack(Material.BLAZE_POWDER), rarity, 17));
|
new ItemStack(Material.BLAZE_POWDER), rarity, 17));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Rain Cloud Particles", "Rain Cloud",
|
addReward(new UnknownPackageReward(donationManager, "Rain Cloud Particles", "Rain Cloud",
|
||||||
new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), rarity, 13));
|
new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), rarity, 13));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Blood Helix Particles", "Blood Helix",
|
addReward(new UnknownPackageReward(donationManager, "Blood Helix Particles", "Blood Helix",
|
||||||
new ItemStack(Material.REDSTONE), rarity, 10));
|
new ItemStack(Material.REDSTONE), rarity, 10));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Emerald Twirl Particles", "Green Ring",
|
addReward(new UnknownPackageReward(donationManager, "Emerald Twirl Particles", "Green Ring",
|
||||||
new ItemStack(Material.EMERALD), rarity, 8));
|
new ItemStack(Material.EMERALD), rarity, 8));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Flame Fairy Particles", "Flame Fairy",
|
addReward(new UnknownPackageReward(donationManager, "Flame Fairy Particles", "Flame Fairy",
|
||||||
new ItemStack(Material.APPLE), rarity, 4));
|
new ItemStack(Material.APPLE), rarity, 4));
|
||||||
addReward(new UnknownPackageReward(this, donationManager, "Heart Particles", "I Heart You",
|
addReward(new UnknownPackageReward(donationManager, "Heart Particles", "I Heart You",
|
||||||
new ItemStack(Material.BLAZE_POWDER), rarity, 2));
|
new ItemStack(Material.BLAZE_POWDER), rarity, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,18 +389,4 @@ public class RewardManager
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logReward(final Player player, final String type, final String rarity, final String reward)
|
|
||||||
{
|
|
||||||
final String parsedReward = ChatColor.stripColor(reward);
|
|
||||||
|
|
||||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
_repository.logReward(player, type, rarity, parsedReward);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
package mineplex.core.reward;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import mineplex.core.database.RepositoryBase;
|
|
||||||
import mineplex.database.Tables;
|
|
||||||
import org.jooq.DSLContext;
|
|
||||||
import org.jooq.impl.DSL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by shaun on 14-09-18.
|
|
||||||
*/
|
|
||||||
public class RewardRepository extends RepositoryBase
|
|
||||||
{
|
|
||||||
public RewardRepository(JavaPlugin plugin)
|
|
||||||
{
|
|
||||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initialize()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logReward(Player player, String type, String rarity, String reward)
|
|
||||||
{
|
|
||||||
DSLContext context;
|
|
||||||
|
|
||||||
synchronized (this)
|
|
||||||
{
|
|
||||||
context = DSL.using(getConnection());
|
|
||||||
}
|
|
||||||
|
|
||||||
context.insertInto(Tables.rewardLog)
|
|
||||||
.set(Tables.rewardLog.accountId, DSL.select(Tables.accounts.id)
|
|
||||||
.from(Tables.accounts)
|
|
||||||
.where(Tables.accounts.uuid.eq(player.getUniqueId().toString())))
|
|
||||||
.set(Tables.rewardLog.date, DSL.currentTimestamp())
|
|
||||||
.set(Tables.rewardLog.type, type)
|
|
||||||
.set(Tables.rewardLog.rarity, rarity)
|
|
||||||
.set(Tables.rewardLog.reward, reward)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,14 +26,14 @@ public class CoinReward extends Reward
|
|||||||
private int _minCoinCount;
|
private int _minCoinCount;
|
||||||
private int _maxCoinCount;
|
private int _maxCoinCount;
|
||||||
|
|
||||||
public CoinReward(RewardManager rewardManager, DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity)
|
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity)
|
||||||
{
|
{
|
||||||
this(rewardManager, donationManager, minCoinCount, maxCoinCount, weight, rarity, RANDOM);
|
this(donationManager, minCoinCount, maxCoinCount, weight, rarity, RANDOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoinReward(RewardManager rewardManager, DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
|
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
|
||||||
{
|
{
|
||||||
super(rewardManager, rarity, weight);
|
super(rarity, weight);
|
||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
_minCoinCount = minCoinCount;
|
_minCoinCount = minCoinCount;
|
||||||
_maxCoinCount = maxCoinCount;
|
_maxCoinCount = maxCoinCount;
|
||||||
|
@ -25,14 +25,14 @@ public class InventoryReward extends Reward
|
|||||||
private int _minAmount;
|
private int _minAmount;
|
||||||
private int _maxAmount;
|
private int _maxAmount;
|
||||||
|
|
||||||
public InventoryReward(RewardManager rewardManager, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
public InventoryReward(InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||||
{
|
{
|
||||||
this(RANDOM, rewardManager, inventoryManager, name, packageName, minAmount, maxAmount, itemStack, rarity, weight);
|
this(RANDOM, inventoryManager, name, packageName, minAmount, maxAmount, itemStack, rarity, weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryReward(Random random, RewardManager rewardManager, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
public InventoryReward(Random random, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||||
{
|
{
|
||||||
super(rewardManager, rarity, weight);
|
super(rarity, weight);
|
||||||
|
|
||||||
_random = random;
|
_random = random;
|
||||||
_name = name;
|
_name = name;
|
||||||
|
@ -23,9 +23,10 @@ public class PetReward extends UnknownPackageReward
|
|||||||
private PetManager _petManager;
|
private PetManager _petManager;
|
||||||
private EntityType _petEntity;
|
private EntityType _petEntity;
|
||||||
|
|
||||||
public PetReward(PetManager petManager, InventoryManager inventoryManager, RewardManager rewardManager, DonationManager donationManager, String name, String packageName, EntityType petEntity, RewardRarity rarity, int weight)
|
public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, EntityType petEntity, RewardRarity rarity, int weight)
|
||||||
{
|
{
|
||||||
super(rewardManager, donationManager, name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petEntity.getTypeId()), rarity, weight);
|
super(donationManager, name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petEntity.getTypeId()), rarity, weight);
|
||||||
|
|
||||||
_petManager = petManager;
|
_petManager = petManager;
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
_petEntity = petEntity;
|
_petEntity = petEntity;
|
||||||
|
@ -19,9 +19,9 @@ public class UnknownPackageReward extends Reward
|
|||||||
private String _name;
|
private String _name;
|
||||||
private String _packageName;
|
private String _packageName;
|
||||||
|
|
||||||
public UnknownPackageReward(RewardManager rewardManager, DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight)
|
public UnknownPackageReward(DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||||
{
|
{
|
||||||
super(rewardManager, rarity, weight);
|
super(rarity, weight);
|
||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
_name = name;
|
_name = name;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
|
@ -5,7 +5,11 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -212,6 +216,13 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
|||||||
|
|
||||||
SetCurrentPageForPlayer(player, page);
|
SetCurrentPageForPlayer(player, page);
|
||||||
|
|
||||||
|
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
if (nmsPlayer.activeContainer != nmsPlayer.defaultContainer)
|
||||||
|
{
|
||||||
|
// Do this so that other inventories know their time is over.
|
||||||
|
CraftEventFactory.handleInventoryCloseEvent(nmsPlayer);
|
||||||
|
nmsPlayer.m();
|
||||||
|
}
|
||||||
player.openInventory(page);
|
player.openInventory(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package mineplex.core.shop.item;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
|
public abstract class ComplexButton implements IButton
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void Clicked(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
if (event.isLeftClick())
|
||||||
|
{
|
||||||
|
if (event.isShiftClick())
|
||||||
|
ClickedShiftLeft((Player) event.getWhoClicked());
|
||||||
|
else
|
||||||
|
ClickedLeft((Player) event.getWhoClicked());
|
||||||
|
}
|
||||||
|
if (event.isRightClick())
|
||||||
|
{
|
||||||
|
if (event.isShiftClick())
|
||||||
|
ClickedShiftRight((Player) event.getWhoClicked());
|
||||||
|
else
|
||||||
|
ClickedRight((Player) event.getWhoClicked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void ClickedLeft(Player player);
|
||||||
|
public abstract void ClickedShiftLeft(Player player);
|
||||||
|
public abstract void ClickedRight(Player player);
|
||||||
|
public abstract void ClickedShiftRight(Player player);
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package mineplex.core.shop.item;
|
package mineplex.core.shop.item;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
public interface IButton
|
public interface IButton
|
||||||
{
|
{
|
||||||
public void ClickedLeft(Player player);
|
public void Clicked(InventoryClickEvent event);
|
||||||
public void ClickedRight(Player player);
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package mineplex.core.shop.item;
|
package mineplex.core.shop.item;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagList;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagString;
|
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
|
||||||
public class ShopItem extends CraftItemStack
|
public class ShopItem extends ItemStack
|
||||||
{
|
{
|
||||||
protected String _name;
|
protected String _name;
|
||||||
private String _deliveryName;
|
private String _deliveryName;
|
||||||
@ -26,13 +27,16 @@ public class ShopItem extends CraftItemStack
|
|||||||
_deliveryName = deliveryName;
|
_deliveryName = deliveryName;
|
||||||
_displayItem = displayItem;
|
_displayItem = displayItem;
|
||||||
_deliveryAmount = deliveryAmount;
|
_deliveryAmount = deliveryAmount;
|
||||||
|
if (itemStack.getItemMeta().hasLore())
|
||||||
_lore = itemStack.getItemMeta().getLore().toArray(new String[0]);
|
_lore = itemStack.getItemMeta().getLore().toArray(new String[0]);
|
||||||
|
else
|
||||||
CraftItemStack craftItem = CraftItemStack.asCraftCopy(itemStack);
|
_lore = new String[0];
|
||||||
getHandle().tag = craftItem.getHandle().tag;
|
|
||||||
|
|
||||||
UpdateVisual(true);
|
UpdateVisual(true);
|
||||||
getHandle().tag.set("AttributeModifiers", new NBTTagList());
|
}
|
||||||
|
|
||||||
|
public net.minecraft.server.v1_7_R4.ItemStack getHandle() {
|
||||||
|
return CraftItemStack.asNMSCopy(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopItem(Material type, String name, int deliveryAmount, boolean locked)
|
public ShopItem(Material type, String name, int deliveryAmount, boolean locked)
|
||||||
@ -93,8 +97,7 @@ public class ShopItem extends CraftItemStack
|
|||||||
|
|
||||||
UpdateVisual(false);
|
UpdateVisual(false);
|
||||||
|
|
||||||
getHandle().tag.setByte("Count", (byte)Math.max(deliveryAmount, 1));
|
setAmount(Math.max(deliveryAmount, 1));
|
||||||
getHandle().tag.set("AttributeModifiers", new NBTTagList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean IsLocked()
|
public boolean IsLocked()
|
||||||
@ -108,7 +111,11 @@ public class ShopItem extends CraftItemStack
|
|||||||
|
|
||||||
//Delivery Name
|
//Delivery Name
|
||||||
if (_deliveryName != null)
|
if (_deliveryName != null)
|
||||||
this.getHandle().c(_deliveryName);
|
{
|
||||||
|
ItemMeta meta = getItemMeta();
|
||||||
|
meta.setDisplayName(_deliveryName);
|
||||||
|
setItemMeta(meta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopItem clone()
|
public ShopItem clone()
|
||||||
@ -119,43 +126,30 @@ public class ShopItem extends CraftItemStack
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if (!super.equals(obj))
|
return super.equals(obj);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
net.minecraft.server.v1_7_R4.ItemStack original = ((CraftItemStack)this).getHandle();
|
|
||||||
net.minecraft.server.v1_7_R4.ItemStack comparison = ((CraftItemStack)obj).getHandle();
|
|
||||||
|
|
||||||
return original.tag == null || original.tag.equals(comparison.tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UpdateVisual(boolean clone)
|
protected void UpdateVisual(boolean clone)
|
||||||
{
|
{
|
||||||
|
ItemMeta meta = getItemMeta();
|
||||||
if (!clone)
|
if (!clone)
|
||||||
{
|
{
|
||||||
if (_locked && !_displayItem)
|
meta.setDisplayName((_locked && !_displayItem? C.cRed:C.cGreen) + C.Bold + _name);
|
||||||
{
|
|
||||||
this.getHandle().c(ChatColor.RED + "§l" + _name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.getHandle().c(ChatColor.GREEN + "§l" + _name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagList lore = new NBTTagList();
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
|
||||||
if (_lore != null)
|
if (_lore != null)
|
||||||
{
|
{
|
||||||
for (String line : _lore)
|
for (String line : _lore)
|
||||||
{
|
{
|
||||||
if (line != null && !line.isEmpty())
|
if (line != null && !line.isEmpty())
|
||||||
lore.add(new NBTTagString(line));
|
lore.add(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
meta.setLore(lore);;
|
||||||
|
|
||||||
getHandle().tag.getCompound("display").set("Lore", lore);
|
setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean IsDisplay()
|
public boolean IsDisplay()
|
||||||
@ -188,17 +182,19 @@ public class ShopItem extends CraftItemStack
|
|||||||
{
|
{
|
||||||
_lore = string;
|
_lore = string;
|
||||||
|
|
||||||
NBTTagList lore = new NBTTagList();
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
|
||||||
if (_lore != null)
|
if (_lore != null)
|
||||||
{
|
{
|
||||||
for (String line : _lore)
|
for (String line : _lore)
|
||||||
{
|
{
|
||||||
if (line != null && !line.isEmpty())
|
if (line != null && !line.isEmpty())
|
||||||
lore.add(new NBTTagString(line));
|
lore.add(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getHandle().tag.getCompound("display").set("Lore", lore);
|
ItemMeta meta = getItemMeta();
|
||||||
|
meta.setLore(lore);
|
||||||
|
setItemMeta(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
package mineplex.core.shop.item;
|
package mineplex.core.shop.item;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
public abstract class SingleButton implements IButton
|
public abstract class SingleButton implements IButton
|
||||||
{
|
{
|
||||||
public abstract void Clicked(Player player);
|
public abstract void Clicked(Player player);
|
||||||
|
|
||||||
public void ClickedLeft(Player player)
|
@Override
|
||||||
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
Clicked(player);
|
Clicked((Player)event.getWhoClicked());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
Clicked(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,13 @@ import mineplex.core.common.util.C;
|
|||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends ShopPageBase<PluginType, ShopType> implements Runnable
|
public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends ShopPageBase<PluginType, ShopType> implements Runnable
|
||||||
{
|
{
|
||||||
@ -59,30 +61,18 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
|||||||
IButton okClicked = new IButton()
|
IButton okClicked = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
OkClicked(player);
|
OkClicked((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
OkClicked(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IButton cancelClicked = new IButton()
|
IButton cancelClicked = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
CancelClicked(player);
|
CancelClicked((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
CancelClicked(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -201,15 +191,9 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
|||||||
IButton returnButton = new IButton()
|
IButton returnButton = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
CancelClicked(player);
|
CancelClicked((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
CancelClicked(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -227,15 +211,9 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
|||||||
IButton returnButton = new IButton()
|
IButton returnButton = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void ClickedLeft(Player player)
|
public void Clicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
CancelClicked(player);
|
CancelClicked((Player)event.getWhoClicked());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ClickedRight(Player player)
|
|
||||||
{
|
|
||||||
CancelClicked(player);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
@ -14,6 +15,7 @@ import mineplex.core.account.CoreClientManager;
|
|||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.ShopBase;
|
import mineplex.core.shop.ShopBase;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
@ -114,10 +116,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
|||||||
{
|
{
|
||||||
if (ButtonMap.containsKey(event.getRawSlot()))
|
if (ButtonMap.containsKey(event.getRawSlot()))
|
||||||
{
|
{
|
||||||
if (event.isLeftClick())
|
ButtonMap.get(event.getRawSlot()).Clicked(event);
|
||||||
ButtonMap.get(event.getRawSlot()).ClickedLeft(Player);
|
|
||||||
if (event.isRightClick())
|
|
||||||
ButtonMap.get(event.getRawSlot()).ClickedRight(Player);
|
|
||||||
}
|
}
|
||||||
else if (event.getRawSlot() != -999)
|
else if (event.getRawSlot() != -999)
|
||||||
{
|
{
|
||||||
@ -175,4 +174,24 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
|||||||
{
|
{
|
||||||
setItem(column + (row * 9), itemStack);
|
setItem(column + (row * 9), itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShopType getShop()
|
||||||
|
{
|
||||||
|
return Shop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginType getPlugin()
|
||||||
|
{
|
||||||
|
return Plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreClientManager getClientManager()
|
||||||
|
{
|
||||||
|
return ClientManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DonationManager getDonationManager()
|
||||||
|
{
|
||||||
|
return DonationManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
package mineplex.core.spawn;
|
package mineplex.core.spawn;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -26,13 +19,20 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class Spawn extends MiniPlugin
|
public class Spawn extends MiniPlugin
|
||||||
{
|
{
|
||||||
public ArrayList<Location> spawnList;
|
private SpawnRepository _repository;
|
||||||
|
|
||||||
public Spawn(JavaPlugin plugin)
|
private List<Location> _spawns = new ArrayList<Location>();
|
||||||
|
|
||||||
|
public Spawn(JavaPlugin plugin, String serverName)
|
||||||
{
|
{
|
||||||
super("Spawn", plugin);
|
super("Spawn", plugin);
|
||||||
|
|
||||||
ReadSpawns();
|
_repository = new SpawnRepository(plugin, serverName);
|
||||||
|
|
||||||
|
for (String spawn : _repository.retrieveSpawns())
|
||||||
|
{
|
||||||
|
_spawns.add(UtilWorld.strToLoc(spawn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,25 +43,31 @@ public class Spawn extends MiniPlugin
|
|||||||
|
|
||||||
public Location getSpawn()
|
public Location getSpawn()
|
||||||
{
|
{
|
||||||
if (spawnList.isEmpty())
|
if (_spawns.isEmpty())
|
||||||
return UtilServer.getServer().getWorld("world").getSpawnLocation();
|
return UtilServer.getServer().getWorld("world").getSpawnLocation();
|
||||||
|
|
||||||
return spawnList.get(UtilMath.r(spawnList.size()));
|
return _spawns.get(UtilMath.r(_spawns.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSpawn(Player player)
|
public void AddSpawn(Player player)
|
||||||
{
|
{
|
||||||
//Set Spawn Point
|
//Set Spawn Point
|
||||||
Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
|
|
||||||
//Set World Spawn
|
//Set World Spawn
|
||||||
player.getWorld().setSpawnLocation((int)loc.getX(), (int)loc.getY(), (int)loc.getZ());
|
player.getWorld().setSpawnLocation((int)loc.getX(), (int)loc.getY(), (int)loc.getZ());
|
||||||
|
|
||||||
//Add Spawn
|
//Add Spawn
|
||||||
spawnList.add(loc);
|
_spawns.add(loc);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
WriteSpawns();
|
runAsync(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
_repository.addSpawn(UtilWorld.locToStr(loc));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(player, F.main(_moduleName, "You added a Spawn Node."));
|
UtilPlayer.message(player, F.main(_moduleName, "You added a Spawn Node."));
|
||||||
@ -73,10 +79,16 @@ public class Spawn extends MiniPlugin
|
|||||||
public void ClearSpawn(Player player)
|
public void ClearSpawn(Player player)
|
||||||
{
|
{
|
||||||
//Add Spawn
|
//Add Spawn
|
||||||
spawnList.clear();
|
_spawns.clear();
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
WriteSpawns();
|
runAsync(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
_repository.clearSpawns();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(player, F.main(_moduleName, "You cleared all Spawn Nodes."));
|
UtilPlayer.message(player, F.main(_moduleName, "You cleared all Spawn Nodes."));
|
||||||
@ -90,132 +102,4 @@ public class Spawn extends MiniPlugin
|
|||||||
{
|
{
|
||||||
event.setRespawnLocation(getSpawn());
|
event.setRespawnLocation(getSpawn());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadSpawns()
|
|
||||||
{
|
|
||||||
spawnList = new ArrayList<Location>();
|
|
||||||
|
|
||||||
FileInputStream fstream = null;
|
|
||||||
DataInputStream in = null;
|
|
||||||
BufferedReader br = null;
|
|
||||||
|
|
||||||
if (!new File("data/spawns.dat").exists())
|
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fstream = new FileInputStream("data/spawns.dat");
|
|
||||||
in = new DataInputStream(fstream);
|
|
||||||
br = new BufferedReader(new InputStreamReader(in));
|
|
||||||
String strLine = br.readLine();
|
|
||||||
|
|
||||||
while (strLine != null)
|
|
||||||
{
|
|
||||||
System.out.println(strLine);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Location spawn = UtilWorld.strToLoc(strLine);
|
|
||||||
spawnList.add(spawn);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
strLine = br.readLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.err.println("Spawn Read Error: " + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (br != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
br.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fstream != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fstream.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WriteSpawns()
|
|
||||||
{
|
|
||||||
FileWriter fstream = null;
|
|
||||||
BufferedWriter out = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fstream = new FileWriter("data/spawns.dat");
|
|
||||||
out = new BufferedWriter(fstream);
|
|
||||||
|
|
||||||
for (Location loc : spawnList)
|
|
||||||
{
|
|
||||||
out.write(UtilWorld.locToStr(loc) + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.err.println("Spawn Write Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (out != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fstream != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fstream.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package mineplex.core.spawn;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.database.RepositoryBase;
|
||||||
|
import mineplex.core.database.ResultSetCallable;
|
||||||
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
|
||||||
|
public class SpawnRepository extends RepositoryBase
|
||||||
|
{
|
||||||
|
private static String CREATE_SPAWN_TABLE = "CREATE TABLE IF NOT EXISTS spawns (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), location VARCHAR(100), PRIMARY KEY (id), INDEX serverNameIndex (serverName));";
|
||||||
|
private static String RETRIEVE_SPAWNS = "SELECT location FROM spawns WHERE serverName = ?;";
|
||||||
|
private static String ADD_SERVER_SPAWN = "INSERT INTO spawns (serverName, location) VALUES (?, ?);";
|
||||||
|
private static String DELETE_SERVER_SPAWN = "DELETE FROM spawns WHERE serverName = ?;";
|
||||||
|
|
||||||
|
private String _serverName;
|
||||||
|
|
||||||
|
public SpawnRepository(JavaPlugin plugin, String serverName)
|
||||||
|
{
|
||||||
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||||
|
|
||||||
|
_serverName = serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initialize()
|
||||||
|
{
|
||||||
|
executeUpdate(CREATE_SPAWN_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSpawn(String location)
|
||||||
|
{
|
||||||
|
executeUpdate(ADD_SERVER_SPAWN, new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("location", 100, location));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearSpawns()
|
||||||
|
{
|
||||||
|
executeUpdate(DELETE_SERVER_SPAWN, new ColumnVarChar("serverName", 100, _serverName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> retrieveSpawns()
|
||||||
|
{
|
||||||
|
final List<String> spawns = new ArrayList<String>();
|
||||||
|
|
||||||
|
executeQuery(RETRIEVE_SPAWNS, new ResultSetCallable()
|
||||||
|
{
|
||||||
|
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
spawns.add(resultSet.getString(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new ColumnVarChar("serverName", 100, _serverName));
|
||||||
|
|
||||||
|
return spawns;
|
||||||
|
}
|
||||||
|
}
|
@ -3,20 +3,24 @@ package mineplex.core.spawn.command;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.command.MultiCommandBase;
|
||||||
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.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.spawn.Spawn;
|
import mineplex.core.spawn.Spawn;
|
||||||
|
|
||||||
public class SpawnCommand extends CommandBase<Spawn>
|
public class SpawnCommand extends MultiCommandBase<Spawn>
|
||||||
{
|
{
|
||||||
public SpawnCommand(Spawn plugin)
|
public SpawnCommand(Spawn plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "spawn");
|
super(plugin, Rank.ADMIN, "spawn");
|
||||||
|
|
||||||
|
AddCommand(new AddCommand(plugin));
|
||||||
|
AddCommand(new ClearCommand(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Help(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Spawn", "Commands List:"));
|
UtilPlayer.message(caller, F.main("Spawn", "Commands List:"));
|
||||||
UtilPlayer.message(caller, F.help("/spawn add", "Add Location as Spawn", Rank.ADMIN));
|
UtilPlayer.message(caller, F.help("/spawn add", "Add Location as Spawn", Rank.ADMIN));
|
||||||
|
@ -3,13 +3,11 @@ package mineplex.core.teleport;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.spawn.Spawn;
|
|
||||||
import mineplex.core.teleport.command.TeleportCommand;
|
import mineplex.core.teleport.command.TeleportCommand;
|
||||||
|
import mineplex.core.teleport.event.MineplexTeleportEvent;
|
||||||
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.CoreClientManager;
|
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
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;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -25,17 +23,12 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
public class Teleport extends MiniPlugin
|
public class Teleport extends MiniPlugin
|
||||||
{
|
{
|
||||||
private CoreClientManager _clientManager;
|
|
||||||
private Spawn _spawn;
|
|
||||||
|
|
||||||
private LinkedList<Teleporter> teleportList = new LinkedList<Teleporter>();
|
private LinkedList<Teleporter> teleportList = new LinkedList<Teleporter>();
|
||||||
private NautHashMap<String, LinkedList<Location>> _tpHistory = new NautHashMap<String, LinkedList<Location>>();
|
private NautHashMap<String, LinkedList<Location>> _tpHistory = new NautHashMap<String, LinkedList<Location>>();
|
||||||
|
|
||||||
public Teleport(JavaPlugin plugin, CoreClientManager clientManager, Spawn spawn)
|
public Teleport(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super("Teleport", plugin);
|
super("Teleport", plugin);
|
||||||
|
|
||||||
_spawn = spawn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -177,18 +170,6 @@ public class Teleport extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerToSpawn(Player caller, String target)
|
|
||||||
{
|
|
||||||
Player player = UtilPlayer.searchOnline(caller, target, true);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + F.elem("Spawn") + ".");
|
|
||||||
String mB = F.main("Teleport", "You teleported " + F.count(player.getName()) + " to " + F.elem("Spawn") + ".");
|
|
||||||
Add(player, _spawn.getSpawn(), mA, true, caller, mB, player.getName() + " teleported to Spawn via " + caller.getName() + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(Player pA, Location loc, String mA, boolean record, Player pB, String mB, String log)
|
public void Add(Player pA, Location loc, String mA, boolean record, Player pB, String mB, String log)
|
||||||
{
|
{
|
||||||
teleportList.addLast(new Teleporter(this, pA, pB, mA, mB, loc, record, log));
|
teleportList.addLast(new Teleporter(this, pA, pB, mA, mB, loc, record, log));
|
||||||
@ -199,8 +180,15 @@ public class Teleport extends MiniPlugin
|
|||||||
TP(player, getLocation, true);
|
TP(player, getLocation, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TP(Player player, Location getLocation, boolean dettach)
|
public void TP(Player player, Location loc, boolean dettach)
|
||||||
{
|
{
|
||||||
|
//Event
|
||||||
|
MineplexTeleportEvent event = new MineplexTeleportEvent(player, loc);
|
||||||
|
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
if (dettach)
|
if (dettach)
|
||||||
{
|
{
|
||||||
player.eject();
|
player.eject();
|
||||||
@ -210,7 +198,7 @@ public class Teleport extends MiniPlugin
|
|||||||
player.setFallDistance(0);
|
player.setFallDistance(0);
|
||||||
player.setVelocity(new Vector(0,0,0));
|
player.setVelocity(new Vector(0,0,0));
|
||||||
|
|
||||||
player.teleport(getLocation);
|
player.teleport(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedList<Location> GetTPHistory(Player player)
|
public LinkedList<Location> GetTPHistory(Player player)
|
||||||
|
@ -10,7 +10,7 @@ public class HereCommand extends CommandBase<Teleport>
|
|||||||
{
|
{
|
||||||
public HereCommand(Teleport plugin)
|
public HereCommand(Teleport plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.MODERATOR, "here", "h");
|
super(plugin, Rank.ADMIN, "here", "h");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package mineplex.core.teleport.command;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.teleport.Teleport;
|
|
||||||
|
|
||||||
public class SpawnCommand extends CommandBase<Teleport>
|
|
||||||
{
|
|
||||||
public SpawnCommand(Teleport plugin)
|
|
||||||
{
|
|
||||||
super(plugin, Rank.ADMIN, "spawn", "s");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void Execute(Player caller, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length == 0)
|
|
||||||
Plugin.playerToSpawn(caller, caller.getName());
|
|
||||||
else
|
|
||||||
Plugin.playerToSpawn(caller, args[0]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
|
|||||||
AddCommand(new AllCommand(plugin));
|
AddCommand(new AllCommand(plugin));
|
||||||
AddCommand(new BackCommand(plugin));
|
AddCommand(new BackCommand(plugin));
|
||||||
AddCommand(new HereCommand(plugin));
|
AddCommand(new HereCommand(plugin));
|
||||||
AddCommand(new SpawnCommand(plugin));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,7 +49,6 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
|
|||||||
UtilPlayer.message(caller, F.help("/tp here <player>", "Teleport Player to Self", Rank.ADMIN));
|
UtilPlayer.message(caller, F.help("/tp here <player>", "Teleport Player to Self", Rank.ADMIN));
|
||||||
UtilPlayer.message(caller, F.help("/tp <player> <target>", "Teleport Player to Player", Rank.ADMIN));
|
UtilPlayer.message(caller, F.help("/tp <player> <target>", "Teleport Player to Player", Rank.ADMIN));
|
||||||
UtilPlayer.message(caller, F.help("/tp <X> <Y> <Z>", "Teleport to Location", Rank.ADMIN));
|
UtilPlayer.message(caller, F.help("/tp <X> <Y> <Z>", "Teleport to Location", Rank.ADMIN));
|
||||||
UtilPlayer.message(caller, F.help("/tp spawn", "Teleport to Spawn", Rank.ADMIN));
|
|
||||||
UtilPlayer.message(caller, F.help("/tp all", "Teleport All to Self", Rank.OWNER));
|
UtilPlayer.message(caller, F.help("/tp all", "Teleport All to Self", Rank.OWNER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package mineplex.core.teleport.event;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class MineplexTeleportEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private Player _entity;
|
||||||
|
private Location _loc;
|
||||||
|
|
||||||
|
private boolean _cancelled = false;
|
||||||
|
|
||||||
|
public MineplexTeleportEvent(Player entity, Location loc)
|
||||||
|
{
|
||||||
|
_entity = entity;
|
||||||
|
_loc = loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation()
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean cancel)
|
||||||
|
{
|
||||||
|
_cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled()
|
||||||
|
{
|
||||||
|
return _cancelled;
|
||||||
|
}
|
||||||
|
}
|
@ -23,8 +23,10 @@ import mineplex.core.common.util.Callback;
|
|||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.punish.Category;
|
import mineplex.core.punish.Category;
|
||||||
import mineplex.core.punish.Punish;
|
import mineplex.core.punish.Punish;
|
||||||
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
@ -32,6 +34,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
|||||||
{
|
{
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private DonationManager _donationManager;
|
private DonationManager _donationManager;
|
||||||
|
private InventoryManager _inventoryManager;
|
||||||
private Punish _punish;
|
private Punish _punish;
|
||||||
|
|
||||||
private TempRepository _repository;
|
private TempRepository _repository;
|
||||||
@ -44,12 +47,13 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
|||||||
|
|
||||||
private SimpleDateFormat _dateFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
|
private SimpleDateFormat _dateFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
|
||||||
|
|
||||||
public Enjin(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Punish punish)
|
public Enjin(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, Punish punish)
|
||||||
{
|
{
|
||||||
super("Enjin", plugin);
|
super("Enjin", plugin);
|
||||||
|
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
|
_inventoryManager = inventoryManager;
|
||||||
|
|
||||||
_punish = punish;
|
_punish = punish;
|
||||||
_repository = new TempRepository(plugin);
|
_repository = new TempRepository(plugin);
|
||||||
@ -140,25 +144,27 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
|||||||
if (label.equalsIgnoreCase("enjin_mineplex"))
|
if (label.equalsIgnoreCase("enjin_mineplex"))
|
||||||
{
|
{
|
||||||
final String name = args[1];
|
final String name = args[1];
|
||||||
UUID playerUUID = null;
|
UUID uuid = null;
|
||||||
|
|
||||||
if (_cachedUUIDs.containsKey(name))
|
if (_cachedUUIDs.containsKey(name))
|
||||||
playerUUID = _cachedUUIDs.get(name).getKey();
|
uuid = _cachedUUIDs.get(name).getKey();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Fails if not in DB and if duplicate.
|
// Fails if not in DB and if duplicate.
|
||||||
playerUUID = _clientManager.loadUUIDFromDB(name);
|
uuid = _clientManager.loadUUIDFromDB(name);
|
||||||
|
|
||||||
if (playerUUID == null)
|
if (uuid == null)
|
||||||
playerUUID = UUIDFetcher.getUUIDOf(name);
|
uuid = UUIDFetcher.getUUIDOf(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerUUID == null)
|
if (uuid == null)
|
||||||
{
|
{
|
||||||
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID.");
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final UUID playerUUID = uuid;
|
||||||
|
|
||||||
_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"))
|
||||||
@ -209,6 +215,104 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
|||||||
_repository.addGemBooster(name, amount);
|
_repository.addGemBooster(name, amount);
|
||||||
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Gem Boosters" + ".");
|
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Gem Boosters" + ".");
|
||||||
}
|
}
|
||||||
|
else if (args.length >= 3 && args[0].equalsIgnoreCase("key"))
|
||||||
|
{
|
||||||
|
final int amount = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
|
if (args.length == 4)
|
||||||
|
{
|
||||||
|
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Keys" + ".");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add arg so we don't add back to windows api call
|
||||||
|
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, playerUUID.toString(), "Treasure", "Treasure Key", amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
|
||||||
|
{
|
||||||
|
public void run(TransactionResponse data)
|
||||||
|
{
|
||||||
|
if (data == TransactionResponse.Success)
|
||||||
|
{
|
||||||
|
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Keys" + ".");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add arg so we don't add back to windows api call
|
||||||
|
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, playerUUID.toString(), "Treasure", "Treasure Key", amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_commandQueue.add(new QueuedCommand(sender, command, label, args));
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, name, playerUUID, "Treasure Key " + amount, false, 0, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length >= 3 && args[0].equalsIgnoreCase("chest"))
|
||||||
|
{
|
||||||
|
final int amount = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
|
if (args.length == 4)
|
||||||
|
{
|
||||||
|
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Chests" + ".");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add arg so we don't add back to windows api call
|
||||||
|
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Chests. Queuing for run later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, playerUUID.toString(), "Utility", "Treasure Chest", amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
|
||||||
|
{
|
||||||
|
public void run(TransactionResponse data)
|
||||||
|
{
|
||||||
|
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Chests" + ".");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add arg so we don't add back to windows api call
|
||||||
|
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Chests. Queuing for run later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, playerUUID.toString(), "Utility", "Treasure Chest", amount);
|
||||||
|
}
|
||||||
|
}, name, playerUUID, "Treasure Chest " + amount, false, 0, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))
|
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))
|
||||||
{
|
{
|
||||||
final String rank = args[2];
|
final String rank = args[2];
|
||||||
|
@ -3,6 +3,7 @@ package mineplex.enjinTranslator;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.punish.Punish;
|
import mineplex.core.punish.Punish;
|
||||||
import mineplex.core.updater.Updater;
|
import mineplex.core.updater.Updater;
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ public class EnjinTranslator extends JavaPlugin
|
|||||||
Punish punish = new Punish(this, GetWebServerAddress(), clientManager);
|
Punish punish = new Punish(this, GetWebServerAddress(), clientManager);
|
||||||
|
|
||||||
//Main Modules
|
//Main Modules
|
||||||
new Enjin(this, clientManager, donationManager, punish);
|
new Enjin(this, clientManager, donationManager, new InventoryManager(this, clientManager), punish);
|
||||||
|
|
||||||
new Updater(this);
|
new Updater(this);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ public class QueuedCommand
|
|||||||
public String Label;
|
public String Label;
|
||||||
public String[] Args;
|
public String[] Args;
|
||||||
|
|
||||||
public QueuedCommand(CommandSender sender, Command command, String label, String[] args)
|
public QueuedCommand(CommandSender sender, Command command, String label, String...args)
|
||||||
{
|
{
|
||||||
Sender = sender;
|
Sender = sender;
|
||||||
Command = command;
|
Command = command;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||||
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Clans,"/>
|
||||||
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Clans,"/>
|
||||||
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Clans,"/>
|
||||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||||
@ -7,7 +10,7 @@
|
|||||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
||||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value=""/>
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.Game.Clans}"/>
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.Game.Clans}"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||||
<triggers>full,incremental,</triggers>
|
<triggers>auto,full,incremental,</triggers>
|
||||||
<arguments>
|
<arguments>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>LaunchConfigHandle</key>
|
<key>LaunchConfigHandle</key>
|
||||||
|
3
Plugins/Mineplex.Game.Clans/plugin.yml
Normal file
3
Plugins/Mineplex.Game.Clans/plugin.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name: Clans
|
||||||
|
main: mineplex.game.clans.Clans
|
||||||
|
version: 0.1
|
@ -1,18 +1,16 @@
|
|||||||
package mineplex.game.clans;
|
package mineplex.game.clans;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
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.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
import mineplex.core.common.util.FileUtil;
|
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.creature.Creature;
|
import mineplex.core.creature.Creature;
|
||||||
import mineplex.core.disguise.DisguiseManager;
|
import mineplex.core.disguise.DisguiseManager;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.energy.Energy;
|
||||||
import mineplex.core.friend.FriendManager;
|
import mineplex.core.friend.FriendManager;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
@ -22,6 +20,7 @@ import mineplex.core.memory.MemoryFix;
|
|||||||
import mineplex.core.message.MessageManager;
|
import mineplex.core.message.MessageManager;
|
||||||
import mineplex.core.monitor.LagMeter;
|
import mineplex.core.monitor.LagMeter;
|
||||||
import mineplex.core.mount.MountManager;
|
import mineplex.core.mount.MountManager;
|
||||||
|
import mineplex.core.movement.Movement;
|
||||||
import mineplex.core.npc.NpcManager;
|
import mineplex.core.npc.NpcManager;
|
||||||
import mineplex.core.packethandler.PacketHandler;
|
import mineplex.core.packethandler.PacketHandler;
|
||||||
import mineplex.core.pet.PetManager;
|
import mineplex.core.pet.PetManager;
|
||||||
@ -32,12 +31,23 @@ 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.teleport.Teleport;
|
import mineplex.core.teleport.Teleport;
|
||||||
import mineplex.core.updater.FileUpdater;
|
import mineplex.core.updater.FileUpdater;
|
||||||
import mineplex.core.updater.Updater;
|
import mineplex.core.updater.Updater;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.fields.Field;
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||||
|
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
|
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||||
|
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||||
|
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||||
|
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||||
|
import mineplex.minecraft.game.core.fire.Fire;
|
||||||
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -49,16 +59,12 @@ public class Clans extends JavaPlugin
|
|||||||
//Modules
|
//Modules
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private DonationManager _donationManager;
|
private DonationManager _donationManager;
|
||||||
private DamageManager _damageManager;
|
|
||||||
|
|
||||||
private ServerConfiguration _serverConfiguration;
|
private ServerConfiguration _serverConfiguration;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
//Delete Old Games Folders
|
|
||||||
DeleteFolders();
|
|
||||||
|
|
||||||
//Configs
|
//Configs
|
||||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||||
@ -83,18 +89,12 @@ public class Clans 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);
|
|
||||||
Spawn spawn = new Spawn(this);
|
|
||||||
Teleport teleport = new Teleport(this, _clientManager, spawn);
|
|
||||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
||||||
|
new Spawn(this, serverStatusManager.getCurrentServerName());
|
||||||
|
Teleport teleport = new Teleport(this);
|
||||||
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
|
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
|
||||||
new FileUpdater(this, portal);
|
new FileUpdater(this, portal);
|
||||||
PacketHandler packetHandler = new PacketHandler(this);
|
|
||||||
|
|
||||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
|
||||||
|
|
||||||
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
|
|
||||||
|
|
||||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||||
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
||||||
@ -102,46 +102,18 @@ public class Clans extends JavaPlugin
|
|||||||
|
|
||||||
BlockRestore blockRestore = new BlockRestore(this);
|
BlockRestore blockRestore = new BlockRestore(this);
|
||||||
|
|
||||||
ProjectileManager projectileManager = new ProjectileManager(this);
|
|
||||||
|
|
||||||
//Inventory
|
|
||||||
InventoryManager inventoryManager = new InventoryManager(this);
|
|
||||||
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
|
|
||||||
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
|
||||||
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
|
|
||||||
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, true);
|
|
||||||
cosmeticManager.setInterfaceSlot(7);
|
|
||||||
|
|
||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
new CustomTagFix(this, packetHandler);
|
|
||||||
|
|
||||||
new FriendManager(this, _clientManager, preferenceManager);
|
new FriendManager(this, _clientManager, preferenceManager);
|
||||||
|
new InventoryManager(this, _clientManager);
|
||||||
|
|
||||||
|
new ClansManager(this, serverStatusManager.getCurrentServerName(), _clientManager, _donationManager, blockRestore, teleport, webServerAddress);
|
||||||
|
new Recipes(this);
|
||||||
|
new Farming(this);
|
||||||
|
|
||||||
//Updates
|
//Updates
|
||||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||||
|
|
||||||
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
|
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteFolders()
|
|
||||||
{
|
|
||||||
File curDir = new File(".");
|
|
||||||
|
|
||||||
File[] filesList = curDir.listFiles();
|
|
||||||
for(File file : filesList)
|
|
||||||
{
|
|
||||||
if (!file.isDirectory())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (file.getName().length() < 4)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!file.getName().substring(0, 4).equalsIgnoreCase("Game"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
FileUtil.DeleteFolder(file);
|
|
||||||
|
|
||||||
System.out.println("Deleted Old Game: " + file.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
package mineplex.game.clans;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class Farming extends MiniPlugin
|
||||||
|
{
|
||||||
|
public Farming(JavaPlugin plugin)
|
||||||
|
{
|
||||||
|
super("Farming", plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void BlockBreak(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getBlock().getType() != Material.LEAVES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getPlayer().getItemInHand() != null)
|
||||||
|
if (event.getPlayer().getItemInHand().getType() == Material.SHEARS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Math.random() > 0.9)
|
||||||
|
event.getBlock().getWorld().dropItemNaturally(
|
||||||
|
event.getBlock().getLocation().add(0.5, 0.5, 0.5),
|
||||||
|
ItemStackFactory.Instance.CreateStack(Material.APPLE));
|
||||||
|
|
||||||
|
if (Math.random() > 0.999)
|
||||||
|
event.getBlock().getWorld().dropItemNaturally(
|
||||||
|
event.getBlock().getLocation().add(0.5, 0.5, 0.5),
|
||||||
|
ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void BlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (
|
||||||
|
event.getBlock().getTypeId() != 59 &&
|
||||||
|
event.getBlock().getTypeId() != 83 &&
|
||||||
|
event.getBlock().getTypeId() != 104 &&
|
||||||
|
event.getBlock().getTypeId() != 105 &&
|
||||||
|
event.getBlock().getTypeId() != 127 &&
|
||||||
|
event.getBlock().getTypeId() != 141 &&
|
||||||
|
event.getBlock().getTypeId() != 142
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getBlock().getLocation().getY() < event.getBlock().getWorld().getSeaLevel() - 12)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot plant " +
|
||||||
|
F.item(ItemStackFactory.Instance.GetName(event.getPlayer().getItemInHand(), true)) + " this deep underground."));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (event.getBlock().getLocation().getY() > event.getBlock().getWorld().getSeaLevel() + 24)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot plant " +
|
||||||
|
F.item(ItemStackFactory.Instance.GetName(event.getPlayer().getItemInHand(), true)) + " at this altitude."));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
220
Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Recipes.java
Normal file
220
Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Recipes.java
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
package mineplex.game.clans;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||||
|
import org.bukkit.inventory.CraftingInventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class Recipes extends MiniPlugin
|
||||||
|
{
|
||||||
|
public Recipes(JavaPlugin plugin)
|
||||||
|
{
|
||||||
|
super("Recipes", plugin);
|
||||||
|
|
||||||
|
ShapedRecipe goldAxe = new ShapedRecipe(new ItemStack(Material.GOLD_AXE, 1));
|
||||||
|
goldAxe.shape("#MM","#SM","#S#");
|
||||||
|
goldAxe.setIngredient('M', Material.GOLD_BLOCK);
|
||||||
|
goldAxe.setIngredient('S', Material.STICK);
|
||||||
|
UtilServer.getServer().addRecipe(goldAxe);
|
||||||
|
|
||||||
|
ShapedRecipe diamondAxe = new ShapedRecipe(new ItemStack(Material.DIAMOND_AXE, 1));
|
||||||
|
diamondAxe.shape("#MM","#SM","#S#");
|
||||||
|
diamondAxe.setIngredient('M', Material.DIAMOND_BLOCK);
|
||||||
|
diamondAxe.setIngredient('S', Material.STICK);
|
||||||
|
UtilServer.getServer().addRecipe(diamondAxe);
|
||||||
|
|
||||||
|
ShapedRecipe goldSword = new ShapedRecipe(new ItemStack(Material.GOLD_SWORD, 1));
|
||||||
|
goldSword.shape("M","M","S");
|
||||||
|
goldSword.setIngredient('M', Material.GOLD_BLOCK);
|
||||||
|
goldSword.setIngredient('S', Material.STICK);
|
||||||
|
UtilServer.getServer().addRecipe(goldSword);
|
||||||
|
|
||||||
|
ShapedRecipe diamondSword = new ShapedRecipe(new ItemStack(Material.DIAMOND_SWORD, 1));
|
||||||
|
diamondSword.shape("M","M","S");
|
||||||
|
diamondSword.setIngredient('M', Material.DIAMOND_BLOCK);
|
||||||
|
diamondSword.setIngredient('S', Material.STICK);
|
||||||
|
UtilServer.getServer().addRecipe(diamondSword);
|
||||||
|
|
||||||
|
//Iron Door
|
||||||
|
ShapedRecipe ironDoor = new ShapedRecipe(new ItemStack(Material.IRON_DOOR, 1));
|
||||||
|
ironDoor.shape("I","I");
|
||||||
|
ironDoor.setIngredient('I', Material.IRON_INGOT);
|
||||||
|
UtilServer.getServer().addRecipe(ironDoor);
|
||||||
|
|
||||||
|
//Chain Helm
|
||||||
|
ShapedRecipe chainHelm = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_HELMET, 1));
|
||||||
|
|
||||||
|
chainHelm.shape("SIS","I#I");
|
||||||
|
|
||||||
|
chainHelm.setIngredient('I', Material.IRON_INGOT);
|
||||||
|
chainHelm.setIngredient('S', Material.GOLD_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainHelm);
|
||||||
|
|
||||||
|
//Chain Chest
|
||||||
|
ShapedRecipe chainChest = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_CHESTPLATE, 1));
|
||||||
|
|
||||||
|
chainChest.shape("I#I","SIS","ISI");
|
||||||
|
|
||||||
|
chainChest.setIngredient('I', Material.IRON_INGOT);
|
||||||
|
chainChest.setIngredient('S', Material.GOLD_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainChest);
|
||||||
|
|
||||||
|
//Chain Legs
|
||||||
|
ShapedRecipe chainLegs = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_LEGGINGS, 1));
|
||||||
|
|
||||||
|
chainLegs.shape("ISI","S#S","I#I");
|
||||||
|
|
||||||
|
chainLegs.setIngredient('I', Material.IRON_INGOT);
|
||||||
|
chainLegs.setIngredient('S', Material.GOLD_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainLegs);
|
||||||
|
|
||||||
|
//Chain Boots
|
||||||
|
ShapedRecipe chainBoots = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_BOOTS, 1));
|
||||||
|
|
||||||
|
chainBoots.shape("S#S","I#I");
|
||||||
|
|
||||||
|
chainBoots.setIngredient('I', Material.IRON_INGOT);
|
||||||
|
chainBoots.setIngredient('S', Material.GOLD_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainBoots);
|
||||||
|
|
||||||
|
//Chain Helm
|
||||||
|
ShapedRecipe chainHelm2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_HELMET, 1));
|
||||||
|
|
||||||
|
chainHelm2.shape("SIS","I#I");
|
||||||
|
|
||||||
|
chainHelm2.setIngredient('I', Material.GOLD_INGOT);
|
||||||
|
chainHelm2.setIngredient('S', Material.IRON_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainHelm2);
|
||||||
|
|
||||||
|
//Chain Chest
|
||||||
|
ShapedRecipe chainChest2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_CHESTPLATE, 1));
|
||||||
|
|
||||||
|
chainChest2.shape("I#I","SIS","ISI");
|
||||||
|
|
||||||
|
chainChest2.setIngredient('I', Material.GOLD_INGOT);
|
||||||
|
chainChest2.setIngredient('S', Material.IRON_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainChest2);
|
||||||
|
|
||||||
|
//Chain Legs
|
||||||
|
ShapedRecipe chainLegs2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_LEGGINGS, 1));
|
||||||
|
|
||||||
|
chainLegs2.shape("ISI","S#S","I#I");
|
||||||
|
|
||||||
|
chainLegs2.setIngredient('I', Material.GOLD_INGOT);
|
||||||
|
chainLegs2.setIngredient('S', Material.IRON_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainLegs2);
|
||||||
|
|
||||||
|
//Chain Boots
|
||||||
|
ShapedRecipe chainBoots2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_BOOTS, 1));
|
||||||
|
|
||||||
|
chainBoots2.shape("S#S","I#I");
|
||||||
|
|
||||||
|
chainBoots2.setIngredient('I', Material.GOLD_INGOT);
|
||||||
|
chainBoots2.setIngredient('S', Material.IRON_INGOT);
|
||||||
|
|
||||||
|
UtilServer.getServer().addRecipe(chainBoots2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void ReplaceDoor(PrepareItemCraftEvent event)
|
||||||
|
{
|
||||||
|
if (event.getRecipe().getResult() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Material type = event.getRecipe().getResult().getType();
|
||||||
|
|
||||||
|
if (type != Material.WOOD_DOOR && type != Material.WOODEN_DOOR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getInventory() instanceof CraftingInventory))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
||||||
|
|
||||||
|
//Feedback
|
||||||
|
ItemStack result = ItemStackFactory.Instance.CreateStack(Material.IRON_DOOR);
|
||||||
|
inv.setResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void DenySword(PrepareItemCraftEvent event)
|
||||||
|
{
|
||||||
|
if (event.getRecipe().getResult() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Material type = event.getRecipe().getResult().getType();
|
||||||
|
|
||||||
|
if (type != Material.DIAMOND_SWORD && type != Material.GOLD_SWORD &&
|
||||||
|
type != Material.DIAMOND_AXE && type != Material.GOLD_AXE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getInventory() instanceof CraftingInventory))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
||||||
|
|
||||||
|
for (ItemStack cur : inv.getMatrix())
|
||||||
|
if (cur != null)
|
||||||
|
if (cur.getType() == Material.GOLD_BLOCK || cur.getType() == Material.DIAMOND_BLOCK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String name = ItemStackFactory.Instance.GetName(event.getRecipe().getResult(), true);
|
||||||
|
String matName = "Gold";
|
||||||
|
if (type == Material.DIAMOND_AXE || type == Material.DIAMOND_SWORD)
|
||||||
|
matName = "Diamond";
|
||||||
|
|
||||||
|
//Feedback
|
||||||
|
ItemStack result = ItemStackFactory.Instance.CreateStack(36, (byte)0, 1, "§r" + C.cGray + "Recipe changed for " + F.item(name) + ".",
|
||||||
|
new String[] {C.cGray + "Use " + F.item(matName + " Blocks") + " instead of " + F.item(matName + " Ingots") + "."});
|
||||||
|
|
||||||
|
inv.setResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void DenyGeneral(PrepareItemCraftEvent event)
|
||||||
|
{
|
||||||
|
if (event.getRecipe().getResult() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Material type = event.getRecipe().getResult().getType();
|
||||||
|
|
||||||
|
if (
|
||||||
|
type != Material.GOLDEN_APPLE &&
|
||||||
|
type != Material.GOLDEN_CARROT &&
|
||||||
|
type != Material.ENDER_CHEST &&
|
||||||
|
type != Material.ENCHANTMENT_TABLE &&
|
||||||
|
type != Material.BREWING_STAND &&
|
||||||
|
type != Material.TNT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getInventory() instanceof CraftingInventory))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
||||||
|
|
||||||
|
String name = ItemStackFactory.Instance.GetName(event.getRecipe().getResult(), true);
|
||||||
|
|
||||||
|
//Feedback
|
||||||
|
ItemStack result = ItemStackFactory.Instance.CreateStack(36, (byte)0, 1,
|
||||||
|
"§r" + C.cGray + "Crafting of " + F.item(name) + " is disabled.", new String[] {});
|
||||||
|
|
||||||
|
inv.setResult(result);
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,9 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -81,6 +84,21 @@ public class ClanInfo
|
|||||||
|
|
||||||
_dateCreated = token.DateCreated;
|
_dateCreated = token.DateCreated;
|
||||||
_lastOnline = token.LastOnline;
|
_lastOnline = token.LastOnline;
|
||||||
|
|
||||||
|
for (ClanMemberToken memberToken : token.Members)
|
||||||
|
{
|
||||||
|
_memberMap.put(memberToken.Name, Role.valueOf(memberToken.ClanRole));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ClanTerritoryToken territoryToken : token.Territories)
|
||||||
|
{
|
||||||
|
_claimSet.add(territoryToken.Chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ClanAllianceToken allianceToken : token.Alliances)
|
||||||
|
{
|
||||||
|
_allyMap.put(allianceToken.ClanName, allianceToken.Trusted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getClaims()
|
public int getClaims()
|
||||||
@ -377,4 +395,9 @@ public class ClanInfo
|
|||||||
{
|
{
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setId(int id)
|
||||||
|
{
|
||||||
|
_id = id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package mineplex.game.clans.clans;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
|
||||||
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.UtilInput;
|
import mineplex.core.common.util.UtilInput;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilWorld;
|
|||||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class ClansAdmin
|
public class ClansAdmin
|
||||||
@ -161,7 +162,7 @@ public class ClansAdmin
|
|||||||
return clan;
|
return clan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create(Player caller, String[] args)
|
public void create(final Player caller, final String[] args)
|
||||||
{
|
{
|
||||||
if (args.length < 3)
|
if (args.length < 3)
|
||||||
{
|
{
|
||||||
@ -187,7 +188,7 @@ public class ClansAdmin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String cur : Clans.CCommand().denyClan)
|
for (String cur : Clans.denyClan)
|
||||||
{
|
{
|
||||||
if (cur.equalsIgnoreCase(args[2]))
|
if (cur.equalsIgnoreCase(args[2]))
|
||||||
{
|
{
|
||||||
@ -196,21 +197,24 @@ public class ClansAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (Clans.getClan(args[2]) != null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", F.elem("Clan " + args[2]) + " already exists."));
|
UtilPlayer.message(caller, F.main("Clans Admin", F.elem("Clan " + args[2]) + " already exists."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Clans.getClientManager().checkPlayerNameExact(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(final Boolean nameExists)
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getScheduler().runTask(Clans.GetPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (nameExists)
|
||||||
|
UtilPlayer.message(caller, F.main("Clans Admin", "Clan name cannot be a Player name."));
|
||||||
|
else
|
||||||
|
{
|
||||||
//Inform
|
//Inform
|
||||||
UtilServer.broadcast(F.main("Clans Admin", caller.getName() + " formed " + F.elem("Admin Clan " + args[2]) + "."));
|
UtilServer.broadcast(F.main("Clans Admin", caller.getName() + " formed " + F.elem("Admin Clan " + args[2]) + "."));
|
||||||
|
|
||||||
@ -223,6 +227,11 @@ public class ClansAdmin
|
|||||||
// Inform
|
// Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "You are mimicing Clan " + args[2] + "."));
|
UtilPlayer.message(caller, F.main("Clans Admin", "You are mimicing Clan " + args[2] + "."));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, args[2]);
|
||||||
|
}
|
||||||
|
|
||||||
public void delete(Player caller, String[] args)
|
public void delete(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
@ -444,9 +453,9 @@ public class ClansAdmin
|
|||||||
|
|
||||||
public void trust(Player caller, String[] args)
|
public void trust(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
ClanInfo cA = getMimic(caller, true);
|
ClanInfo callerClan = getMimic(caller, true);
|
||||||
|
|
||||||
if (cA == null)
|
if (callerClan == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (args.length < 3)
|
if (args.length < 3)
|
||||||
@ -455,31 +464,31 @@ public class ClansAdmin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClanInfo cB = Clans.getClanUtility().searchClanPlayer(caller, args[2], true);
|
ClanInfo otherClan = Clans.getClanUtility().searchClanPlayer(caller, args[2], true);
|
||||||
|
|
||||||
if (cB == null)
|
if (otherClan == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!cA.isAlly(cB.getName()))
|
if (!callerClan.isAlly(otherClan.getName()))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot give trust to enemies."));
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot give trust to enemies."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
if (Clans.getClanDataAccess().trust(cA, cB, caller.getName()))
|
if (Clans.getClanDataAccess().trust(callerClan, otherClan, caller.getName()))
|
||||||
{
|
{
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "You gave trust to Clan " + cB.getName() + "."));
|
UtilPlayer.message(caller, F.main("Clans Admin", "You gave trust to Clan " + otherClan.getName() + "."));
|
||||||
cA.inform(caller.getName() + " has given trust to Clan " + cB.getName() + ".", caller.getName());
|
callerClan.inform(caller.getName() + " has given trust to Clan " + otherClan.getName() + ".", caller.getName());
|
||||||
cB.inform("Clan " + cA.getName() + " has given trust to you.", null);
|
otherClan.inform("Clan " + callerClan.getName() + " has given trust to you.", null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "You revoked trust to Clan " + cB.getName() + "."));
|
UtilPlayer.message(caller, F.main("Clans Admin", "You revoked trust to Clan " + otherClan.getName() + "."));
|
||||||
cA.inform(caller.getName() + " has revoked trust to Clan " + cB.getName() + ".", caller.getName());
|
callerClan.inform(caller.getName() + " has revoked trust to Clan " + otherClan.getName() + ".", caller.getName());
|
||||||
cB.inform("Clan " + cA.getName() + " has revoked trust to you.", null);
|
otherClan.inform("Clan " + callerClan.getName() + " has revoked trust to you.", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,139 @@
|
|||||||
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class ClansBlocks
|
||||||
|
{
|
||||||
|
public HashSet<Integer> denyInteract = new HashSet<Integer>();
|
||||||
|
public HashSet<Integer> allowInteract = new HashSet<Integer>();
|
||||||
|
|
||||||
|
public HashSet<Integer> denyUsePlace = new HashSet<Integer>();
|
||||||
|
public HashSet<Integer> allowUsePlace = new HashSet<Integer>();
|
||||||
|
|
||||||
|
public HashSet<Integer> allowBreak = new HashSet<Integer>();
|
||||||
|
|
||||||
|
public boolean denyInteract(int id)
|
||||||
|
{
|
||||||
|
if (denyInteract.isEmpty())
|
||||||
|
{
|
||||||
|
denyInteract.add(22); //Lapis
|
||||||
|
denyInteract.add(23); //Dispenser
|
||||||
|
denyInteract.add(26); //Bed
|
||||||
|
denyInteract.add(54); //Chest
|
||||||
|
denyInteract.add(61); //Furance
|
||||||
|
denyInteract.add(62); //Furnace
|
||||||
|
denyInteract.add(64); //Wood Door
|
||||||
|
//denyInteract.add(69); //Lever
|
||||||
|
//denyInteract.add(70); //Stone Plate
|
||||||
|
denyInteract.add(71); //Iron Door
|
||||||
|
//denyInteract.add(72); //Wood Plate
|
||||||
|
//denyInteract.add(77); //Stone Button
|
||||||
|
denyInteract.add(93); //Repeater
|
||||||
|
denyInteract.add(94); //Repeater
|
||||||
|
denyInteract.add(96); //Trap Door
|
||||||
|
denyInteract.add(107); //Fence Gate
|
||||||
|
denyInteract.add(117); //Brewing Stand
|
||||||
|
denyInteract.add(146); //Trap Chest
|
||||||
|
}
|
||||||
|
|
||||||
|
return denyInteract.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allowInteract(int id)
|
||||||
|
{
|
||||||
|
if (allowInteract.isEmpty())
|
||||||
|
{
|
||||||
|
allowInteract.add(64); //Wood Door
|
||||||
|
//allowInteract.add(69); //Lever
|
||||||
|
//allowInteract.add(70); //Stone Plate
|
||||||
|
allowInteract.add(71); //Iron Door
|
||||||
|
//allowInteract.add(72); //Wood Plate
|
||||||
|
//allowInteract.add(77); //Stone Button
|
||||||
|
allowInteract.add(96); //Trap Door
|
||||||
|
allowInteract.add(107); //Fence Gate
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowInteract.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean denyUsePlace(int id)
|
||||||
|
{
|
||||||
|
if (denyUsePlace.isEmpty())
|
||||||
|
{
|
||||||
|
//List PLACEABLE ITEMS
|
||||||
|
denyUsePlace.add(259); //Flint & Steel
|
||||||
|
denyUsePlace.add(321); //Painting
|
||||||
|
denyUsePlace.add(323); //Sign
|
||||||
|
denyUsePlace.add(324); //Wood Door
|
||||||
|
denyUsePlace.add(326); //Water Bucket
|
||||||
|
denyUsePlace.add(327); //Lava Bucket
|
||||||
|
denyUsePlace.add(330); //Iron Door
|
||||||
|
denyUsePlace.add(331); //Redstone
|
||||||
|
denyUsePlace.add(333); //Boat
|
||||||
|
denyUsePlace.add(355); //Bed
|
||||||
|
denyUsePlace.add(356); //Redstone Repeater
|
||||||
|
denyUsePlace.add(379); //Brewing Stand
|
||||||
|
denyUsePlace.add(380); //Cauldron
|
||||||
|
denyUsePlace.add(389); //Frame
|
||||||
|
denyUsePlace.add(390); //Pot
|
||||||
|
denyUsePlace.add(404); //Comparator
|
||||||
|
denyUsePlace.add(407); //TNT Cart
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == 65)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (id > 0 && id < 256)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return denyUsePlace.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allowUsePlace(int id)
|
||||||
|
{
|
||||||
|
if (allowUsePlace.isEmpty())
|
||||||
|
{
|
||||||
|
allowUsePlace.add(37); //Flower
|
||||||
|
allowUsePlace.add(38); //Flower
|
||||||
|
allowUsePlace.add(65); //Ladder
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowUsePlace.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBreak(int id)
|
||||||
|
{
|
||||||
|
if (allowBreak.isEmpty())
|
||||||
|
{
|
||||||
|
allowBreak.add(6); //Saplings
|
||||||
|
allowBreak.add(12); //Sand
|
||||||
|
allowBreak.add(13); //Gravel
|
||||||
|
allowBreak.add(22); //Blue
|
||||||
|
allowBreak.add(30); //Web
|
||||||
|
|
||||||
|
allowBreak.add(39); //Brown Mushroom
|
||||||
|
allowBreak.add(40); //Red Mushroom
|
||||||
|
allowBreak.add(59); //Wheat Seeds
|
||||||
|
allowBreak.add(81); //Cactus
|
||||||
|
allowBreak.add(83); //Sugar Cane
|
||||||
|
allowBreak.add(86); //Pumpkin
|
||||||
|
allowBreak.add(103); //Melon
|
||||||
|
allowBreak.add(104); //Pumpkin Stem
|
||||||
|
allowBreak.add(105); //Melon Stem
|
||||||
|
allowBreak.add(115); //Nether Wart
|
||||||
|
allowBreak.add(127); //Cocoa Plant
|
||||||
|
allowBreak.add(141); //Carrot
|
||||||
|
allowBreak.add(142); //Potato
|
||||||
|
|
||||||
|
allowBreak.add(58); //Workbench
|
||||||
|
allowBreak.add(61); //Furnace
|
||||||
|
allowBreak.add(62); //Furnace
|
||||||
|
//allowBreak.add(116); //Enchanting
|
||||||
|
//allowBreak.add(117); //Brewing
|
||||||
|
allowBreak.add(138); //Beacon
|
||||||
|
//allowBreak.add(145); //Anvil
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowBreak.contains(id);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package mineplex.game.clans.clans;
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -12,7 +10,6 @@ import mineplex.core.common.util.UtilWorld;
|
|||||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||||
import mineplex.game.clans.clans.repository.ClanRepository;
|
import mineplex.game.clans.clans.repository.ClanRepository;
|
||||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||||
|
|
||||||
public class ClansDataAccessLayer
|
public class ClansDataAccessLayer
|
||||||
@ -23,7 +20,7 @@ public class ClansDataAccessLayer
|
|||||||
public ClansDataAccessLayer(ClansManager clans)
|
public ClansDataAccessLayer(ClansManager clans)
|
||||||
{
|
{
|
||||||
_manager = clans;
|
_manager = clans;
|
||||||
_repository = new ClanRepository(clans.GetPlugin(), clans.GetServerName());
|
_repository = new ClanRepository(clans.GetPlugin(), clans.getServerName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(ClanInfo clan)
|
public void delete(ClanInfo clan)
|
||||||
@ -47,7 +44,7 @@ public class ClansDataAccessLayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_repository.deleteClan(clan.getName());
|
_repository.deleteClan(clan.getId());
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Deleted [" + clan.getName() + "].");
|
_manager.log("Deleted [" + clan.getName() + "].");
|
||||||
@ -61,17 +58,12 @@ public class ClansDataAccessLayer
|
|||||||
token.Home = "";
|
token.Home = "";
|
||||||
token.Admin = admin;
|
token.Admin = admin;
|
||||||
|
|
||||||
token.Members = new ArrayList<ClanMemberToken>();
|
|
||||||
ClanMemberToken memberToken = new ClanMemberToken();
|
|
||||||
memberToken.ClanRole = Role.ADMIN.toString();
|
|
||||||
memberToken.Name = creator;
|
|
||||||
|
|
||||||
//Create Clan
|
//Create Clan
|
||||||
ClanInfo clan = new ClanInfo(_manager, token);
|
ClanInfo clan = new ClanInfo(_manager, token);
|
||||||
_manager.getClanMap().put(name, clan);
|
_manager.getClanMap().put(name, clan);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_repository.addClan(token);
|
_repository.addClan(clan, token);
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("[" + clan.getName() + "] with Admin [" + admin + "] created by [" + creator + "].");
|
_manager.log("[" + clan.getName() + "] with Admin [" + admin + "] created by [" + creator + "].");
|
||||||
@ -153,29 +145,28 @@ public class ClansDataAccessLayer
|
|||||||
cB.getAllyMap().put(cA.getName(), false);
|
cB.getAllyMap().put(cA.getName(), false);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_repository.addClanRelationship(cA.getId(), cB.getId(), true);
|
_repository.addClanRelationship(cA.getId(), cB.getId(), false);
|
||||||
_repository.addClanRelationship(cB.getId(), cA.getId(), true);
|
_repository.addClanRelationship(cB.getId(), cA.getId(), false);
|
||||||
|
|
||||||
//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 + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean trust(ClanInfo cA, ClanInfo cB, String player)
|
public boolean trust(ClanInfo ownerClan, ClanInfo otherClan, String player)
|
||||||
{
|
{
|
||||||
if (!cA.getAllyMap().containsKey(cB.getName()))
|
if (!ownerClan.getAllyMap().containsKey(otherClan.getName()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean trust = !cA.getAllyMap().get(cB.getName());
|
boolean trust = !ownerClan.getAllyMap().get(otherClan.getName());
|
||||||
|
|
||||||
//Memory
|
//Memory
|
||||||
cA.getAllyMap().put(cB.getName(), trust);
|
ownerClan.getAllyMap().put(otherClan.getName(), trust);
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
_repository.updateClanRelationship(cA.getId(), cB.getId(), true);
|
_repository.updateClanRelationship(ownerClan.getId(), otherClan.getId(), trust);
|
||||||
_repository.updateClanRelationship(cB.getId(), cA.getId(), true);
|
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Gave Trust [" + trust + "] to [" + cB.getName() + "] for [" + cA.getName() + "] by [" + player + "].");
|
_manager.log((trust ? "Gave" : "Revoked") + " Trust [" + trust + "] to [" + otherClan.getName() + "] for [" + ownerClan.getName() + "] by [" + player + "].");
|
||||||
|
|
||||||
return trust;
|
return trust;
|
||||||
}
|
}
|
||||||
@ -292,4 +283,9 @@ public class ClansDataAccessLayer
|
|||||||
//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 + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClanRepository getRepository()
|
||||||
|
{
|
||||||
|
return _repository;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,15 @@ package mineplex.game.clans.clans;
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
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.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
|
|
||||||
@ -15,17 +18,31 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class ClansDisplay
|
public class ClansDisplay extends MiniPlugin
|
||||||
{
|
{
|
||||||
private ClansManager Clans;
|
private ClansManager Clans;
|
||||||
|
|
||||||
public ClansDisplay(ClansManager clans)
|
public ClansDisplay(JavaPlugin plugin, ClansManager clans)
|
||||||
{
|
{
|
||||||
|
super("Clans Display", plugin);
|
||||||
|
|
||||||
Clans = clans;
|
Clans = clans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void Update(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FASTER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player cur : UtilServer.getPlayers())
|
||||||
|
Update(cur);
|
||||||
|
}
|
||||||
|
|
||||||
public void Update(Player player)
|
public void Update(Player player)
|
||||||
{
|
{
|
||||||
if (player.getWorld().getEnvironment() != Environment.NORMAL)
|
if (player.getWorld().getEnvironment() != Environment.NORMAL)
|
||||||
|
@ -0,0 +1,524 @@
|
|||||||
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||||
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||||
|
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.blockrestore.BlockRestoreData;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEvent;
|
||||||
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
|
import mineplex.core.common.util.UtilGear;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||||
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
|
|
||||||
|
public class ClansGame extends MiniPlugin
|
||||||
|
{
|
||||||
|
private ClansManager Clans;
|
||||||
|
|
||||||
|
public ClansGame(JavaPlugin plugin, ClansManager clans)
|
||||||
|
{
|
||||||
|
super("Clans Game", plugin);
|
||||||
|
|
||||||
|
Clans = clans;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void Update(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player cur : UtilServer.getPlayers())
|
||||||
|
if (Clans.getClanUtility().isSafe(cur.getLocation()))
|
||||||
|
{
|
||||||
|
long lastDamager = Clans.getCombatManager().Get(cur).GetLastCombat();
|
||||||
|
|
||||||
|
if (!UtilTime.elapsed(lastDamager, 15000))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(cur, F.main("Safe Zone", "You are not safe for " +
|
||||||
|
F.time(UtilTime.convertString(15000 - (System.currentTimeMillis() - lastDamager), 1, TimeUnit.FIT))));
|
||||||
|
|
||||||
|
Clans.getCondition().Factory().Custom("Unsafe", cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void SkillTrigger(SkillTriggerEvent event)
|
||||||
|
{
|
||||||
|
if (!Clans.getClanUtility().isSafe(event.GetPlayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
UtilPlayer.message(event.GetPlayer(), F.main("Safe Zone", "You cannot use " + F.skill(event.GetSkillName() + " in " + F.elem("Safe Zone") + ".")));
|
||||||
|
|
||||||
|
event.SetCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void openClanShop(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||||
|
{
|
||||||
|
if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE)
|
||||||
|
{
|
||||||
|
Clans.getClanShop().attemptShopOpen(event.getPlayer());
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void BlockBurn(BlockBurnEvent event)
|
||||||
|
{
|
||||||
|
if (Clans.getClanUtility().isBorderlands(event.getBlock().getLocation()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void BlockSpread(BlockIgniteEvent event)
|
||||||
|
{
|
||||||
|
if (event.getCause() == IgniteCause.SPREAD)
|
||||||
|
if (Clans.getClanUtility().isBorderlands(event.getBlock().getLocation()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void BlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getBlock().getType() != Material.LADDER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF)
|
||||||
|
return;
|
||||||
|
|
||||||
|
final Block block = event.getBlock();
|
||||||
|
|
||||||
|
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Clans.GetPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
Clans.getBlockRestore().Add(block, 65, block.getData(), 30000);
|
||||||
|
|
||||||
|
BlockRestoreData data = Clans.getBlockRestore().GetData(block);
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
data.setFromId(0);
|
||||||
|
data.setFromData((byte)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void BlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String mimic = Clans.Get(event.getPlayer()).getMimic();
|
||||||
|
|
||||||
|
if (mimic.length() != 0)
|
||||||
|
{
|
||||||
|
if (Clans.getClanUtility().searchClanPlayer(event.getPlayer(), mimic, false) != null)
|
||||||
|
mimic = C.cGray + " You are currently mimicing " + C.cGold + mimic;
|
||||||
|
else
|
||||||
|
mimic = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Borderlands
|
||||||
|
if (Clans.getClanUtility().isBorderlands(event.getBlock().getLocation()) && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
||||||
|
" in " +
|
||||||
|
F.elem("Borderlands") +
|
||||||
|
"."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Clans.getClanBlocks().canBreak(event.getBlock().getTypeId()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF)
|
||||||
|
{
|
||||||
|
//Disallow Shops
|
||||||
|
if (event.getBlock().getType() == Material.ENDER_CHEST || event.getBlock().getType() == Material.ENCHANTMENT_TABLE)
|
||||||
|
if (Clans.getClanUtility().isSafe(event.getBlock().getLocation()))
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
||||||
|
" in " +
|
||||||
|
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer().getName()) +
|
||||||
|
"."));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disallow Recruit Chest
|
||||||
|
if (Clans.getClanUtility().isClaimed(event.getBlock().getLocation()))
|
||||||
|
if (event.getBlock().getTypeId() == 54)
|
||||||
|
{
|
||||||
|
if (Clans.getClanUtility().getRole(event.getPlayer()) == Role.RECRUIT)
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Clan Recruits cannot break " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) + "."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Allow
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
||||||
|
" in " +
|
||||||
|
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer().getName()) +
|
||||||
|
"." +
|
||||||
|
mimic));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void Damage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
if (event.IsCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player damagee = event.GetDamageePlayer();
|
||||||
|
if (damagee == null) return;
|
||||||
|
|
||||||
|
if (Clans.getClanUtility().isSafe(damagee))
|
||||||
|
event.SetCancelled("Safe Zone");
|
||||||
|
|
||||||
|
Player damager = event.GetDamagerPlayer(true);
|
||||||
|
if (damager == null) return;
|
||||||
|
|
||||||
|
if (!Clans.getClanUtility().canHurt(damagee, damager))
|
||||||
|
{
|
||||||
|
//Cancel
|
||||||
|
event.SetCancelled("Clans Ally");
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
if (damager != null)
|
||||||
|
{
|
||||||
|
ClanRelation rel = Clans.getRelation(damagee.getName(), damager.getName());
|
||||||
|
UtilPlayer.message(damager, F.main("Clans",
|
||||||
|
"You cannot harm " + Clans.getClanUtility().mRel(rel, damagee.getName(), false) + "."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Block Interact and Placement
|
||||||
|
public void Interact(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (player.getWorld().getEnvironment() != Environment.NORMAL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Block Interaction
|
||||||
|
Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation();
|
||||||
|
if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation();
|
||||||
|
|
||||||
|
//Borderlands
|
||||||
|
if ( player.getGameMode() != GameMode.CREATIVE &&
|
||||||
|
player.getItemInHand() != null &&
|
||||||
|
Clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) &&
|
||||||
|
Clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation()))
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Clans", "You cannot use/place " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
||||||
|
" in " +
|
||||||
|
F.elem("Borderlands") +
|
||||||
|
"."));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanRelation access = Clans.getClanUtility().getAccess(player, loc);
|
||||||
|
|
||||||
|
//Hoe Return
|
||||||
|
if (access != ClanRelation.SELF && !UtilBlock.usable(event.getClickedBlock()))
|
||||||
|
{
|
||||||
|
if (UtilGear.isHoe(player.getItemInHand()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Full Access
|
||||||
|
if (access == ClanRelation.SELF)
|
||||||
|
{
|
||||||
|
//Recruits cannot open Chests
|
||||||
|
if (event.getClickedBlock().getTypeId() == 54)
|
||||||
|
{
|
||||||
|
if (Clans.getClanUtility().getRole(player) == Role.RECRUIT)
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Clans", "Clan Recruits cannot access " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
||||||
|
"."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wilderness Adjacent
|
||||||
|
if ( event.getAction() == Action.RIGHT_CLICK_BLOCK &&
|
||||||
|
!UtilBlock.usable(event.getClickedBlock()) &&
|
||||||
|
player.getItemInHand() != null &&
|
||||||
|
Clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) &&
|
||||||
|
!Clans.getClanUtility().isClaimed(loc))
|
||||||
|
{
|
||||||
|
|
||||||
|
String enemy = null;
|
||||||
|
boolean self = false;
|
||||||
|
|
||||||
|
for (int x=-1 ; x<=1 ; x++)
|
||||||
|
for (int z=-1 ; z<=1 ; z++)
|
||||||
|
{
|
||||||
|
if (self)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (x != 0 && z != 0 || x == 0 && z == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Location sideLoc = new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z);
|
||||||
|
|
||||||
|
if (Clans.getClanUtility().isSelf(player.getName(), sideLoc))
|
||||||
|
self = true;
|
||||||
|
|
||||||
|
if (enemy != null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Clans.getClanUtility().getAccess(player, sideLoc) != ClanRelation.SELF)
|
||||||
|
enemy = Clans.getClanUtility().getOwnerStringRel(
|
||||||
|
new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z),
|
||||||
|
player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enemy != null && !self)
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Clans", "You cannot use/place " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(player.getItemInHand(), true)) +
|
||||||
|
" next to " +
|
||||||
|
enemy +
|
||||||
|
"."));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String mimic = Clans.Get(player).getMimic();
|
||||||
|
|
||||||
|
if (mimic.length() != 0)
|
||||||
|
{
|
||||||
|
if (Clans.getClanUtility().searchClanPlayer(player, mimic, false) != null)
|
||||||
|
mimic = C.cGray + " You are currently mimicing " + C.cGold + mimic;
|
||||||
|
else
|
||||||
|
mimic = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Deny Interaction
|
||||||
|
if (Clans.getClanBlocks().denyInteract(event.getClickedBlock().getTypeId()))
|
||||||
|
{
|
||||||
|
//Block Action
|
||||||
|
if (access == ClanRelation.NEUTRAL)
|
||||||
|
{
|
||||||
|
//Allow Field Chest
|
||||||
|
if (event.getClickedBlock().getTypeId() == 54)
|
||||||
|
if (Clans.getClanUtility().isSpecial(event.getClickedBlock().getLocation(), "Fields"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Clans", "You cannot use " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
||||||
|
" in " +
|
||||||
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
||||||
|
player.getName()) +
|
||||||
|
"." +
|
||||||
|
mimic));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Block is not Trust Allowed
|
||||||
|
else if (!Clans.getClanBlocks().allowInteract(event.getClickedBlock().getTypeId()) || access != ClanRelation.ALLY_TRUST)
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Clans", "You cannot use " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
||||||
|
" in " +
|
||||||
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
||||||
|
player.getName()) +
|
||||||
|
"." +
|
||||||
|
mimic));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Block Placement
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
|
if (player.getItemInHand().getType() != Material.AIR)
|
||||||
|
if (Clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()))
|
||||||
|
{
|
||||||
|
//Disallow
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Clans", "You cannot use/place " +
|
||||||
|
F.elem(ItemStackFactory.Instance.GetName(player.getItemInHand(), true)) +
|
||||||
|
" in " +
|
||||||
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(),
|
||||||
|
player.getName()) +
|
||||||
|
"." +
|
||||||
|
mimic));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void Piston(BlockPistonExtendEvent event)
|
||||||
|
{
|
||||||
|
ClanInfo pistonClan = Clans.getClanUtility().getOwner(event.getBlock().getLocation());
|
||||||
|
|
||||||
|
Block push = event.getBlock();
|
||||||
|
for (int i=0 ; i<13 ; i++)
|
||||||
|
{
|
||||||
|
push = push.getRelative(event.getDirection());
|
||||||
|
|
||||||
|
Block front = push.getRelative(event.getDirection()).getRelative(event.getDirection());
|
||||||
|
|
||||||
|
if (push.getType() == Material.AIR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ClanInfo pushClan = Clans.getClanUtility().getOwner(front.getLocation());
|
||||||
|
|
||||||
|
if (pushClan == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pushClan.isAdmin())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pistonClan == null)
|
||||||
|
{
|
||||||
|
push.getWorld().playEffect(push.getLocation(), Effect.STEP_SOUND, push.getTypeId());
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pistonClan.equals(pushClan))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
push.getWorld().playEffect(push.getLocation(), Effect.STEP_SOUND, push.getTypeId());
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void Quit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
ClanInfo clan = Clans.getClanUtility().getClanByPlayer(event.getPlayer());
|
||||||
|
if (clan == null) return;
|
||||||
|
|
||||||
|
clan.setLastOnline(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void Explosion(EntityExplodeEvent event)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (event.getEntityType() != EntityType.PRIMED_TNT && event.getEntityType() != EntityType.MINECART_TNT)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanInfo clan = Clans.getClanUtility().getOwner(event.getEntity().getLocation());
|
||||||
|
if (clan == null) return;
|
||||||
|
|
||||||
|
if (!clan.isOnline())
|
||||||
|
event.setCancelled(true);
|
||||||
|
else
|
||||||
|
clan.inform(C.cRed + "Your Territory is under attack!", null);
|
||||||
|
}
|
||||||
|
}
|
@ -1,58 +1,73 @@
|
|||||||
package mineplex.game.clans.clans;
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
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;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
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.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.CustomTagFix;
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
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.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.creature.Creature;
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
|
||||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||||
|
import mineplex.core.disguise.DisguiseManager;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.energy.Energy;
|
||||||
|
import mineplex.core.movement.Movement;
|
||||||
|
import mineplex.core.npc.NpcManager;
|
||||||
|
import mineplex.core.packethandler.PacketHandler;
|
||||||
|
import mineplex.core.projectile.ProjectileManager;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.teleport.Teleport;
|
import mineplex.core.teleport.Teleport;
|
||||||
import mineplex.core.updater.UpdateType;
|
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
|
||||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
|
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||||
|
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||||
|
import mineplex.game.clans.clans.commands.ClansCommand;
|
||||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||||
|
import mineplex.game.clans.fields.Field;
|
||||||
|
import mineplex.game.clans.gameplay.Gameplay;
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
||||||
|
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
|
||||||
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
|
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||||
|
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||||
|
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||||
|
import mineplex.minecraft.game.core.IRelation;
|
||||||
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.condition.ConditionManager;
|
||||||
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||||
|
import mineplex.minecraft.game.core.fire.Fire;
|
||||||
|
|
||||||
public class ClansManager extends MiniClientPlugin<ClientClan>
|
public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelation
|
||||||
{
|
{
|
||||||
|
private String _serverName;
|
||||||
|
|
||||||
|
private CoreClientManager _clientManager;
|
||||||
private CombatManager _combatManager;
|
private CombatManager _combatManager;
|
||||||
private ClansUtility _clanUtility;
|
private ClansUtility _clanUtility;
|
||||||
private ClansDataAccessLayer _clanDataAccess;
|
private ClansDataAccessLayer _clanDataAccess;
|
||||||
private ClansDisplay _clanDisplay;
|
private ClansDisplay _clanDisplay;
|
||||||
private ClansAdmin _clanAdmin;
|
private ClansAdmin _clanAdmin;
|
||||||
|
private ClansGame _clanGame;
|
||||||
|
private ClansBlocks _clanBlocks;
|
||||||
private BlockRestore _blockRestore;
|
private BlockRestore _blockRestore;
|
||||||
private Teleport _teleport;
|
private Teleport _teleport;
|
||||||
|
private ConditionManager _condition;
|
||||||
|
private ClassCombatShop _classShop;
|
||||||
|
private ClassManager _classManager;
|
||||||
|
|
||||||
private int _dominanceLimit = 16;
|
|
||||||
private int _inviteExpire = 2;
|
private int _inviteExpire = 2;
|
||||||
private int _nameMin = 3;
|
private int _nameMin = 3;
|
||||||
private int _nameMax = 10;
|
private int _nameMax = 10;
|
||||||
@ -65,17 +80,69 @@ 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, BlockRestore blockRestore, Teleport teleport)
|
public String[] denyClan = new String[] {
|
||||||
|
"neut", "neutral", "sethome", "promote", "demote", "admin", "help", "create", "disband", "delete", "invite", "join", "kick", "ally", "trust", "claim", "unclaim", "territory", "home"};
|
||||||
|
|
||||||
|
public ClansManager(JavaPlugin plugin, String serverName, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore, Teleport teleport, String webServerAddress)
|
||||||
{
|
{
|
||||||
super("Clans Manager", plugin);
|
super("Clans Manager", plugin);
|
||||||
|
|
||||||
_combatManager = combatManager;
|
_serverName = serverName;
|
||||||
_clanUtility = new ClansUtility(this);
|
_clientManager = clientManager;
|
||||||
|
_combatManager = new CombatManager(plugin);
|
||||||
|
|
||||||
_blockRestore = blockRestore;
|
_blockRestore = blockRestore;
|
||||||
_teleport = teleport;
|
_teleport = teleport;
|
||||||
_clanDataAccess = new ClansDataAccessLayer(this);
|
|
||||||
_clanDisplay = new ClansDisplay(this);
|
|
||||||
_clanAdmin = new ClansAdmin(this);
|
_clanAdmin = new ClansAdmin(this);
|
||||||
|
_clanBlocks = new ClansBlocks();
|
||||||
|
_clanDataAccess = new ClansDataAccessLayer(this);
|
||||||
|
_clanDisplay = new ClansDisplay(plugin, this);
|
||||||
|
_clanGame = new ClansGame(plugin, this);
|
||||||
|
_clanUtility = new ClansUtility(this);
|
||||||
|
|
||||||
|
Energy energy = new Energy(plugin);
|
||||||
|
PacketHandler packetHandler = new PacketHandler(plugin);
|
||||||
|
new CustomTagFix(plugin, packetHandler);
|
||||||
|
DisguiseManager disguiseManager = new DisguiseManager(plugin, packetHandler);
|
||||||
|
_condition = new SkillConditionManager(plugin);
|
||||||
|
Creature creature = new Creature(plugin);
|
||||||
|
|
||||||
|
new Field(plugin, creature, _condition, energy, serverName);
|
||||||
|
|
||||||
|
DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager);
|
||||||
|
|
||||||
|
new Gameplay(plugin, this, blockRestore, damageManager);
|
||||||
|
ProjectileManager throwManager = new ProjectileManager(plugin);
|
||||||
|
Fire fire = new Fire(plugin, _condition, damageManager);
|
||||||
|
ItemFactory itemFactory = new ItemFactory(plugin, blockRestore, _condition, damageManager, energy, fire, throwManager, webServerAddress);
|
||||||
|
SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, throwManager, disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress);
|
||||||
|
_classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress);
|
||||||
|
|
||||||
|
StatsManager statsManager = new StatsManager(plugin, _clientManager);
|
||||||
|
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager);
|
||||||
|
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
|
||||||
|
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
|
||||||
|
|
||||||
|
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
||||||
|
{
|
||||||
|
ClanInfo clan = new ClanInfo(this, token);
|
||||||
|
_clanMap.put(token.Name, clan);
|
||||||
|
|
||||||
|
for (ClanMemberToken memberToken : token.Members)
|
||||||
|
_clanMemberMap.put(memberToken.Name, clan);
|
||||||
|
|
||||||
|
for (ClanTerritoryToken territoryToken : token.Territories)
|
||||||
|
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void AddCommands()
|
||||||
|
{
|
||||||
|
addCommand(new ClansCommand(this));
|
||||||
|
addCommand(new ClansChatCommand(this));
|
||||||
|
addCommand(new ClansAllyChatCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInviteExpire()
|
public int getInviteExpire()
|
||||||
@ -103,215 +170,168 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
return _claimMap;
|
return _claimMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void commands()
|
|
||||||
{
|
|
||||||
AddCommand("cc");
|
|
||||||
AddCommand("fc");
|
|
||||||
AddCommand("ac");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void command(Player caller, String cmd, String[] args)
|
|
||||||
{
|
|
||||||
if (cmd.equals("cc") || cmd.equals("fc"))
|
|
||||||
CCommand().commandChat(caller, args);
|
|
||||||
|
|
||||||
else if (cmd.equals("ac"))
|
|
||||||
CCommand().commandAllyChat(caller, args);
|
|
||||||
|
|
||||||
else
|
|
||||||
CCommand().command(caller, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void Update(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (event.getType() == UpdateType.FAST)
|
|
||||||
CGame().UpdateSafe();
|
|
||||||
|
|
||||||
if (event.getType() == UpdateType.FASTER)
|
|
||||||
CGame().UpdateDisplay();
|
|
||||||
|
|
||||||
if (event.getType() == UpdateType.SEC)
|
|
||||||
{
|
|
||||||
for (ClansClan clan : _clanMap.values())
|
|
||||||
{
|
|
||||||
if (clan.GeneratorUpdate())
|
|
||||||
_genUpdateList.add(clan);
|
|
||||||
|
|
||||||
clan.OutpostUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_genUpdateList.size() > 0)
|
|
||||||
{
|
|
||||||
CRepo().Repository.UpdateClanTNTGenerators(_genUpdateList);
|
|
||||||
_genUpdateList.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getType() == UpdateType.FAST)
|
|
||||||
for (ClansClan clan : _clanMap.values())
|
|
||||||
if (clan.GetOutpost() != null)
|
|
||||||
clan.GetOutpost().BuildUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long lastPower = System.currentTimeMillis();
|
public long lastPower = System.currentTimeMillis();
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
|
||||||
public void BlockBurn(BlockBurnEvent event)
|
|
||||||
{
|
|
||||||
CGame().BlockBurn(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler
|
||||||
public void BlockIgnite(BlockIgniteEvent event)
|
public void savePlayerActiveBuild(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
CGame().BlockSpread(event);
|
if (_classManager.Get(event.getPlayer()) != null && _classManager.Get(event.getPlayer()).GetGameClass() != null)
|
||||||
}
|
{
|
||||||
|
CustomBuildToken activeBuild = _classManager.Get(event.getPlayer()).GetActiveCustomBuild(_classManager.Get(event.getPlayer()).GetGameClass());
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
if (activeBuild == null)
|
||||||
public void BlockPlace(BlockPlaceEvent event)
|
|
||||||
{
|
|
||||||
if (event.isCancelled())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CGame().BlockPlace(event);
|
activeBuild.PlayerName = event.getPlayer().getName();
|
||||||
|
|
||||||
|
// 0 is set aside for active build so we just dupe build to this row whenever we update it.
|
||||||
|
activeBuild.CustomBuildNumber = 0;
|
||||||
|
_classManager.GetRepository().SaveCustomBuild(activeBuild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
|
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
|
||||||
{
|
{
|
||||||
ClansClan clan = _clanUtility.getOwner(event.GetLocation());
|
ClanInfo 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"))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void Damage(CustomDamageEvent event)
|
|
||||||
{
|
|
||||||
if (event.IsCancelled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
CGame().Damage(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void Interact(PlayerInteractEvent event)
|
public void Interact(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
CGame().Interact(event);
|
getClanGame().Interact(event);
|
||||||
CDisplay().handleInteract(event);
|
getClanDisplay().handleInteract(event);
|
||||||
|
|
||||||
if (Util().Event().isAction(event, ActionType.R_BLOCK))
|
|
||||||
if (event.getClickedBlock().getType() == Material.BREWING_STAND && !event.isCancelled())
|
|
||||||
{
|
|
||||||
for (ClansClan clan : _clanMap.values())
|
|
||||||
clan.GeneratorUse(event.getPlayer(), event.getClickedBlock().getLocation());
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
else if (event.getClickedBlock().getType() == Material.BEACON)
|
|
||||||
{
|
|
||||||
for (ClansClan clan : _clanMap.values())
|
|
||||||
clan.OutpostUse(event.getPlayer(), event.getClickedBlock().getLocation());
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void Piston(BlockPistonExtendEvent event)
|
|
||||||
{
|
|
||||||
CGame().Piston(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
|
||||||
public void SkillTrigger(SkillTriggerEvent event)
|
|
||||||
{
|
|
||||||
CGame().SafeSkill(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void Death(CombatDeathEvent event)
|
|
||||||
{
|
|
||||||
CGame().DeathDominance(event);
|
|
||||||
|
|
||||||
CGame().DeathColor(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void Join(PlayerJoinEvent event)
|
public void handlePlayerChat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
CGame().Join(event);
|
if (event.isCancelled())
|
||||||
}
|
return;
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void Quit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
CGame().Quit(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void Explosion(EntityExplodeEvent event)
|
|
||||||
{
|
|
||||||
CGame().Explode(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean HandleClanChat(AsyncPlayerChatEvent event, String filteredMessage)
|
|
||||||
{
|
|
||||||
ClientClan client = Get(event.getPlayer());
|
ClientClan client = Get(event.getPlayer());
|
||||||
|
|
||||||
if (client == null)
|
if (client == null)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
if (!client.isClanChat())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
||||||
|
|
||||||
|
if (client.isClanChat())
|
||||||
|
{
|
||||||
if (clan == null)
|
if (clan == null)
|
||||||
{
|
{
|
||||||
Get(event.getPlayer()).setClanChat(false);
|
Get(event.getPlayer()).setClanChat(false);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatClan(clan, event.getPlayer(), event.getMessage(), filteredMessage);
|
event.setFormat(C.cAqua + "%1$s " + C.cDAqua + "%2$s");
|
||||||
return true;
|
event.getRecipients().clear();
|
||||||
}
|
|
||||||
|
|
||||||
public boolean HandleAllyChat(AsyncPlayerChatEvent event, String filteredMessage)
|
for (String cur : clan.getMembers().keySet())
|
||||||
{
|
{
|
||||||
if (!Get(event.getPlayer()).isAllyChat())
|
Player player = UtilPlayer.searchOnline(null, cur, false);
|
||||||
return false;
|
|
||||||
|
|
||||||
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
if (player == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
event.getRecipients().add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (client.isAllyChat())
|
||||||
|
{
|
||||||
if (clan == null)
|
if (clan == null)
|
||||||
{
|
{
|
||||||
Get(event.getPlayer()).setAllyChat(false);
|
Get(event.getPlayer()).setAllyChat(false);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatAlly(clan, event.getPlayer(), event.getMessage(), filteredMessage);
|
event.setFormat(C.cDGreen + clan.getName() + " " + C.cDGreen + "%1$s " + C.cGreen + "%2$s");
|
||||||
return true;
|
event.getRecipients().clear();
|
||||||
|
|
||||||
|
for (String cur : clan.getMembers().keySet())
|
||||||
|
{
|
||||||
|
Player player = UtilPlayer.searchOnline(null, cur, false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
event.getRecipients().add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChatClan(ClanInfo clan, Player sender, String message, String filteredMessage)
|
for (String allyName : clan.getAllyMap().keySet())
|
||||||
{
|
{
|
||||||
clan.chat(sender, message, filteredMessage);
|
ClanInfo ally = _clanUtility.getClanByClanName(allyName);
|
||||||
}
|
|
||||||
|
|
||||||
public void ChatAlly(ClanInfo clan, Player sender, String message, String filteredMessage)
|
|
||||||
{
|
|
||||||
for (String cur : clan.getAllyMap().keySet())
|
|
||||||
{
|
|
||||||
ClanInfo ally = _clanUtility.getClanByClanName(cur);
|
|
||||||
if (ally == null) continue;
|
if (ally == null) continue;
|
||||||
|
|
||||||
ally.allyChat(clan, sender, message, filteredMessage);
|
for (String playerName : ally.getMembers().keySet())
|
||||||
|
{
|
||||||
|
Player player = UtilPlayer.searchOnline(null, playerName, false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
event.getRecipients().add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (clan == null)
|
||||||
|
{
|
||||||
|
event.setFormat(C.cYellow + "%1$s " + C.cWhite + "%2$s");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clan.allyChat(clan, sender, message, filteredMessage);
|
event.setFormat(C.cGold + clan.getName() + " " + C.cYellow + "%1$s " + C.cWhite + "%2$s");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void chatClan(ClanInfo clan, Player caller, String message)
|
||||||
|
{
|
||||||
|
for (String cur : clan.getMembers().keySet())
|
||||||
|
{
|
||||||
|
Player player = UtilPlayer.searchOnline(null, cur, false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
UtilPlayer.message(player, C.cAqua + caller.getName() + " " + C.cDAqua + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void chatAlly(ClanInfo clan, Player caller, String message)
|
||||||
|
{
|
||||||
|
for (String cur : clan.getMembers().keySet())
|
||||||
|
{
|
||||||
|
Player player = UtilPlayer.searchOnline(null, cur, false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
UtilPlayer.message(player, C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String allyName : clan.getAllyMap().keySet())
|
||||||
|
{
|
||||||
|
ClanInfo ally = _clanUtility.getClanByClanName(allyName);
|
||||||
|
if (ally == null) continue;
|
||||||
|
|
||||||
|
for (String playerName : ally.getMembers().keySet())
|
||||||
|
{
|
||||||
|
Player player = UtilPlayer.searchOnline(null, playerName, false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
UtilPlayer.message(player, C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNameMin()
|
public int getNameMin()
|
||||||
@ -352,13 +372,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
|
|
||||||
public ClanRelation getRelation(String playerA, String playerB)
|
public ClanRelation getRelation(String playerA, String playerB)
|
||||||
{
|
{
|
||||||
return Get(playerA).getRelation(playerB);
|
return getClanUtility().rel(_clanMemberMap.get(playerA), _clanMemberMap.get(playerB));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChatColor GetColorOfFor(String other, Player player)
|
|
||||||
{
|
|
||||||
return _clanUtility.relChatColor(Get(player).getRelation(other), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getOnlineTime()
|
public long getOnlineTime()
|
||||||
@ -382,11 +396,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
return new ClientClan();
|
return new ClientClan();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockRestore getBlockRestore()
|
public BlockRestore getBlockRestore()
|
||||||
{
|
{
|
||||||
return _blockRestore;
|
return _blockRestore;
|
||||||
@ -416,4 +425,34 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
{
|
{
|
||||||
return _clanAdmin;
|
return _clanAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClansGame getClanGame()
|
||||||
|
{
|
||||||
|
return _clanGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClansBlocks getClanBlocks()
|
||||||
|
{
|
||||||
|
return _clanBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerName()
|
||||||
|
{
|
||||||
|
return _serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreClientManager getClientManager()
|
||||||
|
{
|
||||||
|
return _clientManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionManager getCondition()
|
||||||
|
{
|
||||||
|
return _condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassCombatShop getClanShop()
|
||||||
|
{
|
||||||
|
return _classShop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,9 +301,14 @@ public class ClansUtility
|
|||||||
|
|
||||||
public ClanRelation getAccess(Player player, Location loc)
|
public ClanRelation getAccess(Player player, Location loc)
|
||||||
{
|
{
|
||||||
ClanInfo owner = this.getOwner(loc);
|
ClanInfo owner = getOwner(loc);
|
||||||
ClanInfo clan = getClanByPlayer(player);
|
ClanInfo clan = getClanByPlayer(player);
|
||||||
|
|
||||||
|
String mimic = Clans.Get(player).getMimic();
|
||||||
|
|
||||||
|
if (mimic.length() != 0)
|
||||||
|
clan = Clans.getClanUtility().searchClanPlayer(player, mimic, false);
|
||||||
|
|
||||||
if (owner == null)
|
if (owner == null)
|
||||||
return ClanRelation.SELF;
|
return ClanRelation.SELF;
|
||||||
|
|
||||||
|
@ -6,14 +6,13 @@ public class ClientClan
|
|||||||
private boolean _allyChat;
|
private boolean _allyChat;
|
||||||
|
|
||||||
private boolean _mapOn;
|
private boolean _mapOn;
|
||||||
private boolean _canJoin;
|
|
||||||
private long _joinDelay;
|
private long _joinDelay;
|
||||||
|
|
||||||
private String _territory;
|
private String _territory = "";
|
||||||
private boolean _autoClaim;
|
private boolean _autoClaim;
|
||||||
private String _owner;
|
private String _owner = "";
|
||||||
private boolean _safe;
|
private boolean _safe;
|
||||||
private String _mimic;
|
private String _mimic = "";
|
||||||
|
|
||||||
public boolean isAllyChat()
|
public boolean isAllyChat()
|
||||||
{
|
{
|
||||||
@ -47,7 +46,10 @@ public class ClientClan
|
|||||||
|
|
||||||
public boolean canJoin()
|
public boolean canJoin()
|
||||||
{
|
{
|
||||||
return _canJoin;
|
if (System.currentTimeMillis() > _joinDelay)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDelay()
|
public long getDelay()
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package mineplex.game.clans.clans.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
|
||||||
|
public class ClansAllyChatCommand extends CommandBase<ClansManager>
|
||||||
|
{
|
||||||
|
public ClansAllyChatCommand(ClansManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ALL, "ac");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args == null || args.length == 0)
|
||||||
|
{
|
||||||
|
Plugin.Get(caller).setAllyChat(!Plugin.Get(caller).isAllyChat());
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat())));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Single Clan
|
||||||
|
if (!Plugin.Get(caller).isAllyChat())
|
||||||
|
{
|
||||||
|
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||||
|
if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||||
|
else Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package mineplex.game.clans.clans.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
|
||||||
|
public class ClansChatCommand extends CommandBase<ClansManager>
|
||||||
|
{
|
||||||
|
public ClansChatCommand(ClansManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ALL, "cc", "fc");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args == null || args.length == 0)
|
||||||
|
{
|
||||||
|
Plugin.Get(caller).setClanChat(!Plugin.Get(caller).isClanChat());
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat())));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Single Clan
|
||||||
|
if (!Plugin.Get(caller).isClanChat())
|
||||||
|
{
|
||||||
|
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||||
|
if (clan == null)
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||||
|
else
|
||||||
|
Plugin.chatClan(clan, caller, F.combine(args, 0, null, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,6 @@ import mineplex.game.clans.clans.ClientClan;
|
|||||||
|
|
||||||
public class ClansCommand extends CommandBase<ClansManager>
|
public class ClansCommand extends CommandBase<ClansManager>
|
||||||
{
|
{
|
||||||
public String[] denyClan = new String[] {
|
|
||||||
"neut", "neutral", "sethome", "promote", "demote", "admin", "help", "create", "disband", "delete", "invite", "join", "kick", "ally", "trust", "claim", "unclaim", "territory", "home"};
|
|
||||||
|
|
||||||
public ClansCommand(ClansManager plugin)
|
public ClansCommand(ClansManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "c", "clans", "f", "factions");
|
super(plugin, Rank.ALL, "c", "clans", "f", "factions");
|
||||||
@ -36,7 +33,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args == null || args.length == 0)
|
||||||
{
|
{
|
||||||
if (Plugin.getClanMemberMap().containsKey(caller.getName()))
|
if (Plugin.getClanMemberMap().containsKey(caller.getName()))
|
||||||
infoClan(caller, Plugin.getClanMemberMap().get(caller.getName()).getName());
|
infoClan(caller, Plugin.getClanMemberMap().get(caller.getName()).getName());
|
||||||
@ -129,7 +126,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
if (clan == null)
|
if (clan == null)
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||||
else
|
else
|
||||||
Plugin.ChatClan(clan, caller, F.combine(args, 0, null, false), F.combine(args, 0, null, false));
|
Plugin.chatClan(clan, caller, F.combine(args, 0, null, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +144,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
{
|
{
|
||||||
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||||
if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||||
else Plugin.ChatAlly(clan, caller, F.combine(args, 0, null, false), F.combine(args, 0, null, false));
|
else Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,14 +186,15 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
if (!client.canJoin())
|
if (!client.canJoin())
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You recently left a Clan with low Dominance."));
|
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " +
|
UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " +
|
||||||
C.mTime + UtilTime.convertString(System.currentTimeMillis() - client.getDelay(), 1, TimeUnit.FIT) +
|
C.mTime + UtilTime.convertString(System.currentTimeMillis() - client.getDelay(), 1, TimeUnit.FIT) +
|
||||||
C.mBody + "."));
|
C.mBody + "."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
@ -222,7 +220,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String cur : denyClan)
|
for (String cur : Plugin.denyClan)
|
||||||
{
|
{
|
||||||
if (cur.equalsIgnoreCase(args[1]))
|
if (cur.equalsIgnoreCase(args[1]))
|
||||||
{
|
{
|
||||||
@ -317,8 +315,6 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
|
|
||||||
public void join(Player caller, String[] args)
|
public void join(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
ClanInfo cA = Plugin.getClan(Plugin.getClanMemberMap().get(caller.getName()).getName());
|
|
||||||
|
|
||||||
if (Plugin.getClanMemberMap().containsKey(caller.getName()))
|
if (Plugin.getClanMemberMap().containsKey(caller.getName()))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
|
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
|
||||||
|
@ -13,6 +13,7 @@ import mineplex.core.database.column.ColumnBoolean;
|
|||||||
import mineplex.core.database.column.ColumnInt;
|
import mineplex.core.database.column.ColumnInt;
|
||||||
import mineplex.core.database.column.ColumnLong;
|
import mineplex.core.database.column.ColumnLong;
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
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;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||||
@ -20,30 +21,30 @@ import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
|||||||
|
|
||||||
public class ClanRepository extends RepositoryBase
|
public class ClanRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
private static String CREATE_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS clans (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), description VARCHAR(140), home VARCHAR(140), admin BOOL, dateCreated LONG, lastOnline LONG, PRIMARY KEY (id), INDEX clanName (name));";
|
private static String CREATE_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS clans (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), name VARCHAR(100), description VARCHAR(140), home VARCHAR(140), admin BOOL, dateCreated LONG, lastOnline LONG, PRIMARY KEY (id), INDEX clanName (name));";
|
||||||
private static String CREATE_ACCOUNT_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS accountClan (id INT NOT NULL AUTO_INCREMENT, accountId INT, clanId INT, clanRole VARCHAR(140), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
private static String CREATE_ACCOUNT_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS accountClan (id INT NOT NULL AUTO_INCREMENT, accountId INT, clanId INT, clanRole VARCHAR(140), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
||||||
private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverName VARCHAR(100), chunk VARCHAR(100), safe BOOL, PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverName));";
|
private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverName VARCHAR(100), chunk VARCHAR(100), safe BOOL, PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverName));";
|
||||||
private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BOOL, PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BOOL, PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
||||||
|
|
||||||
private static String RETRIEVE_START_CLAN_INFO = "SELECT id, name, description, home, admin, dateCreated, lastOnline, ct.chunk, ct.safe FROM clans AS c INNER JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE serverName = ?;";
|
private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverName = ?;";
|
||||||
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, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverName = ?;";
|
||||||
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 WHERE c.serverName = ?;";
|
||||||
|
|
||||||
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_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? 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_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;";
|
||||||
private static String DELETE_CLAN_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ? AND serverName = ? AND chunk = ?;";
|
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_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;";
|
||||||
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
|
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_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;";
|
||||||
private static String DELETE_CLAN = "DELETE FROM clans WHERE name = ?;";
|
private static String DELETE_CLAN = "DELETE FROM clans WHERE id = ?;";
|
||||||
|
|
||||||
private static String ADD_CLAN = "INSERT INTO clans (name, description, home, admin, dateCreated, lastOnline) VALUES (?, ?, ?, ?, now(), now());";
|
private static String ADD_CLAN = "INSERT INTO clans (serverName, 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_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_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);";
|
||||||
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, serverName, chunk, safe) 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 = "UPDATE clans SET name = ?, description = ?, 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_MEMBER = "UPDATE accountClan AS AC INNER JOIN accounts ON accounts.id = AC.accountId SET AC.clanRole = ? WHERE AC.clanId = ? AND accounts.name = ?;";
|
||||||
private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;";
|
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 static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverName = ? AND chunk = ?;";
|
||||||
|
|
||||||
@ -69,6 +70,8 @@ public class ClanRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
final NautHashMap<String, ClanToken> clans = new NautHashMap<String, ClanToken>();
|
final NautHashMap<String, ClanToken> clans = new NautHashMap<String, ClanToken>();
|
||||||
|
|
||||||
|
System.out.println("Running retrieveClans");
|
||||||
|
|
||||||
executeQuery(RETRIEVE_START_CLAN_INFO, new ResultSetCallable()
|
executeQuery(RETRIEVE_START_CLAN_INFO, new ResultSetCallable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -86,6 +89,7 @@ public class ClanRepository extends RepositoryBase
|
|||||||
token.LastOnline = resultSet.getLong(7);
|
token.LastOnline = resultSet.getLong(7);
|
||||||
|
|
||||||
ClanTerritoryToken territoryToken = new ClanTerritoryToken();
|
ClanTerritoryToken territoryToken = new ClanTerritoryToken();
|
||||||
|
territoryToken.ClanName = token.Name;
|
||||||
territoryToken.Chunk = resultSet.getString(8);
|
territoryToken.Chunk = resultSet.getString(8);
|
||||||
territoryToken.Safe = resultSet.getBoolean(9);
|
territoryToken.Safe = resultSet.getBoolean(9);
|
||||||
|
|
||||||
@ -94,6 +98,7 @@ public class ClanRepository extends RepositoryBase
|
|||||||
clans.put(token.Name, token);
|
clans.put(token.Name, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (territoryToken.Chunk != null)
|
||||||
clans.get(token.Name).Territories.add(territoryToken);
|
clans.get(token.Name).Territories.add(territoryToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +125,7 @@ public class ClanRepository extends RepositoryBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
}, new ColumnVarChar("serverName", 100, _serverName));
|
||||||
|
|
||||||
executeQuery(RETRIEVE_CLAN_ALLIANCE_INFO, new ResultSetCallable()
|
executeQuery(RETRIEVE_CLAN_ALLIANCE_INFO, new ResultSetCallable()
|
||||||
{
|
{
|
||||||
@ -152,28 +157,28 @@ public class ClanRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteClan(String name)
|
public void deleteClan(int clanId)
|
||||||
{
|
{
|
||||||
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnVarChar("name", 100, name));
|
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnInt("clanid", clanId));
|
||||||
executeUpdate(DELETE_CLAN_TERRITORIES, new ColumnVarChar("name", 100, name));
|
executeUpdate(DELETE_CLAN_TERRITORIES, new ColumnInt("clanid", clanId));
|
||||||
executeUpdate(DELETE_CLAN_ALLIANCES, new ColumnVarChar("name", 100, name));
|
executeUpdate(DELETE_CLAN_ALLIANCES, new ColumnInt("clanid", clanId), new ColumnInt("clanid", clanId));
|
||||||
executeUpdate(DELETE_CLAN, new ColumnVarChar("name", 100, name));
|
executeUpdate(DELETE_CLAN, new ColumnInt("clanid", clanId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addClan(final ClanToken token)
|
public void addClan(final ClanInfo clan, final ClanToken token)
|
||||||
{
|
{
|
||||||
executeUpdate(ADD_CLAN, new ResultSetCallable()
|
executeInsert(ADD_CLAN, new ResultSetCallable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
while (resultSet.next())
|
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));
|
clan.setId(resultSet.getInt(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}, new ColumnVarChar("name", 100, token.Name), new ColumnVarChar("description", 100, token.Description), new ColumnVarChar("home", 100, token.Home), new ColumnBoolean("admin", token.Admin));
|
}, new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("name", 100, token.Name), new ColumnVarChar("description", 100, token.Description), new ColumnVarChar("home", 100, token.Home), new ColumnBoolean("admin", token.Admin));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +194,7 @@ public class ClanRepository extends RepositoryBase
|
|||||||
|
|
||||||
public void updateMember(int clanId, String playerName, String role)
|
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));
|
executeUpdate(UPDATE_CLAN_MEMBER, new ColumnVarChar("clanRole", 100, role) , new ColumnInt("clanid", clanId), new ColumnVarChar("name", 100, playerName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addClanRelationship(int clanId, int otherClanId, boolean trusted)
|
public void addClanRelationship(int clanId, int otherClanId, boolean trusted)
|
||||||
@ -199,7 +204,7 @@ public class ClanRepository extends RepositoryBase
|
|||||||
|
|
||||||
public void updateClanRelationship(int clanId, int otherClanId, boolean 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));
|
executeUpdate(UPDATE_CLAN_ALLIANCE, new ColumnBoolean("trusted", trusted), new ColumnInt("clanid", clanId), new ColumnInt("otherClanId", otherClanId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeClanRelationship(int clanId, int otherClanId)
|
public void removeClanRelationship(int clanId, int otherClanId)
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
package mineplex.game.clans.clans.repository;
|
package mineplex.game.clans.clans.repository;
|
||||||
|
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||||
|
|
||||||
public class ClanTerritory
|
public class ClanTerritory
|
||||||
{
|
{
|
||||||
|
public ClanTerritory() { }
|
||||||
|
|
||||||
|
public ClanTerritory(ClanTerritoryToken territoryToken)
|
||||||
|
{
|
||||||
|
Owner = territoryToken.ClanName;
|
||||||
|
Safe = territoryToken.Safe;
|
||||||
|
Chunk = territoryToken.Chunk;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean Safe;
|
public boolean Safe;
|
||||||
public String Owner;
|
public String Owner = "";
|
||||||
public String Chunk;
|
public String Chunk = "";
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user