Iron Golem and Skeleton converted to Google Sheets

This commit is contained in:
Sam 2017-04-22 23:07:44 +01:00
parent 2f478e46f3
commit e350c62f54
23 changed files with 652 additions and 240 deletions

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import mineplex.core.google.GoogleSheetsManager;
import net.minecraft.server.v1_8_R3.EntityLiving; import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -233,6 +234,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private ScoreboardManager _scoreboardManager; private ScoreboardManager _scoreboardManager;
private NextBestGameManager _nextBestGameManager; private NextBestGameManager _nextBestGameManager;
private TrackManager _trackManager; private TrackManager _trackManager;
private GoogleSheetsManager _sheetsManager;
private IncognitoManager _incognitoManager; private IncognitoManager _incognitoManager;
@ -578,6 +580,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_trackManager = require(TrackManager.class); _trackManager = require(TrackManager.class);
_titles = require(Titles.class); _titles = require(Titles.class);
Titles.BOOK_SLOT = 4; Titles.BOOK_SLOT = 4;
_sheetsManager = require(GoogleSheetsManager.class);
} }
@Override @Override
@ -790,6 +794,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _customDataManager; return _customDataManager;
} }
public GoogleSheetsManager getSheetsManager()
{
return _sheetsManager;
}
public ChatColor GetColor(Player player) public ChatColor GetColor(Player player)
{ {
if (_game == null) if (_game == null)

View File

@ -1,27 +1,52 @@
package nautilus.game.arcade.game; package nautilus.game.arcade.game;
import java.util.ArrayList; import com.google.common.collect.Lists;
import java.util.Collection; import com.mojang.authlib.GameProfile;
import java.util.HashMap; import mineplex.core.Managers;
import java.util.HashSet; import mineplex.core.antihack.AntiHack;
import java.util.Iterator; import mineplex.core.arcadeevents.CoreGameStartEvent;
import java.util.LinkedList; import mineplex.core.arcadeevents.CoreGameStopEvent;
import java.util.List; import mineplex.core.command.CommandCenter;
import java.util.Map; import mineplex.core.common.Rank;
import java.util.Map.Entry; import mineplex.core.common.util.*;
import java.util.Optional; import mineplex.core.disguise.disguises.DisguisePlayer;
import java.util.Set; import mineplex.core.elo.EloPlayer;
import java.util.UUID; import mineplex.core.elo.EloTeam;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.lifetimes.Lifetimed;
import mineplex.core.lifetimes.ListenerComponent;
import mineplex.core.lifetimes.PhasedLifetime;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilGameProfile;
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.build.Build;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.kit.*;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.managers.lobby.LobbyManager;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import nautilus.game.arcade.stats.*;
import nautilus.game.arcade.wineffect.WinEffectManager;
import nautilus.game.arcade.world.WorldData;
import net.minecraft.server.v1_8_R3.EntityItem; import net.minecraft.server.v1_8_R3.EntityItem;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.apache.commons.lang3.tuple.Triple; import org.apache.commons.lang3.tuple.Triple;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
@ -41,79 +66,12 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.google.common.collect.Lists; import java.util.*;
import com.mojang.authlib.GameProfile; import java.util.Map.Entry;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.arcadeevents.CoreGameStartEvent;
import mineplex.core.arcadeevents.CoreGameStopEvent;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.elo.EloPlayer;
import mineplex.core.elo.EloTeam;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.lifetimes.Lifetimed;
import mineplex.core.lifetimes.ListenerComponent;
import mineplex.core.lifetimes.PhasedLifetime;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilGameProfile;
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.build.Build;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.kit.ChampionsKit;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.managers.lobby.LobbyManager;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import nautilus.game.arcade.stats.AssistsStatTracker;
import nautilus.game.arcade.stats.DamageDealtStatTracker;
import nautilus.game.arcade.stats.DamageTakenStatTracker;
import nautilus.game.arcade.stats.DeathsStatTracker;
import nautilus.game.arcade.stats.ExperienceStatTracker;
import nautilus.game.arcade.stats.GamesPlayedStatTracker;
import nautilus.game.arcade.stats.KillsStatTracker;
import nautilus.game.arcade.stats.LoseStatTracker;
import nautilus.game.arcade.stats.StatTracker;
import nautilus.game.arcade.stats.WinStatTracker;
import nautilus.game.arcade.wineffect.WinEffectManager;
import nautilus.game.arcade.world.WorldData;
public abstract class Game extends ListenerComponent implements Lifetimed public abstract class Game extends ListenerComponent implements Lifetimed
{ {
@ -2460,7 +2418,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
public void cleanupCommands() public void cleanupCommands()
{ {
this._debugCommands.forEach(command -> CommandCenter.Instance.removeCommand(command)); this._debugCommands.forEach(command -> CommandCenter.Instance.removeCommand(command));
this._debugCommands.clear();
} }
public <T extends Module> T getModule(Class<T> clazz) public <T extends Module> T getModule(Class<T> clazz)

View File

@ -24,6 +24,7 @@ import nautilus.game.arcade.game.games.smash.perks.SmashUltimate;
import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.managers.PerkSpreadsheetModule;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -39,7 +40,6 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashMap; import java.util.HashMap;
@ -89,10 +89,13 @@ public abstract class SuperSmash extends Game
WorldWaterDamage = 1000; WorldWaterDamage = 1000;
HideTeamSheep = true; HideTeamSheep = true;
ReplaceTeamsWithKits = true; ReplaceTeamsWithKits = true;
new CompassModule() new CompassModule()
.setGiveCompassToAlive(true) .setGiveCompassToAlive(true)
.register(this); .register(this);
new PerkSpreadsheetModule(this, "SMASH_KITS");
registerDebugCommand(new DebugCommand("cooldown", Rank.ADMIN) registerDebugCommand(new DebugCommand("cooldown", Rank.ADMIN)
{ {
@Override @Override

View File

@ -19,15 +19,18 @@ 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 java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
public class SuperSmashTraining extends SuperSmash public class SuperSmashTraining extends SuperSmash
{ {
private static final long GAME_TIME = TimeUnit.HOURS.toMillis(3); private static final long GAME_TIME = TimeUnit.MINUTES.toMillis(3);
private static final long GAME_WARN_TIME = GAME_TIME - TimeUnit.MINUTES.toMillis(5); private static final long GAME_WARN_TIME = GAME_TIME - TimeUnit.MINUTES.toMillis(1);
private static final String[] INFO_HOLOGRAM = { private static final String[] INFO_HOLOGRAM = {
C.cYellow + "Select a " + C.cGreen + "Kit", C.cYellow + "Select a " + C.cGreen + "Kit",
C.cYellow + "Jump off the island to use your abilities", C.cYellow + "Jump off the island to use your abilities",
@ -37,10 +40,8 @@ public class SuperSmashTraining extends SuperSmash
private Location _borderA; private Location _borderA;
private Location _borderB; private Location _borderB;
private Function<Player, Boolean> safeFunction = player -> private Function<Player, Boolean> _safeFunction = player -> !UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB);
{ private Map<UUID, Long> _lastDeath;
return !UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB);
};
private boolean _announceEnd; private boolean _announceEnd;
@ -56,9 +57,11 @@ public class SuperSmashTraining extends SuperSmash
GiveClock = false; GiveClock = false;
HungerSet = 20; HungerSet = 20;
_lastDeath = new HashMap<>();
new TrainingGameModule() new TrainingGameModule()
.setSkillFunction(safeFunction) .setSkillFunction(_safeFunction)
.setDamageFunction(safeFunction) .setDamageFunction(_safeFunction)
.addBot(TrainingBot.class) .addBot(TrainingBot.class)
.register(this); .register(this);
} }
@ -155,12 +158,30 @@ public class SuperSmashTraining extends SuperSmash
@EventHandler @EventHandler
public void playerDeath(PlayerDeathEvent event) public void playerDeath(PlayerDeathEvent event)
{ {
_lastDeath.put(event.getEntity().getUniqueId(), System.currentTimeMillis());
} }
@EventHandler @EventHandler
public void smashActivating(SmashActivateEvent event) public void cleanlastDeath(UpdateEvent event)
{ {
if (!safeFunction.apply(event.getPlayer())) if (!IsLive() || event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : GetPlayers(true))
{
if (_safeFunction.apply(player))
{
_lastDeath.remove(player.getUniqueId());
}
}
}
@EventHandler
public void smashActivate(SmashActivateEvent event)
{
if (!_safeFunction.apply(event.getPlayer()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -195,7 +216,12 @@ public class SuperSmashTraining extends SuperSmash
@Override @Override
protected boolean displayKitInfo(Player player) protected boolean displayKitInfo(Player player)
{ {
return super.displayKitInfo(player) || !safeFunction.apply(player); if (_lastDeath.containsKey(player.getUniqueId()))
{
return UtilTime.elapsed(_lastDeath.get(player.getUniqueId()), 2000);
}
return super.displayKitInfo(player) || !_safeFunction.apply(player);
} }
private void spawnInfoHologram(Location location) private void spawnInfoHologram(Location location)

View File

@ -27,8 +27,8 @@ public class KitGolem extends SmashKit
{ {
private static final Perk[] PERKS = { private static final Perk[] PERKS = {
new PerkSmashStats(7, 1.0, 0.2, 8), new PerkSmashStats(),
new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkDoubleJump("Double Jump"),
new PerkSlow(0), new PerkSlow(0),
new PerkFissure(), new PerkFissure(),
new PerkIronHook(), new PerkIronHook(),

View File

@ -35,13 +35,13 @@ public class KitSkeleton extends SmashKit
private static double ARROW_DAMAGE = 6; private static double ARROW_DAMAGE = 6;
private static final Perk[] PERKS = { private static final Perk[] PERKS = {
new PerkSmashStats(5, 1.25, 0.2, 6), new PerkSmashStats(),
new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkDoubleJump("Double Jump"),
new PerkFletcher(3, 3, false), new PerkFletcher(),
new PerkKnockbackArrow(1.5), new PerkKnockbackArrow(),
new PerkBoneExplosion(), new PerkBoneExplosion(),
new PerkRopedArrow("Roped Arrow", 1, 5000), new PerkRopedArrow("Roped Arrow"),
new PerkBarrage(5, 300, true, false, true), new PerkBarrage(),
new SmashSkeleton() new SmashSkeleton()
}; };

View File

@ -17,35 +17,56 @@ public class PerkSmashStats extends Perk
private double _damage; private double _damage;
private double _knockbackTaken; private double _knockbackTaken;
private double _regen; private double _regen;
private double _armor;
public PerkSmashStats()
{
super("Smash Stats");
}
public PerkSmashStats(double damage, double knockbackTaken, double regen, double armor) public PerkSmashStats(double damage, double knockbackTaken, double regen, double armor)
{ {
super("Smash Stats", new String[] super("Smash Stats", new String[]{});
{
(C.cAqua + "Damage: " + C.cWhite + damage) + C.cWhite + " " + (C.cAqua + "Knockback Taken: " + C.cWhite + (int)(knockbackTaken*100) + "%"),
(C.cAqua + "Armor: " + C.cWhite + armor) + C.cWhite + " " + (C.cAqua + "Health Regeneration: " + C.cWhite + regen + " per Second"),
});
_damage = damage; _damage = damage;
_knockbackTaken = knockbackTaken; _knockbackTaken = knockbackTaken;
_regen = regen; _regen = regen;
_armor = armor;
setDesc(
(C.cAqua + "Damage: " + C.cWhite + _damage) + C.cWhite + " " + (C.cAqua + "Knockback Taken: " + C.cWhite + (int) (_knockbackTaken * 100) + "%"),
(C.cAqua + "Armor: " + C.cWhite + _armor) + C.cWhite + " " + (C.cAqua + "Health Regeneration: " + C.cWhite + _regen + " per Second")
);
}
@Override
public void setupValues()
{
_damage = getPerkDouble("Damage");
_knockbackTaken = getPerkPercentage("Knockback Taken");
_regen = getPerkDouble("Regeneration");
_armor = getPerkDouble("Armor");
setDesc(
(C.cAqua + "Damage: " + C.cWhite + _damage) + C.cWhite + " " + (C.cAqua + "Knockback Taken: " + C.cWhite + (int) (_knockbackTaken * 100) + "%"),
(C.cAqua + "Armor: " + C.cWhite + _armor) + C.cWhite + " " + (C.cAqua + "Health Regeneration: " + C.cWhite + _regen + " per Second")
);
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void Damage(CustomDamageEvent event) public void Damage(CustomDamageEvent event)
{ {
if (event.GetCause() != DamageCause.ENTITY_ATTACK) if (event.GetCause() != DamageCause.ENTITY_ATTACK)
{
return; return;
}
Player damager = event.GetDamagerPlayer(false); Player damager = event.GetDamagerPlayer(false);
if (damager == null) return;
if (!Kit.HasKit(damager)) if (damager == null || !Kit.HasKit(damager) || !Manager.IsAlive(damager))
return; {
if (!Manager.IsAlive(damager))
return; return;
}
double mod = _damage - event.GetDamageInitial(); double mod = _damage - event.GetDamageInitial();
@ -56,13 +77,20 @@ public class PerkSmashStats extends Perk
public void Knockback(CustomDamageEvent event) public void Knockback(CustomDamageEvent event)
{ {
Player damagee = event.GetDamageePlayer(); Player damagee = event.GetDamageePlayer();
if (damagee == null) return; if (damagee == null)
{
return;
}
if (!Kit.HasKit(damagee)) if (!Kit.HasKit(damagee))
{
return; return;
}
if (!Manager.IsAlive(damagee)) if (!Manager.IsAlive(damagee))
{
return; return;
}
event.AddKnockback("Knockback Multiplier", _knockbackTaken); event.AddKnockback("Knockback Multiplier", _knockbackTaken);
} }
@ -71,12 +99,16 @@ public class PerkSmashStats extends Perk
public void Regeneration(UpdateEvent event) public void Regeneration(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
{
return; return;
}
for (Player player : Manager.GetGame().GetPlayers(true)) for (Player player : Manager.GetGame().GetPlayers(true))
{ {
if (!Kit.HasKit(player)) if (!Kit.HasKit(player))
{
continue; continue;
}
UtilPlayer.health(player, _regen); UtilPlayer.health(player, _regen);
} }

View File

@ -1,17 +1,5 @@
package nautilus.game.arcade.game.games.smash.perks; package nautilus.game.arcade.game.games.smash.perks;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import mineplex.core.common.util.UtilServer;
import nautilus.game.arcade.game.games.smash.events.SmashActivateEvent;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
@ -19,10 +7,14 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import java.util.*;
public class SmashUltimate extends Perk public class SmashUltimate extends Perk
{ {
@ -42,6 +34,12 @@ public class SmashUltimate extends Perk
_length = length; _length = length;
} }
@Override
public void setupValues()
{
_length = getPerkTime("Duration", _length);
}
public void activate(Player player) public void activate(Player player)
{ {
_lastUltimate.put(player.getUniqueId(), System.currentTimeMillis()); _lastUltimate.put(player.getUniqueId(), System.currentTimeMillis());

View File

@ -24,7 +24,7 @@ import nautilus.game.arcade.kit.perks.data.FissureData;
public class PerkFissure extends Perk public class PerkFissure extends Perk
{ {
private static final int COOLDOWN = 8000; private int _cooldown;
private Set<FissureData> _active = new HashSet<>(); private Set<FissureData> _active = new HashSet<>();
@ -33,6 +33,12 @@ public class PerkFissure extends Perk
super("Fissure", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Fissure" }); super("Fissure", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Fissure" });
} }
@Override
public void setupValues()
{
_cooldown = getPerkTime("Cooldown");
}
@EventHandler @EventHandler
public void Leap(PlayerInteractEvent event) public void Leap(PlayerInteractEvent event)
{ {
@ -69,7 +75,7 @@ public class PerkFissure extends Perk
return; return;
} }
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{ {
return; return;
} }

View File

@ -25,14 +25,23 @@ import nautilus.game.arcade.game.games.smash.perks.SmashUltimate;
public class SmashGolem extends SmashUltimate public class SmashGolem extends SmashUltimate
{ {
private static final int DURATION = 16000; private int _hitFrequency;
private static final int HIT_FREQUENCY = 400; private int _damageRadius;
private static final int DAMAGE_RADIUS = 2; private int _effectRadius;
private static final int EFFECT_RADIUS = 5;
public SmashGolem() public SmashGolem()
{ {
super("Earthquake", new String[] {}, Sound.IRONGOLEM_HIT, DURATION); super("Earthquake", new String[] {}, Sound.IRONGOLEM_HIT, 0);
}
@Override
public void setupValues()
{
super.setupValues();
_hitFrequency = getPerkInt("Hit Frequency (ms)");
_damageRadius = getPerkInt("Damage Radius");
_effectRadius = getPerkInt("Effect Radius");
} }
@Override @Override
@ -71,7 +80,7 @@ public class SmashGolem extends SmashUltimate
boolean grounded = false; boolean grounded = false;
for (Block block : UtilBlock.getInRadius(other.getLocation(), DAMAGE_RADIUS).keySet()) for (Block block : UtilBlock.getInRadius(other.getLocation(), _damageRadius).keySet())
{ {
if (block.getType() != Material.AIR) if (block.getType() != Material.AIR)
{ {
@ -89,13 +98,13 @@ public class SmashGolem extends SmashUltimate
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, 1 + 2 * Math.random(), false, false, false, other.getName(), GetName()); Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, 1 + 2 * Math.random(), false, false, false, other.getName(), GetName());
// Velocity // Velocity
if (Recharge.Instance.use(other, GetName() + " Hit", HIT_FREQUENCY, false, false)) if (Recharge.Instance.use(other, GetName() + " Hit", _hitFrequency, false, false))
{ {
UtilAction.velocity(other, new Vector(Math.random() - 0.5, Math.random() * 0.2, Math.random() - 0.5), Math.random() * 1 + 1, false, 0, 0.1 + Math.random() * 0.2, 2, true); UtilAction.velocity(other, new Vector(Math.random() - 0.5, Math.random() * 0.2, Math.random() - 0.5), Math.random() * 1 + 1, false, 0, 0.1 + Math.random() * 0.2, 2, true);
} }
// Effect // Effect
for (Block block : UtilBlock.getInRadius(other.getLocation(), EFFECT_RADIUS).keySet()) for (Block block : UtilBlock.getInRadius(other.getLocation(), _effectRadius).keySet())
{ {
if (Math.random() < 0.98) if (Math.random() < 0.98)
{ {

View File

@ -33,6 +33,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.perks.SmashPerk; import nautilus.game.arcade.game.games.smash.perks.SmashPerk;
import org.jooq.util.derby.sys.Sys;
public class PerkBarrage extends SmashPerk public class PerkBarrage extends SmashPerk
{ {
@ -48,6 +49,11 @@ public class PerkBarrage extends SmashPerk
private boolean _noDelay; private boolean _noDelay;
private boolean _useExp; private boolean _useExp;
public PerkBarrage()
{
this(0, 0, false, false);
}
public PerkBarrage(int max, int tick, boolean remove, boolean noDelay) public PerkBarrage(int max, int tick, boolean remove, boolean noDelay)
{ {
this(max, tick, remove, noDelay, false); this(max, tick, remove, noDelay, false);
@ -63,6 +69,16 @@ public class PerkBarrage extends SmashPerk
_noDelay = noDelay; _noDelay = noDelay;
} }
@Override
public void setupValues()
{
_max = getPerkInt("Max", _max);
_tick = getPerkInt("Tick", _tick);
_remove = getPerkBoolean("Remove", _remove);
_noDelay = getPerkBoolean("No Delay", _noDelay);
_useExp = getPerkBoolean("Exp Bar", _useExp);
}
@EventHandler @EventHandler
public void BarrageDrawBow(PlayerInteractEvent event) public void BarrageDrawBow(PlayerInteractEvent event)
{ {

View File

@ -23,16 +23,25 @@ import nautilus.game.arcade.game.games.smash.perks.SmashPerk;
public class PerkBoneExplosion extends SmashPerk public class PerkBoneExplosion extends SmashPerk
{ {
private static final int COOLDOWN = 10000; private int _cooldown;
private static final int DAMAGE_RADIUS = 7; private int _damageRadius;
private static final int DAMAGE = 6; private int _damage;
private static final float KNOCKBACK_MAGNITUDE = 2.5F; private float _knockbackMagnitude;
public PerkBoneExplosion() public PerkBoneExplosion()
{ {
super("Bone Explosion", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Bone Explosion" }); super("Bone Explosion", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Bone Explosion" });
} }
@Override
public void setupValues()
{
_cooldown = getPerkTime("Cooldown");
_damageRadius = getPerkInt("Damage Radius");
_damage = getPerkInt("Damage");
_knockbackMagnitude = getPerkFloat("Knockback Magnitude");
}
@EventHandler @EventHandler
public void Skill(PlayerInteractEvent event) public void Skill(PlayerInteractEvent event)
{ {
@ -68,12 +77,12 @@ public class PerkBoneExplosion extends SmashPerk
return; return;
} }
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{ {
return; return;
} }
Map<Player, Double> nearby = UtilPlayer.getInRadius(player.getLocation(), DAMAGE_RADIUS); Map<Player, Double> nearby = UtilPlayer.getInRadius(player.getLocation(), _damageRadius);
for (Player other : nearby.keySet()) for (Player other : nearby.keySet())
{ {
@ -86,7 +95,7 @@ public class PerkBoneExplosion extends SmashPerk
UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(player) + player.getName()) + " used " + F.skill(GetName()) + ".")); UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(player) + player.getName()) + " used " + F.skill(GetName()) + "."));
// Damage Event // Damage Event
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE * nearby.get(other), true, true, false, player.getName(), GetName()); Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage * nearby.get(other), true, true, false, player.getName(), GetName());
} }
// Inform // Inform
@ -104,6 +113,6 @@ public class PerkBoneExplosion extends SmashPerk
return; return;
} }
event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); event.AddKnockback(GetName(), _knockbackMagnitude);
} }
} }

View File

@ -21,13 +21,11 @@ import nautilus.game.arcade.game.games.smash.perks.SmashUltimate;
public class SmashSkeleton extends SmashUltimate public class SmashSkeleton extends SmashUltimate
{ {
private static final int DURATION = 10000; private Set<Projectile> _arrows = new HashSet<>();
private Set<Projectile> _arrows = new HashSet<Projectile>();
public SmashSkeleton() public SmashSkeleton()
{ {
super("Arrow Storm", new String[] {}, Sound.SKELETON_HURT, DURATION); super("Arrow Storm", new String[] {}, Sound.SKELETON_HURT, 0);
} }
@EventHandler @EventHandler
@ -72,14 +70,6 @@ public class SmashSkeleton extends SmashUltimate
return; return;
} }
for (Iterator<Projectile> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) _arrows.removeIf(arrow -> arrow.isDead() || !arrow.isValid());
{
Projectile arrow = arrowIterator.next();
if (arrow.isDead() || !arrow.isValid())
{
arrowIterator.remove();
}
}
} }
} }

View File

@ -1,9 +1,7 @@
package nautilus.game.arcade.kit; package nautilus.game.arcade.kit;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.managers.PerkSpreadsheetModule;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -18,6 +16,13 @@ public abstract class Perk implements Listener
private boolean _display; private boolean _display;
private int _upgradeLevel; private int _upgradeLevel;
private PerkSpreadsheetModule _spreadsheet;
public Perk(String name)
{
this(name, new String[0], true);
}
public Perk(String name, String[] perkDesc) public Perk(String name, String[] perkDesc)
{ {
this(name, perkDesc, true); this(name, perkDesc, true);
@ -63,11 +68,26 @@ public abstract class Perk implements Listener
Kit = kit; Kit = kit;
} }
public final void setSpreadsheet(PerkSpreadsheetModule spreadsheet)
{
_spreadsheet = spreadsheet;
setupValues();
}
public void setupValues()
{
}
public String GetName() public String GetName()
{ {
return _perkName; return _perkName;
} }
public void setDesc(String... desc)
{
_perkDesc = desc;
}
public String[] GetDesc() public String[] GetDesc()
{ {
return _perkDesc; return _perkDesc;
@ -93,8 +113,92 @@ public abstract class Perk implements Listener
// When listener has been registered // When listener has been registered
} }
public Material getIcon() private String getPerkObject(String id)
{ {
return Material.SLIME_BALL; String key = _spreadsheet.getKey(this, id);
if (!_spreadsheet.getDataMap().containsKey(key))
{
return null;
}
return _spreadsheet.getDataMap().get(key);
}
protected boolean getPerkBoolean(String id)
{
return Boolean.valueOf(getPerkObject(id));
}
protected int getPerkInt(String id)
{
return Integer.parseInt(getPerkObject(id));
}
protected double getPerkDouble(String id)
{
return Double.parseDouble(getPerkObject(id));
}
protected float getPerkFloat(String id)
{
return Float.parseFloat(getPerkObject(id));
}
protected double getPerkPercentage(String id)
{
String value = getPerkObject(id);
value = value.substring(0, value.length() - 1);
double doubleValue = Double.parseDouble(value);
return doubleValue / 100;
}
protected int getPerkTime(String id)
{
return getPerkInt(id) * 1000;
}
protected boolean getPerkBoolean(String id, boolean defaultV)
{
String v = getPerkObject(id);
return v != null ? Boolean.valueOf(v) : defaultV;
}
protected int getPerkInt(String id, int defaultV)
{
String v = getPerkObject(id);
return v != null ? Integer.valueOf(v) : defaultV;
}
protected double getPerkDouble(String id, double defaultV)
{
String v = getPerkObject(id);
return v != null ? Double.valueOf(v) : defaultV;
}
protected double getPerkFloat(String id, float defaultV)
{
String v = getPerkObject(id);
return v != null ? Float.valueOf(v) : defaultV;
}
protected double getPerkPercentage(String id, double defaultV)
{
String value = getPerkObject(id);
if (value == null)
{
return defaultV;
}
value = value.substring(0, value.length() - 1);
double doubleValue = Double.parseDouble(value);
return doubleValue / 100;
}
protected int getPerkTime(String id, int defaultV)
{
int v = getPerkInt(id, Integer.MIN_VALUE);
return v == Integer.MIN_VALUE ? defaultV : v * 1000;
} }
} }

View File

@ -30,6 +30,11 @@ public class PerkDoubleJump extends Perk
private HashSet<Player> _disabled = new HashSet<Player>(); private HashSet<Player> _disabled = new HashSet<Player>();
public PerkDoubleJump(String name)
{
this(name, 0, 0, false);
}
public PerkDoubleJump(String name, double power, double heightLimit, boolean control) public PerkDoubleJump(String name, double power, double heightLimit, boolean control)
{ {
super(name, new String[] super(name, new String[]
@ -70,6 +75,14 @@ public class PerkDoubleJump extends Perk
_displayForce = displayForce; _displayForce = displayForce;
} }
@Override
public void setupValues()
{
_power = getPerkDouble("Power", _power);
_heightMax = getPerkDouble("Height Limit", _heightMax);
_control = getPerkBoolean("Control", _control);
}
@EventHandler @EventHandler
public void FlightHop(PlayerToggleFlightEvent event) public void FlightHop(PlayerToggleFlightEvent event)
{ {

View File

@ -40,6 +40,11 @@ public class PerkFletcher extends Perk
private boolean _instant = true; private boolean _instant = true;
private String _name; private String _name;
public PerkFletcher()
{
this(0, 0, false);
}
public PerkFletcher(int time, int max, boolean remove) public PerkFletcher(int time, int max, boolean remove)
{ {
this(time, max, remove, -1); this(time, max, remove, -1);
@ -75,6 +80,16 @@ public class PerkFletcher extends Perk
_name = name; _name = name;
} }
@Override
public void setupValues()
{
_time = getPerkInt("Time", _time);
_max = getPerkInt("Max", _max);
_remove = getPerkBoolean("Remove", _remove);
setDesc("Receive 1 Arrow every " + _time + " seconds. Maximum of " + _max + ".");
}
public boolean isFletchedArrow(ItemStack stack) public boolean isFletchedArrow(ItemStack stack)
{ {
if (!UtilGear.isMat(stack, Material.ARROW)) if (!UtilGear.isMat(stack, Material.ARROW))

View File

@ -31,14 +31,21 @@ import nautilus.game.arcade.kit.Perk;
public class PerkIronHook extends Perk implements IThrown public class PerkIronHook extends Perk implements IThrown
{ {
private static final long COOLDOWN = 8000; private long _cooldown;
private static final int DAMAGE = 4; private int _damage;
public PerkIronHook() public PerkIronHook()
{ {
super("Iron Hook", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Pickaxe to " + C.cGreen + "Iron Hook" }); super("Iron Hook", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Pickaxe to " + C.cGreen + "Iron Hook" });
} }
@Override
public void setupValues()
{
_cooldown = getPerkTime("Cooldown");
_damage = getPerkInt("Damage");
}
@EventHandler @EventHandler
public void Activate(PlayerInteractEvent event) public void Activate(PlayerInteractEvent event)
{ {
@ -69,7 +76,7 @@ public class PerkIronHook extends Perk implements IThrown
return; return;
} }
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{ {
return; return;
} }
@ -118,7 +125,7 @@ public class PerkIronHook extends Perk implements IThrown
Manager.GetCondition().Factory().Falling(GetName(), target, player, 10, false, true); Manager.GetCondition().Factory().Falling(GetName(), target, player, 10, false, true);
// Damage Event // Damage Event
Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, velocity * DAMAGE, false, true, false, player.getName(), GetName()); Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, velocity * _damage, false, true, false, player.getName(), GetName());
// Inform // Inform
UtilPlayer.message(target, F.main("Skill", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); UtilPlayer.message(target, F.main("Skill", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + "."));

View File

@ -13,16 +13,26 @@ public class PerkKnockbackArrow extends Perk
{ {
private double _power; private double _power;
public PerkKnockbackArrow()
{
this(0);
}
public PerkKnockbackArrow(double power) public PerkKnockbackArrow(double power)
{ {
super("Arrow Knockback", new String[] super("Knockback Arrow");
{
C.cGray + "Arrows deal " + (int)(power*100) + "% Knockback.",
});
_power = power; _power = power;
} }
@Override
public void setupValues()
{
_power = getPerkPercentage("Power", _power);
setDesc(C.cGray + "Arrows deal " + (int)(_power * 100) + "% Knockback.");
}
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void Knockback(CustomDamageEvent event) public void Knockback(CustomDamageEvent event)
{ {

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade.kit.perks; package nautilus.game.arcade.kit.perks;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -32,9 +31,14 @@ public class PerkRopedArrow extends SmashPerk
private String _name; private String _name;
private double _power; private double _power;
private long _recharge; private int _recharge;
public PerkRopedArrow(String name, double power, long recharge) public PerkRopedArrow(String name)
{
this(name, 0, 0);
}
public PerkRopedArrow(String name, double power, int recharge)
{ {
super(name, new String[] super(name, new String[]
{ {
@ -46,6 +50,13 @@ public class PerkRopedArrow extends SmashPerk
_recharge = recharge; _recharge = recharge;
} }
@Override
public void setupValues()
{
_power = getPerkDouble("Power", _power);
_recharge = getPerkTime("Cooldown", _recharge);
}
@EventHandler @EventHandler
public void Fire(PlayerInteractEvent event) public void Fire(PlayerInteractEvent event)
{ {
@ -111,12 +122,6 @@ public class PerkRopedArrow extends SmashPerk
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
return; return;
for (Iterator<Entity> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) _arrows.removeIf(arrow -> !arrow.isValid());
{
Entity arrow = arrowIterator.next();
if (!arrow.isValid())
arrowIterator.remove();
}
} }
} }

View File

@ -34,11 +34,11 @@ import nautilus.game.arcade.kit.Perk;
public class PerkSeismicSlam extends Perk public class PerkSeismicSlam extends Perk
{ {
private static final long COOLDOWN = 7000; private long _cooldown;
private static final long TIME = 1000; private long _time;
private static final int DAMAGE = 10; private int _damage;
private static final int RADIUS = 8; private int _radius;
private static final float KNOCKBACK_MAGNITUDE = 2.4F; private float _knockbackMagnitude;
private Map<LivingEntity, Long> _live = new HashMap<>(); private Map<LivingEntity, Long> _live = new HashMap<>();
@ -47,6 +47,16 @@ public class PerkSeismicSlam extends Perk
super("Seismic Slam", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam" }); super("Seismic Slam", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam" });
} }
@Override
public void setupValues()
{
_cooldown = getPerkTime("Cooldown");
_time = getPerkTime("Time");
_damage = getPerkInt("Damage");
_radius = getPerkInt("Radius");
_knockbackMagnitude = getPerkFloat("Knockback Magnitude");
}
@EventHandler @EventHandler
public void deactivateDeath(PlayerDeathEvent event) public void deactivateDeath(PlayerDeathEvent event)
{ {
@ -93,7 +103,7 @@ public class PerkSeismicSlam extends Perk
return; return;
} }
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
return; return;
// Action // Action
@ -132,7 +142,7 @@ public class PerkSeismicSlam extends Perk
continue; continue;
} }
if (!UtilTime.elapsed(_live.get(player), TIME)) if (!UtilTime.elapsed(_live.get(player), _time))
{ {
continue; continue;
} }
@ -141,7 +151,7 @@ public class PerkSeismicSlam extends Perk
// Action // Action
Map<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), RADIUS); Map<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), _radius);
for (LivingEntity cur : targets.keySet()) for (LivingEntity cur : targets.keySet())
{ {
@ -156,7 +166,7 @@ public class PerkSeismicSlam extends Perk
} }
// Damage Event // Damage Event
Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, DAMAGE * targets.get(cur) + 0.5, true, true, false, player.getName(), GetName()); Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, _damage * targets.get(cur) + 0.5, true, true, false, player.getName(), GetName());
// Condition // Condition
Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true);
@ -187,6 +197,6 @@ public class PerkSeismicSlam extends Perk
return; return;
} }
event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); event.AddKnockback(GetName(), _knockbackMagnitude);
} }
} }

View File

@ -0,0 +1,180 @@
package nautilus.game.arcade.managers;
import mineplex.core.common.Pair;
import mineplex.core.common.util.UtilServer;
import mineplex.core.google.GoogleSheetsManager;
import mineplex.core.google.SheetObjectDeserialiser;
import mineplex.core.slack.SlackAPI;
import mineplex.core.slack.SlackMessage;
import mineplex.core.slack.SlackTeam;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class PerkSpreadsheetModule implements Listener
{
private static final String SLACK_CHANNEL_NAME = "#google-sheet-errors";
private static final String SLACK_USERNAME = "Google Sheets";
private static final String SLACK_ICON = "http://moppletop.github.io/mineplex/google-sheets-image.png";
private static boolean _reportedError;
private static final SheetObjectDeserialiser<Pair<String, String>> DESERIALISER = values -> Pair.create(values[0], values.length == 1 ? "" : values[1]);
private final Game _game;
private final Map<String, String> _dataMap;
private final String _fileName;
public PerkSpreadsheetModule(Game game, String fileName)
{
_game = game;
_fileName = fileName;
_dataMap = new HashMap<>();
UtilServer.RegisterEvents(this);
setup();
}
@EventHandler
public void cleanup(GameStateChangeEvent event)
{
if (event.GetState() != Game.GameState.End)
{
return;
}
UtilServer.Unregister(this);
}
private void setup()
{
// File Name must not be null
Objects.requireNonNull(_fileName);
GoogleSheetsManager manager = _game.getArcadeManager().getSheetsManager();
Map<String, List<List<String>>> map = manager.getSheetData(_fileName);
for (Map.Entry<String, List<List<String>>> entry : map.entrySet())
{
String key = entry.getKey();
List<List<String>> value = entry.getValue();
Kit kit = getFromName(key);
if (kit == null)
{
manager.log("No kit found for the name " + key);
continue;
}
Perk currentPerk = null;
for (List<String> rows : value)
{
try
{
Pair<String, String> pair = DESERIALISER.deserialise(rows.toArray(new String[0]));
Perk perk = getFromName(kit, pair.getLeft());
if (perk != null)
{
currentPerk = perk;
continue;
}
if (currentPerk != null)
{
String id = getKey(currentPerk, pair.getLeft());
_dataMap.put(id, pair.getRight());
}
}
catch (Exception e)
{
// Continue the loop
}
}
}
for (Kit kit : _game.GetKits())
{
for (Perk perk : kit.GetPerks())
{
perk.setSpreadsheet(this);
}
}
}
private Kit getFromName(String name)
{
for (Kit kit : _game.GetKits())
{
if (kit.GetName().equalsIgnoreCase(name))
{
return kit;
}
}
return null;
}
private Perk getFromName(Kit kit, String name)
{
for (Perk perk : kit.GetPerks())
{
if (perk.GetName().equalsIgnoreCase(name))
{
return perk;
}
}
return null;
}
public String getKey(Perk perk, String value)
{
return perk.GetName() + "." + value;
}
public Map<String, String> getDataMap()
{
return _dataMap;
}
public void reportError(Exception exception, String sheetName, String dataKey)
{
// Only allow one error report per lifetime, as the game causes an infinite loop.
if (_reportedError)
{
return;
}
_reportedError = true;
String message = "A parsing error has occurred on spreadsheet *" + sheetName + "* with data key *" + dataKey + "*.\n Details: " + exception.getMessage();
System.out.println(message);
try
{
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, SLACK_CHANNEL_NAME, new SlackMessage(SLACK_USERNAME, new URL(SLACK_ICON), message), true);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
}

View File

@ -14,11 +14,23 @@ public class GoogleSheetController
public static void main(String[] args) throws InterruptedException public static void main(String[] args) throws InterruptedException
{ {
String sheetToRead = System.getProperty("sheet");
SpreadsheetType[] types;
if (sheetToRead == null)
{
types = SpreadsheetType.values();
}
else
{
types = new SpreadsheetType[]{SpreadsheetType.valueOf(sheetToRead)};
}
System.out.println("Loading Sheet Provider"); System.out.println("Loading Sheet Provider");
SheetProvider provider = new SheetProvider(); SheetProvider provider = new SheetProvider();
System.out.println("Loaded Sheet Provider"); System.out.println("Loaded Sheet Provider");
for (SpreadsheetType type : SpreadsheetType.values()) for (SpreadsheetType type : types)
{ {
System.out.println("Sleeping..."); System.out.println("Sleeping...");
Thread.sleep(SLEEP_TIME); Thread.sleep(SLEEP_TIME);

View File

@ -8,11 +8,12 @@ public enum SpreadsheetType
GEM_HUNTERS_CHESTS("11Noztgbpu_gUKkc5F4evKKfyxS-Jv1coE0IrBToX_gg"), GEM_HUNTERS_CHESTS("11Noztgbpu_gUKkc5F4evKKfyxS-Jv1coE0IrBToX_gg"),
GEM_HUNTERS_SHOP("1OcYktxVZaW6Fm29Zh6w4Lb-UVyuN8r1x-TFb_3USYYI"), GEM_HUNTERS_SHOP("1OcYktxVZaW6Fm29Zh6w4Lb-UVyuN8r1x-TFb_3USYYI"),
SMASH_KITS("1Z_SLBzjiIVqu25PMGw9TwNKR3wd9Y9sX7rSDBl_rpxk")
; ;
private String _id; private String _id;
private SpreadsheetType(String id) SpreadsheetType(String id)
{ {
_id = id; _id = id;
} }