Merge branch 'MC_1.8' of ssh://184.154.0.242:7999/min/Mineplex into alex-ctf

This commit is contained in:
AlexTheCoder 2015-11-08 01:02:06 -05:00
commit dfbf19c66a
26 changed files with 2548 additions and 118 deletions

View File

@ -0,0 +1,139 @@
From a793ae3653b54c211b2c40147e031449d3e1cf72 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Tue, 3 Nov 2015 21:21:02 +1300
Subject: [PATCH] Vegetate head ai
diff --git a/src/main/java/net/minecraft/server/ControllerLook.java b/src/main/java/net/minecraft/server/ControllerLook.java
index f2d7b1e..1538ca6 100644
--- a/src/main/java/net/minecraft/server/ControllerLook.java
+++ b/src/main/java/net/minecraft/server/ControllerLook.java
@@ -9,6 +9,28 @@ public class ControllerLook
private double e;
private double f;
private double g;
+ private boolean _allowInput = true;
+ private boolean _resetPitch = true;
+
+ public boolean isPitchReset()
+ {
+ return _resetPitch;
+ }
+
+ public boolean setPitchReset(boolean resetPitch)
+ {
+ _resetPitch = resetPitch;
+ }
+
+ public boolean isAllowInput()
+ {
+ return _allowInput;
+ }
+
+ public void setAllowInput(boolean allowInput)
+ {
+ _allowInput = allowInput;
+ }
public ControllerLook(EntityInsentient paramEntityInsentient)
{
@@ -16,6 +38,9 @@ public class ControllerLook
}
public void a(Entity paramEntity, float paramFloat1, float paramFloat2) {
+
+ if (!isAllowInput())
+ return;
this.e = paramEntity.locX;
if ((paramEntity instanceof EntityLiving))
this.f = (paramEntity.locY + paramEntity.getHeadHeight());
@@ -29,6 +54,8 @@ public class ControllerLook
}
public void a(double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat1, float paramFloat2) {
+ if (!isAllowInput())
+ return;
this.e = paramDouble1;
this.f = paramDouble2;
this.g = paramDouble3;
@@ -37,15 +64,8 @@ public class ControllerLook
this.d = true;
}
- public void vegetateHead(boolean vegetate)
- {
- _vegeHead = vegetate;
- }
-
- private boolean _vegeHead;
-
public void a() {
- if (_vegeHead)return;
+ if (isResetPitch())
this.a.pitch = 0.0F;
if (this.d) {
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index b7647bc..c2ef000 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -512,6 +512,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.world.methodProfiler.a("move");
this.moveController.c();
this.world.methodProfiler.c("look");
+ if (!isVegetatedHead())
this.lookController.a();
this.world.methodProfiler.c("jump");
this.g.b();
@@ -542,6 +543,8 @@ public abstract class EntityInsentient extends EntityLiving {
float f2 = (float) (MathHelper.b(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
float f3 = (float) (-(MathHelper.b(d2, d3) * 180.0D / 3.1415927410125732D));
+ if (isVegetatedHead())
+ return;
this.pitch = this.b(this.pitch, f3, f1);
this.yaw = this.b(this.yaw, f2, f);
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index b861dbe..4de7e4c 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -113,6 +113,18 @@ public abstract class EntityLiving extends Entity {
_ghost = ghost;
}
+ private boolean _vegetateHead;
+
+ public boolean isHeadVegetated()
+ {
+ return _vegetateHead;
+ }
+
+ public void setHeadVegetated(boolean vegetateHead)
+ {
+ _vegetateHead = vegetateHead;
+ }
+
public EntityLiving(World world) {
super(world);
this.initAttributes();
@@ -1497,6 +1509,8 @@ public abstract class EntityLiving extends Entity {
SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
this.m();
+ if (isVegetatedHead())
+ return;
SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
@@ -1607,6 +1621,7 @@ public abstract class EntityLiving extends Entity {
this.pitch = (float) ((double) this.pitch + (this.bh - (double) this.pitch) / (double) this.bc);
--this.bc;
this.setPosition(d0, d1, d2);
+ if (!isHeadVegetated())
this.setYawPitch(this.yaw, this.pitch);
} else if (!this.bM()) {
this.motX *= 0.98D;
--
1.9.5.msysgit.0

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@
</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" />
<sourceTestOutputDir name="target\generated-test-sources\test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
</profile>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" hash="1293212710">
<component name="DataSourceManagerImpl" format="xml" hash="4268976312">
<data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e">
<driver-ref>mysql</driver-ref>
<synchronize>true</synchronize>
@ -13,7 +13,6 @@
<property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" />
</driver-properties>
<libraries />
</data-source>
</component>
</project>

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

Binary file not shown.

View File

@ -113,6 +113,9 @@ public class UtilParticle
MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT, "mobSpellAmbient", "Transparent Black Swirls", Material
.getMaterial(2266), (byte) 0),
/**
* To do certain colors, use "no / 24F" for the random X value, 1 for speed. 0 for count.
*/
NOTE(EnumParticle.NOTE, "note", "Musical Note", Material.JUKEBOX, (byte) 0),
PORTAL(EnumParticle.PORTAL, "portal", "Portal Effect", Material.INK_SACK, (byte) 5),

View File

@ -32,6 +32,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.database.DBPool;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
@ -165,7 +166,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet();
}
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager)
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, GiveawayManager giveawayManager)
{
super("Bonus", plugin);
_repository = new BonusRepository(plugin, this, donationManager);
@ -174,7 +175,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_npcManager = npcManager;
_hologramManager = hologramManager;
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager,
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, giveawayManager,
100, 250,
500, 1000,
4000, 6000,

View File

@ -3,6 +3,7 @@ package mineplex.core.bonuses.gui;
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.gui.DisplayItem;
@ -109,7 +110,14 @@ public class SpinGui extends SimpleGui
}
}
_rewardData = _reward.giveReward(RewardType.SpinnerReal, getPlayer());
_reward.giveReward(RewardType.SpinnerReal, getPlayer(), new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
_rewardData = data;
}
});
}
private void tick()

View File

@ -0,0 +1,51 @@
package mineplex.core.giveaway;
public class Giveaway
{
private int _id;
private String _name;
private String _header;
private String _message;
private boolean _notifyNetwork;
private int _notifyCooldown;
public Giveaway(int id, String name, String header, String message, boolean notifyNetwork, int notifyCooldown)
{
_id = id;
_name = name;
_header = header;
_message = message;
_notifyNetwork = notifyNetwork;
_notifyCooldown = notifyCooldown;
}
public int getId()
{
return _id;
}
public String getName()
{
return _name;
}
public String getMessage()
{
return _message;
}
public String getHeader()
{
return _header;
}
public boolean isNotifyNetwork()
{
return _notifyNetwork;
}
public int getNotifyCooldown()
{
return _notifyCooldown;
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.giveaway;
public class GiveawayCooldown
{
private int _id;
private String _name;
private int _cooldown;
public GiveawayCooldown(int id, String name, int cooldown)
{
_id = id;
_name = name;
_cooldown = cooldown;
}
public int getId()
{
return _id;
}
public String getName()
{
return _name;
}
public int getCooldown()
{
return _cooldown;
}
}

View File

@ -0,0 +1,117 @@
package mineplex.core.giveaway;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.Callback;
import mineplex.core.giveaway.redis.GiveawayMessage;
import mineplex.core.giveaway.redis.GiveawayMessageHandler;
import mineplex.serverdata.Region;
import mineplex.serverdata.commands.ServerCommandManager;
public class GiveawayManager extends MiniPlugin
{
private CoreClientManager _clientManager;
private GiveawayRepository _repository;
private HashMap<String, Giveaway> _giveawayMap;
private HashMap<String, GiveawayCooldown> _cooldownMap;
public GiveawayManager(JavaPlugin plugin, CoreClientManager clientManager)
{
super("Giveaway Manager", plugin);
_clientManager = clientManager;
_repository = new GiveawayRepository(plugin);
_giveawayMap = _repository.loadGiveaways();
_cooldownMap = _repository.loadCooldowns();
ServerCommandManager.getInstance().registerCommandType("GiveawayMessage", GiveawayMessage.class, new GiveawayMessageHandler());
}
public void attemptToGiveaway(final String giveawayName, final String cooldownName, final Player player, final Callback<GiveawayResponse> callback)
{
final int accountId = _clientManager.getAccountId(player);
if (accountId == -1)
{
callback.run(new GiveawayResponse(GiveawayResponse.FailReason.INVALID_ACCOUNT_ID));
return;
}
if (!hasGiveaway(giveawayName))
{
callback.run(new GiveawayResponse(GiveawayResponse.FailReason.INVALID_GIVEAWAY));
return;
}
if (!hasCooldown(cooldownName))
{
callback.run(new GiveawayResponse(GiveawayResponse.FailReason.INVALID_COOLDOWN));
return;
}
final Giveaway giveaway = _giveawayMap.get(giveawayName);
final GiveawayCooldown cooldown = _cooldownMap.get(cooldownName);
runAsync(new Runnable()
{
@Override
public void run()
{
final GiveawayResponse response;
if (_repository.canGiveaway(accountId, giveawayName, cooldownName))
{
UUID uuid = UUID.randomUUID();
if (_repository.addGiveaway(accountId, giveaway.getId(), cooldown.getId(), Region.US, "", uuid))
{
response = new GiveawayResponse(uuid);
}
else
{
response = new GiveawayResponse(GiveawayResponse.FailReason.QUERY_FAILED);
}
}
else
{
response = new GiveawayResponse(GiveawayResponse.FailReason.CANNOT_GIVEAWAY);
}
runSync(new Runnable()
{
@Override
public void run()
{
try
{
if (response.isSuccess())
{
GiveawayMessage message = new GiveawayMessage(giveawayName, player.getName(), giveaway.getMessage(), giveaway.getHeader());
message.publish();
}
}
catch (Exception e)
{
}
if (callback != null) callback.run(response);
}
});
}
});
}
public boolean hasGiveaway(String name)
{
return _giveawayMap.containsKey(name);
}
public boolean hasCooldown(String name)
{
return _cooldownMap.containsKey(name);
}
}

View File

@ -0,0 +1,118 @@
package mineplex.core.giveaway;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.serverdata.Region;
public class GiveawayRepository extends RepositoryBase
{
private static final String INSERT_GIVEAWAY = "INSERT INTO Account.accountGiveaway (giveawayId, accountId, cooldownId, region, serverName, time, uuid) VALUES (?, ?, ?, ?, ?, now(), ?)";
private static final String LOAD_GIVEAWAY = "SELECT id, name, header, message, max, notifyNetwork, notifyCooldown, canWinTwice FROM Account.giveaway WHERE enabled = TRUE";
private static final String LOAD_COOLDOWN = "SELECT id, name, cooldown FROM Account.giveawayCooldown";
public GiveawayRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
}
public boolean canGiveaway(int accountId, String giveawayName, String cooldownName)
{
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?, ?)}"))
{
callableStatement.setInt(1, accountId);
callableStatement.setString(2, giveawayName);
callableStatement.setString(3, cooldownName);
callableStatement.registerOutParameter(4, Types.BOOLEAN);
callableStatement.executeUpdate();
boolean pass = callableStatement.getBoolean(4);
return pass;
}
catch (Exception e)
{
}
return false;
}
public boolean addGiveaway(int accountId, int giveawayId, int cooldownId, Region region, String serverName, UUID uuid)
{
return 1 == executeUpdate(INSERT_GIVEAWAY, new ColumnInt("giveawayId", giveawayId), new ColumnInt("accountId", accountId),
new ColumnInt("cooldownId", cooldownId), new ColumnVarChar("region", 10, region.name()), new ColumnVarChar("serverName", 64, serverName),
new ColumnVarChar("uuid", 32, uuid.toString().replaceAll("-", "")));
}
public HashMap<String, Giveaway> loadGiveaways()
{
final HashMap<String, Giveaway> map = new HashMap<String, Giveaway>();
executeQuery(LOAD_GIVEAWAY, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
String header = resultSet.getString(3);
String message = resultSet.getString(4);
int max = resultSet.getInt(5);
boolean notifyNetwork = resultSet.getBoolean(6);
int notifyCooldown = resultSet.getInt(7);
boolean canWinTwice = resultSet.getBoolean(8);
Giveaway giveaway = new Giveaway(id, name, header, message, notifyNetwork, notifyCooldown);
map.put(name, giveaway);
}
}
});
return map;
}
public HashMap<String, GiveawayCooldown> loadCooldowns()
{
final HashMap<String, GiveawayCooldown> map = new HashMap<String, GiveawayCooldown>();
executeQuery(LOAD_COOLDOWN, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
int cooldown = resultSet.getInt(3);
GiveawayCooldown cd = new GiveawayCooldown(id, name, cooldown);
map.put(name, cd);
}
}
});
return map;
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
}

View File

@ -0,0 +1,52 @@
package mineplex.core.giveaway;
import java.util.UUID;
public class GiveawayResponse
{
private boolean _success;
private FailReason _failReason;
private UUID _giveawayId;
/**
* Success Constructor
* @param giveawayId
*/
protected GiveawayResponse(UUID giveawayId)
{
_success = true;
_failReason = null;
_giveawayId = giveawayId;
}
/**
* Faulure constructor
* @param failReason
*/
protected GiveawayResponse(FailReason failReason)
{
_success = false;
_failReason = failReason;
_giveawayId = null;
}
public boolean isSuccess()
{
return _success;
}
public UUID getGiveawayId()
{
return _giveawayId;
}
public FailReason getFailReason()
{
return _failReason;
}
public static enum FailReason
{
INVALID_GIVEAWAY, INVALID_COOLDOWN, CANNOT_GIVEAWAY, INVALID_ACCOUNT_ID, QUERY_FAILED;
}
}

View File

@ -0,0 +1,39 @@
package mineplex.core.giveaway.redis;
import mineplex.serverdata.commands.ServerCommand;
public class GiveawayMessage extends ServerCommand
{
private String _giveawayName;
private String _playerName;
private String _giveawayHeader;
private String _giveawayMessage;
public GiveawayMessage(String giveawayName, String playerName, String giveawayMessage, String giveawayHeader)
{
_giveawayName = giveawayName;
_playerName = playerName;
_giveawayMessage = giveawayMessage;
_giveawayHeader = giveawayHeader;
}
public String getPlayerName()
{
return _playerName;
}
public String getGiveawayMessage()
{
return _giveawayMessage;
}
public String getGiveawayHeader()
{
return _giveawayHeader;
}
public String getGiveawayName()
{
return _giveawayName;
}
}

View File

@ -0,0 +1,45 @@
package mineplex.core.giveaway.redis;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class GiveawayMessageHandler implements CommandCallback
{
private HashMap<String, Long> _cooldownMap;
public GiveawayMessageHandler()
{
_cooldownMap = new HashMap<String, Long>();
}
@Override
public void run(ServerCommand command)
{
if (command instanceof GiveawayMessage)
{
GiveawayMessage message = ((GiveawayMessage) command);
// %p - player name
String headerText = message.getGiveawayHeader();
String chatMessage = message.getGiveawayMessage().replaceAll("%p", message.getPlayerName());
// Chat Colors
headerText = ChatColor.translateAlternateColorCodes('&', headerText);
chatMessage = ChatColor.translateAlternateColorCodes('&', chatMessage);
UtilTextMiddle.display(headerText, chatMessage, 20, 80, 20);
for (Player player : UtilServer.getPlayers())
{
player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1);
}
}
}
}

View File

@ -4,6 +4,8 @@ import java.util.Random;
import org.bukkit.entity.Player;
import mineplex.core.common.util.Callback;
/**
* Created by Shaun on 9/2/2014.
*/
@ -13,16 +15,31 @@ public abstract class Reward
private RewardRarity _rarity;
private int _weight;
private boolean _requiresCallback;
public Reward(RewardRarity rarity, int weight)
{
_rarity = rarity;
_weight = weight;
this(rarity, weight, false);
}
public final RewardData giveReward(RewardType rewardType, Player player)
public Reward(RewardRarity rarity, int weight, boolean requiresCallback)
{
return giveRewardCustom(player, rewardType);
_rarity = rarity;
_weight = weight;
_requiresCallback = requiresCallback;
}
public final void giveReward(RewardType rewardType, Player player, Callback<RewardData> rewardDataCallback)
{
if (_requiresCallback)
giveRewardCallback(rewardType, player, rewardDataCallback);
else
rewardDataCallback.run(giveRewardCustom(player, rewardType));
}
protected void giveRewardCallback(RewardType rewardType, Player player, Callback<RewardData> rewardDataCallback)
{
// do nothing
}
protected abstract RewardData giveRewardCustom(Player player, RewardType rewardType);
@ -40,4 +57,9 @@ public abstract class Reward
{
return _weight;
}
public boolean isRequiresCallback()
{
return _requiresCallback;
}
}

View File

@ -14,12 +14,15 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.rewards.CoinReward;
import mineplex.core.reward.rewards.ExperienceReward;
import mineplex.core.reward.rewards.GemReward;
import mineplex.core.reward.rewards.GiveawayReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.RankReward;
@ -36,11 +39,13 @@ public class RewardManager
private boolean _carlSpinner;
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private ServerStatusManager _statusManager;
private GiveawayManager _giveawayManager;
private boolean _doubleGadgetValue;
public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager,
public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager,
int commonValueMin, int commonValueMax,
int uncommonValueMin, int uncommonValueMax,
int rareValueMin, int rareValueMax,
@ -58,6 +63,8 @@ public class RewardManager
_clientManager = clientManager;
_statusManager = statusManager;
_donationManager = donationManager;
_giveawayManager = giveawayManager;
_doubleGadgetValue = doubleGadgetValue;
_carlSpinner = carlSpinner;
@ -393,6 +400,10 @@ public class RewardManager
//Dont give Rank Upgrade if already has Titan
if (rarity == RewardRarity.MYTHICAL)
{
if (canGiveMythical && type == RewardType.MythicalChest && Math.random() <= 0.1)
{
return getLogitechPrize();
}
if (canGiveMythical && type == RewardType.MythicalChest && !_clientManager.Get(player).GetRank().has(Rank.TITAN))
{
return new RankReward(_clientManager, _statusManager, 0, rarity);
@ -462,4 +473,37 @@ public class RewardManager
return null;
}
private Reward getLogitechPrize()
{
double rand = Math.random();
String name;
String cooldown = "logitech";
Material mat = Material.DIAMOND;
String displayName;
if (rand < 0.2)
{
name = "logitechKeyboard";
displayName = C.cRed + "Logitech G910 RGB Keyboard";
}
else if (rand < 0.4)
{
name = "logitechMouse";
displayName = C.cRed + "Logitech G303 Gaming Mouse";
}
else if (rand < 0.6)
{
name = "logitechHeadset";
displayName = C.cRed + "Logitech G430 Gaming Headset";
}
else
{
name = "logitechMousePad";
displayName = C.cRed + "Logitech G240 Gaming Mousepad";
}
return new GiveawayReward(_giveawayManager, _clientManager, _donationManager, _statusManager, name, cooldown, displayName , mat, (byte) 0, RewardRarity.MYTHICAL, 0);
}
}

View File

@ -0,0 +1,97 @@
package mineplex.core.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.giveaway.GiveawayResponse;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.status.ServerStatusManager;
public class GiveawayReward extends Reward
{
private GiveawayManager _giveawayManager;
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private ServerStatusManager _serverStatusManager;
private String _giveawayName;
private String _cooldownName;
private String _displayName;
private Material _icon;
private byte _data;
public GiveawayReward(GiveawayManager giveawayManager, CoreClientManager clientManager, DonationManager donationManager, ServerStatusManager serverStatusManager, String giveawayName, String cooldownName, String displayName, Material icon, byte data, RewardRarity rarity, int weight)
{
super(rarity, weight, true);
_giveawayManager = giveawayManager;
_clientManager = clientManager;
_donationManager = donationManager;
_serverStatusManager = serverStatusManager;
_giveawayName = giveawayName;
_cooldownName = cooldownName;
_displayName = displayName;
_icon = icon;
_data = data;
}
@Override
protected void giveRewardCallback(final RewardType rewardType, final Player player, final Callback<RewardData> rewardDataCallback)
{
_giveawayManager.attemptToGiveaway(_giveawayName, _cooldownName, player, new Callback<GiveawayResponse>()
{
@Override
public void run(GiveawayResponse data)
{
if (data.isSuccess())
{
RewardData rewardData = new RewardData(_displayName, new ItemStack(_icon, 1, (short) 0, _data), getRarity());
if (rewardDataCallback != null) rewardDataCallback.run(rewardData);
}
else
{
System.out.println("GIVEAWAY FAILED: " + data.getFailReason().name());
// Dang, I guess we failed!
if (!_clientManager.hasRank(player, Rank.TITAN))
{
Reward reward = new RankReward(_clientManager, _serverStatusManager, 0, getRarity());
reward.giveReward(rewardType, player, rewardDataCallback);
}
else
{
Reward reward = new CoinReward(_donationManager, 20000, 30000, 0, getRarity());
reward.giveReward(rewardType, player, rewardDataCallback);
}
}
}
});
}
@Override
protected RewardData giveRewardCustom(Player player, RewardType rewardType)
{
// This is a little hacky, this should never be called!
return null;
}
@Override
public RewardData getFakeRewardData(Player player)
{
// Let's pretend we are coins!
return new RewardData(getRarity().getColor() + "Coins", new ItemStack(175), getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
}

View File

@ -19,6 +19,7 @@ import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
@ -196,53 +197,59 @@ public class Treasure
openChest(block, true);
}
public void openChest(Block block, boolean swapList)
public void openChest(final Block block, final boolean swapList)
{
ChestData data = getChestData(block);
// This is very experimental! Pray to god that this works
final ChestData data = getChestData(block);
if (data != null && !data.isOpened() && _currentReward < _rewards.length)
{
Reward reward = _rewards[_currentReward];
RewardData rewardData = reward.giveReward(_rewardType, _player);
_currentReward++;
if (swapList)
{
BlockInfo info = getBlockInfo(block);
_chestBlockInfo.remove(info);
_openedChestBlockInfo.add(info);
}
final Reward reward = _rewards[_currentReward];
data.setOpened(true);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData, _hologramManager);
_animations.add(chestOpenTask);
_currentReward++;
reward.giveReward(_rewardType, _player, new Callback<RewardData>()
{
@Override
public void run(RewardData rewardData)
{
if (swapList)
{
BlockInfo info = getBlockInfo(block);
_chestBlockInfo.remove(info);
_openedChestBlockInfo.add(info);
}
// Extra effects based off the rarity of the treasure
if (reward.getRarity() == RewardRarity.UNCOMMON)
{
_animations.add(new LootUncommonAnimation(this, data.getBlock()));
}
else if (reward.getRarity() == RewardRarity.RARE)
{
_animations.add(new LootRareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cPurple + "Rare " + rewardData.getFriendlyName()));
}
else if (reward.getRarity() == RewardRarity.LEGENDARY)
{
_animations.add(new LootLegendaryAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGreen + "Legendary " + rewardData.getFriendlyName()));
}
else if (reward.getRarity() == RewardRarity.MYTHICAL)
{
_animations.add(new LootMythicalAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Mythical " + rewardData.getFriendlyName()));
}
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(Treasure.this, data, rewardData, _hologramManager);
_animations.add(chestOpenTask);
if (isFinished())
{
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _openedChestBlockInfo, _chestBlockInfo);
_animations.add(animation);
_finished = true;
}
// Extra effects based off the rarity of the treasure
if (reward.getRarity() == RewardRarity.UNCOMMON)
{
_animations.add(new LootUncommonAnimation(Treasure.this, data.getBlock()));
}
else if (reward.getRarity() == RewardRarity.RARE)
{
_animations.add(new LootRareAnimation(Treasure.this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cPurple + "Rare " + rewardData.getFriendlyName()));
}
else if (reward.getRarity() == RewardRarity.LEGENDARY)
{
_animations.add(new LootLegendaryAnimation(Treasure.this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGreen + "Legendary " + rewardData.getFriendlyName()));
}
else if (reward.getRarity() == RewardRarity.MYTHICAL)
{
_animations.add(new LootMythicalAnimation(Treasure.this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Mythical " + rewardData.getFriendlyName()));
}
if (isFinished())
{
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(Treasure.this, _openedChestBlockInfo, _chestBlockInfo);
_animations.add(animation);
_finished = true;
}
}
});
}
}
@ -302,7 +309,14 @@ public class Treasure
for (int i = _currentReward; i < _rewards.length; i++)
{
_rewards[_currentReward].giveReward(_rewardType, _player);
_rewards[_currentReward].giveReward(_rewardType, _player, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
// Do nothing
}
});
}
_currentReward = _rewards.length;

View File

@ -14,6 +14,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
@ -35,7 +36,7 @@ public class TreasureManager extends MiniPlugin
private StatsManager _statsManager;
private List<TreasureLocation> _treasureLocations;
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager)
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager, GiveawayManager giveawayManager)
{
super("Treasure", plugin);
@ -43,7 +44,7 @@ public class TreasureManager extends MiniPlugin
_blockRestore = blockRestore;
_hologramManager = hologramManager;
_statsManager = statsManager;
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, _inventoryManager, petManager, statsManager,
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, _inventoryManager, petManager, statsManager, giveawayManager,
100, 250,
500, 1000,
4000, 6000,

View File

@ -20,6 +20,7 @@ import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
import mineplex.core.friend.FriendManager;
import mineplex.core.give.Give;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
@ -113,6 +114,7 @@ public class Hub extends JavaPlugin implements IRelation
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
GiveawayManager giveawayManager = new GiveawayManager(this, clientManager);
new TitanGiveawayManager(this, clientManager, serverStatusManager);
Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName());
@ -129,7 +131,7 @@ public class Hub extends JavaPlugin implements IRelation
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish, serverStatusManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, giveawayManager);
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);

View File

@ -30,6 +30,7 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.message.PrivateMessageEvent;
@ -119,7 +120,7 @@ import org.bukkit.scoreboard.Scoreboard;
public class HubManager extends MiniClientPlugin<HubClient>
{
// Snowman!
public HubType Type = HubType.Halloween;
public HubType Type = HubType.Normal;
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;
@ -164,7 +165,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Admin
private boolean _gadgetsEnabled = true;
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager)
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager)
{
super("Hub Manager", plugin);
@ -197,13 +198,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager, giveawayManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
new SoccerManager(this, _gadgetManager);
new KothManager(this, _gadgetManager);
new TrickOrTreatManager(_plugin, this, taskManager, donationManager, clientManager);
//new TrickOrTreatManager(_plugin, this, taskManager, donationManager, clientManager);
_petManager = petManager;
_partyManager = partyManager;
@ -225,7 +226,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager);
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager);
// _halloweenManager = new HalloweenSpookinessManager(this);

View File

@ -8,6 +8,8 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.FoodDupeFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.account.CoreClient;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import net.minecraft.server.v1_8_R3.BiomeBase;
import net.minecraft.server.v1_8_R3.MinecraftServer;
@ -146,10 +148,12 @@ public class Arcade extends JavaPlugin
cosmeticManager.disableTeamArmor();
new GlobalPacketManager(this, _clientManager, serverStatusManager);
GiveawayManager giveawayManager = new GiveawayManager(this, _clientManager);
//Arcade Manager
PollManager pollManager = new PollManager(this, _clientManager, _donationManager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager);
new MemoryFix(this);
new CustomTagFix(this, packetHandler);

View File

@ -17,6 +17,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
@ -33,6 +34,7 @@ import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
import mineplex.core.explosion.Explosion;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
@ -51,6 +53,7 @@ import mineplex.core.projectile.ProjectileManager;
import mineplex.core.resourcepack.ResPackManager;
import mineplex.core.resourcepack.ResUnloadCheck;
import mineplex.core.resourcepack.redis.RedisUnloadResPack;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.stats.StatsManager;
@ -188,6 +191,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private StatsManager _statsManager;
private PartyManager _partyManager;
private PreferencesManager _preferencesManager;
private GiveawayManager _giveawayManager;
private TaskManager _taskManager;
private PacketHandler _packetHandler;
@ -216,7 +220,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat,
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager)
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager, GiveawayManager giveawayManager)
{
super("Game Manager", plugin);
@ -270,6 +274,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_portal = portal;
_petManager = petManager;
_eventManager = new EventModule(this, getPlugin());
_giveawayManager = giveawayManager;
// Shop
_arcadeShop = new ArcadeShop(this, clientManager, donationManager);
@ -292,8 +297,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new MiscManager(this);
_hologramManager = hologramManager;
_idleManager = new IdleManager(this);
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
new HolidayManager(this, titanGiveaway);
//TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
//new HolidayManager(this, titanGiveaway);
// Game Addons
new CompassAddon(plugin, this);
@ -302,7 +307,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new NotificationManager(getPlugin(), clientManager);
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager);
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager);
//Champions Modules
_energy = new Energy(plugin);
@ -502,6 +507,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _explosionManager;
}
public GiveawayManager getGiveawayManager()
{
return _giveawayManager;
}
public Fire GetFire()
{
return _fire;
@ -1313,7 +1323,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, pet, pet, type, RewardRarity.OTHER, 0);
if (reward.canGiveReward(player))
reward.giveReward(null, player);
reward.giveReward(null, player, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
}
});
}
public void toggleChampionsModules(GameType gameType)

View File

@ -18,11 +18,13 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
@ -50,7 +52,7 @@ public class GameLootManager implements Listener
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetServerStatusManager(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(),
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetServerStatusManager(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(), Manager.getGiveawayManager(),
100, 250,
500, 1000,
1500, 2500,
@ -133,7 +135,7 @@ public class GameLootManager implements Listener
//Delay after Achievements
}
public boolean giveReward(Player player, boolean force)
public boolean giveReward(final Player player, boolean force)
{
if (!force)
{
@ -162,56 +164,60 @@ public class GameLootManager implements Listener
return false;
}
Reward reward = _rewardManager.nextReward(player, null, false, RewardType.GameLoot, true);
RewardData rewardData = reward.giveReward(RewardType.GameLoot, player);
String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName();
String rarityName = "";
if (reward.getRarity() != RewardRarity.COMMON)
rarityName = " " + reward.getRarity().getColor() + reward.getRarity().getName();
//Log
System.out.println(F.name(player.getName()) + " found" + rarityName + " " + outputName);
//Self Display
UtilTextMiddle.display(C.cGreen + "Game Loot", "You found " + outputName, 20, 120, 20, player);
//if (reward.getRarity() == RewardRarity.COMMON)
// UtilPlayer.message(player, F.main("Loot", "You found " + rarityName + outputName));
Random _random = new Random();
//Announce
//if (reward.getRarity() != RewardRarity.COMMON)
final Reward reward = _rewardManager.nextReward(player, null, false, RewardType.GameLoot, true);
reward.giveReward(RewardType.GameLoot, player, new Callback<RewardData>()
{
Bukkit.broadcastMessage(F.main("Loot", F.name(player.getName()) + " found" + rarityName + " " + outputName));
}
//Effect
if (reward.getRarity() == RewardRarity.UNCOMMON)
{
FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.with(FireworkEffect.Type.STAR)
.build();
@Override
public void run(RewardData rewardData)
{
String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName();
UtilFirework.playFirework(player.getEyeLocation(), effect);
}
else if (reward.getRarity() == RewardRarity.RARE)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.WHITE).build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 5F, 1.2F);
}
else if (reward.getRarity() == RewardRarity.LEGENDARY)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
String rarityName = "";
if (reward.getRarity() != RewardRarity.COMMON)
rarityName = " " + reward.getRarity().getColor() + reward.getRarity().getName();
//Log
System.out.println(F.name(player.getName()) + " found" + rarityName + " " + outputName);
//Self Display
UtilTextMiddle.display(C.cGreen + "Game Loot", "You found " + outputName, 20, 120, 20, player);
//if (reward.getRarity() == RewardRarity.COMMON)
// UtilPlayer.message(player, F.main("Loot", "You found " + rarityName + outputName));
Random _random = new Random();
//Announce
//if (reward.getRarity() != RewardRarity.COMMON)
{
Bukkit.broadcastMessage(F.main("Loot", F.name(player.getName()) + " found" + rarityName + " " + outputName));
}
//Effect
if (reward.getRarity() == RewardRarity.UNCOMMON)
{
FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.with(FireworkEffect.Type.STAR)
.build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
}
else if (reward.getRarity() == RewardRarity.RARE)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.WHITE).build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 5F, 1.2F);
}
else if (reward.getRarity() == RewardRarity.LEGENDARY)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
}
});
return true;
}