From 90fbc397ffd78141980785df45ef905df1636a60 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 18 Oct 2013 00:46:06 -0700 Subject: [PATCH] Converted gem rewards to boolean return from website. Implemented gem transactions and source. --- .../core/account/CoreClientManager.java | 1 - .../account/repository/token/ClientToken.java | 1 - .../core/antihack/AntiHackRepository.java | 141 ++++++++++++++++++ .../src/mineplex/core/chat/ChatClient.java | 16 ++ .../core/chat/command/FilterChatCommand.java | 21 +++ .../core/donation/DonationManager.java | 41 ++--- .../repository/DonationRepository.java | 18 +-- ...erUpdateToken.java => GemRewardToken.java} | 5 +- .../src/mineplex/core/punish/Punish.java | 32 ---- .../mineplex/core/punish/PunishClient.java | 1 - .../mineplex/hub/modules/ParkourManager.java | 8 +- .../hub/tutorial/TutorialManager.java | 2 +- .../minecraft/core/account/GameClass.java | 9 -- .../core/account/GameSalesPackage.java | 8 - .../game/arcade/managers/GameGemManager.java | 6 +- .../repository/DominateRepository.java | 6 +- .../dominate/stats/DominateStatsReporter.java | 12 +- .../nautilus/game/minekart/gp/GPResult.java | 8 +- Website/LOC.Core/LOC.Core.csproj | 4 +- Website/LOC.Core/Model/Account/Account.cs | 2 +- .../Model/Sales/AccountGemTransaction.cs | 15 -- .../LOC.Core/Model/Sales/GemTransaction.cs | 13 ++ .../LOC.Core/Tokens/Client/GemRewardToken.cs | 11 ++ .../Tokens/Client/PlayerUpdateToken.cs | 11 -- .../Models/AccountAdministrator.cs | 24 ++- .../Models/CaptureThePigAdministrator.cs | 6 +- .../Models/DominateAdministrator.cs | 6 +- .../Models/IAccountAdministrator.cs | 2 +- .../Models/ICaptureThePigAdministrator.cs | 2 +- .../Models/IDominateAdministrator.cs | 2 +- .../Manage/Controllers/AccountsController.cs | 11 -- .../Controllers/PlayerAccountController.cs | 47 +----- .../ViewModels/AccountViewModel.cs | 5 - Website/LOCWebsite.suo | Bin 474624 -> 474624 bytes 34 files changed, 278 insertions(+), 219 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/chat/ChatClient.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java rename Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/{PlayerUpdateToken.java => GemRewardToken.java} (56%) delete mode 100644 Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameClass.java delete mode 100644 Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameSalesPackage.java delete mode 100644 Website/LOC.Core/Model/Sales/AccountGemTransaction.cs create mode 100644 Website/LOC.Core/Model/Sales/GemTransaction.cs create mode 100644 Website/LOC.Core/Tokens/Client/GemRewardToken.cs delete mode 100644 Website/LOC.Core/Tokens/Client/PlayerUpdateToken.cs diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 85c50e4c9..832379a03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -138,7 +138,6 @@ public class CoreClientManager implements Listener token = gson.fromJson(response, ClientToken.class); client.SetAccountId(token.AccountId); - client.SetFilterChat(token.FilterChat); client.SetRank(Rank.valueOf(token.Rank)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/ClientToken.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/ClientToken.java index 56d60e6a0..3de776eb6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/ClientToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/ClientToken.java @@ -8,5 +8,4 @@ public class ClientToken public int EconomyBalance; public AccountToken AccountToken; - public Boolean FilterChat; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java new file mode 100644 index 000000000..0c75ecb82 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java @@ -0,0 +1,141 @@ +package mineplex.core.antihack; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Map.Entry; + +import org.bukkit.entity.Player; + +public class AntiHackRepository +{ + private AntiHack _plugin; + private String _serverName; + + private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/Mineplex"; + private String _userName = "root"; + private String _password = "tAbechAk3wR7tuTh"; + + private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256) NOT NULL, hackType VARCHAR(256) NOT NULL, playerName VARCHAR(256) NOT NULL, hackCount INT, updated LONG, PRIMARY KEY (id), UNIQUE KEY serverName_hackType_playerName (serverName, hackType, playerName));"; + private static String UPDATE_PLAYER_OFFENSES = "REPLACE INTO AntiHack (serverName, playerName, hackType, hackCount, updated) VALUES (?, ?, ?, ?, now());"; + + public AntiHackRepository(AntiHack plugin, String serverName) + { + _plugin = plugin; + _serverName = serverName; + } + + public void initialize() + { + Connection connection = null; + PreparedStatement preparedStatement = null; + + try + { + connection = DriverManager.getConnection(_connectionString, _userName, _password); + + // Create table + preparedStatement = connection.prepareStatement(CREATE_TABLE); + preparedStatement.execute(); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (connection != null) + { + try + { + connection.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + } + + public void saveOffenses() + { + new Thread(new Runnable() + { + public void run() + { + Connection connection = null; + PreparedStatement preparedStatement = null; + + try + { + connection = DriverManager.getConnection(_connectionString, _userName, _password); + + preparedStatement = connection.prepareStatement(UPDATE_PLAYER_OFFENSES); + + synchronized (_plugin.getOffensesSynch()) + { + for (Player offender : _plugin.getOffenses().keySet()) + { + for (Entry hackEntry : _plugin.getOffenses().get(offender).entrySet()) + { + preparedStatement.setString(1, _serverName); + preparedStatement.setString(2, offender.getName()); + preparedStatement.setString(3, hackEntry.getKey()); + preparedStatement.setInt(4, hackEntry.getValue()); + preparedStatement.addBatch(); + } + } + + _plugin.getOffenses().clear(); + } + + preparedStatement.executeBatch(); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (connection != null) + { + try + { + connection.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + } + }).start(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/ChatClient.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/ChatClient.java new file mode 100644 index 000000000..cd2a5d9ad --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/ChatClient.java @@ -0,0 +1,16 @@ +package mineplex.core.chat; + +public class ChatClient +{ + private boolean _filterChat = false; + + public void SetFilterChat(boolean filterChat) + { + _filterChat = filterChat; + } + + public boolean GetFilterChat() + { + return _filterChat; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java new file mode 100644 index 000000000..ac05c1877 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/FilterChatCommand.java @@ -0,0 +1,21 @@ +package mineplex.core.chat.command; + +import org.bukkit.entity.Player; + +import mineplex.core.chat.Chat; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +public class FilterChatCommand extends CommandBase +{ + public FilterChatCommand(Chat plugin) + { + super(plugin, Rank.ALL, "filter"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.Get(caller).ToggleFilterChat(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index f42d00f94..0baf4c546 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -8,7 +8,6 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.token.DonorTokenWrapper; -import mineplex.core.donation.repository.token.PlayerUpdateToken; import mineplex.core.server.util.TransactionResponse; import org.bukkit.craftbukkit.libs.com.google.gson.Gson; @@ -130,39 +129,23 @@ public class DonationManager extends MiniPlugin public void RewardGems(final Callback callback, final String caller, final String name, final int greenGems) { - _repository.PlayerUpdate(new Callback() + _repository.PlayerUpdate(new Callback() { - public void run(PlayerUpdateToken token) + public void run(Boolean success) { - Donor donor = Get(name); - - if (donor != null) + if (success) { - donor.AddGems(greenGems); + Donor donor = Get(name); + + if (donor != null) + { + donor.AddGems(greenGems); + } + + if (callback != null) + callback.run(true); } - - if (callback != null) - callback.run(true); } }, caller, name, greenGems); } - - public void RewardGems(final Callback callback, final String name, final int greenGems) - { - _repository.PlayerUpdate(new Callback() - { - public void run(PlayerUpdateToken token) - { - Donor donor = Get(name); - - if (donor != null) - { - donor.AddGems(greenGems); - } - - if (callback != null) - callback.run(true); - } - }, name, greenGems); - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 6e54f2fe5..c5e8b6b13 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -1,7 +1,7 @@ package mineplex.core.donation.repository; import mineplex.core.common.util.Callback; -import mineplex.core.donation.repository.token.PlayerUpdateToken; +import mineplex.core.donation.repository.token.GemRewardToken; import mineplex.core.donation.repository.token.PurchaseToken; import mineplex.core.donation.repository.token.UnknownPurchaseToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; @@ -37,20 +37,12 @@ public class DonationRepository new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseUnknownSalesPackage").Execute(TransactionResponse.class, callback, token); } - public void PlayerUpdate(Callback callback, String name, int greenGems) + public void PlayerUpdate(Callback callback, String giver, String name, int greenGems) { - PlayerUpdateToken token = new PlayerUpdateToken(); - token.Name = name; - token.Gems = greenGems; - new AsyncJsonWebCall(_webAddress + "PlayerAccount/PlayerUpdate").Execute(PlayerUpdateToken.class, callback, token); - } - - public void PlayerUpdate(Callback callback, String giver, String name, int greenGems) - { - PlayerUpdateToken token = new PlayerUpdateToken(); + GemRewardToken token = new GemRewardToken(); token.Source = giver; token.Name = name; - token.Gems = greenGems; - new AsyncJsonWebCall(_webAddress + "PlayerAccount/PlayerUpdate").Execute(PlayerUpdateToken.class, callback, token); + token.Amount = greenGems; + new AsyncJsonWebCall(_webAddress + "PlayerAccount/GemReward").Execute(Boolean.class, callback, token); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/PlayerUpdateToken.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/GemRewardToken.java similarity index 56% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/PlayerUpdateToken.java rename to Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/GemRewardToken.java index d601df147..65b6b0386 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/PlayerUpdateToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/token/GemRewardToken.java @@ -1,9 +1,8 @@ package mineplex.core.donation.repository.token; -public class PlayerUpdateToken +public class GemRewardToken { public String Source; public String Name; - public int Gems; - public boolean FilterChat; + public int Amount; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index a2a146ff5..213497222 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -147,38 +147,6 @@ public class Punish extends MiniPlugin event.disallow(Result.KICK_BANNED, reason); } } - - /* - for (String alias : client.Acc().GetAliasIP()) - { - if (Clients().Get(alias).Ban().IsBanned()) - { - String reason = C.consoleHead + "Alias Banned" + - C.consoleFill + " - " + - C.consoleBody + client.Ban().GetBan().RemainingString() + - C.consoleFill + " - " + - C.consoleBody + client.Ban().Reason(); - - event.disallow(Result.KICK_BANNED, reason); - return; - } - } - - for (String alias : client.Acc().GetAliasMAC()) - { - if (Clients().Get(alias).Ban().IsBanned()) - { - String reason = C.consoleHead + "Alias Banned" + - C.consoleFill + " - " + - C.consoleBody + client.Ban().GetBan().RemainingString() + - C.consoleFill + " - " + - C.consoleBody + client.Ban().Reason(); - - event.disallow(Result.KICK_BANNED, reason); - return; - } - } - */ } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/PunishClient.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/PunishClient.java index 332df7a9f..d23d8fbcf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/PunishClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/PunishClient.java @@ -5,7 +5,6 @@ import java.util.List; import mineplex.core.common.util.NautHashMap; - public class PunishClient { private NautHashMap> _punishments; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index 18f87fa90..b41088d20 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -248,17 +248,17 @@ public class ParkourManager extends MiniPlugin final ParkourData fData = data; _donationManager.RewardGems(new Callback() - { + { public void run(Boolean completed) { UtilPlayer.message(player, F.main("Parkour", "You received " + F.elem(C.cGreen + fData.Gems + " Gems") + ".")); - + _taskManager.completedTask(player, fData.Name); - + //Sound player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); } - }, player.getName(), data.Gems); + }, "Parkour " + data.Name, player.getName(), data.Gems); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java index 7b3e5c82e..195ed7f34 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java @@ -138,7 +138,7 @@ public class TutorialManager extends MiniPlugin //Sound player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); } - }, player.getName(), tut.GetGems()); + }, "Tutorial " + tut.GetTutName(), player.getName(), tut.GetGems()); } } } diff --git a/Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameClass.java b/Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameClass.java deleted file mode 100644 index f572fd371..000000000 --- a/Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameClass.java +++ /dev/null @@ -1,9 +0,0 @@ -package nautilus.minecraft.core.account; - -public class GameClass -{ - public String Name; - public String Description; - public double Price; - public boolean Free; -} diff --git a/Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameSalesPackage.java b/Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameSalesPackage.java deleted file mode 100644 index f644afe22..000000000 --- a/Plugins/Nautilus.Core/src/nautilus/minecraft/core/account/GameSalesPackage.java +++ /dev/null @@ -1,8 +0,0 @@ -package nautilus.minecraft.core.account; - -public class GameSalesPackage -{ - public int GameSalesPackageId; - public int Credits; - public int Points; -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 37d9b81d6..d0144e130 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -120,10 +120,10 @@ public class GameGemManager implements Listener //Give Gems if (give) - GiveGems(player, game.GetPlayerGems().remove(player), game.GemMultiplier); + GiveGems(game, player, game.GetPlayerGems().remove(player), game.GemMultiplier); } - public void GiveGems(Player player, HashMap gems, double gameMult) + public void GiveGems(Game game, Player player, HashMap gems, double gameMult) { if (gems == null) return; @@ -141,7 +141,7 @@ public class GameGemManager implements Listener total = (int) (total * gameMult); - Manager.GetDonation().RewardGems(null, player.getName(), total); + Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), total); } public void AnnounceGems(Game game, Player player, HashMap gems, boolean give) diff --git a/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/repository/DominateRepository.java b/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/repository/DominateRepository.java index bc7ace428..eced51d9d 100644 --- a/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/repository/DominateRepository.java +++ b/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/repository/DominateRepository.java @@ -5,7 +5,7 @@ import java.util.List; import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken; import mineplex.core.common.util.Callback; -import mineplex.core.donation.repository.token.PlayerUpdateToken; +import mineplex.core.donation.repository.token.GemRewardToken; import mineplex.core.server.remotecall.JsonWebCall; import nautilus.game.dominate.stats.DominateGameStatsToken; @@ -18,13 +18,13 @@ public class DominateRepository _webServerAdddress = webServerAddress; } - public void SaveGameStats(final Callback> callback, final DominateGameStatsToken dominationGameStats) + public void SaveGameStats(final Callback> callback, final DominateGameStatsToken dominationGameStats) { Thread asyncThread = new Thread(new Runnable() { public void run() { - List tokenList = new JsonWebCall(_webServerAdddress + "Dominate/UploadStats").Execute(new TypeToken>(){}.getType(), dominationGameStats); + List tokenList = new JsonWebCall(_webServerAdddress + "Dominate/UploadStats").Execute(new TypeToken>(){}.getType(), dominationGameStats); callback.run(tokenList); } }); diff --git a/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/stats/DominateStatsReporter.java b/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/stats/DominateStatsReporter.java index 63b249b44..0bebc5864 100644 --- a/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/stats/DominateStatsReporter.java +++ b/Plugins/Nautilus.Game.Dominate/src/nautilus/game/dominate/stats/DominateStatsReporter.java @@ -8,7 +8,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.donation.DonationManager; import mineplex.core.donation.Donor; -import mineplex.core.donation.repository.token.PlayerUpdateToken; +import mineplex.core.donation.repository.token.GemRewardToken; import nautilus.game.core.engine.TeamType; import nautilus.game.core.events.GamePlayerAfkEvent; import nautilus.game.core.events.team.TeamGameFinishedEvent; @@ -89,11 +89,11 @@ public class DominateStatsReporter implements Listener gameStats.PlayerStats.add(playerStats); } - _repository.SaveGameStats(new Callback>() + _repository.SaveGameStats(new Callback>() { - public void run(List tokenList) + public void run(List tokenList) { - for (PlayerUpdateToken token : tokenList) + for (GemRewardToken token : tokenList) { try { @@ -102,9 +102,9 @@ public class DominateStatsReporter implements Listener if (player != null && player.isOnline()) { - donor.AddGems(token.Gems); + donor.AddGems(token.Amount); - player.sendMessage(F.main("Dominate", "You earned " + ChatColor.YELLOW + token.Gems + C.cGray + " gems for playing!")); + player.sendMessage(F.main("Dominate", "You earned " + ChatColor.YELLOW + token.Amount + C.cGray + " gems for playing!")); } } catch (Exception ex) diff --git a/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/gp/GPResult.java b/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/gp/GPResult.java index 3dbc31fa9..a7e430c98 100644 --- a/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/gp/GPResult.java +++ b/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/gp/GPResult.java @@ -62,7 +62,7 @@ public class GPResult if (_gp.GetTrack().GetPositions().size() > 0 && sortedScores.size() > 0) { _first = sortedScores.get(0); - manager.RewardGems(null, _first.GetDriver().getName(), 8 * _gp.GetPlayers().size() + buffer); + manager.RewardGems(null, "Earned Minekart", _first.GetDriver().getName(), 8 * _gp.GetPlayers().size() + buffer); } buffer += 2; @@ -70,7 +70,7 @@ public class GPResult if (_gp.GetTrack().GetPositions().size() > 1 && sortedScores.size() > 1) { _second = sortedScores.get(1); - manager.RewardGems(null, _second.GetDriver().getName(), 5 * _gp.GetPlayers().size() + buffer); + manager.RewardGems(null, "Earned Minekart", _second.GetDriver().getName(), 5 * _gp.GetPlayers().size() + buffer); } buffer += 2; @@ -78,14 +78,14 @@ public class GPResult if (_gp.GetTrack().GetPositions().size() > 2 && sortedScores.size() > 2) { _third = sortedScores.get(2); - manager.RewardGems(null, _third.GetDriver().getName(), 2 * _gp.GetPlayers().size() + buffer); + manager.RewardGems(null, "Earned Minekart", _third.GetDriver().getName(), 2 * _gp.GetPlayers().size() + buffer); } buffer += 2; for (int i = 3; i < sortedScores.size(); i++) { - manager.RewardGems(null, sortedScores.get(i).GetDriver().getName(), buffer); + manager.RewardGems(null, "Earned Minekart", sortedScores.get(i).GetDriver().getName(), buffer); } _fireworkLocations = new ArrayList(5); diff --git a/Website/LOC.Core/LOC.Core.csproj b/Website/LOC.Core/LOC.Core.csproj index aae58ee64..fa7100964 100644 --- a/Website/LOC.Core/LOC.Core.csproj +++ b/Website/LOC.Core/LOC.Core.csproj @@ -69,7 +69,7 @@ - + @@ -145,7 +145,7 @@ - + diff --git a/Website/LOC.Core/Model/Account/Account.cs b/Website/LOC.Core/Model/Account/Account.cs index d885b58cc..a3e9958fd 100644 --- a/Website/LOC.Core/Model/Account/Account.cs +++ b/Website/LOC.Core/Model/Account/Account.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Sales; - using Server; using Server.GameServer; using Server.GameServer.CaptureThePig.Stats; using Server.GameServer.Dominate.Stats; @@ -62,5 +61,6 @@ public List CaptureThePigStats { get; set; } public List AccountTransactions { get; set; } + public List GemTransactions { get; set; } } } diff --git a/Website/LOC.Core/Model/Sales/AccountGemTransaction.cs b/Website/LOC.Core/Model/Sales/AccountGemTransaction.cs deleted file mode 100644 index 5f0c22bb1..000000000 --- a/Website/LOC.Core/Model/Sales/AccountGemTransaction.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace LOC.Core.Model.Server -{ - public class AccountGemTransaction - { - public int AccountGemTransactionId { get; set; } - - public string Source { get; set; } - - public string Reason { get; set; } - - public bool Earned { get; set; } - - public Account.Account Account { get; set; } - } -} diff --git a/Website/LOC.Core/Model/Sales/GemTransaction.cs b/Website/LOC.Core/Model/Sales/GemTransaction.cs new file mode 100644 index 000000000..b917705b7 --- /dev/null +++ b/Website/LOC.Core/Model/Sales/GemTransaction.cs @@ -0,0 +1,13 @@ +namespace LOC.Core.Model.Sales +{ + public class GemTransaction + { + public int GemTransactionId { get; set; } + + public Account.Account Account { get; set; } + + public string Source { get; set; } + + public int Amount { get; set; } + } +} diff --git a/Website/LOC.Core/Tokens/Client/GemRewardToken.cs b/Website/LOC.Core/Tokens/Client/GemRewardToken.cs new file mode 100644 index 000000000..a34878748 --- /dev/null +++ b/Website/LOC.Core/Tokens/Client/GemRewardToken.cs @@ -0,0 +1,11 @@ +namespace LOC.Core.Tokens.Client +{ + public class GemRewardToken + { + public string Name { get; set; } + + public string Source { get; set; } + + public int Amount { get; set; } + } +} \ No newline at end of file diff --git a/Website/LOC.Core/Tokens/Client/PlayerUpdateToken.cs b/Website/LOC.Core/Tokens/Client/PlayerUpdateToken.cs deleted file mode 100644 index 02e25886f..000000000 --- a/Website/LOC.Core/Tokens/Client/PlayerUpdateToken.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace LOC.Core.Tokens.Client -{ - public class PlayerUpdateToken - { - public string Name { get; set; } - - public int Gems { get; set; } - - public bool FilterChat { get; set; } - } -} diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index 1ed7afd3b..af71b9457 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -148,15 +148,35 @@ } } - public Account UpdateAccount(Account account) + public bool GemReward(GemRewardToken token) { using (var repository = _repositoryFactory.CreateRepository()) { + var account = repository.Where(x => x.Name == token.Name).FirstOrDefault(); + account.LoadNavigationProperties(repository.Context); + + if (account == null) + return false; + + account.Gems += token.Amount; + + var gemTransaction = new GemTransaction + { + Source = token.Source, + Account = account, + Amount = token.Amount + }; + + if (account.GemTransactions == null) + account.GemTransactions = new List(); + + account.GemTransactions.Add(gemTransaction); + repository.Edit(account); repository.CommitChanges(); } - return account; + return true; } public void AddTask(UpdateTaskToken token) diff --git a/Website/LOC.Website.Common/Models/CaptureThePigAdministrator.cs b/Website/LOC.Website.Common/Models/CaptureThePigAdministrator.cs index fa209c534..4a0e26ddd 100644 --- a/Website/LOC.Website.Common/Models/CaptureThePigAdministrator.cs +++ b/Website/LOC.Website.Common/Models/CaptureThePigAdministrator.cs @@ -14,9 +14,9 @@ { public CaptureThePigAdministrator(INautilusRepositoryFactory repositoryFactory) : base(repositoryFactory) { } - public List UploadStats(CaptureThePigGameStatsToken token) + public List UploadStats(CaptureThePigGameStatsToken token) { - var updateTokenList = new List(); + var updateTokenList = new List(); var pointsPerMinute = Math.Min(2 / (token.Length / 60000), 2); using (var repository = RepositoryFactory.CreateRepository()) @@ -28,7 +28,7 @@ UpdateStatsForAccount(repository, account, earnedPoints, playerStats); - updateTokenList.Add(new PlayerUpdateToken { Name = account.Name, Gems = earnedPoints }); + updateTokenList.Add(new GemRewardToken { Name = account.Name, Amount = earnedPoints }); } repository.CommitChanges(); diff --git a/Website/LOC.Website.Common/Models/DominateAdministrator.cs b/Website/LOC.Website.Common/Models/DominateAdministrator.cs index c27dba8e3..34866e4c6 100644 --- a/Website/LOC.Website.Common/Models/DominateAdministrator.cs +++ b/Website/LOC.Website.Common/Models/DominateAdministrator.cs @@ -15,9 +15,9 @@ { public DominateAdministrator(INautilusRepositoryFactory repositoryFactory) : base(repositoryFactory) { } - public List UploadStats(DominateGameStatsToken token) + public List UploadStats(DominateGameStatsToken token) { - var updateTokenList = new List(); + var updateTokenList = new List(); var timeDifference = token.Duration - ((long)new TimeSpan(DateTime.Now.ToUniversalTime().Ticks - new DateTime(1970, 1, 1).Ticks).TotalMilliseconds) - new TimeSpan(0, 15, 0).TotalMilliseconds; var direction = timeDifference / Math.Abs(timeDifference); var pointsAccordingToDuration = Math.Min(Math.Abs(timeDifference), 5) * direction + 35; @@ -31,7 +31,7 @@ UpdateStatsForAccount(repository, account, earnedPoints, playerStats); - updateTokenList.Add(new PlayerUpdateToken { Name = account.Name, Gems = earnedPoints }); + updateTokenList.Add(new GemRewardToken { Name = account.Name, Amount = earnedPoints }); } repository.CommitChanges(); diff --git a/Website/LOC.Website.Common/Models/IAccountAdministrator.cs b/Website/LOC.Website.Common/Models/IAccountAdministrator.cs index bcdb3d36d..52710ce19 100644 --- a/Website/LOC.Website.Common/Models/IAccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/IAccountAdministrator.cs @@ -16,7 +16,7 @@ Account GetAccountByName(string name); Account GetAccountById(int id); Account CreateAccount(string name); - Account UpdateAccount(Account account); + bool GemReward(GemRewardToken token); void ApplySalesPackage(SalesPackage salesPackage, int accountId, decimal gross, decimal fee); Account Login(LoginRequestToken loginToken); void Logout(string name); diff --git a/Website/LOC.Website.Common/Models/ICaptureThePigAdministrator.cs b/Website/LOC.Website.Common/Models/ICaptureThePigAdministrator.cs index 3cb3ef580..c80834079 100644 --- a/Website/LOC.Website.Common/Models/ICaptureThePigAdministrator.cs +++ b/Website/LOC.Website.Common/Models/ICaptureThePigAdministrator.cs @@ -6,6 +6,6 @@ public interface ICaptureThePigAdministrator : IPvpAdministrator { - List UploadStats(CaptureThePigGameStatsToken token); + List UploadStats(CaptureThePigGameStatsToken token); } } diff --git a/Website/LOC.Website.Common/Models/IDominateAdministrator.cs b/Website/LOC.Website.Common/Models/IDominateAdministrator.cs index ba6bdef2b..d6a588fc6 100644 --- a/Website/LOC.Website.Common/Models/IDominateAdministrator.cs +++ b/Website/LOC.Website.Common/Models/IDominateAdministrator.cs @@ -6,6 +6,6 @@ public interface IDominateAdministrator : IPvpAdministrator { - List UploadStats(DominateGameStatsToken token); + List UploadStats(DominateGameStatsToken token); } } diff --git a/Website/LOC.Website.Web/Areas/Manage/Controllers/AccountsController.cs b/Website/LOC.Website.Web/Areas/Manage/Controllers/AccountsController.cs index ee95616f4..b738968b6 100644 --- a/Website/LOC.Website.Web/Areas/Manage/Controllers/AccountsController.cs +++ b/Website/LOC.Website.Web/Areas/Manage/Controllers/AccountsController.cs @@ -83,17 +83,6 @@ namespace LOC.Website.Web.Areas.Manage.Controllers return View(account); } - [HttpPost] - public ActionResult Edit(Account account) - { - if (ModelState.IsValid) - { - _accountAdministrator.UpdateAccount(account); - return RedirectToAction("Index"); - } - return View(account); - } - public ActionResult Delete(int id) { Account account = context.Accounts.Single(x => x.AccountId == id); diff --git a/Website/LOC.Website.Web/Controllers/PlayerAccountController.cs b/Website/LOC.Website.Web/Controllers/PlayerAccountController.cs index d0a0896ca..ac7060d12 100644 --- a/Website/LOC.Website.Web/Controllers/PlayerAccountController.cs +++ b/Website/LOC.Website.Web/Controllers/PlayerAccountController.cs @@ -135,15 +135,9 @@ } [HttpPost] - public ActionResult PlayerUpdate(PlayerUpdateToken token) + public ActionResult GemReward(GemRewardToken token) { - var account = _accountAdministrator.GetAccountByName(token.Name); - account.Gems += token.Gems; - account.FilterChat = token.FilterChat; - - _accountAdministrator.UpdateAccount(account); - - var json = JsonConvert.SerializeObject(token); + var json = JsonConvert.SerializeObject(_accountAdministrator.GemReward(token)); return Content(json, "application/json"); } @@ -154,43 +148,6 @@ return Content(json, "application/json"); } - [HttpPost] - public ActionResult PlayerVoted(string name) - { - var account = _accountAdministrator.GetAccountByName(name); - - var newPoints = 0; - - if (account != null) - { - if (DateTime.Now.Subtract(account.LastVote) < TimeSpan.FromDays(2)) - { - account.VoteModifier = Math.Min(account.VoteModifier + 1, 2); - } - else - { - account.VoteModifier = 0; - } - - newPoints = 30 + (10*account.VoteModifier); - - account.Gems += newPoints; - account.LastVote = DateTime.Now; - - _accountAdministrator.UpdateAccount(account); - } - - var token = new PlayerUpdateToken { Name = name, Gems = newPoints }; - - var json = JsonConvert.SerializeObject(token); - return Content(json, "application/json"); - } - - [HttpPost] - public void RecordDeathStat(DeathStatToken token) - { - } - [HttpPost] public ActionResult GetPunishClient(string name) { diff --git a/Website/LOC.Website.Web/ViewModels/AccountViewModel.cs b/Website/LOC.Website.Web/ViewModels/AccountViewModel.cs index ea35c323c..9c963dc08 100644 --- a/Website/LOC.Website.Web/ViewModels/AccountViewModel.cs +++ b/Website/LOC.Website.Web/ViewModels/AccountViewModel.cs @@ -22,10 +22,5 @@ { return _accountAdministrator.GetAccountByName(name); } - - public Account UpdateAccount(Account account) - { - return _accountAdministrator.UpdateAccount(account); - } } } \ No newline at end of file diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 5878bdd87085b8423eb5d09b76ebba5fcdac3657..08d82d04bf7564f37c9dad5af6b3de5bdb11cc4f 100644 GIT binary patch delta 528 zcmZqpBh&ClWX7qM(FVqs)6VtK;Ez_7i>j8TM<@n8Eyb4DO$0%GRv z6U|wSK5#PV0OfUocsipKlg9Qh>a6}^lbxdtr~7p~Lovje+49!}Kb9 zR;}qvLYWjew1F}PFm2OI>{%Ol1lSoE_Ao%e^h71recSgrupUyIyv5DT$ekgTA(tTt zNR~4sG88eSFoZDVGh_q#c?^0C$qdB|fA=vzWUQDpTSqWGrtpF9-N_%TL>Pl6Pc#sn zeu0CLZ@WSU>jMtPNz)sTFcnWfRK%(v!2af~m<4~5Qq-1?>ZcA%gF!l`=VdbqO;#{7 zTUNvxF}=Z_Rb{#gA9Db!4$y5oCLa{CpKQRwGx@+)p6Lz0SUIL&_|IxE`GSxEk)j&Y z8x+{0CObHIO&nSS8{v%vOGS6RJc zIQ{{J)qpOT?qb9iqNomJfkZ%93yG}@Wb1+W6AO*EzcFGH+0Hl(Y&PSa>5cE1iYGUi ph)tjHhDl&@jg{Q=1$9hn+vQ%fEo0=+1IB|AFx;V0_=b%q5CBbFy5j%< delta 359 zcmZqpBh&ClWhMJ(HkSQy!iSpNP0|9^Xp8KVdz+SO!1P2V)_vReIj|m5o1`Hzy@-i1WOB|Kk;#`*g{EKN zVC37bkiq(ZV{^k92gdCVMXU$Hmp8m%Wtw)7HDG#x9Fxv;0S-ou=}XSA#xQ=E-Wbig zpK-%<$4n;sZRc1IuuuEI=CJJ=t4$1t0MJH|x2C%ov4w~N8DIbs(SpkSn^-8$YXsyN z1F;E6aAKkK_BTdsBHO1sd|(rs{%$7|$7GL3N{n|v_H<64@P