Fix some typos/formatting issues

This commit is contained in:
Shaun Bennett 2015-07-31 10:01:19 -05:00
parent da94c30c02
commit fd65f27f0f
16 changed files with 168 additions and 96 deletions

View File

@ -37,6 +37,6 @@
</codeStyleSettings>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Mineplex" />
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</component>
</project>

View File

@ -5,6 +5,8 @@
<excludeFromCompile>
<directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.Game.Clans" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Nautilus.Game.Arcade" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.Hub" includeSubdirectories="true" />
</excludeFromCompile>
<resourceExtensions />
<wildcardResourcePatterns>

View File

@ -7,7 +7,7 @@
</list>
</component>
<component name="IdProvider" IDEtalkID="7E81636CD93857493DFE224533ECF492" />
<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" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -2,6 +2,7 @@ package mineplex.core.gui;
import org.bukkit.event.inventory.ClickType;
public interface ClickExecutor {
public interface ClickExecutor
{
public void click(ClickType clickType);
}

View File

@ -2,7 +2,8 @@ package mineplex.core.gui;
import org.bukkit.inventory.ItemStack;
public interface GuiItem extends ClickExecutor, Container<ItemStack> {
public interface GuiItem extends ClickExecutor, Container<ItemStack>
{
public void setup();
public void close();
}

View File

@ -1,5 +0,0 @@
package mineplex.core.gui;
public interface ItemRefreasher extends GuiInventory {
public void refreashItem(GuiItem item);
}

View File

@ -0,0 +1,6 @@
package mineplex.core.gui;
public interface ItemRefresher extends GuiInventory
{
public void refreshItem(GuiItem item);
}

View File

@ -18,9 +18,9 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.Plugin;
public class SimpleGui implements ItemRefreasher, Listener {
private Map<Integer, GuiItem> _bottonMap = new HashMap<Integer, GuiItem>();
public class SimpleGui implements ItemRefresher, Listener
{
private Map<Integer, GuiItem> _buttonMap = new HashMap<Integer, GuiItem>();
private Player _player;
private Plugin _plugin;
@ -48,7 +48,7 @@ public class SimpleGui implements ItemRefreasher, Listener {
this(plugin, player, title, size, null);
}
public SimpleGui(Plugin plugin, Player player, String title, int size, Map<Integer, GuiItem> bottonMap)
public SimpleGui(Plugin plugin, Player player, String title, int size, Map<Integer, GuiItem> buttonMap)
{
Validate.notNull(plugin, "The plugin cannot be null!");
@ -67,10 +67,10 @@ public class SimpleGui implements ItemRefreasher, Listener {
else
setTitle(title);
if (bottonMap == null)
this._bottonMap = new HashMap<Integer, GuiItem>();
if (buttonMap == null)
this._buttonMap = new HashMap<Integer, GuiItem>();
else
this._bottonMap = bottonMap;
this._buttonMap = buttonMap;
}
@Override
@ -81,16 +81,18 @@ public class SimpleGui implements ItemRefreasher, Listener {
UtilPlayer.swapToInventory(_player, _inv);
Bukkit.getPluginManager().registerEvents(this, _plugin);
}
public Inventory createInventory() {
for (GuiItem item : new HashSet<GuiItem>(getBottonMap().values())) {
public Inventory createInventory()
{
for (GuiItem item : new HashSet<GuiItem>(getButtonMap().values()))
{
item.setup();
}
Inventory inv = Bukkit.createInventory(_player, getSize(), getTitle());
for (Entry<Integer, GuiItem> entry : _bottonMap.entrySet()) {
for (Entry<Integer, GuiItem> entry : _buttonMap.entrySet())
{
inv.setItem(entry.getKey(), entry.getValue().getObject());
}
return inv;
@ -104,7 +106,7 @@ public class SimpleGui implements ItemRefreasher, Listener {
if (!event.getWhoClicked().equals(_player) || !event.getInventory().equals(_inv))
return;
GuiItem item = _bottonMap.get(event.getSlot());
GuiItem item = _buttonMap.get(event.getSlot());
System.out.println(item);
if (item == null)
return;
@ -124,7 +126,8 @@ public class SimpleGui implements ItemRefreasher, Listener {
_inv = null;
HandlerList.unregisterAll(this);
for (GuiItem item : new HashSet<GuiItem>(getBottonMap().values())) {
for (GuiItem item : new HashSet<GuiItem>(getButtonMap().values()))
{
item.close();
}
}
@ -132,20 +135,21 @@ public class SimpleGui implements ItemRefreasher, Listener {
@Override
public void refreashItem(GuiItem item)
public void refreshItem(GuiItem item)
{
if (_inv == null)
return;
for (Entry<Integer, GuiItem> entry : getBottonMap().entrySet()) {
for (Entry<Integer, GuiItem> entry : getButtonMap().entrySet())
{
if (entry.getValue().equals(item))
_inv.setItem(entry.getKey(), entry.getValue().getObject());
}
}
public void refreashItem(int slot)
public void refreshItem(int slot)
{
GuiItem gi = getBottonMap().get(slot);
GuiItem gi = getButtonMap().get(slot);
if (_inv == null || gi == null)
return;
@ -185,18 +189,18 @@ public class SimpleGui implements ItemRefreasher, Listener {
public void setSize(int size)
{
Validate.isTrue(size % 9 == 0, "The size " + size + " is not divisable by 9");
Validate.isTrue(size % 9 == 0, "The size " + size + " is not divisible by 9");
this._size = size;
}
public Map<Integer, GuiItem> getBottonMap()
public Map<Integer, GuiItem> getButtonMap()
{
return _bottonMap;
return _buttonMap;
}
public void setBottonMap(Map<Integer, GuiItem> bottonMap)
public void setButtonMap(Map<Integer, GuiItem> bottonMap)
{
this._bottonMap = bottonMap;
this._buttonMap = bottonMap;
}
}

View File

@ -8,6 +8,10 @@ public class BonusClientData {
private Timestamp _dailyTime;
private Date _rankTime;
private Date _voteTime;
private int _rankStreak;
private int _maxRankStreak;
private int _voteStreak;
private int _maxVoteStreak;
public Timestamp getDailyTime()
{
@ -38,4 +42,44 @@ public class BonusClientData {
{
this._voteTime = _voteTime;
}
public void setRankStreak(int rankStreak)
{
_rankStreak = rankStreak;
}
public int getRankStreak()
{
return _rankStreak;
}
public void setMaxRankStreak(int maxRankStreak)
{
_maxRankStreak = maxRankStreak;
}
public int getMaxRankStreak()
{
return _maxRankStreak;
}
public void setVoteStreak(int voteStreak)
{
_voteStreak = voteStreak;
}
public int getVoteStreak()
{
return _voteStreak;
}
public void setMaxVoteStreak(int maxVoteStreak)
{
_maxVoteStreak = maxVoteStreak;
}
public int getMaxVoteStreak()
{
return _maxVoteStreak;
}
}

View File

@ -4,9 +4,7 @@ import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.function.Consumer;
@ -96,7 +94,7 @@ public class BonusManager extends MiniDbClientPlugin<BonusClientData> {
{
if (timeTillDailyBonus(player) > 0)
result.accept(false);
getRepository().atteptDailyBonus(player, result);
getRepository().attemptDailyBonus(player, result);
}
public long timeTillDailyBonus(Player player)
@ -120,11 +118,11 @@ public class BonusManager extends MiniDbClientPlugin<BonusClientData> {
}
// RANK BONUS
public void atteptRankBonus(final Player player, final Consumer<Boolean> result)
public void attemptRankBonus(final Player player, final Consumer<Boolean> result)
{
if (timeTillRankBonus(player) > 0)
result.accept(false);
getRepository().atteptRankBonus(player, result);
getRepository().attemptRankBonus(player, result);
}
public long timeTillRankBonus(Player player)
@ -191,7 +189,7 @@ public class BonusManager extends MiniDbClientPlugin<BonusClientData> {
{
if (timeTillRankBonus(player) > 0)
result.accept(false);
getRepository().atteptRankBonus(player, result);
getRepository().attemptRankBonus(player, result);
}
public long timeTillVoteBonus(Player player)

View File

@ -57,9 +57,9 @@ public class BonusRepository extends RepositoryBase {
return clientData;
}
public void atteptDailyBonus(final Player player, final Consumer<Boolean> result)
public void attemptDailyBonus(final Player player, final Consumer<Boolean> result)
{
if (!Recharge.Instance.usable(player, "AtteptDailyBonus")) {
if (!Recharge.Instance.usable(player, "AttemptDailyBonus")) {
result.accept(false);
return;
}
@ -120,14 +120,14 @@ public class BonusRepository extends RepositoryBase {
result.accept(true);
} else {
Recharge.Instance.use(player, "AtteptDailyBonus", 1000 * 10, false, false);
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 10, false, false);
_manager.Get(player).setDailyTime(timeStamp);
result.accept(false);
}
}
});
} catch (Exception e) {
Recharge.Instance.use(player, "AtteptDailyBonus", 1000 * 30, false, false);
Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false);
e.printStackTrace();
result.accept(false);
}
@ -135,9 +135,9 @@ public class BonusRepository extends RepositoryBase {
});
}
public void atteptRankBonus(final Player player, final Consumer<Boolean> result)
public void attemptRankBonus(final Player player, final Consumer<Boolean> result)
{
if (!Recharge.Instance.usable(player, "AtteptRankBonus")) {
if (!Recharge.Instance.usable(player, "AttemptRankBonus")) {
result.accept(false);
return;
}
@ -206,13 +206,13 @@ public class BonusRepository extends RepositoryBase {
result.accept(true);
} else {
Recharge.Instance.use(player, "AtteptRankBonus", 1000 * 10, false, false);
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 10, false, false);
result.accept(false);
}
}
});
} catch (Exception e) {
Recharge.Instance.use(player, "AtteptRankBonus", 1000 * 30, false, false);
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false);
e.printStackTrace();
result.accept(false);
}
@ -222,7 +222,7 @@ public class BonusRepository extends RepositoryBase {
public void voteBonus(final Player player, final Consumer<Boolean> result)
{
if (!Recharge.Instance.usable(player, "AtteptVoteBonus"))
if (!Recharge.Instance.usable(player, "AttemptVoteBonus"))
{
result.accept(false);
return;

View File

@ -2,14 +2,15 @@ package mineplex.hub.bonuses.gui;
import mineplex.core.gui.SimpleGui;
import mineplex.hub.bonuses.BonusManager;
import mineplex.hub.bonuses.gui.buttons.DailyBonusBotton;
import mineplex.hub.bonuses.gui.buttons.RankBonusBotton;
import mineplex.hub.bonuses.gui.buttons.DailyBonusButton;
import mineplex.hub.bonuses.gui.buttons.RankBonusButton;
import mineplex.hub.bonuses.gui.buttons.VoteButton;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class BonusGui extends SimpleGui {
public class BonusGui extends SimpleGui
{
private BonusManager manager;
@ -19,11 +20,11 @@ public class BonusGui extends SimpleGui {
this.manager = manager;
getBottonMap().put(12, new VoteButton(plugin, player, this, manager));
getButtonMap().put(12, new VoteButton(plugin, player, this, manager));
getBottonMap().put(14, new RankBonusBotton(getPlugin(), player, this, manager));
getButtonMap().put(14, new RankBonusButton(getPlugin(), player, this, manager));
getBottonMap().put(16, new DailyBonusBotton(getPlugin(), player, this, manager));
getButtonMap().put(16, new DailyBonusButton(getPlugin(), player, this, manager));
}
@Override

View File

@ -7,7 +7,7 @@ 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.ItemRefreasher;
import mineplex.core.gui.ItemRefresher;
import mineplex.core.gui.pages.LoadingWindow;
import mineplex.core.gui.pages.TimedMessageWindow;
import mineplex.core.itemstack.ItemStackFactory;
@ -28,7 +28,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
public class DailyBonusBotton implements GuiItem, Listener {
public class DailyBonusButton implements GuiItem, Listener {
private ItemStack _item;
@ -37,11 +37,11 @@ public class DailyBonusBotton implements GuiItem, Listener {
private Player _player;
private Plugin _plugin;
private ItemRefreasher _gui;
private ItemRefresher _gui;
private BonusManager _bonusManager;
public DailyBonusBotton(Plugin plugin, Player player, ItemRefreasher gui, BonusManager bonusManager)
public DailyBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
{
this._bonusManager = bonusManager;
this._player = player;
@ -114,7 +114,7 @@ public class DailyBonusBotton implements GuiItem, Listener {
}
public void refreashItem() {
getGui().refreashItem(this);
getGui().refreshItem(this);
}
public void setItem()
@ -149,7 +149,7 @@ public class DailyBonusBotton implements GuiItem, Listener {
return _player;
}
public ItemRefreasher getGui()
public ItemRefresher getGui()
{
return _gui;
}

View File

@ -47,22 +47,25 @@ public class PollButton extends SimpleGui implements GuiItem {
@Override
public void setup()
{
if (_create) {
if (_create)
{
this._poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).GetRank());
setBottonMap(new HashMap<Integer, GuiItem>());
setButtonMap(new HashMap<Integer, GuiItem>());
if (_poll != null) {
if (_poll != null)
{
getBottonMap().putAll(hard);
getButtonMap().putAll(hard);
getBottonMap().put(4, getQuestionItem(_poll.getQuestion()));
getButtonMap().put(4, getQuestionItem(_poll.getQuestion()));
int[] slots = even(9, _poll.getAnswers().length);
for (int i = 0; i < slots.length; i++) {
for (int i = 0; i < slots.length; i++)
{
getBottonMap().put(9 * 2 + slots[i], new AnswerItem(_poll, i));
getButtonMap().put(9 * 2 + slots[i], new AnswerItem(_poll, i));
}
}
@ -82,9 +85,12 @@ public class PollButton extends SimpleGui implements GuiItem {
@Override
public void click(ClickType clickType)
{
if (_poll == null) {
if (_poll == null)
{
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f);
} else {
}
else
{
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
openInventory();
}
@ -108,7 +114,8 @@ public class PollButton extends SimpleGui implements GuiItem {
float interval = (size / amount);
float offset = -(interval / 2);
for (int i = 1; i <= amount; i++) {
for (int i = 1; i <= amount; i++)
{
list[i - 1] = (int) (Math.ceil(i * interval) + offset);
}
return list;
@ -124,7 +131,8 @@ public class PollButton extends SimpleGui implements GuiItem {
return _master;
}
private class AnswerItem implements GuiItem {
private class AnswerItem implements GuiItem
{
private int num;

View File

@ -7,7 +7,7 @@ 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.ItemRefreasher;
import mineplex.core.gui.ItemRefresher;
import mineplex.core.gui.pages.LoadingWindow;
import mineplex.core.gui.pages.TimedMessageWindow;
import mineplex.core.itemstack.ItemStackFactory;
@ -28,7 +28,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
public class RankBonusBotton implements GuiItem, Listener {
public class RankBonusButton implements GuiItem, Listener {
private boolean hasRank;
@ -38,11 +38,11 @@ public class RankBonusBotton implements GuiItem, Listener {
private Player _player;
private Plugin _plugin;
private ItemRefreasher _gui;
private ItemRefresher _gui;
private BonusManager _bonusManager;
public RankBonusBotton(Plugin plugin, Player player, ItemRefreasher gui, BonusManager bonusManager)
public RankBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
{
this._bonusManager = bonusManager;
this._player = player;
@ -80,22 +80,32 @@ public class RankBonusBotton implements GuiItem, Listener {
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
refreashItem();
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
_bonusManager.atteptRankBonus(getPlayer(), new Consumer<Boolean>() {
_bonusManager.attemptRankBonus(getPlayer(), new Consumer<Boolean>()
{
@SuppressWarnings("deprecation")
@Override
public void accept(Boolean t)
{
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 {
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!"));
}
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 {
}
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);
@ -123,7 +133,7 @@ public class RankBonusBotton implements GuiItem, Listener {
}
public void refreashItem() {
getGui().refreashItem(this);
getGui().refreshItem(this);
}
public void setItem()
@ -165,7 +175,7 @@ public class RankBonusBotton implements GuiItem, Listener {
return _player;
}
public ItemRefreasher getGui()
public ItemRefresher getGui()
{
return _gui;
}

View File

@ -4,7 +4,7 @@ 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.ItemRefreasher;
import mineplex.core.gui.ItemRefresher;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -35,11 +35,11 @@ public class VoteButton implements GuiItem, Listener {
private Player _player;
private Plugin _plugin;
private ItemRefreasher _gui;
private ItemRefresher _gui;
private BonusManager _bonusManager;
public VoteButton(Plugin plugin, Player player, ItemRefreasher gui, BonusManager bonusManager)
public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
{
this._bonusManager = bonusManager;
this._player = player;
@ -71,7 +71,8 @@ public class VoteButton implements GuiItem, Listener {
@Override
public void click(ClickType clickType)
{
if (isAvailable()) {
if (isAvailable())
{
getPlayer().closeInventory();
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
@ -97,10 +98,11 @@ public class VoteButton implements GuiItem, Listener {
getPlayer().closeInventory();
} else
}
else
{
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
return;
}
}
@EventHandler
@ -117,8 +119,8 @@ public class VoteButton implements GuiItem, Listener {
return _item;
}
public void refreashItem() {
getGui().refreashItem(this);
public void refreshItem() {
getGui().refreshItem(this);
}
public void setItem()
@ -128,7 +130,7 @@ public class VoteButton implements GuiItem, Listener {
} else {
_item = ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, ChatColor.RED + "Next link in:", new String[] {ChatColor.WHITE + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) });
}
refreashItem();
refreshItem();
}
public long timeLeft()
@ -153,7 +155,7 @@ public class VoteButton implements GuiItem, Listener {
return _player;
}
public ItemRefreasher getGui()
public ItemRefresher getGui()
{
return _gui;
}