Merge remote-tracking branch 'remotes/origin/clans_custom_gear' into clans-beta
Conflicts: Plugins/.idea/misc.xml Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java
This commit is contained in:
commit
bf1f62057c
BIN
Art/Carl.png
Normal file
BIN
Art/Carl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 345 KiB |
@ -1,5 +1,5 @@
|
|||||||
<component name="ArtifactManager">
|
<component name="ArtifactManager">
|
||||||
<artifact name="Mineplex.Hub:test">
|
<artifact build-on-make="true" name="Mineplex.Hub:test">
|
||||||
<output-path>$PROJECT_DIR$/../Testing/Hub/plugins</output-path>
|
<output-path>$PROJECT_DIR$/../Testing/Hub/plugins</output-path>
|
||||||
<root id="root">
|
<root id="root">
|
||||||
<element id="artifact" artifact-name="Mineplex.Hub:jar" />
|
<element id="artifact" artifact-name="Mineplex.Hub:jar" />
|
||||||
|
24
Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml
Normal file
24
Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" build-on-make="true" name="Mineplex.Votifier:jar">
|
||||||
|
<output-path>$PROJECT_DIR$/out/artifacts/</output-path>
|
||||||
|
<root id="archive" name="MineplexVotifier.jar">
|
||||||
|
<element id="module-output" name="Mineplex.Votifier" />
|
||||||
|
<element id="module-output" name="Mineplex.Core" />
|
||||||
|
<element id="module-output" name="Mineplex.Core.Common" />
|
||||||
|
<element id="module-output" name="Mineplex.ServerData" />
|
||||||
|
<element id="module-output" name="Mineplex.ServerMonitor" />
|
||||||
|
<element id="module-output" name="Mineplex.Database" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-io-2.4.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-logging-1.1.1.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-pool2-2.2.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-codec-1.6.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/httpclient-4.2.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/httpcore-4.2.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||||
|
<element id="file-copy" path="$PROJECT_DIR$/Mineplex.Votifier/plugin.yml" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
@ -20,8 +20,16 @@
|
|||||||
<profile default="true" name="Default" enabled="false">
|
<profile default="true" name="Default" enabled="false">
|
||||||
<processorPath useClasspath="true" />
|
<processorPath useClasspath="true" />
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile default="false" name="Annotation profile for bungee" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel target="1.7" />
|
<bytecodeTargetLevel target="1.7">
|
||||||
|
<module name="bungee" target="1.7" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
<component name="JavacSettings">
|
<component name="JavacSettings">
|
||||||
<option name="GENERATE_NO_WARNINGS" value="true" />
|
<option name="GENERATE_NO_WARNINGS" value="true" />
|
||||||
|
@ -2,4 +2,3 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="bukkit">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$PROJECT_DIR$/Libraries/bukkit.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$PROJECT_DIR$/Libraries/bukkit.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
@ -7,6 +7,15 @@
|
|||||||
</list>
|
</list>
|
||||||
</component>
|
</component>
|
||||||
<component name="IdProvider" IDEtalkID="7E81636CD93857493DFE224533ECF492" />
|
<component name="IdProvider" IDEtalkID="7E81636CD93857493DFE224533ECF492" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="ignoredFiles">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$/ParkerFactions/common/pom.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/ParkerFactions/gameplay/pom.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/ParkerFactions/pom.xml" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" group="Core" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" group="Core" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" filepath="$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" group="Core" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" filepath="$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" group="Core" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" filepath="$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" group="Core" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" filepath="$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" filepath="$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" group="Game" />
|
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" filepath="$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" group="Game" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.PvP/Nautilus.Game.PvP.iml" filepath="$PROJECT_DIR$/Nautilus.Game.PvP/Nautilus.Game.PvP.iml" group="Legacy" />
|
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.PvP/Nautilus.Game.PvP.iml" filepath="$PROJECT_DIR$/Nautilus.Game.PvP/Nautilus.Game.PvP.iml" group="Legacy" />
|
||||||
</modules>
|
</modules>
|
||||||
|
@ -39,8 +39,9 @@ public class MotdManager implements Listener, Runnable
|
|||||||
if (new File("updateMOTD.dat").exists())
|
if (new File("updateMOTD.dat").exists())
|
||||||
{
|
{
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<String>();
|
||||||
lines.add(" §b§l◄§f§lNEW§b§l► §f§l◄§b§lSKYWARS§f§l► §b§l◄§f§lNEW§b§l►");
|
lines.add(" §f§l◄ §6§lNEW §f§l▬ §c§lSSM/SG/SW Teams§f§l ▬ §c§lMPS Update §f§l►");
|
||||||
//lines.add(" §d§lRank Sale §a§l40% Off");
|
//lines.add(" §d§lRank Sale §a§l40% Off");
|
||||||
|
//lines.add(" §f§l◄§c§lMAINTENANCE§f§l►");
|
||||||
|
|
||||||
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines);
|
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines);
|
||||||
System.out.println("Updated Bungee MOTD");
|
System.out.println("Updated Bungee MOTD");
|
||||||
|
@ -56,7 +56,7 @@ public class PlayerTracker implements Listener
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
_repository.removeElement(event.getPlayer().getName());
|
_repository.removeElement(event.getPlayer().getName().toLowerCase());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
package mineplex.core.common;
|
package mineplex.core.common;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
public enum Rank
|
public enum Rank
|
||||||
{
|
{
|
||||||
LT("LT", ChatColor.DARK_RED),
|
LT("LT", ChatColor.DARK_RED),
|
||||||
OWNER("Owner", ChatColor.DARK_RED),
|
OWNER("Owner", ChatColor.DARK_RED),
|
||||||
DEVELOPER("Dev", ChatColor.RED),
|
DEVELOPER("Dev", ChatColor.RED),
|
||||||
ADMIN("Admin", ChatColor.RED),
|
ADMIN("Admin", ChatColor.RED),
|
||||||
|
JNR_DEV("Jr.Dev", ChatColor.RED),
|
||||||
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
|
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
|
||||||
MODERATOR("Mod", ChatColor.GOLD),
|
MODERATOR("Mod", ChatColor.GOLD),
|
||||||
JNR_DEV("Jr.Dev", ChatColor.RED),
|
|
||||||
HELPER("Trainee", ChatColor.DARK_AQUA),
|
HELPER("Trainee", ChatColor.DARK_AQUA),
|
||||||
MAPLEAD("MapLead", ChatColor.DARK_PURPLE),
|
MAPLEAD("MapLead", ChatColor.DARK_PURPLE),
|
||||||
MAPDEV("Builder", ChatColor.BLUE),
|
MAPDEV("Builder", ChatColor.BLUE),
|
||||||
|
MEDIA("Media", ChatColor.BLUE),
|
||||||
|
|
||||||
EVENT("Event", ChatColor.WHITE),
|
EVENT("Event", ChatColor.WHITE),
|
||||||
|
|
||||||
@ -51,10 +52,6 @@ public enum Rank
|
|||||||
|
|
||||||
public boolean Has(Player player, Rank rank, Rank[] specific, boolean inform)
|
public boolean Has(Player player, Rank rank, Rank[] specific, boolean inform)
|
||||||
{
|
{
|
||||||
if (player != null)
|
|
||||||
if (player.getName().equals("Chiss"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//Specific Rank
|
//Specific Rank
|
||||||
if (specific != null)
|
if (specific != null)
|
||||||
{
|
{
|
||||||
@ -75,7 +72,7 @@ public enum Rank
|
|||||||
{
|
{
|
||||||
UtilPlayer.message(player, C.mHead + "Permissions> " +
|
UtilPlayer.message(player, C.mHead + "Permissions> " +
|
||||||
C.mBody + "This requires Permission Rank [" +
|
C.mBody + "This requires Permission Rank [" +
|
||||||
C.mHead + rank +
|
C.mHead + rank.Name.toUpperCase() +
|
||||||
C.mBody + "].");
|
C.mBody + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -85,7 +86,8 @@ public class SchematicRunnable implements Runnable
|
|||||||
// We are done
|
// We are done
|
||||||
System.out.println("Finished importing schematic with setblockrunnable!");
|
System.out.println("Finished importing schematic with setblockrunnable!");
|
||||||
|
|
||||||
if (_callback != null) _callback.run(_changedBlocks);
|
if (_callback != null)
|
||||||
|
_callback.run(_changedBlocks);
|
||||||
|
|
||||||
_task.cancel();
|
_task.cancel();
|
||||||
return;
|
return;
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
package mineplex.core.common.util;
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class UtilAction
|
public class UtilAction
|
||||||
{
|
{
|
||||||
|
private static VelocityReceiver _velocityFix;
|
||||||
|
|
||||||
|
public static void registerVelocityFix(VelocityReceiver velocityFix)
|
||||||
|
{
|
||||||
|
_velocityFix = velocityFix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void velocity(Entity ent, Vector vec)
|
||||||
|
{
|
||||||
|
velocity(ent, vec, vec.length(), false, 0, 0, vec.length(), false);
|
||||||
|
}
|
||||||
|
|
||||||
public static void velocity(Entity ent, double str, double yAdd, double yMax, boolean groundBoost)
|
public static void velocity(Entity ent, double str, double yAdd, double yMax, boolean groundBoost)
|
||||||
{
|
{
|
||||||
velocity(ent, ent.getLocation().getDirection(), str, false, 0, yAdd, yMax, groundBoost);
|
velocity(ent, ent.getLocation().getDirection(), str, false, 0, yAdd, yMax, groundBoost);
|
||||||
@ -14,7 +26,10 @@ public class UtilAction
|
|||||||
public static void velocity(Entity ent, Vector vec, double str, boolean ySet, double yBase, double yAdd, double yMax, boolean groundBoost)
|
public static void velocity(Entity ent, Vector vec, double str, boolean ySet, double yBase, double yAdd, double yMax, boolean groundBoost)
|
||||||
{
|
{
|
||||||
if (Double.isNaN(vec.getX()) || Double.isNaN(vec.getY()) || Double.isNaN(vec.getZ()) || vec.length() == 0)
|
if (Double.isNaN(vec.getX()) || Double.isNaN(vec.getY()) || Double.isNaN(vec.getZ()) || vec.length() == 0)
|
||||||
|
{
|
||||||
|
zeroVelocity(ent);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//YSet
|
//YSet
|
||||||
if (ySet)
|
if (ySet)
|
||||||
@ -37,6 +52,29 @@ public class UtilAction
|
|||||||
|
|
||||||
//Velocity
|
//Velocity
|
||||||
ent.setFallDistance(0);
|
ent.setFallDistance(0);
|
||||||
|
|
||||||
|
//Store It!
|
||||||
|
if (ent instanceof Player && _velocityFix != null)
|
||||||
|
{
|
||||||
|
_velocityFix.setPlayerVelocity(((Player)ent), vec);
|
||||||
|
}
|
||||||
|
|
||||||
ent.setVelocity(vec);
|
ent.setVelocity(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void zeroVelocity(Entity ent)
|
||||||
|
{
|
||||||
|
Vector vec = new Vector(0,0,0);
|
||||||
|
ent.setFallDistance(0);
|
||||||
|
|
||||||
|
//Store It!
|
||||||
|
if (ent instanceof Player && _velocityFix != null)
|
||||||
|
{
|
||||||
|
_velocityFix.setPlayerVelocity(((Player)ent), vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
ent.setVelocity(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -25,7 +26,7 @@ public class UtilAlg
|
|||||||
|
|
||||||
public static Location getMidpoint(Location a, Location b)
|
public static Location getMidpoint(Location a, Location b)
|
||||||
{
|
{
|
||||||
return a.add(b.subtract(a).multiply(0.5));
|
return a.clone().add(b.clone().subtract(a.clone()).multiply(0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector getTrajectory(Entity from, Entity to)
|
public static Vector getTrajectory(Entity from, Entity to)
|
||||||
@ -260,4 +261,132 @@ public class UtilAlg
|
|||||||
return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) ||
|
return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) ||
|
||||||
isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit);
|
isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Location getLocationAwayFromPlayers(ArrayList<Location> locs, ArrayList<Player> players)
|
||||||
|
{
|
||||||
|
Location bestLoc = null;
|
||||||
|
double bestDist = 0;
|
||||||
|
|
||||||
|
for (Location loc : locs)
|
||||||
|
{
|
||||||
|
double closest = -1;
|
||||||
|
|
||||||
|
for (Player player : players)
|
||||||
|
{
|
||||||
|
//Different Worlds
|
||||||
|
if (!player.getWorld().equals(loc.getWorld()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||||
|
|
||||||
|
if (closest == -1 || dist < closest)
|
||||||
|
{
|
||||||
|
closest = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closest == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (bestLoc == null || closest > bestDist)
|
||||||
|
{
|
||||||
|
bestLoc = loc;
|
||||||
|
bestDist = closest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Location getLocationNearPlayers(ArrayList<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
|
||||||
|
{
|
||||||
|
Location bestLoc = null;
|
||||||
|
double bestDist = 0;
|
||||||
|
|
||||||
|
for (Location loc : locs)
|
||||||
|
{
|
||||||
|
double closest = -1;
|
||||||
|
|
||||||
|
boolean valid = true;
|
||||||
|
|
||||||
|
//Dont spawn on other players
|
||||||
|
for (Player player : dontOverlap)
|
||||||
|
{
|
||||||
|
if (!player.getWorld().equals(loc.getWorld()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||||
|
|
||||||
|
if (dist < 0.8)
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valid)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Find closest player
|
||||||
|
for (Player player : players)
|
||||||
|
{
|
||||||
|
if (!player.getWorld().equals(loc.getWorld()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||||
|
|
||||||
|
if (closest == -1 || dist < closest)
|
||||||
|
{
|
||||||
|
closest = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closest == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (bestLoc == null || closest < bestDist)
|
||||||
|
{
|
||||||
|
bestLoc = loc;
|
||||||
|
bestDist = closest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector calculateVelocity(Vector from, Vector to, int heightGain)
|
||||||
|
{
|
||||||
|
// Gravity of a potion
|
||||||
|
double gravity = 0.115;
|
||||||
|
// Block locations
|
||||||
|
int endGain = to.getBlockY() - from.getBlockY();
|
||||||
|
|
||||||
|
double dx1 = to.getBlockX() - from.getBlockX();
|
||||||
|
double dz1 = to.getBlockZ() - from.getBlockZ();
|
||||||
|
|
||||||
|
double horizDist = Math.sqrt(dx1 * dx1 + dz1 * dz1);
|
||||||
|
// Height gain
|
||||||
|
int gain = heightGain;
|
||||||
|
double maxGain = gain > (endGain + gain) ? gain : (endGain + gain);
|
||||||
|
// Solve quadratic equation for velocity
|
||||||
|
double a = -horizDist * horizDist / (4 * maxGain);
|
||||||
|
double b = horizDist;
|
||||||
|
double c = -endGain;
|
||||||
|
double slope = -b / (2 * a) - Math.sqrt(b * b - 4 * a * c) / (2 * a);
|
||||||
|
// Vertical velocity
|
||||||
|
double vy = Math.sqrt(maxGain * gravity);
|
||||||
|
// Horizontal velocity
|
||||||
|
double vh = vy / slope;
|
||||||
|
// Calculate horizontal direction
|
||||||
|
int dx = to.getBlockX() - from.getBlockX();
|
||||||
|
int dz = to.getBlockZ() - from.getBlockZ();
|
||||||
|
double mag = Math.sqrt(dx * dx + dz * dz);
|
||||||
|
double dirx = dx / mag;
|
||||||
|
double dirz = dz / mag;
|
||||||
|
// Horizontal velocity components
|
||||||
|
double vx = vh * dirx;
|
||||||
|
double vz = vh * dirz;
|
||||||
|
return new Vector(vx, vy, vz);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,24 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityBat;
|
import net.minecraft.server.v1_7_R4.EntityBat;
|
||||||
import net.minecraft.server.v1_7_R4.EntityCreature;
|
import net.minecraft.server.v1_7_R4.EntityCreature;
|
||||||
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
|
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
|
||||||
import net.minecraft.server.v1_7_R4.EntityHuman;
|
import net.minecraft.server.v1_7_R4.EntityHuman;
|
||||||
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
||||||
import net.minecraft.server.v1_7_R4.EntityLiving;
|
import net.minecraft.server.v1_7_R4.EntityLiving;
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityTrackerEntry;
|
||||||
import net.minecraft.server.v1_7_R4.Navigation;
|
import net.minecraft.server.v1_7_R4.Navigation;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_7_R4.PathfinderGoal;
|
import net.minecraft.server.v1_7_R4.PathfinderGoal;
|
||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
|
||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction;
|
||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
|
||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
|
||||||
|
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -32,6 +35,7 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.Giant;
|
import org.bukkit.entity.Giant;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||||
|
|
||||||
@ -582,6 +586,36 @@ public class UtilEnt
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean CreatureLook(Entity ent, Entity target)
|
||||||
|
{
|
||||||
|
return CreatureLook(ent, target instanceof LivingEntity ? ((LivingEntity) target).getEyeLocation() : target.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean CreatureLook(Entity ent, Location target)
|
||||||
|
{
|
||||||
|
Vector vec = UtilAlg.getTrajectory(ent.getLocation(), target);
|
||||||
|
|
||||||
|
return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean CreatureLook(Entity ent, float pitch, float yaw)
|
||||||
|
{
|
||||||
|
if (!(ent instanceof LivingEntity))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
EntityLiving ec = ((CraftLivingEntity) ent).getHandle();
|
||||||
|
Location loc = ent.getLocation();
|
||||||
|
|
||||||
|
ec.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), yaw, pitch);
|
||||||
|
ec.al = true;
|
||||||
|
|
||||||
|
EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.world).tracker.trackedEntities.get(ec.getId());
|
||||||
|
|
||||||
|
entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, (byte) (ec.yaw * 256.0F / 360.0F)));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void CreatureMove(Entity ent, Location target, float speed)
|
public static void CreatureMove(Entity ent, Location target, float speed)
|
||||||
{
|
{
|
||||||
if (!(ent instanceof Creature))
|
if (!(ent instanceof Creature))
|
||||||
|
@ -16,7 +16,8 @@ public class UtilEvent
|
|||||||
L_BLOCK,
|
L_BLOCK,
|
||||||
R,
|
R,
|
||||||
R_AIR,
|
R_AIR,
|
||||||
R_BLOCK
|
R_BLOCK,
|
||||||
|
ANY
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAction(PlayerInteractEvent event, ActionType action)
|
public static boolean isAction(PlayerInteractEvent event, ActionType action)
|
||||||
@ -39,6 +40,9 @@ public class UtilEvent
|
|||||||
if (action == ActionType.R_BLOCK)
|
if (action == ActionType.R_BLOCK)
|
||||||
return (event.getAction() == Action.RIGHT_CLICK_BLOCK);
|
return (event.getAction() == Action.RIGHT_CLICK_BLOCK);
|
||||||
|
|
||||||
|
if (action == ActionType.ANY)
|
||||||
|
return event.getAction() != Action.PHYSICAL;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,5 +90,11 @@ public class UtilMath
|
|||||||
|
|
||||||
return Math.random() * d;
|
return Math.random() * d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T randomElement(T[] array) {
|
||||||
|
if (array.length == 0)
|
||||||
|
return null;
|
||||||
|
return array[random.nextInt(array.length)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,21 +7,25 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_7_R4.Packet;
|
||||||
|
import net.minecraft.server.v1_7_R4.PlayerConnection;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.Packet;
|
|
||||||
import net.minecraft.server.v1_7_R4.PlayerConnection;
|
|
||||||
|
|
||||||
public class UtilPlayer
|
public class UtilPlayer
|
||||||
{
|
{
|
||||||
private static Random RANDOM = new Random();
|
private static Random RANDOM = new Random();
|
||||||
@ -656,6 +660,18 @@ public class UtilPlayer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static InventoryView swapToInventory(Player player, Inventory inv) {
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
return player.openInventory(inv);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void setListName(Player player, CoreClient client)
|
public void setListName(Player player, CoreClient client)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,8 @@ package mineplex.core.common.util;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.WordUtils;
|
||||||
|
|
||||||
public class UtilText {
|
public class UtilText {
|
||||||
public static <T> String listToString(Collection<T> inputList, boolean comma) {
|
public static <T> String listToString(Collection<T> inputList, boolean comma) {
|
||||||
String out = "";
|
String out = "";
|
||||||
@ -48,6 +50,11 @@ public class UtilText {
|
|||||||
|
|
||||||
public static boolean isStringSimilar(String newString, String oldString, float matchRequirement)
|
public static boolean isStringSimilar(String newString, String oldString, float matchRequirement)
|
||||||
{
|
{
|
||||||
|
if (newString.length() <= 3)
|
||||||
|
{
|
||||||
|
return newString.toLowerCase().equals(oldString.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0 ; i < newString.length() * matchRequirement ; i++)
|
for (int i=0 ; i < newString.length() * matchRequirement ; i++)
|
||||||
{
|
{
|
||||||
int matchFromIndex = 0;
|
int matchFromIndex = 0;
|
||||||
@ -56,7 +63,7 @@ public class UtilText {
|
|||||||
for (int j=0 ; j < oldString.length() ; j++)
|
for (int j=0 ; j < oldString.length() ; j++)
|
||||||
{
|
{
|
||||||
//End of newString
|
//End of newString
|
||||||
if (i+j > newString.length())
|
if (i+j >= newString.length())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -79,4 +86,13 @@ public class UtilText {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] wrap(String text, int lineLength)
|
||||||
|
{
|
||||||
|
return wrap(text, lineLength, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] wrap(String text, int lineLength, boolean wrapLongerWords) {
|
||||||
|
return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public interface VelocityReceiver
|
||||||
|
{
|
||||||
|
public void setPlayerVelocity(Player player, Vector velocity);
|
||||||
|
}
|
@ -12,7 +12,7 @@
|
|||||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
|
||||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
|
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
|
||||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
|
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
|
|
||||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
|
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -21,7 +21,7 @@ public abstract class MiniDbClientPlugin<DataType extends Object> extends MiniCl
|
|||||||
clientManager.addStoredProcedureLoginProcessor(this);
|
clientManager.addStoredProcedureLoginProcessor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
public abstract void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException;
|
||||||
|
|
||||||
public CoreClientManager getClientManager()
|
public CoreClientManager getClientManager()
|
||||||
{
|
{
|
||||||
|
10
Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java
Normal file
10
Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package mineplex.core;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
|
|
||||||
|
public class NCPDataManFix
|
||||||
|
{
|
||||||
|
public NCPDataManFix() {
|
||||||
|
//ConfigManager.getConfigFile().set("data.consistencychecks.suppresswarnings", true);
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,11 @@ public class CoreClient
|
|||||||
{
|
{
|
||||||
private int _accountId = -1;
|
private int _accountId = -1;
|
||||||
private String _name;
|
private String _name;
|
||||||
|
private String _disguisedAs;
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private Rank _rank;
|
private Rank _rank;
|
||||||
|
private Rank _disguisedRank;
|
||||||
|
private boolean _disguised;
|
||||||
|
|
||||||
public CoreClient(Player player)
|
public CoreClient(Player player)
|
||||||
{
|
{
|
||||||
@ -62,4 +65,34 @@ public class CoreClient
|
|||||||
{
|
{
|
||||||
_rank = rank;
|
_rank = rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDisguisedAs()
|
||||||
|
{
|
||||||
|
return _disguisedAs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisguisedAs(String originalName)
|
||||||
|
{
|
||||||
|
this._disguisedAs = originalName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only use this method if the client is actually disguised!
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Rank getDisguisedRank() {
|
||||||
|
return _disguisedRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisguisedRank(Rank disguisedRank) {
|
||||||
|
this._disguisedRank = disguisedRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisguised() {
|
||||||
|
return _disguised;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisguised(boolean disguised) {
|
||||||
|
this._disguised = disguised;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package mineplex.core.account;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -50,6 +51,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
private RedisDataRepository<AccountCache> _accountCacheRepository;
|
private RedisDataRepository<AccountCache> _accountCacheRepository;
|
||||||
|
|
||||||
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
||||||
|
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
|
||||||
|
|
||||||
private Object _clientLock = new Object();
|
private Object _clientLock = new Object();
|
||||||
|
|
||||||
@ -118,16 +120,19 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
synchronized(_clientLock)
|
synchronized(_clientLock)
|
||||||
{
|
{
|
||||||
|
for(CoreClient client : _clientList.values())
|
||||||
|
{
|
||||||
|
if(client.getDisguisedAs() != null)
|
||||||
|
if(client.getDisguisedAs().equalsIgnoreCase(name))
|
||||||
|
return client;
|
||||||
|
}
|
||||||
return _clientList.get(name);
|
return _clientList.get(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreClient Get(Player player)
|
public CoreClient Get(Player player)
|
||||||
{
|
{
|
||||||
synchronized(_clientLock)
|
return Get(player.getName());
|
||||||
{
|
|
||||||
return _clientList.get(player.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerCountIncludingConnecting()
|
public int getPlayerCountIncludingConnecting()
|
||||||
@ -135,6 +140,16 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get());
|
return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the databse account id for a player. Requires the player is online
|
||||||
|
* @param player
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getAccountId(Player player)
|
||||||
|
{
|
||||||
|
return Get(player).getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void AsyncLogin(AsyncPlayerPreLoginEvent event)
|
public void AsyncLogin(AsyncPlayerPreLoginEvent event)
|
||||||
{
|
{
|
||||||
@ -221,13 +236,13 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
|
|
||||||
CoreClient client = Add(playerName);
|
CoreClient client = Add(playerName);
|
||||||
client.SetRank(Rank.valueOf(token.Rank));
|
client.SetRank(Rank.valueOf(token.Rank));
|
||||||
client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName()));
|
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
|
|
||||||
if (client.getAccountId() > 0)
|
if (client.getAccountId() > 0)
|
||||||
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()));
|
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -248,7 +263,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress)
|
public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress)
|
||||||
{
|
{
|
||||||
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");
|
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");
|
||||||
long timeStart = System.currentTimeMillis();
|
long timeStart = System.currentTimeMillis();
|
||||||
@ -261,7 +276,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName()));
|
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
|
||||||
_clientLoginLock.remove(client.GetPlayerName());
|
_clientLoginLock.remove(client.GetPlayerName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -301,7 +316,16 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId());
|
System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId());
|
||||||
|
|
||||||
if (client.getAccountId() > 0)
|
if (client.getAccountId() > 0)
|
||||||
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()));
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return !_clientLoginLock.containsKey(client.GetPlayerName());
|
return !_clientLoginLock.containsKey(client.GetPlayerName());
|
||||||
}
|
}
|
||||||
@ -473,11 +497,13 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
clientIterator.remove();
|
clientIterator.remove();
|
||||||
|
|
||||||
if (clientPlayer != null)
|
if (clientPlayer != null)
|
||||||
|
{
|
||||||
_plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName()));
|
_plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void debug(UpdateEvent event)
|
public void debug(UpdateEvent event)
|
||||||
@ -496,6 +522,11 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
_loginProcessors.put(processor.getName(), processor);
|
_loginProcessors.put(processor.getName(), processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addStoredProcedureLoginProcessor(IQuerylessLoginProcessor processor)
|
||||||
|
{
|
||||||
|
_querylessLoginProcessors.add(processor);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasRank(Player player, Rank rank)
|
public boolean hasRank(Player player, Rank rank)
|
||||||
{
|
{
|
||||||
CoreClient client = Get(player);
|
CoreClient client = Get(player);
|
||||||
|
@ -7,7 +7,7 @@ public interface ILoginProcessor
|
|||||||
{
|
{
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException;
|
||||||
|
|
||||||
String getQuery(int accountId, String uuid, String name);
|
String getQuery(int accountId, String uuid, String name);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package mineplex.core.account;
|
||||||
|
|
||||||
|
public interface IQuerylessLoginProcessor
|
||||||
|
{
|
||||||
|
public void processLogin(String playerName, int accountId);
|
||||||
|
}
|
@ -19,12 +19,20 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
|||||||
{
|
{
|
||||||
public UpdateRank(CoreClientManager plugin)
|
public UpdateRank(CoreClientManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "updateRank");
|
super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV /*On test servers only*/}, "updateRank");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(final Player caller, String[] args)
|
public void Execute(final Player caller, String[] args)
|
||||||
{
|
{
|
||||||
|
boolean testServer = Plugin.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing");
|
||||||
|
|
||||||
|
if (Plugin.Get(caller).GetRank() == Rank.JNR_DEV && !testServer)
|
||||||
|
{
|
||||||
|
F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.GetTag(true, true)) + "s are only permitted to set ranks on test servers!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args == null)
|
if (args == null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + AliasUsed + " joeschmo MODERATOR"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + AliasUsed + " joeschmo MODERATOR"));
|
||||||
@ -52,9 +60,10 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
|||||||
|
|
||||||
final Rank rank = tempRank;
|
final Rank rank = tempRank;
|
||||||
|
|
||||||
if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.JNR_DEV || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.JNR_DEV || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
||||||
|
if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.JNR_DEV || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
||||||
{
|
{
|
||||||
if (rank == Rank.ADMIN && !Plugin.hasRank(caller, Rank.LT))
|
if (!testServer && rank.Has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Insufficient privileges!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Insufficient privileges!"));
|
||||||
return;
|
return;
|
||||||
|
@ -6,6 +6,7 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.account.ILoginProcessor;
|
import mineplex.core.account.ILoginProcessor;
|
||||||
|
import mineplex.core.account.IQuerylessLoginProcessor;
|
||||||
import mineplex.core.account.repository.token.LoginToken;
|
import mineplex.core.account.repository.token.LoginToken;
|
||||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
@ -55,7 +57,7 @@ public class AccountRepository extends RepositoryBase
|
|||||||
//executeUpdate(CREATE_ACCOUNT_TABLE);
|
//executeUpdate(CREATE_ACCOUNT_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int login(NautHashMap<String, ILoginProcessor> loginProcessors, String uuid, String name)
|
public int login(NautHashMap<String, ILoginProcessor> loginProcessors, LinkedList<IQuerylessLoginProcessor> querylessLoginProcessors, String uuid, String name)
|
||||||
{
|
{
|
||||||
int accountId = -1;
|
int accountId = -1;
|
||||||
try (
|
try (
|
||||||
@ -142,9 +144,14 @@ public class AccountRepository extends RepositoryBase
|
|||||||
|
|
||||||
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||||
{
|
{
|
||||||
loginProcessor.processLoginResultSet(name, statement.getResultSet());
|
loginProcessor.processLoginResultSet(name, accountId, statement.getResultSet());
|
||||||
statement.getMoreResults();
|
statement.getMoreResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (IQuerylessLoginProcessor loginProcessor : querylessLoginProcessors)
|
||||||
|
{
|
||||||
|
loginProcessor.processLogin(name, accountId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ public enum Achievement
|
|||||||
//Survival Games
|
//Survival Games
|
||||||
SURVIVAL_GAMES_WINS("Katniss Everdeen", 600,
|
SURVIVAL_GAMES_WINS("Katniss Everdeen", 600,
|
||||||
new String[]{"Survival Games.Wins"},
|
new String[]{"Survival Games.Wins"},
|
||||||
new String[]{"Win 30 games of Survival Games"},
|
new String[]{"Win 20 games of Survival Games"},
|
||||||
new int[]{30},
|
new int[]{30},
|
||||||
AchievementCategory.SURVIVAL_GAMES),
|
AchievementCategory.SURVIVAL_GAMES),
|
||||||
|
|
||||||
@ -87,8 +87,8 @@ public enum Achievement
|
|||||||
//Skywars
|
//Skywars
|
||||||
SKYWARS_WINS("Sky King",2000,
|
SKYWARS_WINS("Sky King",2000,
|
||||||
new String[]{"Skywars.Wins"},
|
new String[]{"Skywars.Wins"},
|
||||||
new String[]{"Win 30 Games of Skywars"},
|
new String[]{"Win 20 Games of Skywars"},
|
||||||
new int[]{30},
|
new int[]{20},
|
||||||
AchievementCategory.SKYWARS),
|
AchievementCategory.SKYWARS),
|
||||||
|
|
||||||
SKYWARS_BOMBER("Master Bomber",500,
|
SKYWARS_BOMBER("Master Bomber",500,
|
||||||
@ -326,7 +326,7 @@ public enum Achievement
|
|||||||
|
|
||||||
SUPER_PAINTBALL_FLAWLESS_VICTORY("Flawless Victory", 1000,
|
SUPER_PAINTBALL_FLAWLESS_VICTORY("Flawless Victory", 1000,
|
||||||
new String[]{"Super Paintball.Wins"},
|
new String[]{"Super Paintball.Wins"},
|
||||||
new String[]{"Win a team with your entire team alive"},
|
new String[]{"Win a game with your entire team alive"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.SUPER_PAINTBALL),
|
AchievementCategory.SUPER_PAINTBALL),
|
||||||
|
|
||||||
@ -630,6 +630,44 @@ public enum Achievement
|
|||||||
new String[]{"Kill 2 enemies while blinded from", "a single flashbang"},
|
new String[]{"Kill 2 enemies while blinded from", "a single flashbang"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.MINE_STRIKE),
|
AchievementCategory.MINE_STRIKE),
|
||||||
|
|
||||||
|
//Bomb Lobbers
|
||||||
|
BOMB_LOBBERS_WINS("Master Bomber", 1200,
|
||||||
|
new String[]{"Bomb Lobbers.Wins"},
|
||||||
|
new String[]{"Win 100 games of Bomb Lobbers"},
|
||||||
|
new int[] {100},
|
||||||
|
AchievementCategory.BOMB_LOBBERS),
|
||||||
|
|
||||||
|
BOMB_LOBBERS_PROFESSIONAL_LOBBER("Professional Lobber", 1000,
|
||||||
|
new String[]{"Bomb Lobbers.Thrown"},
|
||||||
|
new String[]{"Throw 2000 TNT"},
|
||||||
|
new int[]{2000},
|
||||||
|
AchievementCategory.BOMB_LOBBERS),
|
||||||
|
|
||||||
|
BOMB_LOBBERS_ULTIMATE_KILLER("Ultimate Killer", 800,
|
||||||
|
new String[]{"Bomb Lobbers.Killer"},
|
||||||
|
new String[]{"Kill 6 players in a single game"},
|
||||||
|
new int[]{1},
|
||||||
|
AchievementCategory.BOMB_LOBBERS),
|
||||||
|
|
||||||
|
BOMB_LOBBERS_EXPLOSION_PROOF("Jelly Skin", 1200,
|
||||||
|
new String[]{"Bomb Lobbers.JellySkin"},
|
||||||
|
new String[]{"Win a game without taking any damage."},
|
||||||
|
new int[]{1},
|
||||||
|
AchievementCategory.BOMB_LOBBERS),
|
||||||
|
|
||||||
|
BOMB_LOBBERS_BLAST_PROOF("Blast Proof", 800,
|
||||||
|
new String[]{"Bomb Lobbers.BlastProof"},
|
||||||
|
new String[]{"Win 20 games using Armorer"},
|
||||||
|
new int[]{20},
|
||||||
|
AchievementCategory.BOMB_LOBBERS),
|
||||||
|
|
||||||
|
BOMB_LOBBERS_SNIPER("Sniper", 1000,
|
||||||
|
new String[]{"Bomb Lobbers.Direct Hit"},
|
||||||
|
new String[]{"Get 50 direct hits"},
|
||||||
|
new int[]{50},
|
||||||
|
AchievementCategory.BOMB_LOBBERS)
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private String _name;
|
private String _name;
|
||||||
@ -754,7 +792,7 @@ public enum Achievement
|
|||||||
return _category;
|
return _category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AchievementData getLevelData(int exp)
|
public AchievementData getLevelData(long exp)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _levels.length; i++)
|
for (int i = 0; i < _levels.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,8 @@ import mineplex.core.stats.StatsManager;
|
|||||||
public enum AchievementCategory
|
public enum AchievementCategory
|
||||||
{
|
{
|
||||||
GLOBAL("Global", null,
|
GLOBAL("Global", null,
|
||||||
new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME },
|
new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null, new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote") },
|
||||||
Material.EMERALD, 0, GameCategory.GLOBAL, null),
|
Material.EMERALD, 0, GameCategory.GLOBAL, "None"),
|
||||||
|
|
||||||
BRIDGES("The Bridges", null,
|
BRIDGES("The Bridges", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
@ -28,15 +28,15 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
SKYWARS("Skywars",null,
|
SKYWARS("Skywars",null,
|
||||||
new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
|
new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
|
||||||
Material.FEATHER, 5, GameCategory.SURVIVAL, "Destructor Kit"),
|
Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit"),
|
||||||
|
|
||||||
UHC("Ultra Hardcore", null,
|
UHC("Ultra Hardcore", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
|
Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"),
|
||||||
|
|
||||||
WIZARDS("Wizards", null,
|
WIZARDS("Wizards", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
|
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit"),
|
||||||
|
|
||||||
CASTLE_SIEGE("Castle Siege", null,
|
CASTLE_SIEGE("Castle Siege", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"),
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"),
|
||||||
@ -45,7 +45,7 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
BLOCK_HUNT("Block Hunt", null,
|
BLOCK_HUNT("Block Hunt", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.GRASS, 0, GameCategory.CLASSICS, null),
|
Material.GRASS, 0, GameCategory.CLASSICS, "Infestor Kit"),
|
||||||
|
|
||||||
SMASH_MOBS("Super Smash Mobs", null,
|
SMASH_MOBS("Super Smash Mobs", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
@ -53,11 +53,11 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
MINE_STRIKE("MineStrike", null,
|
MINE_STRIKE("MineStrike", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.TNT, 0, GameCategory.CLASSICS, null),
|
Material.TNT, 0, GameCategory.CLASSICS, "None"),
|
||||||
|
|
||||||
DRAW_MY_THING("Draw My Thing", null,
|
DRAW_MY_THING("Draw My Thing", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
||||||
Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, null),
|
Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit"),
|
||||||
|
|
||||||
CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"},
|
CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"},
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
@ -65,7 +65,7 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
MASTER_BUILDERS("Master Builders", null,
|
MASTER_BUILDERS("Master Builders", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
||||||
Material.WOOD, 0, GameCategory.CLASSICS, null),
|
Material.WOOD, 0, GameCategory.CLASSICS, "None"),
|
||||||
|
|
||||||
//Arcade
|
//Arcade
|
||||||
DRAGONS("Dragons", null,
|
DRAGONS("Dragons", null,
|
||||||
@ -74,7 +74,7 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
DRAGON_ESCAPE("Dragon Escape", null,
|
DRAGON_ESCAPE("Dragon Escape", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
||||||
Material.DRAGON_EGG, 0, GameCategory.ARCADE, null),
|
Material.DRAGON_EGG, 0, GameCategory.ARCADE, "Digger Kit"),
|
||||||
|
|
||||||
SHEEP_QUEST("Sheep Quest", null,
|
SHEEP_QUEST("Sheep Quest", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
@ -82,11 +82,11 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
SNEAKY_ASSASSINS("Sneaky Assassins", null,
|
SNEAKY_ASSASSINS("Sneaky Assassins", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.INK_SACK, 0, GameCategory.ARCADE, null),
|
Material.INK_SACK, 0, GameCategory.ARCADE, "Briber Kit"),
|
||||||
|
|
||||||
ONE_IN_THE_QUIVER("One in the Quiver", null,
|
ONE_IN_THE_QUIVER("One in the Quiver", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.BOW, 0, GameCategory.ARCADE, null),
|
Material.BOW, 0, GameCategory.ARCADE, "Slam Shooter Kit"),
|
||||||
|
|
||||||
SUPER_PAINTBALL("Super Paintball", null,
|
SUPER_PAINTBALL("Super Paintball", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
@ -97,11 +97,11 @@ public enum AchievementCategory
|
|||||||
Material.HARD_CLAY, 14, GameCategory.ARCADE, null),
|
Material.HARD_CLAY, 14, GameCategory.ARCADE, null),
|
||||||
|
|
||||||
RUNNER("Runner", null,
|
RUNNER("Runner", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null),
|
Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null),
|
||||||
|
|
||||||
SPLEEF("Super Spleef", null,
|
SPLEEF("Super Spleef", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.IRON_SPADE, 0, GameCategory.ARCADE, null),
|
Material.IRON_SPADE, 0, GameCategory.ARCADE, null),
|
||||||
|
|
||||||
DEATH_TAG("Death Tag", null,
|
DEATH_TAG("Death Tag", null,
|
||||||
@ -110,7 +110,7 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
SNAKE("Snake", null,
|
SNAKE("Snake", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.WOOL, 4, GameCategory.ARCADE, null),
|
Material.WOOL, 4, GameCategory.ARCADE, "Reversal Snake Kit"),
|
||||||
|
|
||||||
BACON_BRAWL("Bacon Brawl", null,
|
BACON_BRAWL("Bacon Brawl", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
@ -118,8 +118,11 @@ public enum AchievementCategory
|
|||||||
|
|
||||||
MICRO_BATTLE("Micro Battle", null,
|
MICRO_BATTLE("Micro Battle", null,
|
||||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
Material.LAVA, 0, GameCategory.ARCADE, null);
|
Material.LAVA, 0, GameCategory.ARCADE, null),
|
||||||
|
|
||||||
|
BOMB_LOBBERS("Bomb Lobbers", null,
|
||||||
|
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||||
|
Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit");
|
||||||
|
|
||||||
private String _name;
|
private String _name;
|
||||||
private String[] _statsToPull;
|
private String[] _statsToPull;
|
||||||
|
@ -3,10 +3,10 @@ package mineplex.core.achievement;
|
|||||||
public class AchievementData
|
public class AchievementData
|
||||||
{
|
{
|
||||||
private int _level;
|
private int _level;
|
||||||
private int _expRemainder;
|
private long _expRemainder;
|
||||||
private int _expNextLevel;
|
private long _expNextLevel;
|
||||||
|
|
||||||
public AchievementData(int level, int expRemainder, int expNextLevel)
|
public AchievementData(int level, long expRemainder, long expNextLevel)
|
||||||
{
|
{
|
||||||
_level = level;
|
_level = level;
|
||||||
_expRemainder = expRemainder;
|
_expRemainder = expRemainder;
|
||||||
@ -18,12 +18,12 @@ public class AchievementData
|
|||||||
return _level;
|
return _level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpRemainder()
|
public long getExpRemainder()
|
||||||
{
|
{
|
||||||
return _expRemainder;
|
return _expRemainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpNextLevel()
|
public long getExpNextLevel()
|
||||||
{
|
{
|
||||||
return _expNextLevel;
|
return _expNextLevel;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ package mineplex.core.achievement;
|
|||||||
|
|
||||||
public class AchievementLog
|
public class AchievementLog
|
||||||
{
|
{
|
||||||
public int Amount;
|
public long Amount;
|
||||||
public boolean LevelUp;
|
public boolean LevelUp;
|
||||||
|
|
||||||
public AchievementLog(int amount, boolean levelUp)
|
public AchievementLog(long amount, boolean levelUp)
|
||||||
{
|
{
|
||||||
Amount = amount;
|
Amount = amount;
|
||||||
LevelUp = levelUp;
|
LevelUp = levelUp;
|
||||||
|
@ -137,15 +137,6 @@ public class AchievementManager extends MiniPlugin
|
|||||||
_log.remove(event.getPlayer().getName());
|
_log.remove(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void playerJoin(PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
if (_giveInterfaceItem)
|
|
||||||
{
|
|
||||||
giveInterfaceItem(event.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearLog(Player player)
|
public void clearLog(Player player)
|
||||||
{
|
{
|
||||||
_log.remove(player.getName());
|
_log.remove(player.getName());
|
||||||
@ -161,22 +152,7 @@ public class AchievementManager extends MiniPlugin
|
|||||||
_giveInterfaceItem = giveInterfaceItem;
|
_giveInterfaceItem = giveInterfaceItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveInterfaceItem(Player player)
|
/*@EventHandler
|
||||||
{
|
|
||||||
if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.SKULL_ITEM))
|
|
||||||
{
|
|
||||||
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats");
|
|
||||||
SkullMeta meta = ((SkullMeta) item.getItemMeta());
|
|
||||||
meta.setOwner(player.getName());
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
|
|
||||||
player.getInventory().setItem(_interfaceSlot, item);
|
|
||||||
|
|
||||||
UtilInv.Update(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void openShop(PlayerInteractEvent event)
|
public void openShop(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!_shopEnabled)
|
if (!_shopEnabled)
|
||||||
@ -188,7 +164,7 @@ public class AchievementManager extends MiniPlugin
|
|||||||
|
|
||||||
openShop(event.getPlayer());
|
openShop(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public boolean hasCategory(Player player, Achievement[] required)
|
public boolean hasCategory(Player player, Achievement[] required)
|
||||||
{
|
{
|
||||||
@ -208,18 +184,22 @@ public class AchievementManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
|
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
|
||||||
|
|
||||||
|
if (sender.getName().equalsIgnoreCase("B2_mp"))
|
||||||
|
return 101;
|
||||||
|
|
||||||
|
if (rank.Has(Rank.MODERATOR))
|
||||||
|
level = Math.max(level, 5);
|
||||||
|
if (rank.Has(Rank.SNR_MODERATOR))
|
||||||
|
level = Math.max(level, 15);
|
||||||
|
if (rank.Has(Rank.JNR_DEV))
|
||||||
|
level = Math.max(level, 25);
|
||||||
|
if (rank.Has(Rank.ADMIN))
|
||||||
|
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||||
|
if (rank.Has(Rank.OWNER))
|
||||||
|
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||||
|
|
||||||
if (sender.getName().equalsIgnoreCase("Phinary"))
|
if (sender.getName().equalsIgnoreCase("Phinary"))
|
||||||
level = -level;
|
level = -level;
|
||||||
else if (sender.getName().equalsIgnoreCase("B2_mp"))
|
|
||||||
return 101;
|
|
||||||
else if (rank.Has(Rank.OWNER))
|
|
||||||
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
|
||||||
else if (rank.Has(Rank.ADMIN))
|
|
||||||
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
|
||||||
else if (rank.Has(Rank.SNR_MODERATOR))
|
|
||||||
level = Math.max(level, 15);
|
|
||||||
else if (rank.Has(Rank.MODERATOR))
|
|
||||||
level = Math.max(level, 5);
|
|
||||||
|
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
|||||||
|
|
||||||
ArrayList<String> lore = new ArrayList<String>();
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
lore.add(" ");
|
lore.add(" ");
|
||||||
category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 5 : 2,
|
category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 10 : 2,
|
||||||
getPlayer(), _target);
|
getPlayer(), _target);
|
||||||
lore.add(" ");
|
lore.add(" ");
|
||||||
addAchievements(category, lore, 9);
|
addAchievements(category, lore, 9);
|
||||||
|
@ -345,7 +345,7 @@ public class AntiHack extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Auto-Kick
|
//Auto-Kick
|
||||||
if (!handled && _clientManager.Get(player).GetRank() == Rank.YOUTUBE)
|
if (!handled && _clientManager.Get(player).GetRank() != Rank.YOUTUBE && _clientManager.Get(player).GetRank() != Rank.TWITCH)
|
||||||
{
|
{
|
||||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f);
|
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
Set(playerName, _repository.retrievePlayerBenefitData(resultSet));
|
Set(playerName, _repository.retrievePlayerBenefitData(resultSet));
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,8 @@ public class BlockRestoreData
|
|||||||
if (_toID == 78) _toData = (byte)Math.min(7, _toData + addData);
|
if (_toID == 78) _toData = (byte)Math.min(7, _toData + addData);
|
||||||
else _toData = addData;
|
else _toData = addData;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
_toData = addData;
|
||||||
|
|
||||||
_toID = toID;
|
_toID = toID;
|
||||||
|
|
||||||
|
159
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java
Normal file
159
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
package mineplex.core.bonuses;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
public class BonusAmount
|
||||||
|
{
|
||||||
|
private int _gems;
|
||||||
|
private int _coins;
|
||||||
|
private int _gold;
|
||||||
|
private int _bonusGems;
|
||||||
|
private int _bonusCoins;
|
||||||
|
private int _bonusGold;
|
||||||
|
private int _experience;
|
||||||
|
private int _bonusExperience;
|
||||||
|
private int _tickets;
|
||||||
|
|
||||||
|
public BonusAmount()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGems()
|
||||||
|
{
|
||||||
|
return _gems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGems(int gems)
|
||||||
|
{
|
||||||
|
_gems = gems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCoins()
|
||||||
|
{
|
||||||
|
return _coins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoins(int coins)
|
||||||
|
{
|
||||||
|
_coins = coins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGold()
|
||||||
|
{
|
||||||
|
return _gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGold(int gold)
|
||||||
|
{
|
||||||
|
_gold = gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBonusGems()
|
||||||
|
{
|
||||||
|
return _bonusGems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBonusGems(int bonusGems)
|
||||||
|
{
|
||||||
|
_bonusGems = bonusGems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBonusCoins()
|
||||||
|
{
|
||||||
|
return _bonusCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBonusCoins(int bonusCoins)
|
||||||
|
{
|
||||||
|
_bonusCoins = bonusCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBonusGold()
|
||||||
|
{
|
||||||
|
return _bonusGold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBonusGold(int bonusGold)
|
||||||
|
{
|
||||||
|
_bonusGold = bonusGold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalGems()
|
||||||
|
{
|
||||||
|
return getGems() + getBonusGems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalCoins()
|
||||||
|
{
|
||||||
|
return getCoins() + getBonusCoins();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalGold()
|
||||||
|
{
|
||||||
|
return getGold() + getBonusGold();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExperience()
|
||||||
|
{
|
||||||
|
return _experience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExperience(int experience)
|
||||||
|
{
|
||||||
|
_experience = experience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBonusExperience()
|
||||||
|
{
|
||||||
|
return _bonusExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBonusExperience(int bonusExperience)
|
||||||
|
{
|
||||||
|
_bonusExperience = bonusExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalExperience()
|
||||||
|
{
|
||||||
|
return getExperience() + getBonusExperience();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTickets()
|
||||||
|
{
|
||||||
|
return _tickets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTickets(int tickets)
|
||||||
|
{
|
||||||
|
_tickets = tickets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGreaterThanZero()
|
||||||
|
{
|
||||||
|
return _bonusCoins > 0 || _coins > 0 || _bonusGems > 0 || _gems > 0 || _gold > 0 || _bonusGold > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLore(List<String> lore)
|
||||||
|
{
|
||||||
|
lore.add(C.cYellow + "Rewards");
|
||||||
|
addLore(lore, getTickets(), 0, "Carl Spin Ticket" + (getTickets() > 1 ? "s" : ""));
|
||||||
|
addLore(lore, getCoins(), getBonusCoins(), "Coins");
|
||||||
|
addLore(lore, getGems(), getBonusGems(), "Gems");
|
||||||
|
addLore(lore, getGold(), getBonusGold(), "Gold");
|
||||||
|
addLore(lore, getExperience(), getBonusExperience(), "Experience");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addLore(List<String> lore, int amount, int bonus, String suffix)
|
||||||
|
{
|
||||||
|
if (amount > 0)
|
||||||
|
lore.add(" " + C.cWhite + amount + " " + suffix);
|
||||||
|
|
||||||
|
// if (bonus > 0)
|
||||||
|
// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,127 @@
|
|||||||
|
package mineplex.core.bonuses;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
import mineplex.core.hologram.Hologram;
|
||||||
|
import mineplex.database.tables.records.BonusRecord;
|
||||||
|
|
||||||
|
public class BonusClientData
|
||||||
|
{
|
||||||
|
private Hologram _hologram;
|
||||||
|
|
||||||
|
private int _accountId;
|
||||||
|
private Timestamp _dailyTime;
|
||||||
|
private Date _rankTime;
|
||||||
|
private Date _voteTime;
|
||||||
|
private int _dailyStreak;
|
||||||
|
private int _maxDailyStreak;
|
||||||
|
private int _voteStreak;
|
||||||
|
private int _maxVoteStreak;
|
||||||
|
private int _tickets;
|
||||||
|
|
||||||
|
public BonusClientData()
|
||||||
|
{
|
||||||
|
_accountId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(Integer value)
|
||||||
|
{
|
||||||
|
_accountId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAccountId()
|
||||||
|
{
|
||||||
|
return _accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDailyTime(Timestamp value)
|
||||||
|
{
|
||||||
|
_dailyTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getDailyTime()
|
||||||
|
{
|
||||||
|
return _dailyTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRankTime(Date value)
|
||||||
|
{
|
||||||
|
_rankTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getRankTime()
|
||||||
|
{
|
||||||
|
return _rankTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoteTime(Date value)
|
||||||
|
{
|
||||||
|
_voteTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getVoteTime()
|
||||||
|
{
|
||||||
|
return _voteTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDailyStreak(Integer value)
|
||||||
|
{
|
||||||
|
_dailyStreak = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDailyStreak()
|
||||||
|
{
|
||||||
|
return _dailyStreak;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxDailyStreak(Integer value)
|
||||||
|
{
|
||||||
|
_maxDailyStreak = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMaxDailyStreak()
|
||||||
|
{
|
||||||
|
return _maxDailyStreak;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoteStreak(Integer value)
|
||||||
|
{
|
||||||
|
_voteStreak = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getVoteStreak()
|
||||||
|
{
|
||||||
|
return _voteStreak;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxVoteStreak(Integer value)
|
||||||
|
{
|
||||||
|
_maxVoteStreak = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMaxVoteStreak()
|
||||||
|
{
|
||||||
|
return _maxVoteStreak;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTickets(Integer value)
|
||||||
|
{
|
||||||
|
_tickets = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTickets()
|
||||||
|
{
|
||||||
|
return _tickets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hologram getHologram()
|
||||||
|
{
|
||||||
|
return _hologram;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHologram(Hologram hologram)
|
||||||
|
{
|
||||||
|
_hologram = hologram;
|
||||||
|
}
|
||||||
|
}
|
1152
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
Normal file
1152
Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,446 @@
|
|||||||
|
package mineplex.core.bonuses;
|
||||||
|
|
||||||
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||||
|
import mineplex.core.bonuses.gui.SpinGui;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.database.DBPool;
|
||||||
|
import mineplex.core.database.RepositoryBase;
|
||||||
|
import mineplex.core.database.ResultSetCallable;
|
||||||
|
import mineplex.core.database.column.ColumnInt;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.database.Tables;
|
||||||
|
import mineplex.database.tables.records.BonusRecord;
|
||||||
|
import org.jooq.Configuration;
|
||||||
|
import org.jooq.DSLContext;
|
||||||
|
import org.jooq.Record2;
|
||||||
|
import org.jooq.SQLDialect;
|
||||||
|
import org.jooq.TableField;
|
||||||
|
import org.jooq.impl.DSL;
|
||||||
|
import org.jooq.impl.DefaultConfiguration;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class BonusRepository extends RepositoryBase
|
||||||
|
{
|
||||||
|
private static String CREATE_BONUS_TABLE = "CREATE TABLE IF NOT EXISTS bonus (accountId INT NOT NULL AUTO_INCREMENT, dailytime TIMESTAMP NULL DEFAULT NULL, ranktime DATE NULL DEFAULT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||||
|
private BonusManager _manager;
|
||||||
|
private DonationManager _donationManager;
|
||||||
|
|
||||||
|
public BonusRepository(JavaPlugin plugin, BonusManager bonusManager, DonationManager donationManager)
|
||||||
|
{
|
||||||
|
super(plugin, DBPool.ACCOUNT);
|
||||||
|
_manager = bonusManager;
|
||||||
|
_donationManager = donationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BonusRecord loadRecord(String playerName, int accountId)
|
||||||
|
{
|
||||||
|
DSLContext create = jooq();
|
||||||
|
|
||||||
|
BonusRecord record = create.selectFrom(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne();
|
||||||
|
|
||||||
|
if (record == null)
|
||||||
|
{
|
||||||
|
// Need to create new record!
|
||||||
|
record = create.newRecord(Tables.bonus);
|
||||||
|
record.setAccountId(accountId);
|
||||||
|
record.setDailyStreak(0);
|
||||||
|
record.setMaxDailyStreak(0);
|
||||||
|
record.setVoteStreak(0);
|
||||||
|
record.setMaxVoteStreak(0);
|
||||||
|
record.setTickets(0);
|
||||||
|
record.store(); // Todo - is this necessary?
|
||||||
|
}
|
||||||
|
System.out.println("Loaded record. Daily time: " + record.getDailytime());
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BonusClientData loadData(final int accountId, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
BonusClientData clientData = new BonusClientData();
|
||||||
|
clientData.setAccountId(accountId);
|
||||||
|
|
||||||
|
boolean foundClient = false;
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
foundClient = true;
|
||||||
|
clientData.setDailyTime(resultSet.getTimestamp(2));
|
||||||
|
clientData.setRankTime(resultSet.getDate(3));
|
||||||
|
clientData.setVoteTime(resultSet.getDate(4));
|
||||||
|
clientData.setDailyStreak(resultSet.getInt(5));
|
||||||
|
clientData.setMaxDailyStreak(resultSet.getInt(6));
|
||||||
|
clientData.setVoteStreak(resultSet.getInt(7));
|
||||||
|
clientData.setMaxVoteStreak(resultSet.getInt(8));
|
||||||
|
clientData.setTickets(resultSet.getInt(9));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundClient)
|
||||||
|
{
|
||||||
|
_manager.runAsync(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getDailyStreakRecord(Callback<StreakRecord> callback)
|
||||||
|
{
|
||||||
|
getStreakRecord(Tables.bonus.maxDailyStreak, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getVoteStreakRecord(Callback<StreakRecord> callback)
|
||||||
|
{
|
||||||
|
getStreakRecord(Tables.bonus.maxVoteStreak, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getStreakRecord(final TableField<BonusRecord, Integer> field, final Callback<StreakRecord> callback)
|
||||||
|
{
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
final Record2<String, Integer> record = jooq().select(Tables.accounts.name, field)
|
||||||
|
.from(Tables.bonus.join(Tables.accounts).on(Tables.bonus.accountId.eq(Tables.accounts.id)))
|
||||||
|
.orderBy(field.desc()).limit(1).fetchOne();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (record.value1() != null && record.value2() != null)
|
||||||
|
{
|
||||||
|
callback.run(new StreakRecord(record.value1(), record.value2()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attemptAddTickets(final int accountId, final BonusClientData client, final int tickets, final Callback<Boolean> callback)
|
||||||
|
{
|
||||||
|
if (client.getTickets() + tickets < 0)
|
||||||
|
callback.run(false);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
|
||||||
|
create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)).
|
||||||
|
where(Tables.bonus.accountId.eq(accountId)).execute();
|
||||||
|
final int newTickets = create.select(Tables.bonus.tickets).from(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne().value1();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
client.setTickets(newTickets);
|
||||||
|
callback.run(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
callback.run(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attemptDailyBonus(final Player player, final Callback<Boolean> result)
|
||||||
|
{
|
||||||
|
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||||
|
final int coins = 0;
|
||||||
|
final int gems = 0;
|
||||||
|
/*
|
||||||
|
* if (coins == 0 && gems == 0) { result.accept(false); return; }
|
||||||
|
*/
|
||||||
|
final JavaPlugin plug = _manager.getPlugin();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try (Connection connection = getConnection();
|
||||||
|
CallableStatement callableStatement = connection.prepareCall("{call check_daily(?, ?, ?, ?, ?)}"))
|
||||||
|
{
|
||||||
|
callableStatement.setInt(1, accountId);
|
||||||
|
callableStatement.setInt(2, coins);
|
||||||
|
callableStatement.setInt(3, gems);
|
||||||
|
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN);
|
||||||
|
callableStatement.registerOutParameter(5, java.sql.Types.TIMESTAMP);
|
||||||
|
|
||||||
|
callableStatement.executeUpdate();
|
||||||
|
|
||||||
|
final boolean pass = callableStatement.getBoolean(4);
|
||||||
|
|
||||||
|
final Timestamp timeStamp = callableStatement.getTimestamp(5);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(plug, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (pass)
|
||||||
|
{
|
||||||
|
_manager.Get(player).setDailyTime(new Timestamp(BonusManager.getSqlTime()));
|
||||||
|
result.run(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 10, false, false);
|
||||||
|
_manager.Get(player).setDailyTime(timeStamp);
|
||||||
|
result.run(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false);
|
||||||
|
e.printStackTrace();
|
||||||
|
result.run(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void giveTickets(final Player player, final Callback<Boolean> result)
|
||||||
|
{
|
||||||
|
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
final int newTickets = jooq().update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.sub(-1)).
|
||||||
|
where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attemptRankBonus(final Player player, final Callback<Boolean> result)
|
||||||
|
{
|
||||||
|
if (!Recharge.Instance.usable(player, "AttemptRankBonus")) {
|
||||||
|
result.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||||
|
final int coins = _manager.getRankBonusAmount(player).getCoins();
|
||||||
|
|
||||||
|
if (coins == 0/* && gems == 0 */) {
|
||||||
|
result.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final JavaPlugin plug = _manager.getPlugin();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
|
||||||
|
try (Connection connection = getConnection();
|
||||||
|
CallableStatement callableStatement = connection.prepareCall("{call check_rank(?, ?, ?, ?, ?)}")) {
|
||||||
|
callableStatement.setInt(1, accountId);
|
||||||
|
callableStatement.setInt(2, coins);
|
||||||
|
callableStatement.setInt(3, 0);
|
||||||
|
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN);
|
||||||
|
callableStatement.registerOutParameter(5, java.sql.Types.DATE);
|
||||||
|
|
||||||
|
callableStatement.executeUpdate();
|
||||||
|
|
||||||
|
final boolean pass = callableStatement.getBoolean(4);
|
||||||
|
|
||||||
|
final Date date = callableStatement.getDate(5);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(plug, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
_manager.Get(player).setRankTime(date);
|
||||||
|
|
||||||
|
if (pass)
|
||||||
|
{
|
||||||
|
result.run(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 10, false, false);
|
||||||
|
result.run(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false);
|
||||||
|
e.printStackTrace();
|
||||||
|
result.run(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attemptVoteBonus(final int accountId, final Callback<Pair<Boolean, Date>> result)
|
||||||
|
{
|
||||||
|
final int coins = 0;
|
||||||
|
final int gems = 0;
|
||||||
|
|
||||||
|
final JavaPlugin plug = _manager.getPlugin();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
|
||||||
|
try (Connection connection = getConnection();
|
||||||
|
CallableStatement callableStatement = connection.prepareCall("{call check_vote(?, ?, ?, ?, ?)}")) {
|
||||||
|
callableStatement.setInt(1, accountId);
|
||||||
|
callableStatement.setInt(2, coins);
|
||||||
|
callableStatement.setInt(3, gems);
|
||||||
|
callableStatement.registerOutParameter(4, Types.BOOLEAN);
|
||||||
|
callableStatement.registerOutParameter(5, Types.DATE);
|
||||||
|
|
||||||
|
callableStatement.executeUpdate();
|
||||||
|
|
||||||
|
final boolean pass = callableStatement.getBoolean(4);
|
||||||
|
final Date date = callableStatement.getDate(5);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(plug, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
// _manager.Get(player).setVoteTime(date);
|
||||||
|
result.run(Pair.create(pass, date));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
result.run(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getTimeOffset(final Callback<Long> callback)
|
||||||
|
{
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
|
final Plugin plugin = _manager.getPlugin();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
executeQuery("SELECT CURRENT_TIMESTAMP", new ResultSetCallable() {
|
||||||
|
@Override
|
||||||
|
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
resultSet.next();
|
||||||
|
|
||||||
|
long theirTimeUnadjusted = resultSet.getTimestamp(1).getTime();
|
||||||
|
|
||||||
|
long ourCurrentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
long latencyOffset = (ourCurrentTime - startTime) / 2;
|
||||||
|
|
||||||
|
long theirTime = theirTimeUnadjusted - latencyOffset;
|
||||||
|
|
||||||
|
final long offSet = theirTime - ourCurrentTime;
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
callback.run(offSet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getClientData(final int accountId, final Callback<BonusClientData> callback)
|
||||||
|
{
|
||||||
|
String query = "SELECT * FROM bonus WHERE accountId = '" + accountId + "';";
|
||||||
|
|
||||||
|
executeQuery(query, new ResultSetCallable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
BonusClientData clientData = loadData(accountId, resultSet);
|
||||||
|
callback.run(clientData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveStreak(int accountId, BonusClientData clientData)
|
||||||
|
{
|
||||||
|
jooq().update(Tables.bonus).set(Tables.bonus.dailyStreak, clientData.getDailyStreak())
|
||||||
|
.set(Tables.bonus.maxDailyStreak, clientData.getMaxDailyStreak())
|
||||||
|
.set(Tables.bonus.voteStreak, clientData.getVoteStreak())
|
||||||
|
.set(Tables.bonus.maxVoteStreak, clientData.getMaxVoteStreak())
|
||||||
|
.where(Tables.bonus.accountId.eq(accountId)).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initialize()
|
||||||
|
{
|
||||||
|
executeUpdate(CREATE_BONUS_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package mineplex.core.bonuses;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class GiveDonorData
|
||||||
|
{
|
||||||
|
private String _playerName;
|
||||||
|
private int _accountId;
|
||||||
|
private UUID _uuid;
|
||||||
|
private int _giveAmount;
|
||||||
|
private int _attempts;
|
||||||
|
|
||||||
|
public GiveDonorData(String playerName, int accountId, UUID uuid, int giveAmount)
|
||||||
|
{
|
||||||
|
_playerName = playerName;
|
||||||
|
_accountId = accountId;
|
||||||
|
_uuid = uuid;
|
||||||
|
_giveAmount = giveAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerName()
|
||||||
|
{
|
||||||
|
return _playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAccountId()
|
||||||
|
{
|
||||||
|
return _accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid()
|
||||||
|
{
|
||||||
|
return _uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGiveAmount()
|
||||||
|
{
|
||||||
|
return _giveAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAttempts()
|
||||||
|
{
|
||||||
|
return _attempts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementAttempts()
|
||||||
|
{
|
||||||
|
_attempts++;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package mineplex.core.bonuses;
|
||||||
|
|
||||||
|
public class StreakRecord
|
||||||
|
{
|
||||||
|
private String _playerName;
|
||||||
|
private int _streak;
|
||||||
|
|
||||||
|
public StreakRecord(String playerName, int streak)
|
||||||
|
{
|
||||||
|
_playerName = playerName;
|
||||||
|
_streak = streak;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerName()
|
||||||
|
{
|
||||||
|
return _playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStreak()
|
||||||
|
{
|
||||||
|
return _streak;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,290 @@
|
|||||||
|
package mineplex.core.bonuses.animations;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.reward.Reward;
|
||||||
|
import mineplex.core.reward.RewardData;
|
||||||
|
import mineplex.core.reward.RewardRarity;
|
||||||
|
import mineplex.core.treasure.animation.Animation;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class AnimationCarl extends Animation
|
||||||
|
{
|
||||||
|
private boolean _isDone;
|
||||||
|
private Block _creeper;
|
||||||
|
private Object _type;
|
||||||
|
private Player _player;
|
||||||
|
|
||||||
|
private HashSet<Item> _items = new HashSet<Item>();
|
||||||
|
|
||||||
|
public AnimationCarl(Entity creeper)
|
||||||
|
{
|
||||||
|
_creeper = creeper.getLocation().getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tick()
|
||||||
|
{
|
||||||
|
if(_type instanceof String)
|
||||||
|
{
|
||||||
|
if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL"))
|
||||||
|
{
|
||||||
|
for (int i = 50; i < 60; i++)
|
||||||
|
{
|
||||||
|
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||||
|
Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i));
|
||||||
|
_items.add(gem);
|
||||||
|
_items.add(coin);
|
||||||
|
|
||||||
|
Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d));
|
||||||
|
UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false);
|
||||||
|
UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(((String) _type).contentEquals("RANK"))
|
||||||
|
{
|
||||||
|
for (int i = 50; i < 60; i++)
|
||||||
|
{
|
||||||
|
Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i));
|
||||||
|
_items.add(coin);
|
||||||
|
|
||||||
|
Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||||
|
UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!((String) _type).contentEquals("DAILY")&& !((String) _type).contentEquals("RANK")&& !((String) _type).contentEquals("POLL"))
|
||||||
|
{
|
||||||
|
|
||||||
|
Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64));
|
||||||
|
_items.add(paper);
|
||||||
|
|
||||||
|
Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d));
|
||||||
|
UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false);
|
||||||
|
|
||||||
|
for (int i = 50; i < 60; i++)
|
||||||
|
{
|
||||||
|
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||||
|
_items.add(gem);
|
||||||
|
|
||||||
|
Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d));
|
||||||
|
UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
if(_type instanceof Reward)
|
||||||
|
{
|
||||||
|
if(getTicks() == 0)
|
||||||
|
{
|
||||||
|
RewardData rewardData = ((Reward)_type).getFakeRewardData(_player);
|
||||||
|
ItemStack itemStack = rewardData.getDisplayItem();
|
||||||
|
Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack);
|
||||||
|
_items.add(item);
|
||||||
|
|
||||||
|
Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ());
|
||||||
|
|
||||||
|
UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((Reward)_type).getRarity() == RewardRarity.RARE)
|
||||||
|
{
|
||||||
|
RareAnimation();
|
||||||
|
}
|
||||||
|
else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY)
|
||||||
|
{
|
||||||
|
LegendAnimation();
|
||||||
|
}
|
||||||
|
else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL)
|
||||||
|
{
|
||||||
|
MythicalAnimation();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onFinish() {
|
||||||
|
_isDone = true;
|
||||||
|
setTicks(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDone()
|
||||||
|
{
|
||||||
|
return _isDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDone(boolean b)
|
||||||
|
{
|
||||||
|
_isDone = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Object type)
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayer(Player player)
|
||||||
|
{
|
||||||
|
_player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LegendAnimation()
|
||||||
|
{
|
||||||
|
if (getTicks() < 1)
|
||||||
|
{
|
||||||
|
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTicks() == 1)
|
||||||
|
{
|
||||||
|
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
|
||||||
|
}
|
||||||
|
else if (getTicks() < 35)
|
||||||
|
{
|
||||||
|
double radius = 2 - (getTicks() / 10D * 2);
|
||||||
|
int particleAmount = 20 - (getTicks() * 2);
|
||||||
|
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||||
|
for (int i = 0; i < particleAmount; i++)
|
||||||
|
{
|
||||||
|
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||||
|
{
|
||||||
|
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||||
|
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MythicalAnimation()
|
||||||
|
{
|
||||||
|
if (getTicks() < 30)
|
||||||
|
{
|
||||||
|
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTicks() == 1)
|
||||||
|
{
|
||||||
|
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
|
||||||
|
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
|
||||||
|
}
|
||||||
|
else if (getTicks() < 40)
|
||||||
|
{
|
||||||
|
UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
|
||||||
|
new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
|
||||||
|
|
||||||
|
//Particle Spiral Up
|
||||||
|
double radius = getTicks() / 20D;
|
||||||
|
int particleAmount = getTicks() / 2;
|
||||||
|
for (int i = 0; i < particleAmount; i++)
|
||||||
|
{
|
||||||
|
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
|
||||||
|
Location location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff);
|
||||||
|
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
|
||||||
|
ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
}
|
||||||
|
|
||||||
|
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||||
|
for (int i = 0; i < particleAmount; i++)
|
||||||
|
{
|
||||||
|
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
for(double e = 0.1 ; e < 3 ; e += 0.5)
|
||||||
|
{
|
||||||
|
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||||
|
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RareAnimation()
|
||||||
|
{
|
||||||
|
if (getTicks() == 1)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false);
|
||||||
|
}
|
||||||
|
_creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F);
|
||||||
|
}
|
||||||
|
else if (getTicks() >= 60)
|
||||||
|
{
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (getTicks() < 35)
|
||||||
|
{
|
||||||
|
double radius = 2 - (getTicks() / 10D * 2);
|
||||||
|
int particleAmount = 20 - (getTicks() * 2);
|
||||||
|
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||||
|
for (int i = 0; i < particleAmount; i++)
|
||||||
|
{
|
||||||
|
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||||
|
for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||||
|
{
|
||||||
|
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||||
|
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void itemClean()
|
||||||
|
{
|
||||||
|
Iterator<Item> itemIterator = _items.iterator();
|
||||||
|
|
||||||
|
while (itemIterator.hasNext())
|
||||||
|
{
|
||||||
|
Item item = itemIterator.next();
|
||||||
|
|
||||||
|
if (item.isOnGround() || !item.isValid() || item.getTicksLived() > 60)
|
||||||
|
{
|
||||||
|
item.remove();
|
||||||
|
itemIterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package mineplex.core.bonuses.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.reward.RewardType;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
|
||||||
|
public class AnimationCommand extends CommandBase<BonusManager>{
|
||||||
|
|
||||||
|
private BonusManager _plugin;
|
||||||
|
|
||||||
|
public AnimationCommand(BonusManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.DEVELOPER, "animation");
|
||||||
|
_plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(args != null)
|
||||||
|
{
|
||||||
|
caller = Bukkit.getPlayer(args[0]);
|
||||||
|
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true));
|
||||||
|
}
|
||||||
|
if(args.length >= 2)
|
||||||
|
{
|
||||||
|
_plugin.addPendingExplosion(caller, args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package mineplex.core.bonuses.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.bonuses.gui.BonusGui;
|
||||||
|
|
||||||
|
public class GuiCommand extends CommandBase<BonusManager>{
|
||||||
|
|
||||||
|
public GuiCommand(BonusManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.DEVELOPER, "bonus");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager()).openInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package mineplex.core.bonuses.commands;
|
||||||
|
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class TicketCommand extends CommandBase<BonusManager>
|
||||||
|
{
|
||||||
|
public TicketCommand(BonusManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ADMIN, "ticket");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(final Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Carl", "Missing Args: " + F.elem("/ticket <player> <amount>")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String targetName = args[0];
|
||||||
|
final String ticketString = args[1];
|
||||||
|
Player target = UtilPlayer.searchExact(targetName);
|
||||||
|
|
||||||
|
|
||||||
|
rewardTickets(caller, target, target.getName(), ticketString);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rewardTickets(final Player caller, final Player target, final String targetName, String ticketString)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final int tickets = Integer.parseInt(ticketString);
|
||||||
|
int accountId = Plugin.getClientManager().getAccountId(target);
|
||||||
|
Plugin.getRepository().attemptAddTickets(accountId, Plugin.Get(target), tickets, new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run(Boolean data)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + "."));
|
||||||
|
|
||||||
|
if (target != null && !target.equals(caller))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + "."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Carl", "Failed to give tickets. Try again later!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Carl", "Invalid Ticket Amount"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package mineplex.core.bonuses.event;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player attempts to purchase a spin through carl
|
||||||
|
*/
|
||||||
|
public class CarlSpinnerEvent extends Event implements Cancellable
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private Player _player;
|
||||||
|
private boolean _cancelled;
|
||||||
|
|
||||||
|
public CarlSpinnerEvent(Player player)
|
||||||
|
{
|
||||||
|
_player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayer(Player player)
|
||||||
|
{
|
||||||
|
_player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled()
|
||||||
|
{
|
||||||
|
return _cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean b)
|
||||||
|
{
|
||||||
|
_cancelled = b;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package mineplex.core.bonuses.gui;
|
||||||
|
|
||||||
|
import mineplex.core.gui.SimpleGui;
|
||||||
|
import mineplex.core.reward.RewardManager;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.bonuses.gui.buttons.CarlSpinButton;
|
||||||
|
import mineplex.core.bonuses.gui.buttons.DailyBonusButton;
|
||||||
|
import mineplex.core.bonuses.gui.buttons.PollButton;
|
||||||
|
import mineplex.core.bonuses.gui.buttons.RankBonusButton;
|
||||||
|
import mineplex.core.bonuses.gui.buttons.VoteButton;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class BonusGui extends SimpleGui
|
||||||
|
{
|
||||||
|
|
||||||
|
private BonusManager manager;
|
||||||
|
|
||||||
|
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager)
|
||||||
|
{
|
||||||
|
super(plugin, player, player.getName() + "'s Bonuses", 5 * 9);
|
||||||
|
|
||||||
|
this.manager = manager;
|
||||||
|
|
||||||
|
setItem(10, new VoteButton(plugin, player, this, manager));
|
||||||
|
|
||||||
|
setItem(12, new RankBonusButton(getPlugin(), player, this, manager));
|
||||||
|
|
||||||
|
setItem(14, new DailyBonusButton(getPlugin(), player, this, manager));
|
||||||
|
|
||||||
|
setItem(16, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager));
|
||||||
|
|
||||||
|
setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void finalize() throws Throwable
|
||||||
|
{
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
|
}
|
280
Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java
Normal file
280
Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java
Normal file
@ -0,0 +1,280 @@
|
|||||||
|
package mineplex.core.bonuses.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.gui.DisplayItem;
|
||||||
|
import mineplex.core.gui.SimpleGui;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.reward.Reward;
|
||||||
|
import mineplex.core.reward.RewardData;
|
||||||
|
import mineplex.core.reward.RewardManager;
|
||||||
|
import mineplex.core.reward.RewardRarity;
|
||||||
|
import mineplex.core.reward.RewardType;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.bonuses.gui.buttons.RewardButton;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class SpinGui extends SimpleGui
|
||||||
|
{
|
||||||
|
private static final int HOPPER_SLOT = 4;
|
||||||
|
private static final int CARL_SLOT = 22;
|
||||||
|
private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ };
|
||||||
|
|
||||||
|
private int _tickCount;
|
||||||
|
private RewardData _rewardData;
|
||||||
|
private Reward _reward;
|
||||||
|
private BonusManager _manager;
|
||||||
|
private int _currentRewardIndex;
|
||||||
|
private int _ticksThisSwap;
|
||||||
|
private int _ticksPerSwap;
|
||||||
|
private int _swapCount;
|
||||||
|
private Reward[] _rewards;
|
||||||
|
private boolean _stopped;
|
||||||
|
private boolean _rewarded;
|
||||||
|
private ArrayList<Integer> _ticks;
|
||||||
|
private int _frame;
|
||||||
|
private float _pitch;
|
||||||
|
private int _stopSpinnerAt;
|
||||||
|
|
||||||
|
public SpinGui(Plugin plugin, Player player, RewardManager rewardManager, BonusManager manager)
|
||||||
|
{
|
||||||
|
super(plugin, player, "Carl's Spinner", 27);
|
||||||
|
|
||||||
|
_manager = manager;
|
||||||
|
|
||||||
|
ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false);
|
||||||
|
|
||||||
|
setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER)));
|
||||||
|
//setItem(CARL_SLOT, new DisplayItem(carlItem));
|
||||||
|
|
||||||
|
|
||||||
|
_ticks = new ArrayList<>();
|
||||||
|
_frame = 0;
|
||||||
|
_pitch = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_ticksPerSwap = 1;
|
||||||
|
|
||||||
|
for (int i=0 ; i<40 ; i++)
|
||||||
|
_ticks.add(1);
|
||||||
|
|
||||||
|
for (int i=0 ; i<20 ; i++)
|
||||||
|
_ticks.add(2);
|
||||||
|
|
||||||
|
for (int i=0 ; i<10 ; i++)
|
||||||
|
_ticks.add(4);
|
||||||
|
|
||||||
|
for (int i=0 ; i<4 ; i++)
|
||||||
|
_ticks.add(6);
|
||||||
|
|
||||||
|
for (int i=0 ; i<3 ; i++)
|
||||||
|
_ticks.add(8);
|
||||||
|
|
||||||
|
if (Math.random() > 0.5)
|
||||||
|
{
|
||||||
|
_ticks.add(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
_stopSpinnerAt = _ticks.size();
|
||||||
|
|
||||||
|
//Create Rewards
|
||||||
|
_rewards = new Reward[_stopSpinnerAt+10]; //Adding 10, so theres items to the right still.
|
||||||
|
for (int i = 0; i < _stopSpinnerAt+10 ; i++)
|
||||||
|
{
|
||||||
|
if (i != _stopSpinnerAt + 4)
|
||||||
|
{
|
||||||
|
_rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerFiller, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerReal, true);
|
||||||
|
_reward = _rewards[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_rewardData = _reward.giveReward("Carls Spinner", getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tick()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(_stopped)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_ticksThisSwap++;
|
||||||
|
|
||||||
|
// Swap
|
||||||
|
if (_ticksThisSwap >= _ticksPerSwap)
|
||||||
|
{
|
||||||
|
_ticksThisSwap = 0;
|
||||||
|
_swapCount++;
|
||||||
|
|
||||||
|
if(_pitch == 1)
|
||||||
|
_pitch = (float) 1.5;
|
||||||
|
else if(_pitch == 1.5)
|
||||||
|
_pitch = 2;
|
||||||
|
else if(_pitch == 2)
|
||||||
|
_pitch = 1;
|
||||||
|
|
||||||
|
getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch);
|
||||||
|
|
||||||
|
_currentRewardIndex++;
|
||||||
|
|
||||||
|
updateGui();
|
||||||
|
|
||||||
|
// Slow
|
||||||
|
_ticksPerSwap = _ticks.get(_currentRewardIndex - 1);
|
||||||
|
|
||||||
|
if(_currentRewardIndex == _stopSpinnerAt)
|
||||||
|
_stopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_tickCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGui()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
int index = _currentRewardIndex + i;
|
||||||
|
|
||||||
|
int slot = 9 + i;
|
||||||
|
RewardData data = _rewards[index].getFakeRewardData(getPlayer());
|
||||||
|
setItem(slot, new RewardButton(data));
|
||||||
|
|
||||||
|
// Glass Panes
|
||||||
|
for (int j = 0; j < LINE_NUMS.length; j++)
|
||||||
|
{
|
||||||
|
int paneSlot = slot + LINE_NUMS[j];
|
||||||
|
if (paneSlot == HOPPER_SLOT)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
setItem(paneSlot, new DisplayItem(data.getRarity().getItemStack()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void update(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tick();
|
||||||
|
checkIfDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void close(InventoryCloseEvent event)
|
||||||
|
{
|
||||||
|
if(_rewarded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.getPlayer() != getPlayer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||||
|
|
||||||
|
if (_reward.getRarity() == RewardRarity.RARE)
|
||||||
|
{
|
||||||
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
else if (_reward.getRarity() == RewardRarity.LEGENDARY)
|
||||||
|
{
|
||||||
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
else if (_reward.getRarity() == RewardRarity.MYTHICAL)
|
||||||
|
{
|
||||||
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void Glass(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!_stopped)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!_rewarded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(_frame == 0)
|
||||||
|
{
|
||||||
|
setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
_frame++;
|
||||||
|
}
|
||||||
|
else if(_frame < 5)
|
||||||
|
{
|
||||||
|
setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
|
||||||
|
setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
|
||||||
|
setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||||
|
_frame++;
|
||||||
|
}
|
||||||
|
if(_frame == 6)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkIfDone()
|
||||||
|
{
|
||||||
|
if(!_stopped)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(_rewarded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||||
|
if (_reward.getRarity() == RewardRarity.RARE)
|
||||||
|
{
|
||||||
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
else if (_reward.getRarity() == RewardRarity.LEGENDARY)
|
||||||
|
{
|
||||||
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
else if (_reward.getRarity() == RewardRarity.MYTHICAL)
|
||||||
|
{
|
||||||
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||||
|
}
|
||||||
|
ItemStack item = getInventory().getItem(13);
|
||||||
|
getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName()));
|
||||||
|
_rewarded = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package mineplex.core.bonuses.gui.buttons;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.gui.GuiItem;
|
||||||
|
import mineplex.core.reward.RewardManager;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.bonuses.BonusClientData;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
|
||||||
|
public class CarlSpinButton implements GuiItem
|
||||||
|
{
|
||||||
|
private Plugin _plugin;
|
||||||
|
private Player _player;
|
||||||
|
private BonusManager _bonusManager;
|
||||||
|
private RewardManager _rewardManager;
|
||||||
|
|
||||||
|
public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, RewardManager rewardManager)
|
||||||
|
{
|
||||||
|
_plugin = plugin;
|
||||||
|
_player = player;
|
||||||
|
_bonusManager = bonusManager;
|
||||||
|
_rewardManager = rewardManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
BonusClientData client = _bonusManager.Get(_player);
|
||||||
|
int tickets = client.getTickets();
|
||||||
|
|
||||||
|
if (tickets > 0)
|
||||||
|
{
|
||||||
|
_bonusManager.attemptCarlSpin(_player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// new SpinGui(_plugin, _player, _rewardManager).openInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
BonusClientData client = _bonusManager.Get(_player);
|
||||||
|
int tickets = client.getTickets();
|
||||||
|
|
||||||
|
String name = (tickets > 0 ? C.cGreen : C.cRed) + C.Bold + "Carl's Spinner";
|
||||||
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
Material material = Material.SKULL_ITEM;
|
||||||
|
byte data = (byte) 4;
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
if (tickets > 0)
|
||||||
|
{
|
||||||
|
lore.add(ChatColor.RESET + "Click to Spin");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lore.add(ChatColor.RESET + "You need a Carl Spin Ticket to Spin");
|
||||||
|
}
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.YELLOW + "Your Tickets: " + C.cWhite + tickets);
|
||||||
|
|
||||||
|
return new ShopItem(material, data, name, lore.toArray(new String[0]), 1, false, false);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,211 @@
|
|||||||
|
package mineplex.core.bonuses.gui.buttons;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.gui.GuiItem;
|
||||||
|
import mineplex.core.gui.ItemRefresher;
|
||||||
|
import mineplex.core.gui.pages.LoadingWindow;
|
||||||
|
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.core.bonuses.BonusAmount;
|
||||||
|
import mineplex.core.bonuses.BonusClientData;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.bonuses.StreakRecord;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class DailyBonusButton implements GuiItem, Listener
|
||||||
|
{
|
||||||
|
|
||||||
|
private ItemStack _item;
|
||||||
|
|
||||||
|
private Player _player;
|
||||||
|
private Plugin _plugin;
|
||||||
|
private ItemRefresher _gui;
|
||||||
|
|
||||||
|
private BonusManager _bonusManager;
|
||||||
|
|
||||||
|
public DailyBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
|
||||||
|
{
|
||||||
|
this._bonusManager = bonusManager;
|
||||||
|
this._player = player;
|
||||||
|
this._plugin = plugin;
|
||||||
|
this._gui = gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||||
|
setItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
if (isAvailable()) {
|
||||||
|
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||||
|
refreshItem();
|
||||||
|
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
||||||
|
_bonusManager.attemptDailyBonus(getPlayer(), _bonusManager.getDailyBonusAmount(_player), new Callback<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void run(Boolean t)
|
||||||
|
{
|
||||||
|
if (t) {
|
||||||
|
|
||||||
|
setItem();
|
||||||
|
|
||||||
|
if (getPlayer().getOpenInventory() != null) {
|
||||||
|
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6*9, 20*3, getGui()).openInventory();
|
||||||
|
} else {
|
||||||
|
UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!"));
|
||||||
|
}
|
||||||
|
_bonusManager.addPendingExplosion(getPlayer(), "DAILY");
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||||
|
} else {
|
||||||
|
if (getPlayer().getOpenInventory() != null) {
|
||||||
|
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6*9, 20*3, getGui()).openInventory();
|
||||||
|
} else {
|
||||||
|
UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!"));
|
||||||
|
}
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10);
|
||||||
|
}
|
||||||
|
getPlayer().closeInventory();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getType().equals(UpdateType.SEC))
|
||||||
|
return;
|
||||||
|
// refreshItem(); // Todo Unnecessary?
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setItem()
|
||||||
|
{
|
||||||
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
Material material;
|
||||||
|
String itemName;
|
||||||
|
byte data = 0;
|
||||||
|
|
||||||
|
if (isAvailable())
|
||||||
|
{
|
||||||
|
material = Material.CHEST;
|
||||||
|
itemName = C.cGreen + C.Bold + "Daily Reward";
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "Click to Claim!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
material = Material.REDSTONE_BLOCK;
|
||||||
|
itemName = C.cRed + C.Bold + "Daily Reward";
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
|
||||||
|
BonusClientData client = _bonusManager.Get(_player);
|
||||||
|
|
||||||
|
BonusAmount bonusAmount = _bonusManager.getDailyBonusAmount(_player);
|
||||||
|
bonusAmount.addLore(lore);
|
||||||
|
lore.add(" ");
|
||||||
|
|
||||||
|
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getDailyStreak());
|
||||||
|
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + _bonusManager.getDailyMultiplier(_player) + "%");
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak());
|
||||||
|
|
||||||
|
if (client.getDailyTime() != null)
|
||||||
|
{
|
||||||
|
long lastBonus = _bonusManager.getLocalTime(client.getDailyTime().getTime());
|
||||||
|
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME);
|
||||||
|
|
||||||
|
if (timeLeft > 0)
|
||||||
|
{
|
||||||
|
lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StreakRecord streakRecord = _bonusManager.getDailyStreak();
|
||||||
|
if (streakRecord != null)
|
||||||
|
{
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
|
||||||
|
lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
return _item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshItem()
|
||||||
|
{
|
||||||
|
getGui().refreshItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long timeLeft()
|
||||||
|
{
|
||||||
|
long timeLeft = _bonusManager.nextDailyBonus(getPlayer()) - System.currentTimeMillis();
|
||||||
|
return timeLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAvailable()
|
||||||
|
{
|
||||||
|
return (timeLeft() <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin()
|
||||||
|
{
|
||||||
|
return _plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemRefresher getGui()
|
||||||
|
{
|
||||||
|
return _gui;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,219 @@
|
|||||||
|
package mineplex.core.bonuses.gui.buttons;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.bonuses.BonusAmount;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilText;
|
||||||
|
import mineplex.core.gui.GuiInventory;
|
||||||
|
import mineplex.core.gui.GuiItem;
|
||||||
|
import mineplex.core.gui.SimpleGui;
|
||||||
|
import mineplex.core.gui.SimpleGuiItem;
|
||||||
|
import mineplex.core.gui.botton.BackBotton;
|
||||||
|
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.poll.Poll;
|
||||||
|
import mineplex.core.poll.PollManager;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class PollButton extends SimpleGui implements GuiItem {
|
||||||
|
|
||||||
|
protected boolean _create;
|
||||||
|
|
||||||
|
private PollManager _pollManager;
|
||||||
|
private BonusManager _bonusManager;
|
||||||
|
private CoreClientManager _clientManager;
|
||||||
|
private GuiInventory _master;
|
||||||
|
|
||||||
|
private HashMap<Integer, GuiItem> hard = new HashMap<Integer, GuiItem>();
|
||||||
|
|
||||||
|
private Poll _poll;
|
||||||
|
|
||||||
|
public PollButton(Plugin plugin, Player player, PollManager pollManager, CoreClientManager clientManager, GuiInventory master, BonusManager bonusManager)
|
||||||
|
{
|
||||||
|
super(plugin, player, "Poll:", 6 * 9);
|
||||||
|
this._create = true;
|
||||||
|
this._master = master;
|
||||||
|
this._clientManager = clientManager;
|
||||||
|
this._pollManager = pollManager;
|
||||||
|
hard.put(0, new BackBotton(master));
|
||||||
|
_bonusManager = bonusManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
if (_create)
|
||||||
|
{
|
||||||
|
this._poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).GetRank());
|
||||||
|
|
||||||
|
if (_poll != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
setItem(13, getQuestionItem(_poll.getQuestion()));
|
||||||
|
|
||||||
|
int[] slots = even(9, _poll.getAnswers().length);
|
||||||
|
|
||||||
|
for (int i = 0; i < slots.length; i++)
|
||||||
|
{
|
||||||
|
AnswerItem item = new AnswerItem(_poll, i);
|
||||||
|
setItem(9 * 3 + slots[i], item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
ArrayList<String> lore = new ArrayList<>();
|
||||||
|
if (_poll == null)
|
||||||
|
{
|
||||||
|
lore.add("");
|
||||||
|
lore.add(C.cWhite + "You've voted on all of the polls!");
|
||||||
|
return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, ChatColor.RED + C.Bold + "Vote on Poll", lore);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lore.add("");
|
||||||
|
lore.add(C.cWhite + _poll.getQuestion());
|
||||||
|
lore.add("");
|
||||||
|
int i = 1;
|
||||||
|
for(String str : _poll.getAnswers())
|
||||||
|
{
|
||||||
|
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
lore.add("");
|
||||||
|
BonusAmount amount = new BonusAmount();
|
||||||
|
amount.setCoins(_poll.getCoinReward());
|
||||||
|
amount.setGems(_poll.getCoinReward());
|
||||||
|
amount.addLore(lore);
|
||||||
|
// lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
|
||||||
|
lore.add("");
|
||||||
|
lore.add(C.cGreen + "Click to go to the vote page!");
|
||||||
|
return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
if (_poll == null)
|
||||||
|
{
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||||
|
openInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiItem getQuestionItem(String question)
|
||||||
|
{
|
||||||
|
|
||||||
|
ArrayList<String> lore = new ArrayList<>();
|
||||||
|
lore.add("");
|
||||||
|
for (String string : wrap(question))
|
||||||
|
lore.add(C.cWhite + string);
|
||||||
|
lore.add("");
|
||||||
|
int i = 1;
|
||||||
|
for(String str : _poll.getAnswers())
|
||||||
|
{
|
||||||
|
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
lore.add("");
|
||||||
|
BonusAmount amount = new BonusAmount();
|
||||||
|
amount.setCoins(_poll.getCoinReward());
|
||||||
|
amount.setGems(_poll.getCoinReward());
|
||||||
|
amount.addLore(lore);
|
||||||
|
|
||||||
|
return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + C.cGreen + C.Bold + "Vote on Poll",
|
||||||
|
lore));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] wrap(String text)
|
||||||
|
{
|
||||||
|
return UtilText.wrap(text, 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] even(int size, int amount)
|
||||||
|
{
|
||||||
|
int[] list = new int[amount];
|
||||||
|
|
||||||
|
float interval = (size / amount);
|
||||||
|
float offset = -(interval / 2);
|
||||||
|
|
||||||
|
for (int i = 1; i <= amount; i++)
|
||||||
|
{
|
||||||
|
list[i - 1] = (int) (Math.ceil(i * interval) + offset);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Poll getPoll()
|
||||||
|
{
|
||||||
|
return _poll;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiInventory getMaster()
|
||||||
|
{
|
||||||
|
return _master;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AnswerItem implements GuiItem
|
||||||
|
{
|
||||||
|
|
||||||
|
private int num;
|
||||||
|
|
||||||
|
private AnswerItem(Poll poll, int num)
|
||||||
|
{
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
ArrayList<String> lore = new ArrayList<>();
|
||||||
|
lore.add("");
|
||||||
|
lore.add(C.cWhite + getPoll().getAnswers()[num]);
|
||||||
|
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
_create = true;
|
||||||
|
|
||||||
|
_pollManager.answerPoll(getPlayer(), _poll, num);
|
||||||
|
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||||
|
|
||||||
|
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory();
|
||||||
|
_bonusManager.addPendingExplosion(getPlayer(), "POLL");
|
||||||
|
getPlayer().closeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {}
|
||||||
|
}
|
@ -0,0 +1,242 @@
|
|||||||
|
package mineplex.core.bonuses.gui.buttons;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.gui.GuiItem;
|
||||||
|
import mineplex.core.gui.ItemRefresher;
|
||||||
|
import mineplex.core.gui.pages.LoadingWindow;
|
||||||
|
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.core.bonuses.BonusAmount;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class RankBonusButton implements GuiItem, Listener {
|
||||||
|
|
||||||
|
private boolean hasRank;
|
||||||
|
|
||||||
|
private ItemStack _item;
|
||||||
|
|
||||||
|
private Player _player;
|
||||||
|
private Plugin _plugin;
|
||||||
|
private ItemRefresher _gui;
|
||||||
|
|
||||||
|
private BonusManager _bonusManager;
|
||||||
|
|
||||||
|
public RankBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
|
||||||
|
{
|
||||||
|
this._bonusManager = bonusManager;
|
||||||
|
this._player = player;
|
||||||
|
this._plugin = plugin;
|
||||||
|
this._gui = gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
if (_bonusManager.getRankBonusAmount(getPlayer()).isGreaterThanZero())
|
||||||
|
{
|
||||||
|
this.hasRank = true;
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.hasRank = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
setItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
if (isAvailable() && _bonusManager.isPastAugust()) {
|
||||||
|
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||||
|
refreshItem();
|
||||||
|
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
||||||
|
_bonusManager.attemptRankBonus(getPlayer(), new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run(Boolean t)
|
||||||
|
{
|
||||||
|
setItem();
|
||||||
|
|
||||||
|
if (t)
|
||||||
|
{
|
||||||
|
if (getPlayer().getOpenInventory() != null)
|
||||||
|
{
|
||||||
|
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6 * 9, 20 * 3, getGui()).openInventory();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!"));
|
||||||
|
}
|
||||||
|
_bonusManager.addPendingExplosion(getPlayer(), "RANK");
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (getPlayer().getOpenInventory() != null)
|
||||||
|
{
|
||||||
|
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6 * 9, 20 * 3, getGui()).openInventory();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!"));
|
||||||
|
}
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10);
|
||||||
|
}
|
||||||
|
getPlayer().closeInventory();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getType().equals(UpdateType.SEC))
|
||||||
|
return;
|
||||||
|
// refreshItem(); // Todo Unnecessary?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
return _item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setItem()
|
||||||
|
{
|
||||||
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
Material material;
|
||||||
|
String itemName;
|
||||||
|
byte data = 0;
|
||||||
|
|
||||||
|
if (_bonusManager.isPastAugust())
|
||||||
|
{
|
||||||
|
if (!hasRank)
|
||||||
|
{
|
||||||
|
material = Material.REDSTONE_BLOCK;
|
||||||
|
itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus";
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
|
||||||
|
lore.add(ChatColor.WHITE + "");
|
||||||
|
lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly");
|
||||||
|
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly");
|
||||||
|
lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly");
|
||||||
|
lore.add(ChatColor.WHITE + "");
|
||||||
|
lore.add(ChatColor.WHITE + "Purchase a Rank at;");
|
||||||
|
lore.add(ChatColor.WHITE + "www.mineplex.com/shop");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isAvailable())
|
||||||
|
{
|
||||||
|
material = Material.ENDER_CHEST;
|
||||||
|
itemName = C.cGreen + C.Bold + "Rank Monthly Bonus";
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "Click to Claim!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
material = Material.REDSTONE_BLOCK;
|
||||||
|
itemName = C.cRed + C.Bold + "Rank Monthly Bonus";
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name);
|
||||||
|
BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player);
|
||||||
|
bonusAmount.addLore(lore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus";
|
||||||
|
material = Material.REDSTONE_BLOCK;
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "You can claim your Monthly Bonus");
|
||||||
|
lore.add(ChatColor.RESET + "here, starting from September!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshItem()
|
||||||
|
{
|
||||||
|
_gui.refreshItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long timeLeft()
|
||||||
|
{
|
||||||
|
return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAvailable()
|
||||||
|
{
|
||||||
|
if (!hasRank)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(getPlayer(), "----------------------------------------");
|
||||||
|
UtilPlayer.message(getPlayer(), "");
|
||||||
|
UtilPlayer.message(getPlayer(), "Purchase a Rank at the Mineplex Shop:");
|
||||||
|
UtilPlayer.message(getPlayer(), C.cGreen + "www.mineplex.com/shop");
|
||||||
|
UtilPlayer.message(getPlayer(), "");
|
||||||
|
UtilPlayer.message(getPlayer(), "----------------------------------------");
|
||||||
|
|
||||||
|
getPlayer().closeInventory();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (timeLeft() <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin()
|
||||||
|
{
|
||||||
|
return _plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemRefresher getGui()
|
||||||
|
{
|
||||||
|
return _gui;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package mineplex.core.bonuses.gui.buttons;
|
||||||
|
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import mineplex.core.gui.GuiItem;
|
||||||
|
import mineplex.core.reward.RewardData;
|
||||||
|
|
||||||
|
public class RewardButton implements GuiItem
|
||||||
|
{
|
||||||
|
private RewardData _data;
|
||||||
|
|
||||||
|
public RewardButton(RewardData data)
|
||||||
|
{
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
ItemStack stack = _data.getDisplayItem();
|
||||||
|
ItemMeta meta = stack.getItemMeta();
|
||||||
|
meta.setDisplayName(_data.getFriendlyName());
|
||||||
|
stack.setItemMeta(meta);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,186 @@
|
|||||||
|
package mineplex.core.bonuses.gui.buttons;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mineplex.core.common.jsonchat.ClickEvent;
|
||||||
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.gui.GuiItem;
|
||||||
|
import mineplex.core.gui.ItemRefresher;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
import mineplex.core.bonuses.BonusAmount;
|
||||||
|
import mineplex.core.bonuses.BonusClientData;
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.bonuses.StreakRecord;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class VoteButton implements GuiItem, Listener {
|
||||||
|
|
||||||
|
private ItemStack _item;
|
||||||
|
|
||||||
|
private String _url;
|
||||||
|
|
||||||
|
private Player _player;
|
||||||
|
private Plugin _plugin;
|
||||||
|
private ItemRefresher _gui;
|
||||||
|
|
||||||
|
private BonusManager _bonusManager;
|
||||||
|
|
||||||
|
public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
|
||||||
|
{
|
||||||
|
this._bonusManager = bonusManager;
|
||||||
|
this._player = player;
|
||||||
|
this._plugin = plugin;
|
||||||
|
this._gui = gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
//TODO get url from db
|
||||||
|
_url = _bonusManager.getVoteLink();
|
||||||
|
|
||||||
|
setItem();
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
if (isAvailable())
|
||||||
|
{
|
||||||
|
getPlayer().closeInventory();
|
||||||
|
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||||
|
|
||||||
|
UtilPlayer.message(getPlayer(), "----------------------------------------------------");
|
||||||
|
UtilPlayer.message(getPlayer(), "");
|
||||||
|
|
||||||
|
new JsonMessage("Click to Open in Web Browser").click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
|
||||||
|
new JsonMessage(C.cGreen + _url).click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
|
||||||
|
UtilPlayer.message(getPlayer(), "");
|
||||||
|
UtilPlayer.message(getPlayer(), "Please be patient, votes may take a few minutes to register.");
|
||||||
|
UtilPlayer.message(getPlayer(), "");
|
||||||
|
UtilPlayer.message(getPlayer(), "----------------------------------------------------");
|
||||||
|
|
||||||
|
getPlayer().closeInventory();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
return _item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setItem()
|
||||||
|
{
|
||||||
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
|
Material material;
|
||||||
|
String itemName;
|
||||||
|
byte data = 0;
|
||||||
|
|
||||||
|
if (isAvailable())
|
||||||
|
{
|
||||||
|
material = Material.JUKEBOX;
|
||||||
|
itemName = C.cGreen + C.Bold + "Vote for Mineplex";
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "Click to Vote!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
material = Material.REDSTONE_BLOCK;
|
||||||
|
itemName = C.cRed + C.Bold + "Vote for Mineplex";
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(ChatColor.RESET + "Next vote in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
|
||||||
|
BonusClientData client = _bonusManager.Get(_player);
|
||||||
|
|
||||||
|
BonusAmount bonusAmount = _bonusManager.getVoteBonusAmount(_player);
|
||||||
|
bonusAmount.addLore(lore);
|
||||||
|
lore.add(" ");
|
||||||
|
|
||||||
|
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak());
|
||||||
|
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplyer(client.getVoteStreak()) + "%");
|
||||||
|
if (client.getVoteTime() != null)
|
||||||
|
{
|
||||||
|
long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime());
|
||||||
|
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME);
|
||||||
|
|
||||||
|
if (timeLeft > 0)
|
||||||
|
{
|
||||||
|
lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak());
|
||||||
|
|
||||||
|
StreakRecord streakRecord = _bonusManager.getVoteStreak();
|
||||||
|
if (streakRecord != null)
|
||||||
|
{
|
||||||
|
lore.add(" ");
|
||||||
|
lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
|
||||||
|
lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
|
||||||
|
}
|
||||||
|
|
||||||
|
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long timeLeft()
|
||||||
|
{
|
||||||
|
return _bonusManager.nextVoteTime(getPlayer()) - System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAvailable()
|
||||||
|
{
|
||||||
|
if (_url == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (timeLeft() <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin()
|
||||||
|
{
|
||||||
|
return _plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemRefresher getGui()
|
||||||
|
{
|
||||||
|
return _gui;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package mineplex.core.bonuses.redis;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.serverdata.commands.CommandCallback;
|
||||||
|
import mineplex.serverdata.commands.ServerCommand;
|
||||||
|
|
||||||
|
public class VoteHandler implements CommandCallback
|
||||||
|
{
|
||||||
|
private BonusManager _bonusManager;
|
||||||
|
|
||||||
|
public VoteHandler(BonusManager bonusManager)
|
||||||
|
{
|
||||||
|
_bonusManager = bonusManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ServerCommand command)
|
||||||
|
{
|
||||||
|
VotifierCommand v = ((VotifierCommand) command);
|
||||||
|
|
||||||
|
Player player = UtilPlayer.searchExact(v.getPlayerName());
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
_bonusManager.handleVote(player, v.getGemsReceived());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package mineplex.core.bonuses.redis;
|
||||||
|
|
||||||
|
import mineplex.serverdata.commands.ServerCommand;
|
||||||
|
|
||||||
|
public class VotifierCommand extends ServerCommand
|
||||||
|
{
|
||||||
|
private String _playerName;
|
||||||
|
private int _gemsReceived;
|
||||||
|
|
||||||
|
public VotifierCommand(String playerName, int gemsReceived, String... targetServer)
|
||||||
|
{
|
||||||
|
super(targetServer);
|
||||||
|
|
||||||
|
_playerName = playerName;
|
||||||
|
_gemsReceived = gemsReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerName()
|
||||||
|
{
|
||||||
|
return _playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGemsReceived()
|
||||||
|
{
|
||||||
|
return _gemsReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -144,7 +144,7 @@ public class Chat extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void lagTest(PlayerCommandPreprocessEvent event)
|
public void lagTest(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
if (event.getMessage().equals("lag") || event.getMessage().equals("ping"))
|
if (event.getMessage().equals("/lag") || event.getMessage().equals("/ping"))
|
||||||
{
|
{
|
||||||
event.getPlayer().sendMessage(F.main(getName(), "PONG!"));
|
event.getPlayer().sendMessage(F.main(getName(), "PONG!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -329,7 +329,7 @@ public class Chat extends MiniPlugin
|
|||||||
UtilPlayer.message(sender, F.main("Chat",
|
UtilPlayer.message(sender, F.main("Chat",
|
||||||
"Accusing players of cheating in-game is against the rules."
|
"Accusing players of cheating in-game is against the rules."
|
||||||
+ "If you think someone is cheating, please gather evidence and report it at "
|
+ "If you think someone is cheating, please gather evidence and report it at "
|
||||||
+ F.link("www.mineplex.com/supporthub/")));
|
+ F.link("www.mineplex.com/reports")));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (_playerLastMessage.containsKey(sender.getUniqueId()))
|
else if (_playerLastMessage.containsKey(sender.getUniqueId()))
|
||||||
|
@ -19,6 +19,9 @@ import mineplex.core.common.util.UtilServer;
|
|||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.gadgets.OutfitTeam;
|
||||||
|
import mineplex.core.gadget.types.Gadget;
|
||||||
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.mount.MountManager;
|
import mineplex.core.mount.MountManager;
|
||||||
@ -191,4 +194,15 @@ public class CosmeticManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return _treasureManager;
|
return _treasureManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disableTeamArmor()
|
||||||
|
{
|
||||||
|
for (Gadget gadget : getGadgetManager().getGadgets(GadgetType.Costume))
|
||||||
|
{
|
||||||
|
if (gadget instanceof OutfitTeam)
|
||||||
|
{
|
||||||
|
((OutfitTeam)gadget).setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,15 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||||
import mineplex.core.cosmetic.ui.button.ActivateGadgetButton;
|
import mineplex.core.cosmetic.ui.button.ActivateGadgetButton;
|
||||||
import mineplex.core.cosmetic.ui.button.DeactivateGadgetButton;
|
import mineplex.core.cosmetic.ui.button.DeactivateGadgetButton;
|
||||||
import mineplex.core.cosmetic.ui.button.GadgetButton;
|
import mineplex.core.cosmetic.ui.button.GadgetButton;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.gadget.gadgets.MorphBlock;
|
||||||
import mineplex.core.gadget.gadgets.MorphNotch;
|
import mineplex.core.gadget.gadgets.MorphNotch;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
@ -41,6 +44,9 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
|
|
||||||
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.Item))
|
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.Item))
|
||||||
{
|
{
|
||||||
|
if (gadget.GetCost(CurrencyType.Coins) == -3)
|
||||||
|
continue;
|
||||||
|
|
||||||
addGadget(gadget, slot);
|
addGadget(gadget, slot);
|
||||||
|
|
||||||
if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetDisplayName()) > 0)
|
if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetDisplayName()) > 0)
|
||||||
@ -68,6 +74,13 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
//setItem(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Disabled " + gadget.GetName(), new String[] { "Sorry! Currently disabled until fix is made for 1.8 players!" }, 1, false, false));
|
//setItem(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Disabled " + gadget.GetName(), new String[] { "Sorry! Currently disabled until fix is made for 1.8 players!" }, 1, false, false));
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
|
else if (gadget instanceof MorphBlock)
|
||||||
|
{
|
||||||
|
//Prevent stacker bug
|
||||||
|
if (getPlayer().getPassenger() != null)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<String> itemLore = new ArrayList<String>();
|
List<String> itemLore = new ArrayList<String>();
|
||||||
|
|
||||||
if (gadget.GetCost(CurrencyType.Coins) >= 0)
|
if (gadget.GetCost(CurrencyType.Coins) >= 0)
|
||||||
@ -78,6 +91,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
{
|
{
|
||||||
itemLore.add(C.cGold + "Found in Treasure Chests.");
|
itemLore.add(C.cGold + "Found in Treasure Chests.");
|
||||||
}
|
}
|
||||||
|
else if (gadget.GetCost(CurrencyType.Coins) == -3)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
itemLore.add(C.cBlack);
|
itemLore.add(C.cBlack);
|
||||||
itemLore.addAll(Arrays.asList(gadget.GetDescription()));
|
itemLore.addAll(Arrays.asList(gadget.GetDescription()));
|
||||||
@ -113,6 +131,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
|
|
||||||
public void purchaseGadget(final Player player, final Gadget gadget)
|
public void purchaseGadget(final Player player, final Gadget gadget)
|
||||||
{
|
{
|
||||||
|
if(getClientManager().Get(player).isDisguised())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
|
@ -52,6 +52,9 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
" ",
|
" ",
|
||||||
ChatColor.RESET + C.cPurple + "Hero Rank",
|
ChatColor.RESET + C.cPurple + "Hero Rank",
|
||||||
ChatColor.RESET + "Receives 15000 Coins per Month",
|
ChatColor.RESET + "Receives 15000 Coins per Month",
|
||||||
|
" ",
|
||||||
|
ChatColor.RESET + C.cGreen + "Legend Rank",
|
||||||
|
ChatColor.RESET + "Recieves 30000 Coins per Month"
|
||||||
}, 1, false));
|
}, 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));
|
||||||
|
@ -82,8 +82,13 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
PetChangeToken token = new PetChangeToken();
|
PetChangeToken token = new PetChangeToken();
|
||||||
|
|
||||||
|
if (getClientManager().Get(getPlayer()) != null)
|
||||||
|
token.AccountId = getClientManager().Get(getPlayer()).getAccountId();
|
||||||
|
|
||||||
token.Name = getPlayer().getName();
|
token.Name = getPlayer().getName();
|
||||||
token.PetType = _pet.GetPetType().toString();
|
token.PetType = _pet.GetPetType().toString();
|
||||||
|
token.PetId = _pet.GetPetType().ordinal();
|
||||||
token.PetName = _tagName;
|
token.PetName = _tagName;
|
||||||
|
|
||||||
PetToken petToken = new PetToken();
|
PetToken petToken = new PetToken();
|
||||||
|
@ -66,6 +66,11 @@ public abstract class RepositoryBase implements Listener
|
|||||||
return _dataSource;
|
return _dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DSLContext jooq()
|
||||||
|
{
|
||||||
|
return DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool!
|
* Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool!
|
||||||
* @see Connection#close()
|
* @see Connection#close()
|
||||||
|
@ -1143,10 +1143,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
|||||||
|
|
||||||
EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity();
|
EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity();
|
||||||
|
|
||||||
|
|
||||||
if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid)
|
if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid)
|
||||||
disguiseIterator.remove();
|
disguiseIterator.remove();
|
||||||
else
|
|
||||||
{
|
try{
|
||||||
for (Iterator<Player> playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();)
|
for (Iterator<Player> playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();)
|
||||||
{
|
{
|
||||||
Player player = playerIterator.next();
|
Player player = playerIterator.next();
|
||||||
@ -1155,6 +1156,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
|||||||
playerIterator.remove();
|
playerIterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception exception) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,18 @@ package mineplex.core.disguise.disguises;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.spigotmc.ProtocolData;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||||
import net.minecraft.server.v1_7_R4.Packet;
|
import net.minecraft.server.v1_7_R4.Packet;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayInSettings;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
|
||||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||||
@ -46,8 +51,8 @@ public class DisguisePlayer extends DisguiseHuman
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't use this if the disguise is already on as it will not work the way you want it to. Contact libraryaddict if you need
|
* Don't use this if the disguise is already on as it will not work the way
|
||||||
* that added.
|
* you want it to. Contact libraryaddict if you need that added.
|
||||||
*/
|
*/
|
||||||
public void setSleeping(BlockFace sleeping)
|
public void setSleeping(BlockFace sleeping)
|
||||||
{
|
{
|
||||||
@ -59,6 +64,11 @@ public class DisguisePlayer extends DisguiseHuman
|
|||||||
_sneaking = sneaking;
|
_sneaking = sneaking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSneaking()
|
||||||
|
{
|
||||||
|
return _sneaking;
|
||||||
|
}
|
||||||
|
|
||||||
public Packet getOldInfoPacket(boolean add)
|
public Packet getOldInfoPacket(boolean add)
|
||||||
{
|
{
|
||||||
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo();
|
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo();
|
||||||
@ -87,12 +97,14 @@ public class DisguisePlayer extends DisguiseHuman
|
|||||||
return newDisguiseInfo;
|
return newDisguiseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("static-access")
|
||||||
@Override
|
@Override
|
||||||
public void UpdateDataWatcher()
|
public void UpdateDataWatcher()
|
||||||
{
|
{
|
||||||
super.UpdateDataWatcher();
|
super.UpdateDataWatcher();
|
||||||
|
|
||||||
byte b0 = DataWatcher.getByte(0);
|
byte b0 = DataWatcher.getByte(0);
|
||||||
|
DataWatcher.watch(10, (Object)(byte)0x40);
|
||||||
|
|
||||||
if(_sneaking)
|
if(_sneaking)
|
||||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)));
|
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)));
|
||||||
|
@ -295,6 +295,11 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
|||||||
_coinQueue.clear();
|
_coinQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rewardGold(Callback<Boolean> callback, String caller, Player player, int amount)
|
||||||
|
{
|
||||||
|
rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), amount);
|
||||||
|
}
|
||||||
|
|
||||||
public void rewardGold(Callback<Boolean> callback, String caller, String name, int accountId, int amount)
|
public void rewardGold(Callback<Boolean> callback, String caller, String name, int accountId, int amount)
|
||||||
{
|
{
|
||||||
rewardGold(callback, caller, name, accountId, amount, true);
|
rewardGold(callback, caller, name, accountId, amount, true);
|
||||||
@ -405,7 +410,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
Get(playerName).addGold(_repository.retrieveDonorInfo(resultSet).getGold());
|
Get(playerName).addGold(_repository.retrieveDonorInfo(resultSet).getGold());
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
Set(playerName, _repository.loadClientInformation(resultSet));
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
@ -175,6 +176,7 @@ public class Explosion extends MiniPlugin
|
|||||||
if (Math.random() > Math.min(0.975, chance))
|
if (Math.random() > Math.min(0.975, chance))
|
||||||
{
|
{
|
||||||
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
|
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
|
||||||
|
fall.setDropItem(false);
|
||||||
|
|
||||||
Vector vec = UtilAlg.getTrajectory(fEnt, fall);
|
Vector vec = UtilAlg.getTrajectory(fEnt, fall);
|
||||||
if (vec.getY() < 0) vec.setY(vec.getY() * -1);
|
if (vec.getY() < 0) vec.setY(vec.getY() * -1);
|
||||||
@ -207,6 +209,13 @@ public class Explosion extends MiniPlugin
|
|||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void ExplosionChangeBlock(EntityChangeBlockEvent event)
|
||||||
|
{
|
||||||
|
if (_explosionBlocks.contains(event.getEntity()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void ExplosionBlockUpdate(UpdateEvent event)
|
public void ExplosionBlockUpdate(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -256,14 +265,6 @@ public class Explosion extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void ExplosionItemSpawn(ItemSpawnEvent event)
|
|
||||||
{
|
|
||||||
for (FallingBlock block : _explosionBlocks)
|
|
||||||
if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1)
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void ExplosionBlocks(EntityExplodeEvent event)
|
public void ExplosionBlocks(EntityExplodeEvent event)
|
||||||
{
|
{
|
||||||
@ -347,6 +348,7 @@ public class Explosion extends MiniPlugin
|
|||||||
if (Math.random() > Math.min(0.98, chance))
|
if (Math.random() > Math.min(0.98, chance))
|
||||||
{
|
{
|
||||||
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
|
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
|
||||||
|
fall.setDropItem(false);
|
||||||
|
|
||||||
Vector vec = UtilAlg.getTrajectory(fLoc, fall.getLocation());
|
Vector vec = UtilAlg.getTrajectory(fLoc, fall.getLocation());
|
||||||
if (vec.getY() < 0) vec.setY(vec.getY() * -1);
|
if (vec.getY() < 0) vec.setY(vec.getY() * -1);
|
||||||
|
@ -401,7 +401,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
Set(playerName, _repository.loadClientInformation(resultSet));
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class FriendRepository extends RepositoryBase
|
|||||||
Set<String> friendNames = new HashSet<String>();
|
Set<String> friendNames = new HashSet<String>();
|
||||||
for(FriendStatus status : friendData.getFriends())
|
for(FriendStatus status : friendData.getFriends())
|
||||||
{
|
{
|
||||||
friendNames.add(status.Name);
|
friendNames.add(status.Name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load PlayerStatus' for friends
|
// Load PlayerStatus' for friends
|
||||||
@ -188,7 +188,7 @@ public class FriendRepository extends RepositoryBase
|
|||||||
*/
|
*/
|
||||||
public String fetchPlayerServer(String playerName)
|
public String fetchPlayerServer(String playerName)
|
||||||
{
|
{
|
||||||
PlayerStatus status = _repository.getElement(playerName);
|
PlayerStatus status = _repository.getElement(playerName.toLowerCase());
|
||||||
|
|
||||||
return (status == null) ? null : status.getServer();
|
return (status == null) ? null : status.getServer();
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,19 @@ import java.util.List;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
@ -50,6 +53,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
private DisguiseManager _disguiseManager;
|
private DisguiseManager _disguiseManager;
|
||||||
private BlockRestore _blockRestore;
|
private BlockRestore _blockRestore;
|
||||||
private ProjectileManager _projectileManager;
|
private ProjectileManager _projectileManager;
|
||||||
|
private AchievementManager _achievementManager;
|
||||||
|
|
||||||
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
|
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
|
||||||
|
|
||||||
@ -61,7 +65,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
|
|
||||||
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
|
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
|
||||||
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
|
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
|
||||||
DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager)
|
DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager)
|
||||||
{
|
{
|
||||||
super("Gadget Manager", plugin);
|
super("Gadget Manager", plugin);
|
||||||
|
|
||||||
@ -73,6 +77,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
_disguiseManager = disguiseManager;
|
_disguiseManager = disguiseManager;
|
||||||
_blockRestore = blockRestore;
|
_blockRestore = blockRestore;
|
||||||
_projectileManager = projectileManager;
|
_projectileManager = projectileManager;
|
||||||
|
_achievementManager = achievementManager;
|
||||||
|
|
||||||
CreateGadgets();
|
CreateGadgets();
|
||||||
}
|
}
|
||||||
@ -90,9 +95,8 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new ItemPaintballGun(this));
|
addGadget(new ItemPaintballGun(this));
|
||||||
addGadget(new ItemBatGun(this));
|
addGadget(new ItemBatGun(this));
|
||||||
addGadget(new ItemCoinBomb(this));
|
addGadget(new ItemCoinBomb(this));
|
||||||
//addGadget(new ItemGemBomb(this));
|
addGadget(new ItemPaintbrush(this));
|
||||||
//addGadget(new ItemFootball(this));
|
addGadget(new ItemDuelingSword(this));
|
||||||
//addGadget(new ItemDuelingSword(this));
|
|
||||||
|
|
||||||
// Costume
|
// Costume
|
||||||
addGadget(new OutfitRaveSuit(this, "Rave Hat", -2, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0));
|
addGadget(new OutfitRaveSuit(this, "Rave Hat", -2, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0));
|
||||||
@ -105,6 +109,11 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new OutfitSpaceSuit(this, "Space Pants", -2, ArmorSlot.Legs, Material.GOLD_LEGGINGS, (byte)0));
|
addGadget(new OutfitSpaceSuit(this, "Space Pants", -2, ArmorSlot.Legs, Material.GOLD_LEGGINGS, (byte)0));
|
||||||
addGadget(new OutfitSpaceSuit(this, "Space Boots", -2, ArmorSlot.Boots, Material.GOLD_BOOTS, (byte)0));
|
addGadget(new OutfitSpaceSuit(this, "Space Boots", -2, ArmorSlot.Boots, Material.GOLD_BOOTS, (byte)0));
|
||||||
|
|
||||||
|
addGadget(new OutfitTeam(this, "Team Helmet", -1, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0));
|
||||||
|
addGadget(new OutfitTeam(this, "Team Shirt", -1, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte)0));
|
||||||
|
addGadget(new OutfitTeam(this, "Team Pants", -1, ArmorSlot.Legs, Material.LEATHER_LEGGINGS, (byte)0));
|
||||||
|
addGadget(new OutfitTeam(this, "Team Boots", -1, ArmorSlot.Boots, Material.LEATHER_BOOTS, (byte)0));
|
||||||
|
|
||||||
// Morphs
|
// Morphs
|
||||||
addGadget(new MorphVillager(this));
|
addGadget(new MorphVillager(this));
|
||||||
addGadget(new MorphCow(this));
|
addGadget(new MorphCow(this));
|
||||||
@ -112,14 +121,13 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new MorphBlock(this));
|
addGadget(new MorphBlock(this));
|
||||||
addGadget(new MorphEnderman(this));
|
addGadget(new MorphEnderman(this));
|
||||||
addGadget(new MorphBat(this));
|
addGadget(new MorphBat(this));
|
||||||
//addGadget(new MorphNotch(this));
|
|
||||||
addGadget(new MorphPumpkinKing(this));
|
addGadget(new MorphPumpkinKing(this));
|
||||||
addGadget(new MorphPig(this));
|
addGadget(new MorphPig(this));
|
||||||
addGadget(new MorphCreeper(this));
|
addGadget(new MorphCreeper(this));
|
||||||
addGadget(new MorphBlaze(this));
|
addGadget(new MorphBlaze(this));
|
||||||
//addGadget(new MorphGeno(this));
|
|
||||||
addGadget(new MorphWither(this));
|
addGadget(new MorphWither(this));
|
||||||
addGadget(new MorphBunny(this));
|
addGadget(new MorphBunny(this));
|
||||||
|
addGadget(new MorphSlime(this, _achievementManager));
|
||||||
|
|
||||||
// Particles
|
// Particles
|
||||||
addGadget(new ParticleFoot(this));
|
addGadget(new ParticleFoot(this));
|
||||||
@ -144,7 +152,6 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new MusicGadget(this, "Stal Disc", new String[] {""}, -2, 2263, 150000));
|
addGadget(new MusicGadget(this, "Stal Disc", new String[] {""}, -2, 2263, 150000));
|
||||||
addGadget(new MusicGadget(this, "Strad Disc", new String[] {""}, -2, 2264, 188000));
|
addGadget(new MusicGadget(this, "Strad Disc", new String[] {""}, -2, 2264, 188000));
|
||||||
addGadget(new MusicGadget(this, "Ward Disc", new String[] {""}, -2, 2265, 251000));
|
addGadget(new MusicGadget(this, "Ward Disc", new String[] {""}, -2, 2265, 251000));
|
||||||
//addGadget(new MusicGadget(this, "11 Disc", new String[] {""}, -2, 2266, 71000));
|
|
||||||
addGadget(new MusicGadget(this, "Wait Disc", new String[] {""}, -2, 2267, 238000));
|
addGadget(new MusicGadget(this, "Wait Disc", new String[] {""}, -2, 2267, 238000));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +280,20 @@ public class GadgetManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DisableAll(Player player, List<String> dontDisable)
|
||||||
|
{
|
||||||
|
for (GadgetType gadgetType : _gadgets.keySet())
|
||||||
|
{
|
||||||
|
for (Gadget gadget : _gadgets.get(gadgetType))
|
||||||
|
{
|
||||||
|
if (dontDisable.contains(gadget.GetName()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
gadget.Disable(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PetManager getPetManager()
|
public PetManager getPetManager()
|
||||||
{
|
{
|
||||||
return _petManager;
|
return _petManager;
|
||||||
@ -430,4 +451,16 @@ public class GadgetManager extends MiniPlugin
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void chissMeow(PlayerToggleSneakEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer().getName().equals("Chiss"))
|
||||||
|
{
|
||||||
|
if (!event.getPlayer().isSneaking())
|
||||||
|
{
|
||||||
|
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.core.gadget.gadgets;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.MapUtil;
|
import mineplex.core.common.util.MapUtil;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
@ -64,6 +63,7 @@ public class BlockForm
|
|||||||
DisguiseChicken disguise = new DisguiseChicken(_player);
|
DisguiseChicken disguise = new DisguiseChicken(_player);
|
||||||
disguise.setBaby();
|
disguise.setBaby();
|
||||||
disguise.setSoundDisguise(new DisguiseCat(_player));
|
disguise.setSoundDisguise(new DisguiseCat(_player));
|
||||||
|
disguise.setInvisible(true);
|
||||||
_host.Manager.getDisguiseManager().disguise(disguise);
|
_host.Manager.getDisguiseManager().disguise(disguise);
|
||||||
|
|
||||||
//Apply Falling Block
|
//Apply Falling Block
|
||||||
|
@ -1,66 +1,48 @@
|
|||||||
package mineplex.core.gadget.gadgets;
|
package mineplex.core.gadget.gadgets;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Bat;
|
|
||||||
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.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.UtilGear;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.types.ItemGadget;
|
import mineplex.core.gadget.types.ItemGadget;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
|
||||||
public class ItemDuelingSword extends ItemGadget
|
public class ItemDuelingSword extends ItemGadget
|
||||||
{
|
{
|
||||||
public ItemDuelingSword(GadgetManager manager)
|
public ItemDuelingSword(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Dueling Sword", new String[]
|
super(manager, "PvP Sword", new String[]
|
||||||
{
|
{
|
||||||
C.cWhite + "While active, you are able to fight",
|
C.cGreen + "Activated in King of the Hill",
|
||||||
C.cWhite + "against other people who are also",
|
|
||||||
C.cWhite + "wielding a dueling sword.",
|
|
||||||
},
|
},
|
||||||
-1,
|
-3,
|
||||||
Material.WOOD_SWORD, (byte)3,
|
Material.GOLD_SWORD, (byte)0,
|
||||||
1000, new Ammo("Dueling Sword", "10 Swords", Material.WOOD_SWORD, (byte)0, new String[] { C.cWhite + "10 Swords to duel with" }, 1000, 10));
|
1000, new Ammo("Dueling Sword", "10 Swords", Material.WOOD_SWORD, (byte)0, new String[] { C.cWhite + "10 Swords to duel with" }, 1000, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ApplyItem(Player player, boolean inform)
|
||||||
|
{
|
||||||
|
Manager.RemoveItem(player);
|
||||||
|
|
||||||
|
_active.add(player);
|
||||||
|
|
||||||
|
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "PvP Sword"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void Activate(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ActivateCustom(Player player)
|
public void ActivateCustom(Player player)
|
||||||
{
|
{
|
||||||
ItemStack stack = new ItemStack(Material.GOLD_SWORD);
|
|
||||||
ItemMeta meta = stack.getItemMeta();
|
|
||||||
meta.setDisplayName("Dueling Sword");
|
|
||||||
stack.setItemMeta(meta);
|
|
||||||
|
|
||||||
player.getInventory().setItem(Manager.getActiveItemSlot(), stack);
|
|
||||||
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
public void damage(EntityDamageByEntityEvent event)
|
|
||||||
{
|
|
||||||
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player damager = (Player)event.getDamager();
|
|
||||||
Player damagee = (Player)event.getEntity();
|
|
||||||
|
|
||||||
if (!UtilGear.isMat(damager.getItemInHand(), Material.GOLD_SWORD) || !UtilGear.isMat(damagee.getItemInHand(), Material.GOLD_SWORD))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(false);
|
|
||||||
|
|
||||||
event.setDamage(4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package mineplex.core.gadget.gadgets;
|
||||||
|
|
||||||
|
public class ItemKothSword {
|
||||||
|
|
||||||
|
}
|
@ -126,6 +126,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
|
|||||||
|
|
||||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.EAT, 1f, 1f);
|
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.EAT, 1f, 1f);
|
||||||
|
|
||||||
|
if (!event.getPlayer().hasPotionEffect(PotionEffectType.SPEED))
|
||||||
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 80, 1), true);
|
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 80, 1), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,15 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||||
import mineplex.core.gadget.types.ItemGadget;
|
import mineplex.core.gadget.types.ItemGadget;
|
||||||
@ -36,10 +42,11 @@ public class ItemPaintballGun extends ItemGadget
|
|||||||
super(manager, "Paintball Gun", new String[]
|
super(manager, "Paintball Gun", new String[]
|
||||||
{
|
{
|
||||||
C.cWhite + "PEW PEW PEW PEW!",
|
C.cWhite + "PEW PEW PEW PEW!",
|
||||||
},
|
}, -1, Material.GOLD_BARDING, (byte) 0, 200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING,
|
||||||
-1,
|
(byte) 0, new String[]
|
||||||
Material.GOLD_BARDING, (byte)0,
|
{
|
||||||
200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING, (byte)0, new String[] { C.cWhite + "100 Paintballs for you to shoot!" }, 500, 100));
|
C.cWhite + "100 Paintballs for you to shoot!"
|
||||||
|
}, 500, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,47 +66,26 @@ public class ItemPaintballGun extends ItemGadget
|
|||||||
if (!_balls.remove(event.getEntity()))
|
if (!_balls.remove(event.getEntity()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity());
|
Location loc = event.getEntity().getLocation();
|
||||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 49);
|
|
||||||
|
|
||||||
byte color = 2;
|
Vector vec = event.getEntity().getVelocity().normalize().multiply(0.05);
|
||||||
double r = Math.random();
|
|
||||||
if (r > 0.8) color = 4;
|
|
||||||
else if (r > 0.6) color = 5;
|
|
||||||
else if (r > 0.4) color = 9;
|
|
||||||
else if (r > 0.2) color = 14;
|
|
||||||
|
|
||||||
for (Block block : UtilBlock.getInRadius(loc, 3d).keySet())
|
if (vec.length() > 0)
|
||||||
{
|
{
|
||||||
if (block.getType() == Material.PORTAL)
|
int i = 0;
|
||||||
return;
|
|
||||||
|
|
||||||
if (block.getType() == Material.CACTUS)
|
while (UtilBlock.airFoliage(loc.getBlock()))
|
||||||
return;
|
{
|
||||||
|
loc.add(vec);
|
||||||
|
|
||||||
if (block.getType() == Material.SUGAR_CANE_BLOCK)
|
if (i++ > 50)
|
||||||
return;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Block> blocks = new ArrayList<Block>();
|
loc.getWorld().playSound(loc, Sound.DIG_STONE, 1.3F, 1.3F);
|
||||||
blocks.addAll(UtilBlock.getInRadius(loc, 1.5d).keySet());
|
|
||||||
|
|
||||||
GadgetBlockEvent gadgetEvent = new GadgetBlockEvent(this, blocks);
|
UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, 0.2F, 0.2F, 0.2F, 1, 70, ViewDist.LONG, UtilServer.getPlayers());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
|
||||||
|
|
||||||
if (gadgetEvent.isCancelled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (Block block : gadgetEvent.getBlocks())
|
|
||||||
{
|
|
||||||
if (!UtilBlock.solid(block))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (block.getType() == Material.CARPET)
|
|
||||||
Manager.getBlockRestore().add(block, 171, color, 4000);
|
|
||||||
else
|
|
||||||
Manager.getBlockRestore().add(block, 35, color, 4000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -0,0 +1,207 @@
|
|||||||
|
package mineplex.core.gadget.gadgets;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Villager;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilEvent;
|
||||||
|
import mineplex.core.common.util.UtilGear;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.ItemGadget;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
public class ItemPaintbrush extends ItemGadget
|
||||||
|
{
|
||||||
|
private NautHashMap<String, Byte> _brushColor = new NautHashMap<String, Byte>();
|
||||||
|
private NautHashMap<String, Location> _brushPrevious = new NautHashMap<String, Location>();
|
||||||
|
|
||||||
|
private NautHashMap<String, Location> _playerLocation = new NautHashMap<String, Location>();
|
||||||
|
|
||||||
|
public ItemPaintbrush(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Paintbrush", new String[]
|
||||||
|
{
|
||||||
|
C.cWhite + "Unleash your inner creativity!",
|
||||||
|
C.cWhite + "",
|
||||||
|
C.cGreen + "Activated at a Painter NPC",
|
||||||
|
},
|
||||||
|
-3,
|
||||||
|
Material.WOOD_SWORD, (byte)0,
|
||||||
|
200, new Ammo("Paint", "100 Pixels", Material.INK_SACK, (byte)0, new String[] { C.cWhite + "100 Pixels worth of Paint!" }, 500, 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ApplyItem(Player player, boolean inform)
|
||||||
|
{
|
||||||
|
Manager.RemoveItem(player);
|
||||||
|
|
||||||
|
_active.add(player);
|
||||||
|
|
||||||
|
List<String> itemLore = new ArrayList<String>();
|
||||||
|
itemLore.addAll(Arrays.asList(GetDescription()));
|
||||||
|
|
||||||
|
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, GetName()));
|
||||||
|
|
||||||
|
if (inform)
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void Activate(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ActivateCustom(Player player)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EnableCustom(Player player)
|
||||||
|
{
|
||||||
|
ApplyItem(player, true);
|
||||||
|
|
||||||
|
_brushColor.put(player.getName(), (byte)15);
|
||||||
|
_playerLocation.put(player.getName(), player.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void DisableCustom(Player player)
|
||||||
|
{
|
||||||
|
_brushColor.remove(player.getName());
|
||||||
|
_brushPrevious.remove(player.getName());
|
||||||
|
_playerLocation.remove(player.getName());
|
||||||
|
|
||||||
|
RemoveItem(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void colorSelect(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (!IsActive(event.getPlayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Block block = player.getTargetBlock(null, 100);
|
||||||
|
if (block == null || block.getType() != Material.STAINED_CLAY)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_brushColor.put(player.getName(), block.getData());
|
||||||
|
|
||||||
|
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void disableDistance(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SEC)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
if (!GetActive().contains(player))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Location loc = _playerLocation.get(player.getName());
|
||||||
|
|
||||||
|
if (loc == null || UtilMath.offset(player.getLocation(), loc) > 12)
|
||||||
|
{
|
||||||
|
Disable(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void paint(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : GetActive())
|
||||||
|
{
|
||||||
|
if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!player.isBlocking())
|
||||||
|
{
|
||||||
|
_brushPrevious.remove(player.getName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = player.getTargetBlock(null, 100);
|
||||||
|
if (block == null || block.getType() != Material.WOOL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Color
|
||||||
|
Manager.getBlockRestore().add(block, 35, _brushColor.get(player.getName()), 30000);
|
||||||
|
|
||||||
|
//Join Dots
|
||||||
|
if (_brushPrevious.containsKey(player.getName()))
|
||||||
|
{
|
||||||
|
while (UtilMath.offset(_brushPrevious.get(player.getName()), block.getLocation().add(0.5, 0.5, 0.5)) > 0.5)
|
||||||
|
{
|
||||||
|
_brushPrevious.get(player.getName()).add(UtilAlg.getTrajectory(_brushPrevious.get(player.getName()), block.getLocation().add(0.5, 0.5, 0.5)).multiply(0.5));
|
||||||
|
|
||||||
|
Block fixBlock = _brushPrevious.get(player.getName()).getBlock();
|
||||||
|
|
||||||
|
if (fixBlock.getType() != Material.WOOL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Manager.getBlockRestore().add(fixBlock, 35, _brushColor.get(player.getName()), 30000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.25f, 2f);
|
||||||
|
|
||||||
|
|
||||||
|
_brushPrevious.put(player.getName(), block.getLocation().add(0.5, 0.5, 0.5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void enableInteract(PlayerInteractEntityEvent event)
|
||||||
|
{
|
||||||
|
if (IsActive(event.getPlayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getRightClicked() instanceof Villager))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Villager villager = (Villager)event.getRightClicked();
|
||||||
|
|
||||||
|
if (villager.getCustomName() != null && villager.getCustomName().contains("Painter"))
|
||||||
|
{
|
||||||
|
Enable(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
package mineplex.core.gadget.gadgets;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilEvent;
|
||||||
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
|
import mineplex.core.disguise.disguises.DisguiseSlime;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.MorphGadget;
|
||||||
|
|
||||||
|
public class MorphSlime extends MorphGadget
|
||||||
|
{
|
||||||
|
private CoreClientManager _clientManager;
|
||||||
|
private AchievementManager _achievementManager;
|
||||||
|
|
||||||
|
public MorphSlime(GadgetManager manager, AchievementManager achievements)
|
||||||
|
{
|
||||||
|
super(manager, "Big Larry Morph", new String[]
|
||||||
|
{
|
||||||
|
C.cWhite + "Become a slime like Big Larry!",
|
||||||
|
" ",
|
||||||
|
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Bounce",
|
||||||
|
" ",
|
||||||
|
C.cWhite + "+1 Slime Size for every 10 Mineplex Levels",
|
||||||
|
},
|
||||||
|
80000,
|
||||||
|
Material.SLIME_BALL, (byte)0);
|
||||||
|
|
||||||
|
_achievementManager = achievements;
|
||||||
|
_clientManager = manager.getClientManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EnableCustom(final Player player)
|
||||||
|
{
|
||||||
|
this.ApplyArmor(player);
|
||||||
|
|
||||||
|
DisguiseSlime disguise = new DisguiseSlime(player);
|
||||||
|
disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
|
||||||
|
disguise.setCustomNameVisible(true);
|
||||||
|
|
||||||
|
int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8;
|
||||||
|
|
||||||
|
if (size < 1)
|
||||||
|
size = 1;
|
||||||
|
|
||||||
|
if (size > 12)
|
||||||
|
size = 12;
|
||||||
|
|
||||||
|
disguise.SetSize(size);
|
||||||
|
|
||||||
|
Manager.getDisguiseManager().disguise(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void DisableCustom(Player player)
|
||||||
|
{
|
||||||
|
this.RemoveArmor(player);
|
||||||
|
Manager.getDisguiseManager().undisguise(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void skill(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!IsActive(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!UtilEvent.isAction(event, ActionType.L))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!UtilEnt.isGrounded(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!Recharge.Instance.use(player, GetName(), 1000, false, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.SLIME_ATTACK, 1f, 1f);
|
||||||
|
|
||||||
|
//Size
|
||||||
|
int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8;
|
||||||
|
|
||||||
|
if (size < 1)
|
||||||
|
size = 1;
|
||||||
|
|
||||||
|
if (size > 12)
|
||||||
|
size = 12;
|
||||||
|
|
||||||
|
//Vel
|
||||||
|
UtilAction.velocity(player, 1 + (size * 0.2), 0, 10, true);
|
||||||
|
}
|
||||||
|
}
|
@ -146,7 +146,7 @@ public class MorphWither extends MorphGadget
|
|||||||
{
|
{
|
||||||
WitherSkull skull = skullIterator.next();
|
WitherSkull skull = skullIterator.next();
|
||||||
|
|
||||||
if (!skull.isValid())
|
if (!skull.isValid() || skull.getTicksLived() > 60)
|
||||||
{
|
{
|
||||||
skullIterator.remove();
|
skullIterator.remove();
|
||||||
skull.remove();
|
skull.remove();
|
||||||
@ -170,7 +170,7 @@ public class MorphWither extends MorphGadget
|
|||||||
player.setFlying(true);
|
player.setFlying(true);
|
||||||
|
|
||||||
if (UtilEnt.isGrounded(player))
|
if (UtilEnt.isGrounded(player))
|
||||||
player.setVelocity(new Vector(0,1,0));
|
UtilAction.velocity(player, new Vector(0,1,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,13 @@ package mineplex.core.gadget.gadgets;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
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.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ public class OutfitRaveSuit extends OutfitGadget
|
|||||||
public OutfitRaveSuit(GadgetManager manager, String name,
|
public OutfitRaveSuit(GadgetManager manager, String name,
|
||||||
int cost, ArmorSlot slot, Material mat, byte data)
|
int cost, ArmorSlot slot, Material mat, byte data)
|
||||||
{
|
{
|
||||||
super(manager, name, new String[] {"Wear the complete set for","awesome bonus effects!", "Bonus coming soon..."}, cost, slot, mat, data);
|
super(manager, name, new String[] {ChatColor.RESET + "Wear the complete set for",ChatColor.RESET + "awesome bonus effects!", ChatColor.RESET + "Bonus coming soon..."}, cost, slot, mat, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -147,4 +149,10 @@ public class OutfitRaveSuit extends OutfitGadget
|
|||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void playerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
_colorPhase.remove(event.getPlayer().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package mineplex.core.gadget.gadgets;
|
package mineplex.core.gadget.gadgets;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ public class OutfitSpaceSuit extends OutfitGadget
|
|||||||
public OutfitSpaceSuit(GadgetManager manager, String name,
|
public OutfitSpaceSuit(GadgetManager manager, String name,
|
||||||
int cost, ArmorSlot slot, Material mat, byte data)
|
int cost, ArmorSlot slot, Material mat, byte data)
|
||||||
{
|
{
|
||||||
super(manager, name, new String[] {"Wear the complete set for","awesome bonus effects!", "Bonus coming soon..."}, cost, slot, mat, data);
|
super(manager, name, new String[] {ChatColor.RESET + "Wear the complete set for",ChatColor.RESET + "awesome bonus effects!", ChatColor.RESET + "Bonus coming soon..."}, cost, slot, mat, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,248 @@
|
|||||||
|
package mineplex.core.gadget.gadgets;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilGear;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||||
|
import mineplex.core.gadget.types.OutfitGadget;
|
||||||
|
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
|
public class OutfitTeam extends OutfitGadget
|
||||||
|
{
|
||||||
|
private boolean _enabled = true;
|
||||||
|
|
||||||
|
private HashMap<String, Color> _colorSetting = new HashMap<String, Color>();
|
||||||
|
|
||||||
|
public OutfitTeam(GadgetManager manager, String name,
|
||||||
|
int cost, ArmorSlot slot, Material mat, byte data)
|
||||||
|
{
|
||||||
|
super(manager, name, new String[] {ChatColor.RESET + "Team up with other players!", ChatColor.RESET + "Equip by typing;", ChatColor.RESET + C.cGreen + "/team <red/yellow/green/blue>"}, cost, slot, mat, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Enable(Player player)
|
||||||
|
{
|
||||||
|
GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
||||||
|
|
||||||
|
if (gadgetEvent.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableCustom(player);
|
||||||
|
Manager.setActive(player, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ApplyArmor(Player player)
|
||||||
|
{
|
||||||
|
Manager.RemoveMorph(player);
|
||||||
|
|
||||||
|
Manager.RemoveOutfit(player, _slot);
|
||||||
|
|
||||||
|
_active.add(player);
|
||||||
|
|
||||||
|
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(
|
||||||
|
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
|
||||||
|
|
||||||
|
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(
|
||||||
|
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
|
||||||
|
|
||||||
|
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(
|
||||||
|
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
|
||||||
|
|
||||||
|
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(
|
||||||
|
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void RemoveArmor(Player player)
|
||||||
|
{
|
||||||
|
if (!_active.remove(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
|
||||||
|
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
|
||||||
|
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
|
||||||
|
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EnableCustom(Player player)
|
||||||
|
{
|
||||||
|
ApplyArmor(player);
|
||||||
|
colorArmor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void DisableCustom(Player player)
|
||||||
|
{
|
||||||
|
RemoveArmor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority=EventPriority.LOWEST)
|
||||||
|
public void setColor(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
if (!_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!event.getMessage().toLowerCase().startsWith("/team"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
String[] args = event.getMessage().toLowerCase().split(" ");
|
||||||
|
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
Disable(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Will only display the message once
|
||||||
|
if (GetSlot() == ArmorSlot.Legs)
|
||||||
|
{
|
||||||
|
if (!Recharge.Instance.use(player, "Set Team Color", 20000, true, false))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!Recharge.Instance.use(player, "Set Team Color " + GetSlot(), 20000, false, false))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Color
|
||||||
|
if (args[1].equals("red"))
|
||||||
|
{
|
||||||
|
_colorSetting.put(player.getName(), Color.RED);
|
||||||
|
|
||||||
|
if (GetSlot() == ArmorSlot.Legs) //Only Display Once
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cRed + "Red Team Outfit") + "!"));
|
||||||
|
}
|
||||||
|
else if (args[1].equals("yellow"))
|
||||||
|
{
|
||||||
|
_colorSetting.put(player.getName(), Color.YELLOW);
|
||||||
|
|
||||||
|
if (GetSlot() == ArmorSlot.Legs) //Only Display Once
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cYellow + "Yellow Team Outfit") + "!"));
|
||||||
|
}
|
||||||
|
else if (args[1].equals("green"))
|
||||||
|
{
|
||||||
|
_colorSetting.put(player.getName(), Color.LIME);
|
||||||
|
|
||||||
|
if (GetSlot() == ArmorSlot.Legs) //Only Display Once
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cGreen + "Green Team Outfit") + "!"));
|
||||||
|
}
|
||||||
|
else if (args[1].equals("blue"))
|
||||||
|
{
|
||||||
|
_colorSetting.put(player.getName(), Color.AQUA);
|
||||||
|
|
||||||
|
if (GetSlot() == ArmorSlot.Legs) //Only Display Once
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cAqua + "Blue Team Outfit") + "!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
colorArmor(player);
|
||||||
|
|
||||||
|
Enable(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void colorArmor(Player player)
|
||||||
|
{
|
||||||
|
if (!_colorSetting.containsKey(player.getName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Get Item
|
||||||
|
ItemStack stack;
|
||||||
|
|
||||||
|
if (GetSlot() == ArmorSlot.Helmet)
|
||||||
|
{
|
||||||
|
stack = player.getInventory().getHelmet();
|
||||||
|
|
||||||
|
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
|
||||||
|
{
|
||||||
|
Disable(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (GetSlot() == ArmorSlot.Chest)
|
||||||
|
{
|
||||||
|
stack = player.getInventory().getChestplate();
|
||||||
|
|
||||||
|
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
|
||||||
|
{
|
||||||
|
Disable(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (GetSlot() == ArmorSlot.Legs)
|
||||||
|
{
|
||||||
|
stack = player.getInventory().getLeggings();
|
||||||
|
|
||||||
|
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
|
||||||
|
{
|
||||||
|
Disable(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (GetSlot() == ArmorSlot.Boots)
|
||||||
|
{
|
||||||
|
stack = player.getInventory().getBoots();
|
||||||
|
|
||||||
|
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
|
||||||
|
{
|
||||||
|
Disable(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Set!
|
||||||
|
LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta();
|
||||||
|
meta.setColor(_colorSetting.get(player.getName()));
|
||||||
|
stack.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void playerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
_colorSetting.remove(event.getPlayer().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getTeamColor(Player player)
|
||||||
|
{
|
||||||
|
return _colorSetting.get(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean var)
|
||||||
|
{
|
||||||
|
_enabled = var;
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@ public abstract class OutfitGadget extends Gadget
|
|||||||
Boots
|
Boots
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArmorSlot _slot;
|
protected ArmorSlot _slot;
|
||||||
|
|
||||||
public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data)
|
public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ public enum GameDisplay
|
|||||||
//Mini
|
//Mini
|
||||||
BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1),
|
BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1),
|
||||||
Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.EXTRA, 2),
|
Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.EXTRA, 2),
|
||||||
|
BossBattles("Boss Battles", Material.SKULL_ITEM, (byte) 0, GameCategory.EVENT, 55),
|
||||||
Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3),
|
Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3),
|
||||||
CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4),
|
CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4),
|
||||||
ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6),
|
ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6),
|
||||||
@ -27,6 +28,7 @@ public enum GameDisplay
|
|||||||
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
|
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
|
||||||
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52),
|
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52),
|
||||||
Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21),
|
Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21),
|
||||||
|
|
||||||
Micro("Micro Battle", Material.LAVA_BUCKET, (byte)0, GameCategory.ARCADE, 24),
|
Micro("Micro Battle", Material.LAVA_BUCKET, (byte)0, GameCategory.ARCADE, 24),
|
||||||
MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27),
|
MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27),
|
||||||
MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CHAMPIONS, 25),// Temp set to CHAMPIONS to fix UI bug
|
MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CHAMPIONS, 25),// Temp set to CHAMPIONS to fix UI bug
|
||||||
@ -50,7 +52,7 @@ public enum GameDisplay
|
|||||||
SquidShooter("Squid Shooter", Material.FIREWORK_CHARGE, (byte)0, GameCategory.ARCADE, 43),
|
SquidShooter("Squid Shooter", Material.FIREWORK_CHARGE, (byte)0, GameCategory.ARCADE, 43),
|
||||||
Stacker("Super Stacker", Material.BOWL, (byte)0, GameCategory.ARCADE, 42),
|
Stacker("Super Stacker", Material.BOWL, (byte)0, GameCategory.ARCADE, 42),
|
||||||
SurvivalGames("Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.SURVIVAL, 22),
|
SurvivalGames("Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.SURVIVAL, 22),
|
||||||
SurvivalGamesTeams("Survival Games Teams", Material.IRON_SWORD, (byte)0, GameCategory.TEAM_VARIANT, 23),
|
SurvivalGamesTeams("Survival Games Teams", "Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.TEAM_VARIANT, 23),
|
||||||
Tug("Tug of Wool", Material.WHEAT, (byte)0, GameCategory.ARCADE, 44),
|
Tug("Tug of Wool", Material.WHEAT, (byte)0, GameCategory.ARCADE, 44),
|
||||||
TurfWars("Turf Wars", Material.STAINED_CLAY, (byte)14, GameCategory.ARCADE, 45),
|
TurfWars("Turf Wars", Material.STAINED_CLAY, (byte)14, GameCategory.ARCADE, 45),
|
||||||
UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46),
|
UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46),
|
||||||
@ -60,7 +62,10 @@ public enum GameDisplay
|
|||||||
|
|
||||||
Build("Master Builders", Material.WOOD, (byte)0, GameCategory.CLASSICS, 50),
|
Build("Master Builders", Material.WOOD, (byte)0, GameCategory.CLASSICS, 50),
|
||||||
Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51),
|
Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51),
|
||||||
Skywars("Skywars", Material.FEATHER, (byte)5, GameCategory.SURVIVAL, 52),
|
Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52),
|
||||||
|
SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53),
|
||||||
|
|
||||||
|
Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54),
|
||||||
|
|
||||||
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
|
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
|
||||||
|
|
||||||
@ -124,4 +129,10 @@ public enum GameDisplay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//May need to actually add this to each game individually, but for now, LobbyName works fine
|
||||||
|
public String getKitGameName()
|
||||||
|
{
|
||||||
|
return _lobbyName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
|
public interface ClickExecutor
|
||||||
|
{
|
||||||
|
public void click(ClickType clickType);
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
public interface Container<T> {
|
||||||
|
public T getObject();
|
||||||
|
}
|
40
Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java
Normal file
40
Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.gui.GuiItem;
|
||||||
|
|
||||||
|
public class DisplayItem implements GuiItem
|
||||||
|
{
|
||||||
|
private ItemStack _item;
|
||||||
|
|
||||||
|
public DisplayItem(ItemStack item)
|
||||||
|
{
|
||||||
|
_item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
return _item;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
|
||||||
|
public interface GuiInventory {
|
||||||
|
public void openInventory();
|
||||||
|
public Inventory getInventory();
|
||||||
|
}
|
9
Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java
Normal file
9
Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public interface GuiItem extends ClickExecutor, Container<ItemStack>
|
||||||
|
{
|
||||||
|
public void setup();
|
||||||
|
public void close();
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
public interface ItemRefresher extends GuiInventory
|
||||||
|
{
|
||||||
|
public void refreshItem(GuiItem item);
|
||||||
|
}
|
241
Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java
Normal file
241
Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class SimpleGui implements ItemRefresher, Listener
|
||||||
|
{
|
||||||
|
// private Map<Integer, GuiItem> _buttonMap = new HashMap<Integer, GuiItem>();
|
||||||
|
private GuiItem[] _items;
|
||||||
|
|
||||||
|
private Player _player;
|
||||||
|
private Plugin _plugin;
|
||||||
|
private int _size;
|
||||||
|
private String _title;
|
||||||
|
private Inventory _inv;
|
||||||
|
|
||||||
|
public SimpleGui(Plugin plugin, Player player)
|
||||||
|
{
|
||||||
|
this(plugin, player, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleGui(Plugin plugin, Player player, int size)
|
||||||
|
{
|
||||||
|
this(plugin, player, null, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleGui(Plugin plugin, Player player, String title)
|
||||||
|
{
|
||||||
|
this(plugin, player, title, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleGui(Plugin plugin, Player player, String title, int size)
|
||||||
|
{
|
||||||
|
|
||||||
|
Validate.notNull(plugin, "The plugin cannot be null!");
|
||||||
|
Validate.notNull(player, "The player cannot be null!");
|
||||||
|
|
||||||
|
this._plugin = plugin;
|
||||||
|
this._player = player;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
setSize(9);
|
||||||
|
else
|
||||||
|
setSize(size);
|
||||||
|
|
||||||
|
if (title == null)
|
||||||
|
setTitle(" ");
|
||||||
|
else
|
||||||
|
setTitle(title);
|
||||||
|
|
||||||
|
updateArray();
|
||||||
|
|
||||||
|
_inv = createInventory();
|
||||||
|
refreshInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateArray()
|
||||||
|
{
|
||||||
|
_items = new GuiItem[_size];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem(int i, GuiItem item)
|
||||||
|
{
|
||||||
|
Validate.isTrue(i >= 0 && i < _size, "Tried to add a gui item outside of inventory range");
|
||||||
|
|
||||||
|
GuiItem oldItem = getItem(i);
|
||||||
|
if (oldItem != null) oldItem.close();
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
_items[i] = item;
|
||||||
|
item.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshItem(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiItem getItem(int i)
|
||||||
|
{
|
||||||
|
return _items[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openInventory()
|
||||||
|
{
|
||||||
|
refreshInventory();
|
||||||
|
UtilPlayer.swapToInventory(_player, _inv);
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory createInventory()
|
||||||
|
{
|
||||||
|
Inventory inv = Bukkit.createInventory(_player, getSize(), getTitle());
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshInventory()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _size; i++)
|
||||||
|
{
|
||||||
|
refreshItem(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryClick(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getWhoClicked().equals(_player) || !event.getInventory().equals(_inv))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getSlot() >= 0 && event.getSlot() < _size)
|
||||||
|
{
|
||||||
|
GuiItem item = getItem(event.getSlot());
|
||||||
|
if (item == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
item.click(event.getClick());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teleport(PlayerTeleportEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getPlayer().equals(_player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryClose(InventoryCloseEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getPlayer().equals(_player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void quit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getPlayer().equals(_player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void close()
|
||||||
|
{
|
||||||
|
// _inv = null; // TODO - do we really need to null the inventory?
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
|
||||||
|
for (int i = 0; i < _size; i++)
|
||||||
|
{
|
||||||
|
GuiItem item = getItem(i);
|
||||||
|
if (item != null) item.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public void refreshItem(GuiItem item)
|
||||||
|
{
|
||||||
|
if (_inv == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < _size; i++)
|
||||||
|
{
|
||||||
|
if (item.equals(getItem(i)))
|
||||||
|
refreshItem(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshItem(int slot)
|
||||||
|
{
|
||||||
|
GuiItem gi = getItem(slot);
|
||||||
|
|
||||||
|
ItemStack itemStack = null;
|
||||||
|
if (gi != null) itemStack = gi.getObject();
|
||||||
|
|
||||||
|
_inv.setItem(slot, itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize()
|
||||||
|
{
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return _title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin()
|
||||||
|
{
|
||||||
|
return _plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title)
|
||||||
|
{
|
||||||
|
this._title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Inventory getInventory()
|
||||||
|
{
|
||||||
|
return _inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(int size)
|
||||||
|
{
|
||||||
|
Validate.isTrue(size % 9 == 0, "The size " + size + " is not divisible by 9");
|
||||||
|
this._size = size;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package mineplex.core.gui;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class SimpleGuiItem extends ItemStack implements GuiItem {
|
||||||
|
|
||||||
|
public SimpleGuiItem(Material type, int amount, short damage)
|
||||||
|
{
|
||||||
|
super(type, amount, damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleGuiItem(Material type, int amount)
|
||||||
|
{
|
||||||
|
super(type, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleGuiItem(Material type)
|
||||||
|
{
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleGuiItem(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
super(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getObject()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package mineplex.core.gui.botton;
|
||||||
|
|
||||||
|
import mineplex.core.gui.GuiInventory;
|
||||||
|
import mineplex.core.gui.SimpleGuiItem;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class BackBotton extends SimpleGuiItem {
|
||||||
|
|
||||||
|
private GuiInventory _gui;
|
||||||
|
|
||||||
|
public BackBotton(GuiInventory gui) {
|
||||||
|
this(ItemStackFactory.Instance.CreateStack(Material.BED, (byte) 0, 1, ChatColor.DARK_GRAY + "<-- Go Back"), gui);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BackBotton(ItemStack itemStack, GuiInventory gui)
|
||||||
|
{
|
||||||
|
super(itemStack);
|
||||||
|
this._gui = gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(ClickType clickType)
|
||||||
|
{
|
||||||
|
getGui().openInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiInventory getGui()
|
||||||
|
{
|
||||||
|
return _gui;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,238 @@
|
|||||||
|
package mineplex.core.gui.pages;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class LoadingWindow implements Runnable, Listener {
|
||||||
|
|
||||||
|
public static String[] messages = new String[]{"Sending Carrier Pigeons...", "#BlameChiss", "Converting to Morse Code...", "Training monkeys..."};
|
||||||
|
public static long defaultWait = 30;
|
||||||
|
|
||||||
|
public ItemStack _background;
|
||||||
|
public ItemStack _barLoading;
|
||||||
|
public ItemStack _barBack;
|
||||||
|
|
||||||
|
private Inventory _inv;
|
||||||
|
private final InventoryView _currentInventory;
|
||||||
|
|
||||||
|
private final int _id;
|
||||||
|
|
||||||
|
private final Plugin _plugin;
|
||||||
|
private final UUID _playersUUID;
|
||||||
|
|
||||||
|
private String _message;
|
||||||
|
private String _title;
|
||||||
|
|
||||||
|
private final int _size;
|
||||||
|
|
||||||
|
private final int[] _activeRows;
|
||||||
|
|
||||||
|
private long _ticker = 0;
|
||||||
|
|
||||||
|
public LoadingWindow(Plugin plugin, Player player, int size) {
|
||||||
|
this(plugin, player, null, size, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadingWindow(Plugin plugin, Player player, long startTime, int size) {
|
||||||
|
this(plugin, player, startTime, size, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadingWindow(Plugin plugin, Player player, long startTime, int size, String message)
|
||||||
|
{
|
||||||
|
this(plugin, player, startTime, size, message, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public LoadingWindow(Plugin plugin, Player player, Long startTime, int size, String title, String message)
|
||||||
|
{
|
||||||
|
Validate.notNull(plugin, "The plugin can not be null!");
|
||||||
|
Validate.notNull(player, "The player can not be null!");
|
||||||
|
|
||||||
|
_currentInventory = player.getOpenInventory();
|
||||||
|
|
||||||
|
_size = size;
|
||||||
|
_activeRows = getActiveRows(size / 9);
|
||||||
|
|
||||||
|
_plugin = plugin;
|
||||||
|
_playersUUID = player.getUniqueId();
|
||||||
|
|
||||||
|
|
||||||
|
_background = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData(), 1, _message);
|
||||||
|
_barLoading = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, _message);
|
||||||
|
_barBack = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.WHITE.getData(), 1, _message);
|
||||||
|
|
||||||
|
|
||||||
|
if (title == null && message == null)
|
||||||
|
{
|
||||||
|
String randomName = UtilMath.randomElement(messages);
|
||||||
|
title = randomName;
|
||||||
|
message = randomName;
|
||||||
|
}
|
||||||
|
else if (title == null)
|
||||||
|
{
|
||||||
|
title = " ";
|
||||||
|
}
|
||||||
|
else if (message == null)
|
||||||
|
{
|
||||||
|
message = UtilMath.randomElement(messages);
|
||||||
|
}
|
||||||
|
if (startTime == null)
|
||||||
|
startTime = defaultWait;
|
||||||
|
|
||||||
|
|
||||||
|
_title = title;
|
||||||
|
setMessage(message);
|
||||||
|
_id = Bukkit.getScheduler().runTaskTimer(plugin, this, startTime, 5).getTaskId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
_message = message;
|
||||||
|
ItemMeta im =_background.getItemMeta();
|
||||||
|
im.setDisplayName(_message);
|
||||||
|
_background.setItemMeta(im);
|
||||||
|
_barBack.setItemMeta(im);
|
||||||
|
_barLoading.setItemMeta(im);
|
||||||
|
|
||||||
|
setBackGround();
|
||||||
|
setLoadingBarItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
_title = title;
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(_playersUUID);
|
||||||
|
if (_inv == null || player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ItemStack[] con = _inv.getContents();
|
||||||
|
|
||||||
|
_inv = Bukkit.createInventory(null, _size, _title);
|
||||||
|
_inv.setContents(con);
|
||||||
|
UtilPlayer.swapToInventory(player, _inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onClick(InventoryClickEvent event) {
|
||||||
|
if (event.getWhoClicked().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryClose(InventoryCloseEvent event) {
|
||||||
|
if (event.getPlayer().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) {
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
Player player = Bukkit.getPlayer(_playersUUID);
|
||||||
|
|
||||||
|
if (player == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) {
|
||||||
|
end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_inv == null) {
|
||||||
|
_inv = Bukkit.createInventory(null, _size, _title);
|
||||||
|
|
||||||
|
setBackGround();
|
||||||
|
setLoadingBarItems();
|
||||||
|
UtilPlayer.swapToInventory(player, _inv);
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||||
|
} else
|
||||||
|
setLoadingBarItems();
|
||||||
|
|
||||||
|
_ticker++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end() {
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
Bukkit.getScheduler().cancelTask(_id);
|
||||||
|
_inv = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBackGround() {
|
||||||
|
if (_inv == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<Integer> ignore = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
for (int row : _activeRows) {
|
||||||
|
|
||||||
|
int rowStart = row * 9;
|
||||||
|
int rowEnd = rowStart + 9;
|
||||||
|
|
||||||
|
for (int i = rowStart; i < rowEnd; i++) {
|
||||||
|
ignore.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _size; i++) {
|
||||||
|
if (!ignore.contains(i))
|
||||||
|
_inv.setItem(i, _background);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLoadingBarItems() {
|
||||||
|
if (_inv == null)
|
||||||
|
return;
|
||||||
|
ItemStack[] loadingBar = getLoadingBar();
|
||||||
|
|
||||||
|
for (int row : _activeRows) {
|
||||||
|
int rowStart = row * 9;
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
_inv.setItem(i + rowStart, loadingBar[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getLoadingBar()
|
||||||
|
{
|
||||||
|
ItemStack[] loadingBar = new ItemStack[9];
|
||||||
|
|
||||||
|
int barStart = (int) (_ticker % 9);
|
||||||
|
int barEnd = (barStart + 3) % 9;
|
||||||
|
|
||||||
|
boolean endAfter = barEnd > barStart;
|
||||||
|
|
||||||
|
for (int i = 0; i < loadingBar.length; i++) {
|
||||||
|
if (endAfter ? (i >= barStart && i < barEnd) : (i >= barStart || i < barEnd))
|
||||||
|
loadingBar[i] = _barLoading;
|
||||||
|
else
|
||||||
|
loadingBar[i] = _barBack;
|
||||||
|
}
|
||||||
|
return loadingBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int[] getActiveRows(int rows)
|
||||||
|
{
|
||||||
|
float mid = rows / 2.0f;
|
||||||
|
if (mid == (int) mid)
|
||||||
|
return new int[] { (int) mid , (int) mid -1};
|
||||||
|
else
|
||||||
|
return new int[] { (int) Math.floor(mid)};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package mineplex.core.gui.pages;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.gui.GuiInventory;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class MessageWindow implements Listener, GuiInventory {
|
||||||
|
|
||||||
|
private UUID _playersUUID;
|
||||||
|
private Plugin _plugin;
|
||||||
|
private Inventory _inv;
|
||||||
|
|
||||||
|
public MessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size)
|
||||||
|
{
|
||||||
|
_plugin = plugin;
|
||||||
|
|
||||||
|
this._playersUUID = player.getUniqueId();
|
||||||
|
|
||||||
|
_inv = Bukkit.createInventory(null, size, title);
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
_inv.setItem(i, is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onClick(InventoryClickEvent e)
|
||||||
|
{
|
||||||
|
if (!e.getWhoClicked().getUniqueId().equals(_playersUUID))
|
||||||
|
return;
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onClose(InventoryCloseEvent e)
|
||||||
|
{
|
||||||
|
if (!e.getPlayer().getUniqueId().equals(_playersUUID))
|
||||||
|
return;
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openInventory()
|
||||||
|
{
|
||||||
|
Player player = Bukkit.getPlayer(_playersUUID);
|
||||||
|
|
||||||
|
if (player == null || player.getOpenInventory().getTopInventory().equals(_inv))
|
||||||
|
return;
|
||||||
|
|
||||||
|
UtilPlayer.swapToInventory(player, _inv);
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||||
|
open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Inventory getInventory()
|
||||||
|
{
|
||||||
|
return _inv;
|
||||||
|
}
|
||||||
|
public UUID getPlayersUUID()
|
||||||
|
{
|
||||||
|
return _playersUUID;
|
||||||
|
}
|
||||||
|
public Plugin getPlugin()
|
||||||
|
{
|
||||||
|
return _plugin;
|
||||||
|
}
|
||||||
|
public void open() {
|
||||||
|
|
||||||
|
}
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package mineplex.core.gui.pages;
|
||||||
|
|
||||||
|
import mineplex.core.gui.GuiInventory;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class TimedMessageWindow extends MessageWindow implements Runnable {
|
||||||
|
private GuiInventory _gui;
|
||||||
|
private int _id;
|
||||||
|
private long _time;
|
||||||
|
|
||||||
|
public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time)
|
||||||
|
{
|
||||||
|
this(plugin, player, is, title, size, time, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time, GuiInventory gui)
|
||||||
|
{
|
||||||
|
super(plugin, player, is, title, size);
|
||||||
|
|
||||||
|
this._gui = gui;
|
||||||
|
this._time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void onClick(InventoryClickEvent e)
|
||||||
|
{
|
||||||
|
super.onClick(e);
|
||||||
|
if (e.isCancelled() && _gui != null && (e.getWhoClicked() instanceof Player)) {
|
||||||
|
_gui.openInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open()
|
||||||
|
{
|
||||||
|
this._id = Bukkit.getScheduler().runTaskLater(getPlugin(), this, _time).getTaskId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
Bukkit.getScheduler().cancelTask(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
Player player = Bukkit.getPlayer(getPlayersUUID());
|
||||||
|
if (player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_gui != null) {
|
||||||
|
_gui.openInventory();
|
||||||
|
} else
|
||||||
|
player.closeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -230,7 +230,7 @@ public class IgnoreManager extends MiniDbClientPlugin<IgnoreData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
Set(playerName, _repository.loadClientInformation(resultSet));
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
Set(playerName, _repository.loadClientInformation(resultSet));
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user