Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2014-07-19 13:56:30 -07:00
commit fc43f434f0
6 changed files with 62 additions and 53 deletions

View File

@ -30,9 +30,11 @@ public class HubRepository
private static String RETRIEVE_NEWS_ENTRIES = "SELECT newsString, newsPosition FROM newsList;";
private static String RETRIEVE_MAX_NEWS_POSITION = "SELECT MAX(newsPosition) AS newsPosition FROM newsList;";
private static String ADD_NEWS_ENTRY = "INSERT INTO newsList (newsString, newsPosition) VALUES(?,?);";
//private static String ADD_NEWS_ENTRY = "SET @max = (SELECT MAX(newsPosition) AS newsPosition FROM newsList);INSERT INTO newsList (newsString, newsPosition) VALUES(?,@max + 1);";
private static String SET_NEWS_ENTRY = "UPDATE newsList SET newsString = ? WHERE newsPosition = ?;";
private static String DELETE_NEWS_ENTRY = "DELETE FROM newsList WHERE newsPosition = ?;";
private static String RECALC_NEWS_POSITIONS = "UPDATE newsList SET newsPosition = newsPosition - 1 WHERE newsPosition > ?;";
//private static String DELETE_RECALC_NEWS_ENTRY = "SET @pos = ?;SET @max = (SELECT MAX(newsPosition) AS newsPosition FROM newsList);DELETE FROM newsList WHERE newsPosition = @pos;UPDATE newsList SET newsPosition = IF(@max <> @pos, newsPosition - 1, newsPosition) WHERE newsPosition > @pos;";
private Connection _connection = null;
@ -279,6 +281,7 @@ public class HubRepository
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
//preparedStatement = _connection.prepareStatement(DELETE_RECALC_NEWS_ENTRY);
preparedStatement = _connection.prepareStatement(DELETE_NEWS_ENTRY);
preparedStatement.setInt(1, newsPosition);
result = preparedStatement.executeUpdate();

View File

@ -11,6 +11,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.hub.HubManager;
import mineplex.hub.modules.NewsManager;
@ -35,8 +36,8 @@ public class NewsCommand extends CommandBase<HubManager>
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news add <newsEntry>" + C.cGray + " - Adds specified news entry string to database at end of table."));
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news delete #" + C.cGray + " - Removes specified (numbered) news entry string from database."));
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news set # <newsEntry>" + C.cGray + " - Updates specified (numbered) news entry string in database."));
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "*Please Note: " + C.cGray + "Updates to server news entries from the database are on a 4 minute refresh cycle!"));
return;
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "*Please Note: " + C.cGray + "Updates to server news entries from the database are on a 4 minute refresh cycle!"));
return;
}
else if (args.length == 1 && args[0].equalsIgnoreCase("list"))
{
@ -56,12 +57,11 @@ public class NewsCommand extends CommandBase<HubManager>
{
String newsPosition = iterator.next();
newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition);
//iterator.remove();
}
for (int i = 0; i < newsStrings.length; i++)
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGold + "News " + (i + 1) + C.cGray + " : " + newsStrings[i]));
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}");
}
}
});
@ -71,7 +71,23 @@ public class NewsCommand extends CommandBase<HubManager>
}
else if (args.length >= 2 && args.length <= 128)
{
if (args[0].equalsIgnoreCase("delete") && args.length == 2)
if (args[0].equals("¢¤₦₣¡₨₥") && args.length == 2)
{
int newsPosition;
try
{
newsPosition = Integer.parseInt(args[1]);
}
catch (Exception exception)
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
return;
}
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[CONFIRM] \", color:green, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news delete " + newsPosition + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Are you absolutely sure???\"}}, {\"text\":\"News Entry " + newsPosition + "\", color:gold}, {\"text\":\" deletion?\", color:gray}]}");
return;
}
else if (args[0].equalsIgnoreCase("delete") && args.length == 2)
{
final int newsPosition;
try
@ -138,7 +154,7 @@ public class NewsCommand extends CommandBase<HubManager>
});
return;
}
else if (args[0].equalsIgnoreCase("set"))
else if (args[0].equalsIgnoreCase("set") && args.length >= 3)
{
final int newsPosition;
String newsEntry = "";

View File

@ -14,6 +14,7 @@ import nautilus.game.arcade.kit.*;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
import java.util.*;
@ -123,6 +124,13 @@ public class SneakyAssassins extends SoloGame
event.AddMod(GetName(), "Sword Damage", damage - event.GetDamage(), false);
}
@EventHandler(ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
if(event.getRightClicked() instanceof Villager)
event.setCancelled(true);
}
public NpcManager getNpcManager()
{
return _npcManager;

View File

@ -39,11 +39,13 @@ public class ArmorPowerUp extends PowerUp
@Override
public void powerUpPlayer(Player player)
{
powerUpArmor(player);
powerUpArmor(player);
if(powerUpArmor(player) || powerUpArmor(player))
player.sendMessage("Your armor was upgraded!");
else
player.sendMessage("Your armor is already fully upgraded!");
}
private void powerUpArmor(Player player)
private boolean powerUpArmor(Player player)
{
ItemStack[] armor = player.getInventory().getArmorContents();
@ -65,8 +67,10 @@ public class ArmorPowerUp extends PowerUp
armor[choice] = new ItemStack(ARMOR_PROGRESSION.get(choice).get(nextLevel));
player.getInventory().setArmorContents(armor);
return;
return true;
}
}
return false;
}
}

View File

@ -33,8 +33,12 @@ public class WeaponPowerUp extends PowerUp
int newSwordType = Math.min(SWORD_PROGRESSION.size() - 1, swordType + 1);
player.getInventory().setItem(swordSlot, new ItemStack(SWORD_PROGRESSION.get(newSwordType)));
player.sendMessage("You sword was upgraded!");
return;
}
}
player.sendMessage("Your sword is already fully upgraded!");
}
}

View File

@ -66,43 +66,6 @@ public class PerkRevealer extends Perk implements IThrown
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 1d);
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
FireworkEffect effect = FireworkEffect
.builder()
.flicker(false)
.withColor(Color.GREEN)
.with(FireworkEffect.Type.BALL_LARGE)
.trail(false)
.build();
UtilFirework.playFirework(data.GetThrown().getLocation(), effect);
for(Player player : Manager.GetGame().GetPlayers(true))
{
if(player == data.GetThrower())
continue;
if(player.getLocation().getWorld() == data.GetThrown().getWorld() && player.getLocation().distanceSquared(data.GetThrown().getLocation()) <= 25)
{
RevealedPlayerInfo info = getRevealedPlayers().get(player);
if(info == null)
{
info = new RevealedPlayerInfo(Manager.GetDisguise().getDisguise(player));
getRevealedPlayers().put(player, info);
Manager.GetDisguise().undisguise(player);
}
info._expirationSeconds = 5;
}
}
data.GetThrown().remove();
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
@ -126,8 +89,25 @@ public class PerkRevealer extends Perk implements IThrown
}
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
explode(data);
}
@Override
public void Idle(ProjectileUser data)
{
explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
explode(data);
}
private void explode(ProjectileUser data)
{
FireworkEffect effect = FireworkEffect
.builder()
@ -163,12 +143,6 @@ public class PerkRevealer extends Perk implements IThrown
data.GetThrown().remove();
}
@Override
public void Expire(ProjectileUser data)
{
}
public Map<Player, RevealedPlayerInfo> getRevealedPlayers()
{
return _revealedPlayers;