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;
@ -77,6 +82,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)
{
Vegetate(entity, false);

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"),
UHC("Ultra Hardcore", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "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"),
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 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.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 StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
//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;
@ -199,6 +200,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)
{

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>>();
@ -98,6 +103,24 @@ 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)
@ -111,6 +134,9 @@ public class Give extends MiniPlugin
{
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,10 +45,13 @@ 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;
@ -54,12 +60,13 @@ public class DamageManager extends MiniPlugin
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
{
@ -230,6 +237,73 @@ 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)
{
@ -295,27 +369,32 @@ public class DamageManager extends MiniPlugin
((CraftLivingEntity)event.GetDamageeEntity()).getHandle().p(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().aZ() + 1);
//Knockback
if (event.IsKnockback() && event.GetDamagerEntity(true) != null)
{
//Base
double knockback = event.GetDamage();
if (knockback < 2) knockback = 2;
knockback = Math.log10(knockback);
//Mults
for (double cur : event.GetKnockback().values())
knockback = knockback * cur;
if (event.IsKnockback())
if (event.GetDamagerEntity(true) != null)
{
//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);
}
}
catch (IllegalAccessException e)
{
@ -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;
@ -239,6 +239,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_damageManager = damageManager;
_damageManager.UseSimpleWeaponDamage = true;
_damageManager.setConditionManager(_conditionManager);
_disguiseManager = disguiseManager;

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);
@ -262,6 +272,11 @@ public class GameTeam
_name = name;
}
public void setDisplayName(String name)
{
_displayName = name;
}
public byte GetColorData()
{
if (GetColor() == ChatColor.WHITE) return (byte)0;
@ -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.*;
@ -111,21 +112,39 @@ public abstract class TeamGame extends Game
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

@ -190,12 +190,14 @@ public class EventGame extends SoloGame
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"));
@ -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);
@ -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)
{

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;
@ -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);
}
}
}
}
@ -473,17 +397,13 @@ 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();
@ -528,10 +446,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()
{
// Wipe Spawns
@ -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

@ -92,7 +92,7 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
for (GameTeam team : teamList)
{
ArrayList<Player> teamPlayers = team.GetPlayers(true);
int rowsNeeded = (teamPlayers.size() / 8) + 1;
int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0);
Collections.sort(teamPlayers, new Comparator<Player>()
{
@ -115,9 +115,11 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
setItem(woolSlot, getTeamItem(team, teamPlayers.size()));
int startPlayerIndex = row * 9;
for (int playerIndex = startPlayerIndex; playerIndex < teamPlayers.size() && playerIndex < startPlayerIndex + 9; playerIndex++)
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;

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;
@ -111,6 +112,8 @@ public class GameLobbyManager implements Listener, IPacketHandler
private boolean _handlingPacket = false;
private String _serverName;
private boolean _colorTick = false;
public GameLobbyManager(ArcadeManager manager, PacketHandler packetHandler)
{
Manager = manager;
@ -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));
}
// 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
@ -916,7 +921,7 @@ public class GameLobbyManager implements Listener, IPacketHandler
Manager.GetGame().GetState() != GameState.Recruit))
{
for (Player player : UtilServer.getPlayers())
player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard());
player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard()); //XXX
}
else
@ -935,7 +940,7 @@ 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");
@ -958,9 +965,16 @@ public class GameLobbyManager implements Listener, IPacketHandler
objective.setDisplayName(ChatColor.WHITE + "§lIn Progress...");
}
else
{
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,23 +1217,44 @@ 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)
{
//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("[" + rankName + teamName + "] adding [" + player.getName() + "]");
System.out.println("Team is Null [" + (scoreboard.getTeam(rankName + teamName) == null) + "]");
System.out.println("[" + rankTeamName + "] adding [" + player.getName() + "]");
System.out.println("Team is Null [" + (scoreboard.getTeam(rankTeamName) == null) + "]");
}
}
}
}
@EventHandler
public void disallowInventoryClick(InventoryClickEvent event)
{

View File

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