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

This commit is contained in:
libraryaddict 2015-05-13 13:19:09 +12:00
commit 744c867990
33 changed files with 1057 additions and 617 deletions

View File

@ -8,14 +8,16 @@ import org.bukkit.entity.Player;
public enum Rank
{
LT("LT", ChatColor.DARK_RED),
OWNER("Owner", ChatColor.DARK_RED),
DEVELOPER("Dev", ChatColor.RED),
ADMIN("Admin", ChatColor.RED),
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
MODERATOR("Mod", ChatColor.GOLD),
HELPER("Helper", ChatColor.DARK_AQUA),
MAPDEV("Builder", ChatColor.BLUE),
HELPER("Trainee", ChatColor.DARK_AQUA),
MAPLEAD("MapLead", ChatColor.DARK_PURPLE),
MAPDEV("Builder", ChatColor.BLUE),
EVENT("Event", ChatColor.WHITE),

View File

@ -7,9 +7,14 @@ import java.util.List;
import net.minecraft.server.v1_7_R4.EntityBat;
import net.minecraft.server.v1_7_R4.EntityCreature;
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.server.v1_7_R4.EntityInsentient;
import net.minecraft.server.v1_7_R4.EntityLiving;
import net.minecraft.server.v1_7_R4.Navigation;
import net.minecraft.server.v1_7_R4.PathfinderGoal;
import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction;
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
import org.bukkit.Bukkit;
@ -76,6 +81,47 @@ public class UtilEnt
leashed.setLeashHolder(holder);
}
public static void addLookAtPlayerAI(Entity entity, float dist)
{
if (((CraftEntity) entity).getHandle() instanceof EntityInsentient)
{
addAI(entity, 7, new PathfinderGoalLookAtPlayer(((EntityInsentient) ((CraftEntity) entity).getHandle()), EntityHuman.class, dist));
addAI(entity, 8, new PathfinderGoalRandomLookaround(((EntityInsentient) ((CraftEntity) entity).getHandle())));
}
}
public static void addAI(Entity entity, int value, PathfinderGoal ai)
{
if (((CraftEntity) entity).getHandle() instanceof EntityInsentient)
{
EntityInsentient ei = ((EntityInsentient) ((CraftEntity) entity).getHandle());
if (_goalSelector == null)
{
try
{
_goalSelector = EntityInsentient.class.getDeclaredField("goalSelector");
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
return;
}
_goalSelector.setAccessible(true);
}
try
{
((PathfinderGoalSelector) _goalSelector.get(ei)).a(value, ai);
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
}
}
public static void Vegetate(Entity entity)
{

View File

@ -103,17 +103,17 @@ public abstract class MiniPlugin implements Listener
System.out.println(F.main(_moduleName, message));
}
protected void runAsync(Runnable runnable)
public void runAsync(Runnable runnable)
{
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, runnable);
}
protected void runSync(Runnable runnable)
public void runSync(Runnable runnable)
{
_plugin.getServer().getScheduler().runTask(_plugin, runnable);
}
protected void runSyncLater(Runnable runnable, long delay)
public void runSyncLater(Runnable runnable, long delay)
{
_plugin.getServer().getScheduler().runTaskLater(_plugin, runnable, delay);
}

View File

@ -191,6 +191,13 @@ public enum Achievement
new int[]{1},
AchievementCategory.DRAW_MY_THING),
// Master Builders
MASTER_BUILDER_WINS("Master Builder", 1000,
new String[]{"Master Builders.Wins"},
new String[]{"Win 30 games of Master Builders"},
new int[]{30},
AchievementCategory.MASTER_BUILDERS),
//Castle Siege
CASTLE_SIEGE_WINS("FOR THE KING!", 600,
new String[]{"Castle Siege.ForTheKing"},

View File

@ -12,136 +12,113 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager;
/**
* Created by Shaun on 8/21/2014.
* Edited by Chris on 9/13/2059.
*/
public enum AchievementCategory
{
GLOBAL("Global", null,
new String[] { "GemsEarned", null, "GamesPlayed", "TimeInGame" },
new String[] { "Gems Earned", null, "Games Played", "Time In Game" },
new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME },
Material.EMERALD, 0, GameCategory.GLOBAL, null),
//Survival
BRIDGES("The Bridges", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_PICKAXE, 0, GameCategory.SURVIVAL, "Destructor Kit"),
SURVIVAL_GAMES("Survival Games", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.IRON_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"),
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.DIAMOND_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"),
MINE_STRIKE("MineStrike", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.TNT, 0, GameCategory.CLASSICS, null),
WIZARDS("Wizards", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
UHC("Ultra Hardcore", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
WIZARDS("Wizards", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
MINE_STRIKE("MineStrike", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.TNT, 0, GameCategory.CLASSICS, null),
//Classics
SMASH_MOBS("Super Smash Mobs", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.SKULL_ITEM, 4, GameCategory.CLASSICS, "Sheep Kit"),
BLOCK_HUNT("Block Hunt", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GRASS, 0, GameCategory.CLASSICS, null),
MASTER_BUILDERS("Master Builders", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
Material.WOOD, 0, GameCategory.CLASSICS, null),
DRAW_MY_THING("Draw My Thing", null,
new String[] {"Wins", "Losses", "GemsEarned"},
new String[] {"Wins", "Losses", "GemsEarned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, null),
CASTLE_SIEGE("Castle Siege", null,
new String[] {"Wins", "Losses", "Kills as Defenders", "Deaths as Defenders", "Kills as Undead", "Deaths as Undead", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills as Defenders", "Deaths as Defenders", "Kills as Undead", "Deaths as Undead", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"),
new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED },
Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null),
//Champions
CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"),
//Arcade
DRAGONS("Dragons", null,
new String[] {"Wins", "Losses", "GemsEarned"},
new String[] {"Wins", "Losses", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
Material.ENDER_STONE, 0, GameCategory.ARCADE, null),
DRAGON_ESCAPE("Dragon Escape", null,
new String[] {"Wins", "Losses", "GemsEarned"},
new String[] {"Wins", "Losses", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED },
Material.DRAGON_EGG, 0, GameCategory.ARCADE, null),
SHEEP_QUEST("Sheep Quest", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.WOOL, 0, GameCategory.ARCADE, null),
SNEAKY_ASSASSINS("Sneaky Assassins", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.INK_SACK, 0, GameCategory.ARCADE, null),
ONE_IN_THE_QUIVER("One in the Quiver", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BOW, 0, GameCategory.ARCADE, null),
SUPER_PAINTBALL("Super Paintball", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.ENDER_PEARL, 0, GameCategory.ARCADE, null),
TURF_WARS("Turf Wars", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.HARD_CLAY, 14, GameCategory.ARCADE, null),
RUNNER("Runner", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null),
SPLEEF("Super Spleef", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_SPADE, 0, GameCategory.ARCADE, null),
DEATH_TAG("Death Tag", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.SKULL_ITEM, 0, GameCategory.ARCADE, null),
SNAKE("Snake", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.WOOL, 4, GameCategory.ARCADE, null),
BACON_BRAWL("Bacon Brawl", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.PORK, 0, GameCategory.ARCADE, null),
MICRO_BATTLE("Micro Battle", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.LAVA, 0, GameCategory.ARCADE, null),
;
@ -149,14 +126,13 @@ public enum AchievementCategory
private String _name;
private String[] _statsToPull;
private String[] _statsToDisplay;
private String[] _friendlyStatNames;
private StatDisplay[] _statDisplays;
private Material _icon;
private GameCategory _gameCategory;
private byte _iconData;
private String _kitReward;
AchievementCategory(String name, String[] statsToPull, String[] statsToDisplay, String[] friendlyStatNames, Material icon, int iconData, GameCategory gameCategory, String kitReward)
AchievementCategory(String name, String[] statsToPull, StatDisplay[] statDisplays, Material icon, int iconData, GameCategory gameCategory, String kitReward)
{
_name = name;
@ -164,9 +140,7 @@ public enum AchievementCategory
_statsToPull = statsToPull;
else
_statsToPull = new String[] {name};
_statsToDisplay = statsToDisplay;
_friendlyStatNames = friendlyStatNames;
_statDisplays = statDisplays;
_icon = icon;
_iconData = (byte)iconData;
_gameCategory = gameCategory;
@ -193,9 +167,9 @@ public enum AchievementCategory
return _statsToPull;
}
public String[] getStatsToDisplay()
public StatDisplay[] getStatsToDisplay()
{
return _statsToDisplay;
return _statDisplays;
}
public byte getIconData()
@ -208,11 +182,6 @@ public enum AchievementCategory
return _gameCategory;
}
public String[] getFriendlyStatNames()
{
return _friendlyStatNames;
}
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, Player player, Player target)
{
addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, target);
@ -221,29 +190,32 @@ public enum AchievementCategory
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, int max, Player player, Player target)
{
PlayerStats stats = statsManager.Get(target);
for (int i = 0; i < _statsToDisplay.length && i < max; i++)
for (int i = 0; i < _statDisplays.length && i < max; i++)
{
// If the stat is null then just display a blank line instead
if (_statsToDisplay[i] == null || _friendlyStatNames[i] == null)
if (_statDisplays[i] == null)
{
lore.add(" ");
continue;
}
String displayName = _statDisplays[i].getDisplayName();
// Skip showing Losses, Kills, Deaths for other players
if (!clientManager.Get(player).GetRank().Has(Rank.MODERATOR) && !player.equals(target) && (_statsToDisplay[i].contains("Losses") || _statsToDisplay[i].contains("Kills") || _statsToDisplay[i].contains("Deaths") || _statsToDisplay[i].equals("Time In Game") || _statsToDisplay.equals("Games Played")))
if (!clientManager.Get(player).GetRank().Has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
continue;
int statNumber = 0;
for (String statToPull : _statsToPull)
statNumber += stats.getStat(statToPull + "." + _statsToDisplay[i]);
for (String statName : _statDisplays[i].getStats())
statNumber += stats.getStat(statToPull + "." + statName);
String statString = C.cWhite + statNumber;
// Need to display special for time
if (_statsToDisplay[i].equalsIgnoreCase("TimeInGame"))
if (displayName.equalsIgnoreCase("Time In Game"))
statString = C.cWhite + UtilTime.convertString(statNumber * 1000L, 0, UtilTime.TimeUnit.FIT);
lore.add(C.cYellow + _friendlyStatNames[i] + ": " + statString);
lore.add(C.cYellow + displayName + ": " + statString);
}
}

View File

@ -0,0 +1,44 @@
package mineplex.core.achievement;
/**
* The purpose of extracting stats to this class is so we can display stats that are a combination
* of different stat values. For example, since we don't have a specific stat for games played of a game,
* we can use this class to display the stat "Games Played" that sums up "Wins" and "Losses"
* See: StatDisplay.GAMES_PLAYED_GAME
*/
public class StatDisplay
{
public String _displayName;
public String[] _stats;
public StatDisplay(String stat)
{
_displayName = stat;
_stats = new String[] { stat };
}
public StatDisplay(String displayName, String... stats)
{
_displayName = displayName;
_stats = stats;
}
public String getDisplayName()
{
return _displayName;
}
public String[] getStats()
{
return _stats;
}
public static final StatDisplay WINS = new StatDisplay("Wins");
public static final StatDisplay LOSSES = new StatDisplay("Losses");
public static final StatDisplay KILLS = new StatDisplay("Kills");
public static final StatDisplay DEATHS = new StatDisplay("Deaths");
public static final StatDisplay GEMS_EARNED = new StatDisplay("Gems Earned", "GemsEarned");
public static final StatDisplay TIME_IN_GAME = new StatDisplay("Time In Game", "TimeInGame");
public static final StatDisplay GAMES_PLAYED_GAME = new StatDisplay("Games Played", "Wins", "Losses");
}

View File

@ -22,9 +22,6 @@ import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.stats.StatsManager;
/**
* Created by Shaun on 8/21/2014.
*/
public class AchievementMainPage extends ShopPageBase<AchievementManager, AchievementShop>
{
protected Player _target;
@ -32,7 +29,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Player target)
{
super(plugin, shop, clientManager, donationManager, name, player);
super(plugin, shop, clientManager, donationManager, name, player, 9 * 4);
_target = target;
_statsManager = statsManager;
@ -45,11 +42,9 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
{
ArrayList<Integer> pageLayout = new ItemLayout(
"XXXXOXXXX",
"XXXXXXXXX",
"OXOXOXOXO",
"XXXXXXXXX",
"OXOXOXOXO",
"XXXXOXXXX").getItemSlots();
"XOXOXOXOX",
"XOXOXOXOX",
"XOXOXOXOX").getItemSlots();
int listSlot = 0;
for (AchievementCategory category : AchievementCategory.values())

View File

@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilTime;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -198,6 +199,30 @@ public class Chat extends MiniPlugin
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSignChange(SignChangeEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN)) return;
// Prevent silenced players from using signs
if (SilenceCheck(event.getPlayer()))
{
event.setCancelled(true);
return;
}
for (int i = 0; i < event.getLines().length; i++)
{
String line = event.getLine(i);
if (line != null && line.length() > 0)
{
String filteredLine = getFilteredMessage(event.getPlayer(), line);
if (filteredLine != null)
event.setLine(i, filteredLine);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void filterChat(AsyncPlayerChatEvent event)
@ -224,7 +249,7 @@ public class Chat extends MiniPlugin
originalMessage = originalMessage.replaceAll("[^\\x00-\\x7F]", "").trim();
final String filterType = "moderate";
final String displayName = player.getPlayerListName();
JSONObject message = buildJsonChatObject(filterType, displayName, playerName, originalMessage, _serverName, 1);
String response = getResponseFromCleanSpeak(message, filterType);

View File

@ -1,9 +1,11 @@
package mineplex.core.give;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
@ -43,13 +45,16 @@ public class Give extends MiniPlugin
help(player);
else if (args.length == 1)
give(player, player.getName(), args[0], "1");
give(player, player.getName(), args[0], "1", "");
else if (args.length == 2)
give(player, args[0], args[1], "1");
give(player, args[0], args[1], "1", "");
else if (args.length == 3)
give(player, args[0], args[1], args[2], "");
else
give(player, args[0], args[1], args[2]);
give(player, args[0], args[1], args[2], args[3]);
}
public void help(Player player)
@ -57,7 +62,7 @@ public class Give extends MiniPlugin
UtilPlayer.message(player, F.main("Give", "Commands List;"));
}
public void give(Player player, String target, String itemNames, String amount)
public void give(Player player, String target, String itemNames, String amount, String enchants)
{
//Item
LinkedList<Entry<Material, Byte>> itemList = new LinkedList<Entry<Material, Byte>>();
@ -97,7 +102,25 @@ public class Give extends MiniPlugin
{
UtilPlayer.message(player, F.main("Give", "Invalid Amount [" + amount + "]. Defaulting to [1]."));
}
//Enchants
HashMap<Enchantment, Integer> enchs = new HashMap<Enchantment, Integer>();
if (enchants.length() > 0)
{
for (String cur : enchants.split(","))
{
try
{
String[] tokens = cur.split(":");
enchs.put(Enchantment.getByName(tokens[0]), Integer.parseInt(tokens[1]));
}
catch (Exception e)
{
UtilPlayer.message(player, F.main("Give", "Invalid Enchantment [" + cur + "]."));
}
}
}
//Create
String givenList = "";
for (Player cur : giveList)
@ -110,7 +133,10 @@ public class Give extends MiniPlugin
for (Player cur : giveList)
{
ItemStack stack = ItemStackFactory.Instance.CreateStack(curItem.getKey(), curItem.getValue(), count);
//Enchants
stack.addUnsafeEnchantments(enchs);
//Give
if (UtilInv.insert(cur, stack))
{

View File

@ -98,10 +98,10 @@ public class InventoryRepository extends RepositoryBase
public boolean incrementClientInventoryItem(int accountId, int itemId, int count)
{
System.out.println("Updating " + accountId + "'s " + itemId + " with " + count);
//System.out.println("Updating " + accountId + "'s " + itemId + " with " + count);
if (executeUpdate(UPDATE_CLIENT_INVENTORY, new ColumnInt("count", count), new ColumnInt("id", accountId), new ColumnInt("itemid", itemId)) < 1)
{
System.out.println("Inserting " + accountId + "'s " + itemId + " with " + count);
//System.out.println("Inserting " + accountId + "'s " + itemId + " with " + count);
return executeUpdate(INSERT_CLIENT_INVENTORY, new ColumnInt("id", accountId), new ColumnInt("itemid", itemId), new ColumnInt("count", count)) > 0;
}
else

View File

@ -4,4 +4,6 @@ public class ClientMessage
{
public String LastTo;
public String LastAdminTo;
public long LastToTime;
public int SpamCounter;
}

View File

@ -1,5 +1,6 @@
package mineplex.core.message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.UUID;
@ -49,7 +50,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
private PreferencesManager _preferences;
private Punish _punish;
private Chat _chat;
private LinkedList<String> _randomMessage;
private ArrayList<String> _randomMessage;
private String _serverName;
public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences,
@ -190,6 +191,25 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
return;
}
// My attempt at trying to mitigate some of the spam bots - Phinary
// Triggers if they are whispering a new player
if (!GetClientManager().Get(from).GetRank().Has(Rank.HELPER) && Get(from).LastTo != null && !Get(from).LastTo.equalsIgnoreCase(to.getName()))
{
long delta = System.currentTimeMillis() - Get(from).LastToTime;
if (Get(from).SpamCounter > 3 && delta < Get(from).SpamCounter * 1000)
{
from.sendMessage(F.main("Cooldown", "Try sending that message again in a few seconds"));
Get(from).LastTo = to.getName();
return;
}
else if (delta < 8000)
{
// Silently increment spam counter whenever delta is less than 8 seconds
Get(from).SpamCounter++;
}
}
message = _chat.getFilteredMessage(from, message);
// Inform
@ -197,11 +217,12 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
// Save
Get(from).LastTo = to.getName();
Get(from).LastToTime = System.currentTimeMillis();
// Chiss or defek7
if (to.getName().equals("Chiss") || to.getName().equals("defek7"))
if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary"))
{
UtilPlayer.message(from, C.cPurple + to.getName() + "is often AFK or minimized, due to plugin development.");
UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development.");
UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
}
@ -254,7 +275,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
@Override
public void enable()
{
_randomMessage = new LinkedList<String>();
_randomMessage = new ArrayList<String>();
_randomMessage.clear();
_randomMessage.add("Hello, do you have any wild boars for purchase?");
_randomMessage.add("There's a snake in my boot!");
@ -307,7 +328,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
return _randomMessage.get(UtilMath.r(_randomMessage.size()));
}
public LinkedList<String> GetRandomMessages()
public ArrayList<String> GetRandomMessages()
{
return _randomMessage;
}

View File

@ -349,6 +349,9 @@ public class NpcManager extends MiniPlugin
UtilEnt.Vegetate(entity);
UtilEnt.silence(entity, true);
UtilEnt.ghost(entity, true, false);
// Add Look AI
UtilEnt.addLookAtPlayerAI(entity, 10.0F);
}
if (npc.getDatabaseRecord().getHelmet() != null)

View File

@ -120,7 +120,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
new Field(plugin, creature, _condition, energy, serverName);
DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager);
DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager, _condition);
new Weapon(plugin, energy);
new Gameplay(plugin, this, blockRestore, damageManager);

View File

@ -146,7 +146,7 @@ public class Hub extends JavaPlugin implements IRelation
ProjectileManager throwManager = new ProjectileManager(this);
SkillConditionManager conditionManager = new SkillConditionManager(this);
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager);
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager);
Fire fire = new Fire(this, conditionManager, damage);
Teleport teleport = new Teleport(this);
Energy energy = new Energy(this);

View File

@ -39,7 +39,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, quickShop, clientManager, donationManager, name, player, 56);
super(plugin, quickShop, clientManager, donationManager, name, player, 47);
createSuperSmashCycle();
createMinigameCycle();

View File

@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.damage;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
@ -16,6 +17,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.npc.NpcManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.compatibility.NpcProtectListener;
import net.minecraft.server.v1_7_R4.DamageSource;
import net.minecraft.server.v1_7_R4.EntityHuman;
@ -28,6 +30,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Fish;
import org.bukkit.entity.LivingEntity;
@ -42,24 +45,28 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import com.sun.jndi.ldap.ManageReferralControl;
public class DamageManager extends MiniPlugin
{
private CombatManager _combatManager;
private DisguiseManager _disguiseManager;
private ConditionManager _conditionManager;
protected Field _lastDamageByPlayerTime;
protected Method _k;
public boolean UseSimpleWeaponDamage = false;
public boolean DisableDamageChanges = false;
private boolean _enabled = true;
public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager)
public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager, ConditionManager conditionManager)
{
super("Damage Manager", plugin);
_combatManager = combatManager;
_disguiseManager = disguiseManager;
_conditionManager = conditionManager;
try
{
@ -100,9 +107,9 @@ public class DamageManager extends MiniPlugin
//Pre-Event Modifications
if (!DisableDamageChanges)
WeaponDamage(event, damager);
double damage = event.getDamage();
//Consistent Arrow Damage
if (projectile != null && projectile instanceof Arrow)
{
@ -113,7 +120,7 @@ public class DamageManager extends MiniPlugin
NewDamageEvent(damagee, damager, projectile, event.getCause(), damage, true, false, false, null, null, preCancel);
//System.out.println(UtilEnt.getName(damagee) + " by " + event.getCause() + " at " + UtilWorld.locToStr(damagee.getLocation()));
event.setCancelled(true);
}
@ -123,7 +130,7 @@ public class DamageManager extends MiniPlugin
if (event.isCancelled())
{
Projectile projectile = GetProjectile(event);
if (projectile instanceof Arrow)
{
projectile.teleport(new Location(projectile.getWorld(), 0, 0, 0));
@ -191,7 +198,7 @@ public class DamageManager extends MiniPlugin
event.SetCancelled("Damagee in Creative");
return;
}
if (UtilPlayer.isSpectator(damagee))
{
event.SetCancelled("Damagee in Spectator");
@ -230,13 +237,80 @@ public class DamageManager extends MiniPlugin
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void handleEnchants(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
//Defensive
Player damagee = event.GetDamageePlayer();
if (damagee != null)
{
for (ItemStack stack : damagee.getInventory().getArmorContents())
{
if (stack == null)
continue;
Map<Enchantment, Integer> enchants = stack.getEnchantments();
for (Enchantment e : enchants.keySet())
{
if (e.equals(Enchantment.PROTECTION_ENVIRONMENTAL))
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FIRE) &&
event.GetCause() == DamageCause.FIRE &&
event.GetCause() == DamageCause.FIRE_TICK &&
event.GetCause() == DamageCause.LAVA)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FALL) &&
event.GetCause() == DamageCause.FALL)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_EXPLOSIONS) &&
event.GetCause() == DamageCause.ENTITY_EXPLOSION)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_PROJECTILE) &&
event.GetCause() == DamageCause.PROJECTILE)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
}
}
}
//Offensive
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
{
ItemStack stack = damager.getItemInHand();
if (stack == null)
return;
Map<Enchantment, Integer> enchants = stack.getEnchantments();
for (Enchantment e : enchants.keySet())
{
if (e.equals(Enchantment.ARROW_KNOCKBACK) || e.equals(Enchantment.KNOCKBACK))
event.AddKnockback("Ench Knockback", 1 + (0.5 * (double)enchants.get(e)));
else if (e.equals(Enchantment.ARROW_DAMAGE))
event.AddMod("Enchant", "Ench Damage", 0.5 * (double)enchants.get(e), true);
else if (e.equals(Enchantment.ARROW_FIRE) || e.equals(Enchantment.FIRE_ASPECT))
if (_conditionManager != null)
_conditionManager.Factory().Ignite("Ench Fire", event.GetDamageeEntity(), damager,
1 * (double)enchants.get(e), false, false);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void EndDamageEvent(CustomDamageEvent event)
{
if (!event.IsCancelled() && event.GetDamage() > 0)
{
Damage(event);
//DING ARROW
if (event.GetProjectile() != null && event.GetProjectile() instanceof Arrow)
{
@ -247,7 +321,7 @@ public class DamageManager extends MiniPlugin
}
}
}
DisplayDamage(event);
}
@ -255,10 +329,10 @@ public class DamageManager extends MiniPlugin
{
if (event.GetDamageeEntity() == null)
return;
if (event.GetDamageeEntity().getHealth() <= 0)
return;
//Player Conditions
if (event.GetDamageePlayer() != null)
{
@ -293,29 +367,34 @@ public class DamageManager extends MiniPlugin
//Sticky Arrow
if (event.GetCause() == DamageCause.PROJECTILE)
((CraftLivingEntity)event.GetDamageeEntity()).getHandle().p(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().aZ() + 1);
//Knockback
double knockback = event.GetDamage();
if (knockback < 2) knockback = 2;
knockback = Math.log10(knockback);
for (double cur : event.GetKnockback().values())
knockback = knockback * cur;
if (event.IsKnockback() && event.GetDamagerEntity(true) != null)
{
//Base
double knockback = event.GetDamage();
if (knockback < 2) knockback = 2;
knockback = Math.log10(knockback);
if (event.IsKnockback())
if (event.GetDamagerEntity(true) != null)
{
Location origin = event.GetDamagerEntity(true).getLocation();
if (event.getKnockbackOrigin() != null)
origin = event.getKnockbackOrigin();
Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation());
trajectory.multiply(0.6 * knockback);
trajectory.setY(Math.abs(trajectory.getY()));
//Mults
for (double cur : event.GetKnockback().values())
knockback = knockback * cur;
//Origin
Location origin = event.GetDamagerEntity(true).getLocation();
if (event.getKnockbackOrigin() != null)
origin = event.getKnockbackOrigin();
//Vec
Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation());
trajectory.multiply(0.6 * knockback);
trajectory.setY(Math.abs(trajectory.getY()));
//Apply
UtilAction.velocity(event.GetDamageeEntity(),
trajectory, 0.2 + trajectory.length() * 0.8, false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true);
}
UtilAction.velocity(event.GetDamageeEntity(),
trajectory, 0.2 + trajectory.length() * 0.8, false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true);
}
}
catch (IllegalAccessException e)
{
@ -365,7 +444,7 @@ public class DamageManager extends MiniPlugin
{
EntityLiving entityDamagee = ((CraftLivingEntity)damagee).getHandle();
EntityLiving entityDamager = null;
if (damager != null)
entityDamager= ((CraftLivingEntity)damager).getHandle();
@ -426,7 +505,7 @@ public class DamageManager extends MiniPlugin
LivingEntity damagee = event.GetDamageeEntity();
if (damagee == null) return;
if (_disguiseManager.isDisguised(damagee))
{
_disguiseManager.getDisguise(damagee).playHurtSound();
@ -576,7 +655,7 @@ public class DamageManager extends MiniPlugin
return null;
}
public void SetEnabled(boolean var)
{
_enabled = var;
@ -586,4 +665,9 @@ public class DamageManager extends MiniPlugin
{
return _combatManager;
}
public void setConditionManager(ConditionManager cm)
{
_conditionManager = cm;
}
}

View File

@ -105,7 +105,7 @@ public class Arcade extends JavaPlugin
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, null);
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);

View File

@ -84,6 +84,7 @@ import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
@ -214,7 +215,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Modules
_blockRestore = new BlockRestore(plugin);
_blood = blood;
_preferencesManager = preferences;
@ -222,8 +222,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_explosionManager.SetDebris(false);
if (serverConfig.GameList.contains(GameType.ChampionsDominate)
|| serverConfig.GameList.contains(GameType.ChampionsTDM)
|| serverConfig.GameList.contains(GameType.ChampionsMOBA))
|| serverConfig.GameList.contains(GameType.ChampionsTDM)
|| serverConfig.GameList.contains(GameType.ChampionsMOBA))
{
_conditionManager = new SkillConditionManager(plugin);
}
@ -231,7 +231,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
_conditionManager = new ConditionManager(plugin);
}
_clientManager = clientManager;
_serverStatusManager = serverStatusManager;
_chat = chat;
@ -239,7 +239,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_damageManager = damageManager;
_damageManager.UseSimpleWeaponDamage = true;
_damageManager.setConditionManager(_conditionManager);
_disguiseManager = disguiseManager;
_donationManager = donationManager;

View File

@ -10,7 +10,7 @@ public class YoutubeCommand extends CommandBase<ArcadeManager>
{
public YoutubeCommand(ArcadeManager plugin)
{
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE}, "youtube");
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, new String[] {"youtube", "twitch"});
}
@Override

View File

@ -54,6 +54,7 @@ public class GameTeam
}
private String _name;
private String _displayName;
private ChatColor _color;
private HashMap<Player, PlayerState> _players = new HashMap<Player, PlayerState>();
@ -75,6 +76,7 @@ public class GameTeam
{
Host = host;
_displayName = name;
_name = name;
_color = color;
_spawns = spawns;
@ -139,11 +141,19 @@ public class GameTeam
{
_players.put(player, in ? PlayerState.IN : PlayerState.OUT);
UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + _name + " Team") + ".");
UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + _displayName + " Team."));
VisibilityManager.Instance.refreshPlayerToAll(player);
}
public void DisbandTeam()
{
for (Player player : _players.keySet())
UtilPlayer.message(player, F.main("Team", _color + C.Bold + _displayName + " Team was disbanded."));
_players.clear();
}
public void RemovePlayer(Player player)
{
_players.remove(player);
@ -261,6 +271,11 @@ public class GameTeam
{
_name = name;
}
public void setDisplayName(String name)
{
_displayName = name;
}
public byte GetColorData()
{
@ -375,4 +390,6 @@ public class GameTeam
return _places;
}
}

View File

@ -11,6 +11,7 @@ import nautilus.game.arcade.kit.*;
import nautilus.game.arcade.stats.TeamDeathsStatTracker;
import nautilus.game.arcade.stats.TeamKillsStatTracker;
import org.bukkit.Bukkit;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
@ -71,9 +72,9 @@ public abstract class TeamGame extends Game
if (player.isDead())
return;
if (player.getWorld().getName().equalsIgnoreCase("world"))
return;
return;
if (!QuitOut)
{
@ -83,7 +84,7 @@ public abstract class TeamGame extends Game
if (GetKit(player) != null)
RejoinKit.put(player.getName(), GetKit(player));
RejoinHealth.put(player.getName(), player.getHealth());
GetLocationStore().put(player.getName(), player.getLocation());
@ -110,22 +111,40 @@ public abstract class TeamGame extends Game
Kit kit = RejoinKit.remove(event.getPlayer().getName());
if (kit != null)
_playerKit.put(event.getPlayer(), kit);
if (RejoinHealth.containsKey(event.getPlayer().getName()))
event.getPlayer().setHealth(RejoinHealth.remove(event.getPlayer().getName()));
// final Player player = event.getPlayer();
// Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
// {
// @Override
// public void run()
// {
// if (RejoinHealth.containsKey(player.getName()))
// {
// double health = RejoinHealth.remove(player.getName());
// player.setHealth(health);
// player.sendMessage("DEBUG: restored hp to " + health);
// }
// }
// }, 20);
return;
}
/*
//Owner Bypass
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER))
}
//Do this on Join, not Login, otherwise player no get heal.
@EventHandler
public void playerRejoinGame(PlayerJoinEvent event)
{
if (!InProgress() || QuitOut)
return;
//Disallow
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.YELLOW + "You cannot join this UHC.");
*/
Player player = event.getPlayer();
if (RejoinHealth.containsKey(player.getName()))
{
double health = RejoinHealth.remove(player.getName());
player.setHealth(health);
}
}
@EventHandler

View File

@ -179,8 +179,22 @@ public class Build extends SoloGame
_words = new String[]
{
"Rollercoaster", "Archery Range", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", "Burger", "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Cannon", "Catapult", "Sailing Boat", "Grim Reaper", "Star Wars", "Elephant", "Penguin", "Ninja", "Pot of Gold", "Shrek", "Fruit", "Breakfast", "Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Flying Creature", "Beach Creature", "Sea Creature", "Spongebob", "Car", "Potted Plant", "Weapons", "Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Aeroplane"
"Rollercoaster", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House",
"Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Pot of Gold", "Shrek", "Fruit", "Breakfast",
"Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Spongebob", "Car", "Potted Plant", "Weapons",
"Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Helicopter", "Knight", "Rabbit",
"Sandwich", "Snowman", "Basketball", "Ice Cream", "Sea Shell", "Lightbulb", "Rainbow", "iPad", "Crayon",
"Volcano", "Hot Tub", "Octopus", "Ghost", "Ant", "Cheese", "Kite", "Reptile", "Leaning Tower Pisa",
"Disney", "Space Ship", "Pixel Art", "Chicken", "Shoe", "Owl", "Bear", "Flowers", "Teapot", "Lighthouse",
"Lion", "Grandfather Clock", "Nintendo", "Television", "Batman", "Tiger", "Computer", "Castle", "House",
"Bed", "Party", "Volleyball", "Toys", "Hula Hooper", "Bow", "Library", "Love", "Seasons", "Skull",
"Hat", "Snake", "Vacation", "Umbrella", "Magic", "Tornado", "Candy", "Dentist", "Pizza", "Bird",
"Superhero", "Turtle", "Chicken", "School", "Build Anything!", "Cabin", "Coral Reef", "Food", "Picnic",
"Trophy", "Pool", "Telephone", "Cell Phone", "Hot Air Balloon", "Train", "Candyland", "Chocolate Bar",
"Mountain", "Potato", "Glasses", "Domino", "Clown", "River", "Mario", "Luigi", "Windmill", "Alligator",
"Police", "Igloo", "Puppy", "Gift", "Harry Potter", "Desk", "Bumblebee", "Jellyfish", "Speedboat",
"Fall", "Summer", "Autumn", "Winter", "Sunset", "Calculator", "Disco", "Giant", "Moose", "Salad",
"Water Gun", "Astronaut", "Kitchen", "Wither", "Meteor"
};
_mobShop = new MobShop(getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation());

View File

@ -32,7 +32,8 @@ public class GroundPage extends ShopPageBase<ArcadeManager, OptionsShop>
new GroundData(Material.STAINED_CLAY, (byte) 0), new GroundData(Material.STAINED_CLAY, (byte) 15),
new GroundData(Material.STAINED_CLAY, (byte) 4), new GroundData(Material.STAINED_CLAY, (byte) 3),
new GroundData(Material.STAINED_CLAY, (byte) 5), new GroundData(Material.STAINED_CLAY, (byte) 6),
new GroundData(Material.QUARTZ_BLOCK)};
new GroundData(Material.QUARTZ_BLOCK), new GroundData(Material.ICE), new GroundData(Material.IRON_BLOCK),
new GroundData(Material.GOLD_BLOCK), new GroundData(Material.DIAMOND_BLOCK)};
private Build _game;

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.build.gui.page;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.entity.Ageable;
@ -155,7 +156,6 @@ public class MobPage extends ShopPageBase<ArcadeManager, MobShop>
}
// Entity look at player (Currently Bugged)
/*
if (_entity instanceof LivingEntity)
{
ShopItem lookAtMe = new ShopItem(Material.GHAST_TEAR, "Look at Me", null, 0, false);
@ -164,16 +164,26 @@ public class MobPage extends ShopPageBase<ArcadeManager, MobShop>
@Override
public void onClick(Player player, ClickType clickType)
{
Location entityLocation = _entity.getLocation();
entityLocation.setDirection(player.getLocation().getDirection().multiply(-1));
_entity.teleport(entityLocation);
final Location newLoc = _entity.getLocation();
newLoc.setDirection(player.getLocation().getDirection().multiply(-1));
((CraftLivingEntity) _entity).getHandle().setPositionRotation(newLoc.getX(), newLoc.getY(), newLoc.getZ(), newLoc.getYaw(), newLoc.getPitch());
((CraftLivingEntity) _entity).getHandle().g(0.05, 0.0, 0.05);
getPlugin().runSyncLater(new Runnable()
{
@Override
public void run()
{
_entity.teleport(newLoc);
}
}, 1L);
UtilPlayer.message(player, F.main("Game", entityName + " is now looking at you"));
}
});
buttonSlot += 2;
}
*/
// Delete Entity
ShopItem deleteButton = new ShopItem(Material.TNT, "Delete " + entityName, null, 0, false);

View File

@ -78,7 +78,7 @@ import nautilus.game.arcade.managers.GameHostManager;
public class EventGame extends SoloGame
{
private GameHostManager _mps;
private GameHostManager _mps;
private String[] _sideText = new String[] {
" "," "," "," "," "," "," "," "," "," "," "," "
@ -89,7 +89,7 @@ public class EventGame extends SoloGame
private NautHashMap<String, Integer> _forcefield = new NautHashMap<String, Integer>();
private ItemStack[] _kitItems = new ItemStack[6];
private boolean _allowAllGadgets = false;
private HashSet<SalesPackageBase> _gadgetWhitelist = new HashSet<SalesPackageBase>();
@ -176,38 +176,40 @@ public class EventGame extends SoloGame
private void commandHelp(Player player)
{
UtilPlayer.message(player, F.main("Event", "Displaying Commands;"));
UtilPlayer.message(player, F.value("/e settings", "View Settings Help"));
UtilPlayer.message(player, F.value("/e tp <Player>", "Teleport to Target"));
UtilPlayer.message(player, F.value("/e tp here <Player>", "Teleport Target to Self"));
UtilPlayer.message(player, F.value("/e tp here all", "Teleport Everyone to Self"));
UtilPlayer.message(player, F.value("/e gadget", "Toggle Gadgets"));
UtilPlayer.message(player, F.value("/e gadget list", "Lists Gadgets (Shows Whitelist)"));
UtilPlayer.message(player, F.value("/e gadget <Gadget>", "Toggles Whitelist for Gadget"));
UtilPlayer.message(player, F.value("/e gadget clear", "Clears Gadget Whitelist"));
UtilPlayer.message(player, F.value("/e silence [Time]", "Silence Chat"));
UtilPlayer.message(player, F.value("/e admin [Player]", "Toggle Event Admin"));
UtilPlayer.message(player, F.value("/e gm [Player]", "Toggle Creative Mode"));
UtilPlayer.message(player, F.value("/e radius [Radius]", "Set Forcefield Radius"));
UtilPlayer.message(player, F.value("/e give <item> <amount>", "Give Item to Self"));
UtilPlayer.message(player, F.value("/e give <player> <item> <amount>", "Give Item to Player"));
UtilPlayer.message(player, F.value("/e give <item> <amount>", "Give Item"));
UtilPlayer.message(player, F.value("/e give <player> <item> <amount> [e:#,e:#...]", "Give Item"));
UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump"));
UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text"));
UtilPlayer.message(player, F.value("/e mob <type> [#Amount] n[Name] s[Size] [angry] [baby]", ""));
UtilPlayer.message(player, F.value("/e mob kill <type>", "Kill Mobs"));
UtilPlayer.message(player, F.value("/e kit set", "Sets Player Kit to your Hotbar"));
UtilPlayer.message(player, F.value("/e kit apply", "Gives Kit to Players"));
UtilPlayer.message(player, F.value("/e kit clear", "Gives Kit to Players"));
UtilPlayer.message(player, F.value("/e effect <player> <type> <mult> <seconds>", ""));
UtilPlayer.message(player, F.value("/e effect <player> clear", ""));
}
@ -276,6 +278,10 @@ public class EventGame extends SoloGame
{
commandSilence(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("admin"))
{
commandAdmin(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("gm"))
{
commandGamemode(event.getPlayer(), args);
@ -590,7 +596,7 @@ public class EventGame extends SoloGame
commandHelpSettings(player);
}
private void commandTime(Player player, String[] args)
{
try
@ -680,32 +686,32 @@ public class EventGame extends SoloGame
Announce(F.main("Inventory", F.value("Allow All Gadgets", F.ed(_allowAllGadgets))));
return;
}
if (args.length >= 2 && args[1].equalsIgnoreCase("clear"))
{
_gadgetWhitelist.clear();
Announce(F.main("Inventory", F.value("Gadget Whitelist", "Cleared.")));
return;
}
if (args.length >= 2 && args[1].equalsIgnoreCase("list"))
{
ChatColor color = ChatColor.AQUA;
//Gadgets
for (GadgetType type : GadgetType.values())
{
String items = C.Bold + type + " Gadgets> ";
for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type))
{
items += color + gadget.GetName().replaceAll(" ", "") + " ";
color = (color == ChatColor.AQUA ? ChatColor.DARK_AQUA : ChatColor.AQUA);
}
UtilPlayer.message(player, items);
}
//Mounts
String mounts = C.Bold + "Mount Gadgets> ";
for (Mount<?> mount : Manager.getCosmeticManager().getMountManager().getMounts())
@ -714,10 +720,10 @@ public class EventGame extends SoloGame
color = (color == ChatColor.AQUA ? ChatColor.DARK_AQUA : ChatColor.AQUA);
}
UtilPlayer.message(player, mounts);
return;
}
if (args.length >= 2)
{
//Gadgets
@ -737,12 +743,12 @@ public class EventGame extends SoloGame
Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget", F.ed(true))));
_gadgetWhitelist.add(gadget);
}
return;
}
}
}
//Mounts
for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts())
{
@ -758,16 +764,16 @@ public class EventGame extends SoloGame
Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget", F.ed(true))));
_gadgetWhitelist.add(mount);
}
return;
}
}
UtilPlayer.message(player, F.main("Inventory", args[1] + " is not a valid gadget."));
return;
}
commandHelp(player);
}
@ -804,6 +810,28 @@ public class EventGame extends SoloGame
}
}
//Gamemode (Self and Others)
private void commandAdmin(Player player, String[] args)
{
Player target = player;
if (args.length >= 2)
{
Player newTarget = UtilPlayer.searchOnline(player, args[1], true);
if (newTarget != null)
target = newTarget;
else
return;
}
if (Manager.GetGameHostManager().isAdmin(target, false))
Manager.GetGameHostManager().giveAdmin(target);
else
Manager.GetGameHostManager().removeAdmin(target.getName());
UtilPlayer.message(player, F.main("Event Admin", target.getName() + " Admin: " + F.tf(Manager.GetGameHostManager().isAdmin(target, false))));
}
//Gamemode (Self and Others)
private void commandGamemode(Player player, String[] args)
{
@ -856,13 +884,13 @@ public class EventGame extends SoloGame
private void commandGive(Player player, String[] args)
{
String[] newArgs = new String[args.length-1];
for (int i=0 ; i<newArgs.length ; i++)
newArgs[i] = args[i+1];
Give.Instance.parseInput(player, newArgs);
}
Give.Instance.parseInput(player, newArgs);
}
//Double Jump
private void commandDoubleJump(Player player, String[] args)
{
@ -1245,44 +1273,44 @@ public class EventGame extends SoloGame
UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed."));
}
private void commandKit(Player caller, String[] args)
{
if (args.length >= 2 && args[1].equalsIgnoreCase("apply"))
{
for (Player player : UtilServer.getPlayers())
giveItems(player);
Announce(F.main("Event Settings", F.value("Player Kit", "Applied to Players")));
return;
}
if (args.length >= 2 && args[1].equalsIgnoreCase("clear"))
{
_kitItems = new ItemStack[6];
Announce(F.main("Event Settings", F.value("Player Kit", "Cleared Kit")));
_kitItems = new ItemStack[6];
Announce(F.main("Event Settings", F.value("Player Kit", "Cleared Kit")));
return;
}
if (args.length >= 2 && args[1].equalsIgnoreCase("set"))
{
_kitItems = new ItemStack[6];
for (int i=0 ; i<6 ; i++)
{
if (caller.getInventory().getItem(i) != null)
_kitItems[i] = caller.getInventory().getItem(i).clone();
else
_kitItems[i] = null;
}
Announce(F.main("Event Settings", F.value("Player Kit", "Updated Items")));
return;
_kitItems = new ItemStack[6];
for (int i=0 ; i<6 ; i++)
{
if (caller.getInventory().getItem(i) != null)
_kitItems[i] = caller.getInventory().getItem(i).clone();
else
_kitItems[i] = null;
}
Announce(F.main("Event Settings", F.value("Player Kit", "Updated Items")));
return;
}
commandHelp(caller);
}
private void commandEffect(Player caller, String[] args)
{
//Clear
@ -1302,12 +1330,12 @@ public class EventGame extends SoloGame
if (targets.isEmpty())
return;
}
for (Player player : targets)
{
//Remove all conditions
Manager.GetCondition().EndCondition(player, null, null);
//Remove all effects
player.removePotionEffect(PotionEffectType.ABSORPTION);
player.removePotionEffect(PotionEffectType.BLINDNESS);
@ -1333,10 +1361,10 @@ public class EventGame extends SoloGame
player.removePotionEffect(PotionEffectType.WEAKNESS);
player.removePotionEffect(PotionEffectType.WITHER);
}
return;
}
//Apply
if (args.length >= 5)
{
@ -1354,7 +1382,7 @@ public class EventGame extends SoloGame
if (targets.isEmpty())
return;
}
//Get Type
PotionEffectType type = PotionEffectType.getByName(args[2]);
if (type == null)
@ -1363,7 +1391,7 @@ public class EventGame extends SoloGame
UtilPlayer.message(caller, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect"));
return;
}
//Get Multiplier
int mult = 0;
try
@ -1380,7 +1408,7 @@ public class EventGame extends SoloGame
UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Level: " + args[3]));
return;
}
//Get Duration
int dur = 0;
try
@ -1395,25 +1423,25 @@ public class EventGame extends SoloGame
UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Duration: " + args[4]));
return;
}
//Apply
PotionEffect effect = new PotionEffect(type, dur*20, mult);
for (Player cur : targets)
{
cur.addPotionEffect(effect);
}
if (args[1].equalsIgnoreCase("all"))
Announce(F.main("Effect", F.value("Applied Effect", type.getName() + " " + (mult+1) + " for " + dur + "s")));
else
UtilPlayer.message(caller, F.main("Effect", "Applied " + type.getName() + " " + (mult+1) + " for " + dur + "s for Targets."));
return;
}
commandHelp(caller);
}
@EventHandler
public void doubleJumpTrigger(PlayerToggleFlightEvent event)
{
@ -1500,7 +1528,7 @@ public class EventGame extends SoloGame
if (_mps.isAdmin(other, false))
continue;
int range = _forcefield.get(player.getName());
if (UtilMath.offset(other, player) > range)
@ -1613,10 +1641,10 @@ public class EventGame extends SoloGame
{
if (_kitItems[i] == null)
continue;
player.getInventory().addItem(_kitItems[i].clone());
}
UtilInv.Update(player);
}
@ -1626,13 +1654,13 @@ public class EventGame extends SoloGame
if (event.getSpawnReason() != SpawnReason.CUSTOM)
event.setCancelled(true);
}
@EventHandler
public void gadgetDisable(GadgetActivateEvent event)
{
if (_allowAllGadgets)
return;
if (!_gadgetWhitelist.contains(event.getGadget()))
{
event.setCancelled(true);
@ -1640,13 +1668,13 @@ public class EventGame extends SoloGame
//event.getPlayer().closeInventory();
}
}
@EventHandler
public void mountDisable(MountActivateEvent event)
{
if (_allowAllGadgets)
return;
if (!_gadgetWhitelist.contains(event.getMount()))
{
event.setCancelled(true);
@ -1654,7 +1682,7 @@ public class EventGame extends SoloGame
//event.getPlayer().closeInventory();
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void entityDeathEvent(EntityDeathEvent event)
{

View File

@ -15,11 +15,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
@ -46,6 +48,8 @@ public class SnowFight extends TeamGame
{
"Just like... kill your enemies. with snow."
});
this.HungerSet = 20;
}
@ -80,11 +84,12 @@ public class SnowFight extends TeamGame
if (!IsSnow(event.getBlock()))
return;
if (player.getInventory().getHeldItemSlot() != 0)
if (UtilInv.contains(player, Material.SNOW_BALL, (byte)0, 16))
return;
//Item
SnowballCount(player, 1);
UtilInv.insert(player, new ItemStack(Material.SNOW_BALL));
//Snow Height
SnowDecrease(event.getBlock(), 1);
@ -93,83 +98,83 @@ public class SnowFight extends TeamGame
event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, 80);
}
@EventHandler
public void InteractSnowball(PlayerInteractEvent event)
{
Player player = event.getPlayer();
// @EventHandler
// public void InteractSnowball(PlayerInteractEvent event)
// {
// Player player = event.getPlayer();
//
// if (!IsLive())
// return;
//
// if (!IsPlaying(player))
// return;
//
// if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL))
// return;
//
// event.setCancelled(true);
//
// if (UtilEvent.isAction(event, ActionType.L))
// SnowballThrow(player);
//
// else if (UtilEvent.isAction(event, ActionType.R_BLOCK))
// SnowballPlace(player, event.getClickedBlock(), 1);
// }
//
// private void SnowballPlace(Player player, Block block, int above)
// {
// if (block.getTypeId() == 78 || UtilBlock.airFoliage(block))
// {
// //Build
// if (block.getTypeId() == 78)
// {
// block.setTypeIdAndData(78, (byte)(block.getData() + 1), true);
//
// if (block.getData() >= 7)
// block.setTypeIdAndData(80, (byte)0, true);
// }
// else
// {
// block.setTypeIdAndData(78, (byte)0, true);
// }
//
// //Sound
// block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, 0.6f);
//
// //Use Snow
// SnowballCount(player, -1);
// }
// else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0)
// {
// SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1);
// }
// }
//
// private void SnowballThrow(Player player)
// {
// //Throw
// player.launchProjectile(Snowball.class);
//
// //Use Snow
// SnowballCount(player, -1);
//
// //Sound
// player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, 1.5f);
// }
if (!IsLive())
return;
if (!IsPlaying(player))
return;
if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL))
return;
event.setCancelled(true);
if (UtilEvent.isAction(event, ActionType.L))
SnowballThrow(player);
else if (UtilEvent.isAction(event, ActionType.R_BLOCK))
SnowballPlace(player, event.getClickedBlock(), 1);
}
private void SnowballPlace(Player player, Block block, int above)
{
if (block.getTypeId() == 78 || UtilBlock.airFoliage(block))
{
//Build
if (block.getTypeId() == 78)
{
block.setTypeIdAndData(78, (byte)(block.getData() + 1), true);
if (block.getData() >= 7)
block.setTypeIdAndData(80, (byte)0, true);
}
else
{
block.setTypeIdAndData(78, (byte)0, true);
}
//Sound
block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, 0.6f);
//Use Snow
SnowballCount(player, -1);
}
else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0)
{
SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1);
}
}
private void SnowballThrow(Player player)
{
//Throw
player.launchProjectile(Snowball.class);
//Use Snow
SnowballCount(player, -1);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, 1.5f);
}
private void SnowballCount(Player player, int count)
{
if (player.getInventory().getItem(1) != null)
count += player.getInventory().getItem(1).getAmount();
if (count > 16)
count = 16;
if (count > 0)
player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count));
else
player.getInventory().setItem(1, null);
}
// private void SnowballCount(Player player, int count)
// {
// if (player.getInventory().getItem(1) != null)
// count += player.getInventory().getItem(1).getAmount();
//
// if (count > 16)
// count = 16;
//
// if (count > 0)
// player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count));
// else
// player.getInventory().setItem(1, null);
// }
private void SnowDecrease(Block block, int height)
{

View File

@ -14,11 +14,9 @@ import org.bukkit.Sound;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLargeFireball;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
@ -37,6 +35,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
@ -44,6 +43,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
@ -54,7 +55,6 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -65,14 +65,11 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.PacketPlayOutWorldBorder;
import mineplex.core.recharge.Recharge;
@ -81,22 +78,30 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatLog;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.serverdata.Utility;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_7_R4.EntityLargeFireball;
public class UHC extends TeamGame
{
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
private NautHashMap<String, Long> _deathTime = new NautHashMap<String, Long>();
// private NautHashMap<String, Long> _combatTime = new NautHashMap<String, Long>();
private int _yMax = 0;
private boolean _mapLoaded = false;
private double _mapLoadPercent = 0;
private int _chunksPerTick = 1;
private int _chunkTotal;
private Chunk _chunk = null;
private int _chunkX = 0;
private int _chunkZ = 0;
@ -110,7 +115,7 @@ public class UHC extends TeamGame
private long _createTime;
private long _serverTime;
private boolean _mapLoaded = false;
private boolean xrayDebug = false;
@ -185,7 +190,7 @@ public class UHC extends TeamGame
this.VersionRequire1_8 = true;
WorldTimeSet = -1;
CraftRecipes();
// Disable Custom Mob Drops (and EXP Disable)
@ -211,6 +216,7 @@ public class UHC extends TeamGame
_chunkX = (int) -(_currentBorder / 16);
_chunkZ = (int) -(_currentBorder / 16);
_chunkTotal = (int) ((_currentBorder * 2 / 16) * (_currentBorder * 2 / 16));
WorldData.MinX = -1000;
WorldData.MinZ = -1000;
@ -296,10 +302,6 @@ public class UHC extends TeamGame
double border = (_previousBorder - 0.3D) + distanceMovedSince;
// 24 @ 100+ reduced to 0 at 32-
double borderAttackDist = Math.max(8, (Math.min(100, border) - 28d) / 3d);
double borderCheckDist = borderAttackDist + 6;
for (Player player : UtilServer.getPlayers())
{
Location loc = player.getLocation();
@ -326,84 +328,6 @@ public class UHC extends TeamGame
}
}
}
if (border < 32)
continue;
// Attack Players who are nearby
boolean isX = true;
Location attackSource = null;
if (loc.getX() > (border - borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setX(border);
}
else if (loc.getX() < (-border - borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setX(border);
}
else if (loc.getZ() > (border - borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setZ(border);
isX = false;
}
else if (loc.getZ() < (-border - borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setZ(border);
isX = false;
}
if (attackSource != null)
{
double dist = UtilMath.offset(player.getLocation(), attackSource);
double scale = 1 - (dist / borderAttackDist);
player.playSound(player.getLocation().add(UtilAlg.getTrajectory(player.getLocation(), attackSource).multiply(8)),
Sound.PORTAL, (float) (1 - (dist / borderCheckDist)) * 2, 2f);
if (!Manager.IsAlive(player))
continue;
// Shoot more frequently when they get closer
if (dist < borderAttackDist && Math.random() < scale)
{
// Spawn Fireball
Location spawn = attackSource.clone();
spawn.add(isX ? 0 : (Math.random() - 0.5) * 12, 4 + Math.random() * 2 + (Math.random() * 12 * scale),
isX ? (Math.random() - 0.5) * 12 : 0);
// Raytrace back
double maxBack = 8;
double back = 0;
while (spawn.getBlock().getType() == Material.AIR && back < maxBack)
{
spawn.subtract(UtilAlg.getTrajectory(spawn, player.getLocation()).multiply(0.2));
back += 0.1;
}
// Move out of block
spawn.add(UtilAlg.getTrajectory(spawn, player.getLocation()).multiply(Math.min(back, 1)));
Fireball ball = player.getWorld().spawn(spawn, Fireball.class);
// Trajectory
Vector traj = UtilAlg.getTrajectory(spawn, player.getLocation());
traj.add(new Vector((Math.random() - 0.5) * 0.2, (Math.random() - 0.5) * 0.2, (Math.random() - 0.5) * 0.2));
EntityLargeFireball eFireball = ((CraftLargeFireball) ball).getHandle();
eFireball.dirX = traj.getX() * 0.1;
eFireball.dirY = traj.getY() * 0.1;
eFireball.dirZ = traj.getZ() * 0.1;
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, spawn, 0, 0, 0, 0, 1, ViewDist.MAX,
UtilServer.getPlayers());
player.getWorld().playSound(attackSource, Sound.GHAST_FIREBALL, 2f, 2f);
}
}
}
}
@ -472,19 +396,15 @@ public class UHC extends TeamGame
if (WorldData.World == null)
return;
int chunksPerTick = 20;
if (GetState() != GameState.Recruit)
return;
// Print Debug
if (event.getType() == UpdateType.SLOW)
if (event.getType() == UpdateType.SLOWER)
{
int chunkTotal = (int) ((_currentBorder * 2 / 16) * (_currentBorder * 2 / 16));
int chunksToGo = chunkTotal - _chunksLoaded;
Announce(C.cGreen + C.Bold + "Generating Map: " + ChatColor.RESET
+ UtilTime.MakeStr((long) ((double) chunksToGo / (double) (20 * chunksPerTick) * 1000d), 1) + " Remaining...");
Announce(C.cGreen + C.Bold + "Generating Map: " + C.cWhite + getMapLoadETA() + " Remaining...", false);
TimingManager.endTotal("UHC Generation", true);
return;
}
@ -495,11 +415,11 @@ public class UHC extends TeamGame
// Timings
TimingManager.startTotal("UHC Generation");
for (int i = 0; i < chunksPerTick; i++)
for (int i = 0; i < _chunksPerTick ; i++)
{
// Unload Previous
if (_chunk != null)
_chunk.unload(true);
// if (_chunk != null)
// _chunk.unload(true);
// Load Chunks
_chunk = WorldData.World.getChunkAt(_chunkX, _chunkZ);
@ -517,8 +437,6 @@ public class UHC extends TeamGame
}
else
{
Announce(C.cGreen + C.Bold + "Generating Map: " + ChatColor.RESET + "Complete!");
_mapLoaded = true;
System.out.println("Map Loading Finished!");
generateSpawns();
@ -527,10 +445,26 @@ public class UHC extends TeamGame
_chunksLoaded++;
}
_mapLoadPercent = (double)_chunksLoaded / (double)_chunkTotal;
// Timings
TimingManager.stopTotal("UHC Generation");
}
@EventHandler
public void chunkUnload(ChunkUnloadEvent event)
{
//Allow unloading after players in
if (IsLive())
return;
if (WorldData.World != null && event.getWorld().equals(WorldData.World))
{
System.out.println("Disallowing Unload of World");
event.setCancelled(true);
}
}
public void generateSpawns()
{
@ -552,8 +486,8 @@ public class UHC extends TeamGame
// Dynamically scale distance requirement based on how many teams need to fit
double dist = (2 * _currentBorder) / (Math.sqrt(this.GetPlayers(true).size()) + 3);
// Ensure distance between Teams
while (true)
// Ensure distance between Teams - 500 Attempts
for (int i=0 ; i<500 ; i++)
{
boolean clash = false;
@ -585,8 +519,8 @@ public class UHC extends TeamGame
// Dynamically scale distance requirement based on how many teams need to fit
double dist = (2 * _currentBorder) / (Math.sqrt(GetTeamList().size()) + 3);
// Ensure distance between Teams
while (true)
// Ensure distance between Teams - 500 Attempts
for (int i=0 ; i<500 ; i++)
{
boolean clash = false;
@ -1537,7 +1471,7 @@ public class UHC extends TeamGame
// Not Loaded (but still joinable)
if (!_mapLoaded)
{
return ChatColor.GOLD + "Generating Map...";
return ChatColor.GREEN + "Generating Map (" + C.cWhite + getMapLoadETA() + C.cGreen + ")";
}
return ChatColor.GREEN + "Recruiting";
@ -1717,4 +1651,150 @@ public class UHC extends TeamGame
{
return _mapLoaded;
}
public String getMapLoadPercent()
{
return (int)(_mapLoadPercent * 100) + "%";
}
public String getMapLoadETA()
{
int chunksToGo = _chunkTotal - _chunksLoaded;
return UtilTime.MakeStr((long) ((double)chunksToGo / (double)(_chunksPerTick * 20) * 1000d), 1);
}
@EventHandler(priority = EventPriority.HIGH)
public void teamSelectInteract(PlayerInteractEntityEvent event)
{
if (GetState() != GameState.Recruit)
return;
if (event.getRightClicked() == null)
return;
if (!(event.getRightClicked() instanceof Player))
return;
Player player = event.getPlayer();
//Observer
if (Manager.IsObserver(player))
{
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
return;
}
selectTeamMate(player, (Player)event.getRightClicked());
}
@EventHandler
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
{
if (GetState() != GameState.Recruit)
return;
if (!event.getMessage().toLowerCase().startsWith("/team "))
return;
event.setCancelled(true);
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
if (target == null)
return;
//Observer
if (Manager.IsObserver(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
return;
}
selectTeamMate(event.getPlayer(), target);
}
public void selectTeamMate(Player player, Player ally)
{
//Accept Invite
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
{
//Remove Prefs
_teamReqs.remove(player);
_teamReqs.remove(ally);
//Inform
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
//Leave Old Teams
if (GetTeam(player) != null)
GetTeam(player).DisbandTeam();
if (GetTeam(ally) != null)
GetTeam(ally).DisbandTeam();
//Get Team
GameTeam team = getEmptyTeam();
if (team == null)
return;
//Join Team
SetPlayerTeam(player, team, true);
SetPlayerTeam(ally, team, true);
team.setDisplayName(player.getName() + " & " + ally.getName());
}
//Send Invite
else
{
//Already on Team with Target
if (GetTeam(player) != null)
if (GetTeam(player).HasPlayer(ally))
return;
//Inform Player
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
//Inform Target
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
{
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
}
//Add Pref
_teamReqs.put(player, ally);
}
}
@EventHandler
public void teamQuit(PlayerQuitEvent event)
{
if (GetState() != GameState.Recruit)
return;
Player player = event.getPlayer();
if (GetTeam(player) != null)
GetTeam(player).DisbandTeam();
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
while (teamIter.hasNext())
{
Player sender = teamIter.next();
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
teamIter.remove();
}
}
public GameTeam getEmptyTeam()
{
for (GameTeam team : GetTeamList())
{
if (team.GetPlayers(false).isEmpty())
return team;
}
return null;
}
}

View File

@ -32,151 +32,153 @@ import nautilus.game.arcade.gui.spectatorMenu.button.SpectatorButton;
public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
{
private ArcadeManager _arcadeManager;
private ArcadeManager _arcadeManager;
public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, SpectatorShop shop, CoreClientManager clientManager,
DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Spectator Menu", player);
_arcadeManager = arcadeManager;
buildPage();
}
public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, SpectatorShop shop, CoreClientManager clientManager,
DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Spectator Menu", player);
_arcadeManager = arcadeManager;
buildPage();
}
@Override
protected void buildPage()
{
int playerCount = _arcadeManager.GetGame().GetPlayers(true).size();
List<GameTeam> teamList = _arcadeManager.GetGame().GetTeamList();
@Override
protected void buildPage()
{
int playerCount = _arcadeManager.GetGame().GetPlayers(true).size();
List<GameTeam> teamList = _arcadeManager.GetGame().GetTeamList();
if (teamList.size() == 1 && playerCount < 28)
buildSingleTeam(teamList.get(0), playerCount);
else
buildMultipleTeams(teamList, playerCount);
if (teamList.size() == 1 && playerCount < 28)
buildSingleTeam(teamList.get(0), playerCount);
else
buildMultipleTeams(teamList, playerCount);
}
}
private void buildSingleTeam(GameTeam team, int playerCount)
{
setItem(13, getTeamItem(team, playerCount));
ArrayList<Player> players = team.GetPlayers(true);
Collections.sort(players, new Comparator<Player>()
{
private void buildSingleTeam(GameTeam team, int playerCount)
{
setItem(13, getTeamItem(team, playerCount));
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
ArrayList<Player> players = team.GetPlayers(true);
int slot = 19;
Collections.sort(players, new Comparator<Player>()
{
for (Player other : players)
{
addPlayerItem(slot, team, other);
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
if ((slot + 2) % 9 == 0)
slot += 3;
else
slot++;
}
}
});
private void buildMultipleTeams(List<GameTeam> teamList, int playerCount)
{
int currentRow = 0;
int slot = 19;
for (GameTeam team : teamList)
{
ArrayList<Player> teamPlayers = team.GetPlayers(true);
int rowsNeeded = (teamPlayers.size() / 8) + 1;
Collections.sort(teamPlayers, new Comparator<Player>()
{
for (Player other : players)
{
addPlayerItem(slot, team, other);
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
if ((slot + 2) % 9 == 0)
slot += 3;
else
slot++;
}
}
for (int row = 0; row < rowsNeeded; row++)
{
int woolSlot = (row * 9) + (currentRow * 9);
private void buildMultipleTeams(List<GameTeam> teamList, int playerCount)
{
int currentRow = 0;
// TODO Need to handle too many players in a better way
if (woolSlot >= getSize())
continue;
for (GameTeam team : teamList)
{
ArrayList<Player> teamPlayers = team.GetPlayers(true);
int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0);
setItem(woolSlot, getTeamItem(team, teamPlayers.size()));
Collections.sort(teamPlayers, new Comparator<Player>()
{
int startPlayerIndex = row * 9;
for (int playerIndex = startPlayerIndex; playerIndex < teamPlayers.size() && playerIndex < startPlayerIndex + 9; playerIndex++)
{
Player other = teamPlayers.get(playerIndex);
int slot = woolSlot + 1 + playerIndex;
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
// TODO Need to handle too many players in a better way
if (slot >= getSize())
continue;
});
addPlayerItem(slot, team, other);
}
}
for (int row = 0; row < rowsNeeded; row++)
{
int woolSlot = (row * 9) + (currentRow * 9);
// Add a line in between teams if the player count is low enough and there are less than 4 teams
if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26)
currentRow += 2;
else
currentRow += rowsNeeded;
}
}
// TODO Need to handle too many players in a better way
if (woolSlot >= getSize())
continue;
private void addPlayerItem(int slot, GameTeam team, Player other)
{
ItemStack playerItem = getPlayerItem(team, other);
ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false);
addButton(slot, shopItem, new SpectatorButton(_arcadeManager, getPlayer(), other));
}
setItem(woolSlot, getTeamItem(team, teamPlayers.size()));
private ItemStack getTeamItem(GameTeam team, int playerCount)
{
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, UtilColor.chatColorToWoolData(team.GetColor()));
int startPlayerIndex = row * 8;
int count = 0;
for (int playerIndex = startPlayerIndex; playerIndex < teamPlayers.size() && count < 8; playerIndex++)
{
count++;
Player other = teamPlayers.get(playerIndex);
int slot = woolSlot + 1 + playerIndex;
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(team.GetFormattedName());
meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + "Players Alive: " + C.cWhite + playerCount));
item.setItemMeta(meta);
// TODO Need to handle too many players in a better way
if (slot >= getSize())
continue;
return item;
}
addPlayerItem(slot, team, other);
}
}
private ItemStack getPlayerItem(GameTeam team, Player other)
{
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
// Add a line in between teams if the player count is low enough and there are less than 4 teams
if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26)
currentRow += 2;
else
currentRow += rowsNeeded;
}
}
double distance = UtilMath.offset(getPlayer(), other);
double heightDifference = other.getLocation().getY() - getPlayer().getLocation().getY();
private void addPlayerItem(int slot, GameTeam team, Player other)
{
ItemStack playerItem = getPlayerItem(team, other);
ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false);
addButton(slot, shopItem, new SpectatorButton(_arcadeManager, getPlayer(), other));
}
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite + _arcadeManager.GetGame().GetKit(other).GetName());
lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite + UtilMath.trim(1, distance));
lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + UtilMath.trim(1, heightDifference));
lore.add(" ");
lore.add(ChatColor.RESET + C.Line + "Click to Spectate");
SkullMeta skullMeta = ((SkullMeta) item.getItemMeta());
skullMeta.setOwner(other.getName());
skullMeta.setDisplayName(team.GetColor() + other.getName());
skullMeta.setLore(lore);
item.setItemMeta(skullMeta);
private ItemStack getTeamItem(GameTeam team, int playerCount)
{
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, UtilColor.chatColorToWoolData(team.GetColor()));
return item;
}
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(team.GetFormattedName());
meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + "Players Alive: " + C.cWhite + playerCount));
item.setItemMeta(meta);
return item;
}
private ItemStack getPlayerItem(GameTeam team, Player other)
{
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
double distance = UtilMath.offset(getPlayer(), other);
double heightDifference = other.getLocation().getY() - getPlayer().getLocation().getY();
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite + _arcadeManager.GetGame().GetKit(other).GetName());
lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite + UtilMath.trim(1, distance));
lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + UtilMath.trim(1, heightDifference));
lore.add(" ");
lore.add(ChatColor.RESET + C.Line + "Click to Spectate");
SkullMeta skullMeta = ((SkullMeta) item.getItemMeta());
skullMeta.setOwner(other.getName());
skullMeta.setDisplayName(team.GetColor() + other.getName());
skullMeta.setLore(lore);
item.setItemMeta(skullMeta);
return item;
}
}

View File

@ -509,7 +509,7 @@ public class GameHostManager implements Listener
public int getMaxPlayerCap()
{
if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE)
if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE || _hostRank == Rank.TWITCH)
return 100;
else if (hasRank(Rank.LEGEND))
return 40;

View File

@ -35,10 +35,10 @@ import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.WatchableObject;
import mineplex.core.account.CoreClient;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
@ -70,6 +70,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.KitSorter;
@ -110,6 +111,8 @@ public class GameLobbyManager implements Listener, IPacketHandler
private boolean _handlingPacket = false;
private String _serverName;
private boolean _colorTick = false;
public GameLobbyManager(ArcadeManager manager, PacketHandler packetHandler)
{
@ -130,7 +133,7 @@ public class GameLobbyManager implements Listener, IPacketHandler
_teamDisplay = new Location(world, 18, 101, 0);
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
_serverName = Manager.getPlugin().getConfig().getString("serverstatus.name");
_serverName = _serverName.substring(0, Math.min(16, _serverName.length()));
}
@ -327,50 +330,52 @@ public class GameLobbyManager implements Listener, IPacketHandler
//UHC
if (game.GetType() == GameType.UHC)
{
if (game.GetTeamList().size() > 1)
{
//Text
WriteTeamLine("", 0, 159, (byte)15);
WriteTeamLine("", 1, 159, (byte)4);
for (int i=0 ; i<game.GetTeamList().size() ; i++)
{
GameTeam team = game.GetTeamList().get(i);
//Circle Math
double lead = i * ((2d * Math.PI)/game.GetTeamList().size());
double sizeMod = 32;
double oX = -Math.sin(lead) * sizeMod;
double oZ = Math.cos(lead) * sizeMod;
//Location
Location entLoc = spawn.clone().add(oX, 0, oZ);
entLoc.setY(_teamDisplay.getY());
//Blocks
SetKitTeamBlocks(entLoc.clone(), 35, team.GetColorData(), _teamBlocks);
entLoc.add(0, 1.5, 0);
entLoc.getChunk().load();
//NPC
Sheep ent = (Sheep)Manager.GetCreature().SpawnEntity(entLoc, EntityType.SHEEP);
ent.setRemoveWhenFarAway(false);
ent.setCustomNameVisible(false);
ent.setColor(DyeColor.getByWoolData(team.GetColorData()));
UtilEnt.Vegetate(ent);
team.SetTeamEntity(ent);
_teams.put(ent, new LobbyEnt(ent, entLoc, team));
}
return;
}
// if (game.GetTeamList().size() > 1)
// {
// //Text
// WriteTeamLine("", 0, 159, (byte)15);
// WriteTeamLine("", 1, 159, (byte)4);
//
// for (int i=0 ; i<game.GetTeamList().size() ; i++)
// {
// GameTeam team = game.GetTeamList().get(i);
//
// //Circle Math
// double lead = i * ((2d * Math.PI)/game.GetTeamList().size());
// double sizeMod = 32;
// double oX = -Math.sin(lead) * sizeMod;
// double oZ = Math.cos(lead) * sizeMod;
//
// //Location
// Location entLoc = spawn.clone().add(oX, 0, oZ);
// entLoc.setY(_teamDisplay.getY());
//
// //Blocks
// SetKitTeamBlocks(entLoc.clone(), 35, team.GetColorData(), _teamBlocks);
//
// entLoc.add(0, 1.5, 0);
//
// entLoc.getChunk().load();
//
// //NPC
// Sheep ent = (Sheep)Manager.GetCreature().SpawnEntity(entLoc, EntityType.SHEEP);
// ent.setRemoveWhenFarAway(false);
// ent.setCustomNameVisible(false);
//
// ent.setColor(DyeColor.getByWoolData(team.GetColorData()));
//
// UtilEnt.Vegetate(ent);
//
// team.SetTeamEntity(ent);
//
// _teams.put(ent, new LobbyEnt(ent, entLoc, team));
// }
//
// return;
//
// }
return;
}
//Standard
@ -912,11 +917,11 @@ public class GameLobbyManager implements Listener, IPacketHandler
return;
if (Manager.GetGame() != null &&
(Manager.GetGame().GetState() != GameState.Loading &&
Manager.GetGame().GetState() != GameState.Recruit))
(Manager.GetGame().GetState() != GameState.Loading &&
Manager.GetGame().GetState() != GameState.Recruit))
{
for (Player player : UtilServer.getPlayers())
player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard());
player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard()); //XXX
}
else
@ -934,8 +939,8 @@ public class GameLobbyManager implements Listener, IPacketHandler
}
}
}
@EventHandler
//this is called from above
public void ScoreboardSet(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
@ -946,6 +951,8 @@ public class GameLobbyManager implements Listener, IPacketHandler
return;
}
_colorTick = !_colorTick;
for (Entry<Player, Scoreboard> entry : _scoreboardMap.entrySet())
{
Objective objective = entry.getValue().getObjective("§l" + "Lobby");
@ -959,7 +966,14 @@ public class GameLobbyManager implements Listener, IPacketHandler
}
else
{
objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players");
if (Manager.GetGame() instanceof UHC && !((UHC)Manager.GetGame()).isMapLoaded())
{
objective.setDisplayName(((UHC)Manager.GetGame()).getMapLoadPercent() + " " + (_colorTick ? ChatColor.GREEN : ChatColor.YELLOW) + "§l" + "Generating Map");
}
else
{
objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players");
}
}
int line = 15;
@ -1203,21 +1217,42 @@ public class GameLobbyManager implements Listener, IPacketHandler
rankName = Rank.ULTRA.Name;
}
teamName = rankName + teamName;
String rankTeamName = rankName + teamName;
for (Scoreboard scoreboard : GetScoreboards())
{
try
{
scoreboard.getTeam(teamName).addPlayer(player);
scoreboard.getTeam(rankTeamName).addPlayer(player);
}
catch (Exception e)
{
System.out.println("GameLobbyManager AddPlayerToScoreboard Error");
System.out.println("[" + rankName + teamName + "] adding [" + player.getName() + "]");
System.out.println("Team is Null [" + (scoreboard.getTeam(rankName + teamName) == null) + "]");
//UHC adds people to teams earlier than usual, which can case this
if (Manager.GetGame() instanceof UHC)
{
try
{
Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName).addPlayer(player);
System.out.println("GameLobbyManager UHC Team Assignment Success");
break;
}
catch(Exception f)
{
System.out.println("GameLobbyManager AddPlayerToScoreboard UHC Error");
System.out.println("[" + teamName + "] adding [" + player.getName() + "]");
System.out.println("Team is Null [" + (Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName) == null) + "]");
}
}
else
{
System.out.println("GameLobbyManager AddPlayerToScoreboard Error");
System.out.println("[" + rankTeamName + "] adding [" + player.getName() + "]");
System.out.println("Team is Null [" + (scoreboard.getTeam(rankTeamName) == null) + "]");
}
}
}
}
@EventHandler

View File

@ -239,7 +239,7 @@ public class GameManager implements Listener
if (force)
game.SetCountdownForce(true);
//Team Preference
TeamPreferenceJoin(game);

View File

@ -93,14 +93,15 @@ public class WorldData
FileUtil.DeleteFolder(dir);
dir = new File(GetFolder() + "/level.dat");
dir.delete();
if (dir.exists())
dir.delete();
//Create Fresh World with Random Seed
WorldCreator creator = new WorldCreator(GetFolder());
creator.seed(UtilMath.r(999999999));
creator.environment(Environment.NORMAL);
creator.generateStructures(true);
World = creator.createWorld();
World = WorldUtil.LoadWorld(creator);
}
else
{