Fix carl spinner and ticket command, Fix polls not displaying in available count, Visual fixes
This commit is contained in:
parent
3bedc4ce84
commit
d833385df4
@ -16,7 +16,7 @@
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" 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" />
|
||||
</component>
|
||||
</project>
|
@ -11,7 +11,6 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" group="Game" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" group="Bungee" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.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" />
|
||||
|
@ -2,6 +2,8 @@ package mineplex.core.bonuses;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
public class BonusAmount
|
||||
@ -138,6 +140,7 @@ public class BonusAmount
|
||||
|
||||
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");
|
||||
@ -148,7 +151,7 @@ public class BonusAmount
|
||||
private void addLore(List<String> lore, int amount, int bonus, String suffix)
|
||||
{
|
||||
if (amount > 0)
|
||||
lore.add(C.cYellow + "Reward: " + C.cWhite + amount + " " + suffix);
|
||||
lore.add(" " + C.cWhite + amount + " " + suffix);
|
||||
|
||||
// if (bonus > 0)
|
||||
// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix);
|
||||
|
@ -43,6 +43,7 @@ import mineplex.core.bonuses.gui.SpinGui;
|
||||
import mineplex.core.poll.PollManager;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -419,35 +420,23 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
CarlSpinnerEvent event = new CarlSpinnerEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
final BonusManager manager = this;
|
||||
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
final int accountId = _clientManager.Get(player).getAccountId();
|
||||
|
||||
runAsync(new Runnable()
|
||||
_repository.attemptAddTickets(accountId, clientData, -1, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
public void run(Boolean data)
|
||||
{
|
||||
try
|
||||
if (data)
|
||||
{
|
||||
final int newTickets = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.sub(1)).
|
||||
where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets();
|
||||
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
clientData.setTickets(newTickets);
|
||||
new SpinGui(getPlugin(), player, _rewardManager, manager).openInventory();
|
||||
}
|
||||
});
|
||||
new SpinGui(_plugin, player, _rewardManager, BonusManager.this).openInventory();
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "There was an error processing your request"));
|
||||
UtilPlayer.message(player, F.main("Carl", "There waa an error processing your request. Try again later"));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -816,6 +805,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (canVote(player)) availableRewards++;
|
||||
if (canRank(player)) availableRewards++;
|
||||
if (canDaily(player)) availableRewards++;
|
||||
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
|
||||
|
||||
Hologram hologram;
|
||||
|
||||
@ -898,14 +888,15 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (clientData.getHologram() != null)
|
||||
clientData.getHologram().stop();
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
clientData.getRecord().store();
|
||||
}
|
||||
});
|
||||
// This shouldnt be necessary anymore
|
||||
// runAsync(new Runnable()
|
||||
// {
|
||||
// @Override
|
||||
// public void run()
|
||||
// {
|
||||
// clientData.getRecord().store();
|
||||
// }
|
||||
// });
|
||||
|
||||
super.UnloadPlayer(event);
|
||||
}
|
||||
|
@ -7,7 +7,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import mineplex.core.bonuses.gui.SpinGui;
|
||||
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;
|
||||
@ -17,7 +21,9 @@ import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.BonusRecord;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -95,6 +101,42 @@ public class BonusRepository extends RepositoryBase
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -36,15 +37,28 @@ public class TicketCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
try
|
||||
{
|
||||
int tickets = Integer.parseInt(ticketString);
|
||||
Plugin.Get(target).setTickets(Plugin.Get(targetName).getTickets() + tickets);
|
||||
|
||||
UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + "."));
|
||||
|
||||
if (target != null)
|
||||
final int tickets = Integer.parseInt(ticketString);
|
||||
int accountId = Plugin.getClientManager().getAccountId(target);
|
||||
Plugin.getRepository().attemptAddTickets(accountId, Plugin.Get(target), tickets, new Callback<Boolean>()
|
||||
{
|
||||
UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + "."));
|
||||
}
|
||||
@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)
|
||||
{
|
||||
|
@ -144,9 +144,7 @@ public class DailyBonusButton implements GuiItem, Listener
|
||||
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());
|
||||
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getDailyMultiplier(_player) + "%");
|
||||
|
||||
if (client.getDailyTime() != null)
|
||||
{
|
||||
@ -159,6 +157,8 @@ public class DailyBonusButton implements GuiItem, Listener
|
||||
}
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak());
|
||||
StreakRecord streakRecord = _bonusManager.getDailyStreak();
|
||||
if (streakRecord != null)
|
||||
{
|
||||
|
@ -131,10 +131,7 @@ public class VoteButton implements GuiItem, Listener {
|
||||
lore.add(" ");
|
||||
|
||||
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak());
|
||||
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + _bonusManager.getVoteMultiplyer(_player) + "%");
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak());
|
||||
|
||||
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplyer(_player) + "%");
|
||||
if (client.getVoteTime() != null)
|
||||
{
|
||||
long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime());
|
||||
@ -146,6 +143,9 @@ public class VoteButton implements GuiItem, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak());
|
||||
|
||||
StreakRecord streakRecord = _bonusManager.getVoteStreak();
|
||||
if (streakRecord != null)
|
||||
{
|
||||
@ -185,4 +185,4 @@ public class VoteButton implements GuiItem, Listener {
|
||||
{
|
||||
return _gui;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user