Merge branches 'develop' and 'feature/report' of ssh://dev.mineplex.com:7999/min/mineplex into feature/report

# Conflicts:
#	Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java
This commit is contained in:
Keir Nellyer 2016-01-31 17:38:08 +00:00
commit 9601eabfeb
37 changed files with 1363 additions and 189 deletions

View File

@ -38,7 +38,7 @@ public class LobbyBalancer implements Listener, Runnable
loadLobbyServers();
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
_plugin.getProxy().getScheduler().schedule(_plugin, this, 250L, 250L, TimeUnit.MILLISECONDS);
_plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS);
}
@EventHandler

View File

@ -36,7 +36,7 @@ public class PlayerCount implements Listener, Runnable
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
_plugin = plugin;
_plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS);
_plugin.getProxy().getScheduler().schedule(_plugin, this, 4L, 4L, TimeUnit.SECONDS);
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
_listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next();

View File

@ -10,6 +10,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -89,14 +90,14 @@ public class UtilItem
_materials.put(Material.FURNACE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
_materials.put(Material.BURNING_FURNACE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING, ItemCategory.GUI));
_materials.put(Material.SIGN_POST, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.WOODEN_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.WOODEN_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR));
_materials.put(Material.LADDER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.CLIMBABLE));
_materials.put(Material.RAILS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.COBBLESTONE_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.WALL_SIGN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.LEVER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.STONE_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.IRON_DOOR_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.IRON_DOOR_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR));
_materials.put(Material.WOOD_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
_materials.put(Material.REDSTONE_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.REDSTONE));
_materials.put(Material.GLOWING_REDSTONE_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.REDSTONE));
@ -121,7 +122,7 @@ public class UtilItem
_materials.put(Material.DIODE_BLOCK_OFF, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE));
_materials.put(Material.DIODE_BLOCK_ON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE));
_materials.put(Material.STAINED_GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
_materials.put(Material.TRAP_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.TRAP_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR));
_materials.put(Material.MONSTER_EGGS, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.SMOOTH_BRICK, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.HUGE_MUSHROOM_1, EnumSet.of(ItemCategory.BLOCK));
@ -199,7 +200,7 @@ public class UtilItem
_materials.put(Material.SLIME_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.BARRIER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.IRON_TRAPDOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
_materials.put(Material.IRON_TRAPDOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR));
_materials.put(Material.PRISMARINE, EnumSet.of(ItemCategory.BLOCK));
_materials.put(Material.SEA_LANTERN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING));
_materials.put(Material.STANDING_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
@ -217,16 +218,16 @@ public class UtilItem
_materials.put(Material.SPRUCE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.BIRCH_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.JUNGLE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.SPRUCE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.BIRCH_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.JUNGLE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.ACACIA_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.DARK_OAK_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.SPRUCE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.BIRCH_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.JUNGLE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.ACACIA_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.DARK_OAK_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.DARK_OAK_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.ACACIA_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.DARK_OAK_DOOR_ITEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
_materials.put(Material.DARK_OAK_DOOR_ITEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR));
// Items
@ -241,10 +242,10 @@ public class UtilItem
_materials.put(Material.MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE));
_materials.put(Material.COOKED_MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
_materials.put(Material.BANNER, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.SPRUCE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.BIRCH_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.JUNGLE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.ACACIA_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
_materials.put(Material.SPRUCE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.BIRCH_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.JUNGLE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.ACACIA_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR));
_materials.put(Material.IRON_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.SHOVEL));
@ -315,13 +316,13 @@ public class UtilItem
_materials.put(Material.PAINTING, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.GOLDEN_APPLE, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
_materials.put(Material.SIGN, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.WOOD_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
_materials.put(Material.WOOD_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK, ItemCategory.DOOR));
_materials.put(Material.BUCKET, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.WATER_BUCKET, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.LAVA_BUCKET, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
_materials.put(Material.SADDLE, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.IRON_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
_materials.put(Material.IRON_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK, ItemCategory.DOOR));
_materials.put(Material.REDSTONE, EnumSet.of(ItemCategory.ITEM, ItemCategory.REDSTONE));
_materials.put(Material.SNOW_BALL, EnumSet.of(ItemCategory.ITEM, ItemCategory.THROWABLE));
_materials.put(Material.BOAT, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
@ -977,6 +978,16 @@ public class UtilItem
return isArmor(stack == null ? null : stack.getType());
}
public static boolean is(ItemStack stack, ItemCategory category)
{
return stack == null ? false : contains(stack.getType(), category);
}
public static boolean is(Block block, ItemCategory category)
{
return block == null ? false : contains(block.getType(), category);
}
private static boolean contains(Material material, ItemCategory category)
{
EnumSet<ItemCategory> set = _materials.get(material);
@ -1047,7 +1058,8 @@ public class UtilItem
BLOCK,
ITEM_BLOCK,
LOG,
LEAVES;
LEAVES,
DOOR
}
public enum ArmorMaterial

View File

@ -64,7 +64,7 @@ public class PlayerCountManager extends MiniPlugin
@EventHandler
public void refresh(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
if (event.getType() != UpdateType.SEC_08)
return;
runAsync(this::updatePlayerCount);

View File

@ -100,7 +100,7 @@ public class Punish extends MiniPlugin
}
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOW)
public void PunishChatEvent(AsyncPlayerChatEvent event)
{
PunishClient client = GetClient(event.getPlayer().getName());

View File

@ -103,6 +103,17 @@ public class ClanWarData
_clanAPoints--;
else throw new RuntimeException("ClanWarData::increment Invalid Clan for War. ClanA: " + _clanA + ", ClanB: " + _clanB + ", Lookup Clan: " + clan);
}
public void set(String clan, int points)
{
update();
if (_clanA.equals(clan))
_clanAPoints++;
else if (_clanB.equals(clan))
_clanAPoints--;
else throw new RuntimeException("ClanWarData::increment Invalid Clan for War. ClanA: " + _clanA + ", ClanB: " + _clanB + ", Lookup Clan: " + clan);
}
private void update()
{

View File

@ -106,9 +106,9 @@ public class Clans extends JavaPlugin
Teleport teleport = new Teleport(this, _clientManager);
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
new ClansBanManager(this, _clientManager, _donationManager);
new ClansBanManager(this, _clientManager, _donationManager);
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false);
@ -140,7 +140,7 @@ public class Clans extends JavaPlugin
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
HologramManager hologram = new HologramManager(this, packetHandler);
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress);
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress);
new Recipes(this);
new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager);

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.core.war.ClanWarData;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -25,7 +26,7 @@ public class ClansAdmin
public void command(Player caller, String[] args)
{
if (!Clans.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.isOp())
if (!Clans.getClientManager().hasRank(caller, Rank.ADMIN) && !Clans.getClientManager().Get(caller).GetRank().equals(Rank.CMOD) && !caller.isOp())
{
return;
}
@ -80,6 +81,9 @@ public class ClansAdmin
else if (args[1].equalsIgnoreCase("autoclaim"))
autoclaim(caller);
else if (args[1].equalsIgnoreCase("wp"))
wp(caller, args);
else
help(caller);
@ -89,23 +93,24 @@ public class ClansAdmin
{
UtilPlayer.message(caller, F.main("Clans Admin", "Admin Commands List;"));
UtilPlayer.message(caller, F.help("/c x create <clan>", "Create Admin Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x create <clan>", "Create Admin Clan", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x set <clan>", "Set Mimic Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c x set <clan>", "Set Mimic Clan", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x wp [remove/set/add] <number> <clan>", "Modify war points", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x home (set)", "Teleport to Mimic Home", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x invite <player>", "Invite Player to Mimic", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x promote <player>", "Promote Player in Mimic", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x demote <player>", "Demote Player in Mimic", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x kick <player>", "Kick Player from Mimic", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x ally <clan>", "Send Alliance to Mimic", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x trust <clan>", "Give Trust to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x neutral <clan>", "Set Neutrality", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x enemy <clan>", "Start Invasion", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x claim", "Claim Territory for Mimic", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c x home (set)", "Teleport to Mimic Home", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x invite <player>", "Invite Player to Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x promote <player>", "Promote Player in Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x demote <player>", "Demote Player in Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x kick <player>", "Kick Player from Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x ally <clan>", "Send Alliance to Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x trust <clan>", "Give Trust to Clan", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x neutral <clan>", "Set Neutrality", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x enemy <clan>", "Start Invasion", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x claim", "Claim Territory for Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.CMOD));
UtilPlayer.message(caller, F.main("Mimic Clan", Clans.Get(caller).getMimic()));
}
@ -269,6 +274,64 @@ public class ClansAdmin
}
});
}
public void wp(Player caller, String[] args)
{
ClanInfo clan = getMimic(caller, true);
if (clan == null)
return;
if (args.length < 5)
{
UtilPlayer.message(caller, F.main("Clans Admin", "You did not supply an operation, value, and clan name."));
return;
}
ClanInfo clanAgainst = Clans.getClan(args[4]);
if (clanAgainst == null)
{
UtilPlayer.message(caller, F.main("Clans Admin", "Invalid Clan against provided."));
return;
}
String operation = args[2];
int value;
try
{
value = Integer.parseInt(args[3]);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Clans Admin", "Invalid value provided."));
return;
}
if (operation.equalsIgnoreCase("remove"))
{
ClanWarData war = clan.getWarData(clanAgainst);
// war.set
//
// Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> {
// UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB())));
// });
}
else if (operation.equalsIgnoreCase("set"))
{
}
else if (operation.equalsIgnoreCase("add"))
{
}
else
{
UtilPlayer.message(caller, F.main("Clans Admin", "Invalid operation provided."));
}
}
public void invite(Player caller, String[] args)
{

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
@ -38,6 +39,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.chat.MessageData;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -60,6 +62,8 @@ import mineplex.core.packethandler.PacketHandler;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
import mineplex.core.punish.PunishClient;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
@ -180,6 +184,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private Explosion _explosion;
private GoldManager _goldManager;
private Punish _punish;
private int _inviteExpire = 2;
private int _nameMin = 3;
private int _nameMax = 10;
@ -203,7 +209,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// Spawn area
public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
{
super("Clans Manager", plugin);
@ -214,6 +220,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_instance = this;
_punish = punish;
_serverName = serverName;
_clientManager = clientManager;
_combatManager = new CombatManager(plugin);
@ -623,6 +631,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}, 20L);
}
@EventHandler
public void disableFlyKick(PlayerKickEvent event)
{
if (event.getReason().toLowerCase().contains("flying is not enabled on this server"))
{
event.setCancelled(true);
}
}
@EventHandler
public void denyBow(EntityShootBowEvent event)
{
@ -684,7 +701,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
if (clan == null)
{
UtilServer.broadcast(String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage()));
UtilServer.broadcast(String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), _chat.getFilteredMessage(event.getPlayer(), event.getMessage())));
return;
}
@ -712,10 +729,58 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
recipients.clear();
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler
public void onSignChange(SignChangeEvent event)
{
PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
if (punishclient != null && punishclient.IsMuted())
{
for (int i = 0; i < event.getLines().length; i++)
{
event.setLine(i, "");
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void handlePlayerChat(AsyncPlayerChatEvent event)
{
event.setCancelled(true);
event.setCancelled(false);
_chat.HandleChat(event);
if (event.isCancelled())
{
return;
}
else
{
event.setCancelled(true);
}
// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
//
// if (punishclient != null && punishclient.IsMuted())
// {
// return;
// }
//
// if (_chat.SilenceCheck(event.getPlayer()))
// {
// return;
// }
// MessageData lastMessage = _chat.lastMessage(event.getPlayer());
// long chatSlowTime = 1000L * _chat.getChatSlow();
// long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
// if (timeDiff < chatSlowTime && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
// {
//
// }
ClientClan client = Get(event.getPlayer());

View File

@ -1,12 +1,11 @@
package mineplex.game.clans.clans.ban;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -15,6 +14,8 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
@ -24,6 +25,10 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
import mineplex.game.clans.clans.ban.commands.ClansBanListCommand;
import mineplex.game.clans.clans.ban.ui.ClansBanListShop;
@ -38,6 +43,8 @@ public class ClansBanManager extends MiniPlugin
private ClansBanShop _shop;
private ClansBanListShop _shop2;
private Object _lock = new Object();
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("Blacklist", plugin);
@ -60,6 +67,24 @@ public class ClansBanManager extends MiniPlugin
addCommand(new ClansBanListCommand(this));
}
@EventHandler
public void clearOldClients(UpdateEvent event)
{
if (!event.getType().equals(UpdateType.MIN_01))
{
return;
}
synchronized (_lock)
{
List<String> purge = Lists.newArrayList();
_clients.keySet().stream().filter(name -> Bukkit.getPlayer(name) == null).forEach(purge::add);
purge.forEach(this::UnloadClient);
}
}
public void ban(ClansBanClient client, String name, long time, String reason, Callback<ClansBanClient> callback)
{
_repository.ban(client.AccountId, time, reason, time == -1);
@ -93,6 +118,11 @@ public class ClansBanManager extends MiniPlugin
;
event.getPlayer().kickPlayer(reason);
ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer());
String name = event.getPlayer().getName();
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> clan.playerOffline(name), 20L);
}
else
{
@ -135,32 +165,46 @@ public class ClansBanManager extends MiniPlugin
public void UnloadClient(ClansBanClient client)
{
String name = "";
for (Entry<String, ClansBanClient> entry : _clients.entrySet())
synchronized (_lock)
{
if (entry.getValue().equals(client))
String name = "";
for (Entry<String, ClansBanClient> entry : _clients.entrySet())
{
name = entry.getKey();
break;
if (entry.getValue().equals(client))
{
name = entry.getKey();
break;
}
}
_clients.remove(name);
}
}
public void UnloadClient(String name)
{
synchronized (_lock)
{
_clients.remove(name);
}
_clients.remove(name);
}
public void LoadClient(final String name, Callback<ClansBanClient> callback)
{
GetRepository().loadBans(name, client -> {
_clients.put(name, client);
System.out.println("> CLIENTS: " + _clients);
if (callback != null) callback.run(client);
synchronized (_lock)
{
_clients.put(name, client);
System.out.println("> CLIENTS: " + _clients);
if (callback != null) callback.run(client);
}
});
}
public ClansBanClient Get(String name)
{
synchronized (this)
synchronized (_lock)
{
return _clients.get(name.toLowerCase());
}

View File

@ -1,6 +1,5 @@
package mineplex.game.clans.clans.ban.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -14,7 +13,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
{
public ClansBanCommand(ClansBanManager plugin)
{
super(plugin, Rank.ADMIN, "cbans", "cb");
super(plugin, Rank.CMOD, "cbans", "cb");
}
@Override
@ -72,7 +71,6 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
Plugin.LoadClient(playerName, client -> {
Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + "."));
Bukkit.broadcastMessage(F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + "."));
Plugin.runSync(() -> target.kickPlayer(C.cRedB + "You have been banned from Clans " + c.getBanTimeFormatted() + "."));
});
});
@ -83,7 +81,6 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
Plugin.LoadClient(playerName, client -> {
Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + c.getBanTimeFormatted() + "."));
Bukkit.broadcastMessage(F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + "."));
});
});
}

View File

@ -127,7 +127,7 @@ public class ClansCommand extends CommandBase<ClansManager>
private void forceJoin(Player caller, String[] args)
{
if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9"))
if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9") /* My UUID (NewGarbo) */)
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission."));
return;

View File

@ -14,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.portal.Portal;
@ -25,7 +26,9 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor
private boolean _enabled;
private String _serverName;
private ConcurrentLinkedQueue<String> _queue;
private CoreClientManager _clientManager;
public ClansLoginManager(JavaPlugin plugin, CoreClientManager clientManager, String serverName)
{
super("Clans Login Manager", plugin);
@ -34,12 +37,13 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor
_enabled = true;
_queue = new ConcurrentLinkedQueue<String>();
clientManager.addStoredProcedureLoginProcessor(this);
_clientManager = clientManager;
}
@EventHandler
public void onPlayerJoin(PlayerLoginEvent event)
{
if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp())
if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp() && _clientManager.hasRank(event.getPlayer(), Rank.CMOD))
{
event.setKickMessage("This is not your Clans home server");
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);

View File

@ -1,11 +1,11 @@
package mineplex.game.clans.clans.outpost;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Predicate;
import org.bukkit.Location;
import org.bukkit.Material;
@ -54,7 +54,7 @@ import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class Outpost implements Listener
{
protected static final long MAX_LIFETIME = 5 * 60 * 1000; // 30 minutes
public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.NETHERRACK, 1).setRawTitle(C.cBlue + "Outpost").setLore("Seems to be a mystical contraption of some sort!").build();
public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.NETHERRACK, 1).setRawTitle(C.cBlue + "Outpost").setLore(C.cWhite + "It appears to be a contraption of some sort!").build();
public static final byte OUTPOST_BLOCK_DATA = (byte) 137;
private OutpostManager _host;
@ -73,7 +73,7 @@ public class Outpost implements Listener
private LinkedHashMap<String, OutpostBlock> _blocks;
private LinkedHashMap<String, OutpostBlock> _buildQueue;
private OutpostType _type;
protected OutpostType _type;
private OutpostState _state;
private Hologram _preHologram;
@ -82,6 +82,10 @@ public class Outpost implements Listener
private LoopIterator<Vector> _circleStages;
private LoopIterator<Vector> _reverseCircleStages;
private List<OutpostBuilder> _builders;
private List<OutpostBuilder> _removalQueue;
private ColorFader _fader = new ColorFader(30, UtilColor.hexToRgb(0x00A296), UtilColor.hexToRgb(0x29E6B6));
private long _spawnTime;
@ -95,6 +99,9 @@ public class Outpost implements Listener
_startCorner = location.clone().subtract(type._size, 1, type._size);
_endCorner = location.clone().add(type._size + .9, type._ySize - 1, type._size + .9);
_builders = new ArrayList<>();
_removalQueue = new ArrayList<>();
_forceFieldStart = _startCorner.clone().subtract(3, 0, 3);
_forceFieldEnd = _endCorner.clone().add(3, 0, 3);
@ -202,6 +209,7 @@ public class Outpost implements Listener
return;
}
System.out.println(_blocks);
_blocks.values().stream().filter(event.getBlock().getLocation()::equals).forEach(block -> {
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks in Outposts."));
event.setCancelled(true);
@ -309,6 +317,19 @@ public class Outpost implements Listener
@EventHandler
public void forcefield(UpdateEvent event)
{
if (!_removalQueue.isEmpty())
{
_builders.remove(_removalQueue.remove(0));
}
if (event.getType() == UpdateType.TICK && getState() == OutpostState.CONSTRUCTING)
{
for (OutpostBuilder builder : _builders)
{
builder.tick();
}
}
if (event.getType() != UpdateType.FAST && getState() == OutpostState.CONSTRUCTING)
{
return;
@ -336,6 +357,12 @@ public class Outpost implements Listener
_state = OutpostState.CONSTRUCTING;
_blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_origin, _clan.Clans));
{
Location pos = UtilBlock.getHighest(_startCorner.getWorld(), _startCorner.clone().subtract(1, 0, 1).getBlockX(), _startCorner.clone().subtract(1, 0, 1).getBlockZ()).getLocation();
_builders.add(new OutpostBuilder(pos, "Peasant", _type.getWallLocations(_origin), this));
}
_clan.inform("Siege", "Your Outpost is now being constructed.", null);
_circleStages = new LoopIterator<Vector>(circleAround(new Vector(0., 0., 0.), 40, .6d));
@ -390,7 +417,7 @@ public class Outpost implements Listener
NonFinalInteger wait = new NonFinalInteger(0);
_blocks.values().stream().filter(block -> UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean()).forEach(block ->
_blocks.values().stream().filter(block -> UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean()).forEach(block ->
_host.runSyncLater(() -> {
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 1f, 1, ViewDist.NORMAL);
_origin.getWorld().playSound(block._loc, Sound.EXPLODE, 1.0f, 1.0f);
@ -448,4 +475,9 @@ public class Outpost implements Listener
{
return _state;
}
public void queueForRemoval(OutpostBuilder builder)
{
_removalQueue.add(builder);
}
}

View File

@ -0,0 +1,130 @@
package mineplex.game.clans.clans.outpost;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.ItemStack;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.game.clans.clans.outpost.pathing.AStar;
import mineplex.game.clans.clans.outpost.pathing.AStar.InvalidPathException;
import mineplex.game.clans.clans.outpost.pathing.PathingResult;
import mineplex.game.clans.clans.outpost.pathing.Tile;
public class OutpostBuilder
{
private Skeleton _entity;
private List<Location> _path;
private int _pathPos;
private List<Location> _moveLocations;
private int _nextLocation;
private long _arrivedTime;
private long _lastMovement;
private Outpost _host;
public OutpostBuilder(Location pos, String name, List<Location> locations, Outpost host)
{
_host = host;
Location spawnLoc = pos;
Skeleton skel = pos.getWorld().spawn(spawnLoc, Skeleton.class);
skel.teleport(spawnLoc);
skel.setHealth(20);
UtilEnt.Vegetate(skel);
UtilEnt.silence(skel, true);
skel.getEquipment().setHelmet(new ItemStack(Material.NETHER_BRICK_ITEM, 1));
skel.getEquipment().setItemInHand(new ItemStack(Material.IRON_PICKAXE, 1));
// Get in range
List<Player> inRange = UtilPlayer.getNearby(spawnLoc, 75d);
// Disguise
DisguisePlayer disguise = new DisguisePlayer(skel, new GameProfile(Bukkit.getOfflinePlayer("Chiss").getUniqueId(), "Chiss"));
host.getClan().Clans.getDisguiseManager().disguise(disguise, inRange.toArray(new Player[inRange.size()]));
_entity = skel;
_moveLocations = locations;
}
public void tick()
{
if (_path == null || _arrivedTime != -1)
{
_nextLocation = UtilMath.random.nextInt(_moveLocations.size());
_path = calculatePath();
_pathPos = 0;
return;
}
if (System.currentTimeMillis() - _lastMovement >= 500)
{
if (_pathPos == _path.size() - 1)
{
_arrivedTime = 1;
}
else
{
_entity.teleport(_path.get(++_pathPos));
_arrivedTime = -1;
}
_lastMovement = System.currentTimeMillis();
}
}
private List<Location> calculatePath()
{
Location start = _entity.getLocation();
Location end = _moveLocations.get(_nextLocation);
int range = _host._type._size * 2;
try
{
AStar pathFinder = new AStar(start, end, range);
ArrayList<Tile> route = pathFinder.iterate();
PathingResult res = pathFinder.getPathingResult();
if (res == PathingResult.NO_PATH)
{
return Arrays.asList(_moveLocations.get(_nextLocation));
}
List<Location> list = new ArrayList<>();
for (Tile tile : route)
{
list.add(tile.getLocation(start));
}
return list;
}
catch (InvalidPathException e)
{
cleanup();
return null;
}
}
private void cleanup()
{
_entity.remove();
_host.queueForRemoval(this);
}
}

View File

@ -50,13 +50,7 @@ public class OutpostManager extends MiniPlugin
{
if (event.getItemInHand().isSimilar(Outpost.OUTPOST_ITEM))
{
if (!Recharge.Instance.use(event.getPlayer(), "Place Outpost", 10000, true, false))
{
event.setCancelled(true);
return;
}
if (Spawn(event.getPlayer(), event.getBlock().getLocation(), OutpostType.ORIGINAL_CLANS))
if (Spawn(event.getPlayer(), event.getBlock().getLocation(), OutpostType.MK2))
{
event.getBlock().setData((byte) Outpost.OUTPOST_BLOCK_DATA);
}
@ -179,7 +173,7 @@ public class OutpostManager extends MiniPlugin
{
if (outpost.getState() != OutpostState.DEAD)
{
if (outpost.getState() == OutpostState.CONSTRUCTING ? event.getType() == UpdateType.FASTER : event.getType() == UpdateType.TICK)
if (outpost.getState() == OutpostState.CONSTRUCTING ? event.getType() == UpdateType.TICK : event.getType() == UpdateType.TICK)
{
outpost.update();
}

View File

@ -1,12 +1,19 @@
package mineplex.game.clans.clans.outpost;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansManager;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
public enum OutpostType
{
@ -204,6 +211,79 @@ public enum OutpostType
return build;
}
public List<Location> getWallLocations(Location middle)
{
List<Location> list = new ArrayList<>();
list.add(middle.clone().add(_size / 2, 0, 0).add(1, 0, 0));
list.add(middle.clone().add(_size / 2, 0, -(_size / 2)).add(1, 0, -1));
list.add(middle.clone().add(-(_size / 2), 0, -(_size / 2)).add(-1, 0, -1));
list.add(middle.clone().add(-(_size / 2), 0, 0).add(-1, 0, 0));
return list;
}
public Location getCoreLocation(Location location)
{
return location.clone().subtract(0, 1, 0);
}
},
MK2(5, 25) {
public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans)
{
try
{
LinkedHashMap<String, OutpostBlock> build = new LinkedHashMap<>();
File file = new File("schematic" + File.separator + "outpost_mk_II.schematic");
System.out.println(file.getAbsolutePath());
Schematic schematic = UtilSchematic.loadSchematic(file);
for (int y = 0; y < schematic.getHeight(); y++)
{
for (int x = 0; x < schematic.getWidth(); x++)
{
for (int z = 0; z < schematic.getLength(); z++)
{
int relativeX = -(schematic.getWidth() / 2) + x;
int relativeZ = -(schematic.getLength() / 2) + z;
Location loc = location.clone().add(relativeX, y - 1, relativeZ);
if (schematic.getBlock(x, y, z) == 0 && loc.getBlock().getType() == Material.AIR)
{
continue;
}
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z)));
}
}
}
//Core
build.put(UtilWorld.locToStr(getCoreLocation(location)), new OutpostBlock(build, getCoreLocation(location), Material.DIAMOND_BLOCK.getId(), (byte)0));
return build;
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
}
public List<Location> getWallLocations(Location middle)
{
List<Location> list = new ArrayList<>();
list.add(middle.clone().add(_size / 2, 0, 0).add(1, 0, 0));
list.add(middle.clone().add(_size / 2, 0, -(_size / 2)).add(1, 0, -1));
list.add(middle.clone().add(-(_size / 2), 0, -(_size / 2)).add(-1, 0, -1));
list.add(middle.clone().add(-(_size / 2), 0, 0).add(-1, 0, 0));
return list;
}
public Location getCoreLocation(Location location)
{
return location.clone().subtract(0, 1, 0);
@ -222,4 +302,6 @@ public enum OutpostType
public abstract LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans);
public abstract Location getCoreLocation(Location location);
public abstract List<Location> getWallLocations(Location location);
}

View File

@ -0,0 +1,391 @@
/*
* By @Adamki11s
*/
package mineplex.game.clans.clans.outpost.pathing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.material.Gate;
/**
* Not made by meee (NewGarbo)
* https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/
*/
public class AStar
{
private final int _sx;
private final int _sy;
private final int _sz;
private final int _ex;
private final int _ey;
private final int _ez;
private final World _world;
private PathingResult _result;
private HashMap<String, Tile> _open = new HashMap<String, Tile>();
private HashMap<String, Tile> _closed = new HashMap<String, Tile>();
private void addToOpenList(Tile t, boolean modify)
{
if (_open.containsKey(t.getUID()))
{
if (modify)
{
_open.put(t.getUID(), t);
}
}
else
{
_open.put(t.getUID(), t);
}
}
private void addToClosedList(Tile t)
{
if (!_closed.containsKey(t.getUID()))
{
_closed.put(t.getUID(), t);
}
}
private final int _range;
private final String _endUID;
public AStar(Location start, Location end, int range) throws InvalidPathException
{
boolean s = true, e = true;
if (!(s = isLocationWalkable(start)) || !(e = isLocationWalkable(end)))
{
throw new InvalidPathException(s, e);
}
_world = start.getWorld();
_sx = start.getBlockX();
_sy = start.getBlockY();
_sz = start.getBlockZ();
_ex = end.getBlockX();
_ey = end.getBlockY();
_ez = end.getBlockZ();
_range = range;
short sh = 0;
Tile t = new Tile(sh, sh, sh, null);
t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true);
_open.put(t.getUID(), t);
processAdjacentTiles(t);
StringBuilder b = new StringBuilder();
b.append(_ex - _sx).append(_ey - _sy).append(_ez - _sz);
_endUID = b.toString();
}
public Location getEndLocation()
{
return new Location(_world, _ex, _ey, _ez);
}
public PathingResult getPathingResult()
{
return _result;
}
protected boolean _checkOnce = false;
private int abs(int i)
{
return (i < 0 ? -i : i);
}
public ArrayList<Tile> iterate()
{
if (!_checkOnce)
{
// invert the boolean flag
_checkOnce ^= true;
if ((abs(_sx - _ex) > _range) || (abs(_sy - _ey) > _range) || (abs(_sz - _ez) > _range))
{
_result = PathingResult.NO_PATH;
return null;// jump out
}
}
// while not at end
Tile current = null;
while (canContinue())
{
// get lowest F cost square on open list
current = getLowestFTile();
// process tiles
processAdjacentTiles(current);
}
if (_result != PathingResult.SUCCESS)
{
return null;
}
else
{
// path found
LinkedList<Tile> routeTrace = new LinkedList<Tile>();
Tile parent;
routeTrace.add(current);
while ((parent = current.getParent()) != null)
{
routeTrace.add(parent);
current = parent;
}
Collections.reverse(routeTrace);
return new ArrayList<Tile>(routeTrace);
}
}
private boolean canContinue()
{
// check if open list is empty, if it is no path has been found
if (_open.size() == 0)
{
_result = PathingResult.NO_PATH;
return false;
}
else
{
if (_closed.containsKey(_endUID))
{
_result = PathingResult.SUCCESS;
return false;
}
else
{
return true;
}
}
}
private Tile getLowestFTile()
{
double f = 0;
Tile drop = null;
// get lowest F cost square
for (Tile t : _open.values())
{
if (f == 0)
{
t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true);
f = t.getF();
drop = t;
}
else
{
t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true);
double posF = t.getF();
if (posF < f)
{
f = posF;
drop = t;
}
}
}
// drop from open list and add to closed
_open.remove(drop.getUID());
addToClosedList(drop);
return drop;
}
private boolean isOnClosedList(Tile t)
{
return _closed.containsKey(t.getUID());
}
// pass in the current tile as the parent
private void processAdjacentTiles(Tile current)
{
// set of possible walk to locations adjacent to current tile
HashSet<Tile> possible = new HashSet<Tile>(26);
for (byte x = -1; x <= 1; x++)
{
for (byte y = -1; y <= 1; y++)
{
for (byte z = -1; z <= 1; z++)
{
if (x == 0 && y == 0 && z == 0)
{
continue;// don't check current square
}
Tile t = new Tile((short) (current.getX() + x), (short) (current.getY() + y), (short) (current.getZ() + z), current);
if (!t.isInRange(_range))
{
// if block is out of bounds continue
continue;
}
if (x != 0 && z != 0 && (y == 0 || y == 1))
{
// check to stop jumping through diagonal blocks
Tile xOff = new Tile((short) (current.getX() + x), (short) (current.getY() + y), (short) (current.getZ()), current), zOff = new Tile((short) (current.getX()), (short) (current.getY() + y), (short) (current.getZ() + z), current);
if (!isTileWalkable(xOff) && !isTileWalkable(zOff))
{
continue;
}
}
if (isOnClosedList(t))
{
// ignore tile
continue;
}
// only process the tile if it can be walked on
if (isTileWalkable(t))
{
t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true);
possible.add(t);
}
}
}
}
for (Tile t : possible)
{
// get the reference of the object in the array
Tile openRef = null;
if ((openRef = isOnOpenList(t)) == null)
{
// not on open list, so add
addToOpenList(t, false);
}
else
{
// is on open list, check if path to that square is better using
// G cost
if (t.getG() < openRef.getG())
{
// if current path is better, change parent
openRef.setParent(current);
// force updates of F, G and H values.
openRef.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true);
}
}
}
}
private Tile isOnOpenList(Tile t)
{
return (_open.containsKey(t.getUID()) ? _open.get(t.getUID()) : null);
/*
* for (Tile o : open) { if (o.equals(t)) { return o; } } return null;
*/
}
private boolean isTileWalkable(Tile t)
{
Location l = new Location(_world, (_sx + t.getX()), (_sy + t.getY()), (_sz + t.getZ()));
Block b = l.getBlock();
int i = b.getTypeId();
// lava, fire, wheat and ladders cannot be walked on, and of course air
// 85, 107 and 113 stops npcs climbing fences and fence gates
if (i != 10 && i != 11 && i != 51 && i != 59 && i != 65 && i != 0 && i != 85 && i != 107 && i != 113 && !canBlockBeWalkedThrough(i))
{
// make sure the blocks above are air
if (b.getRelative(0, 1, 0).getTypeId() == 107)
{
// fench gate check, if closed continue
Gate g = new Gate(b.getRelative(0, 1, 0).getData());
return (g.isOpen() ? (b.getRelative(0, 2, 0).getTypeId() == 0) : false);
}
return (canBlockBeWalkedThrough(b.getRelative(0, 1, 0).getTypeId()) && b.getRelative(0, 2, 0).getTypeId() == 0);
}
else
{
return false;
}
}
private boolean isLocationWalkable(Location l)
{
Block b = l.getBlock();
int i = b.getTypeId();
if (i != 10 && i != 11 && i != 51 && i != 59 && i != 65 && i != 0 && !canBlockBeWalkedThrough(i))
{
// make sure the blocks above are air or can be walked through
return (canBlockBeWalkedThrough(b.getRelative(0, 1, 0).getTypeId()) && b.getRelative(0, 2, 0).getTypeId() == 0);
}
else
{
return false;
}
}
private boolean canBlockBeWalkedThrough(int id)
{
return (id == 0 || id == 6 || id == 50 || id == 63 || id == 30 || id == 31 || id == 32 || id == 37 || id == 38 || id == 39 || id == 40 || id == 55 || id == 66 || id == 75 || id == 76 || id == 78);
}
@SuppressWarnings("serial")
public class InvalidPathException extends Exception
{
private final boolean _s, _e;
public InvalidPathException(boolean s, boolean e)
{
_s = s;
_e = e;
}
public String getErrorReason()
{
StringBuilder sb = new StringBuilder();
if (!_s)
{
sb.append("Start Location was air. ");
}
if (!_e)
{
sb.append("End Location was air.");
}
return sb.toString();
}
public boolean isStartNotSolid()
{
return (!_s);
}
public boolean isEndNotSolid()
{
return (!_e);
}
}
}

View File

@ -0,0 +1,23 @@
package mineplex.game.clans.clans.outpost.pathing;
/**
* Not made by meee (NewGarbo)
* https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/
*/
public enum PathingResult
{
SUCCESS(0),
NO_PATH(-1);
private final int _ec;
PathingResult(int ec)
{
_ec = ec;
}
public int getEndCode()
{
return _ec;
}
}

View File

@ -0,0 +1,183 @@
/*
* By @Adamki11s
*/
package mineplex.game.clans.clans.outpost.pathing;
import org.bukkit.Location;
/**
* Not made by meee (NewGarbo)
* https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/
*/
public class Tile
{
// as offset from starting point
private final short _x;
private final short _y;
private final short _z;
private double _g = -1;
private double _h = -1;
private Tile _parent = null;
private final String _uid;
public Tile(short x, short y, short z, Tile parent)
{
_x = x;
_y = y;
_z = z;
_parent = parent;
StringBuilder b = new StringBuilder();
b.append(x);
b.append(y);
b.append(z);
_uid = b.toString();
}
public boolean isInRange(int range)
{
return ((range - abs(_x) >= 0) && (range - abs(_y) >= 0) && (range - abs(_z) >= 0));
}
public void setParent(Tile parent)
{
_parent = parent;
}
public Location getLocation(Location start)
{
return new Location(start.getWorld(), start.getBlockX() + _x, start.getBlockY() + _y, start.getBlockZ() + _z);
}
public Tile getParent()
{
return _parent;
}
public short getX()
{
return _x;
}
public int getX(Location i)
{
return (i.getBlockX() + _x);
}
public short getY()
{
return _y;
}
public int getY(Location i)
{
return (i.getBlockY() + _y);
}
public short getZ()
{
return _z;
}
public int getZ(Location i)
{
return (i.getBlockZ() + _z);
}
public String getUID()
{
return _uid;
}
public boolean equals(Tile t)
{
return (t.getX() == _x && t.getY() == _y && t.getZ() == _z);
}
public void calculateBoth(int sx, int sy, int sz, int ex, int ey, int ez, boolean update)
{
calculateG(sx, sy, sz, update);
calculateH(sx, sy, sz, ex, ey, ez, update);
}
public void calculateH(int sx, int sy, int sz, int ex, int ey, int ez, boolean update)
{
// only update if h hasn't been calculated or if forced
if ((!update && _h == -1) || update)
{
int hx = sx + _x, hy = sy + _y, hz = sz + _z;
_h = getEuclideanDistance(hx, hy, hz, ex, ey, ez);
}
}
// G = the movement cost to move from the starting point A to a given square
// on the grid, following the path generated to get there.
public void calculateG(int sx, int sy, int sz, boolean update)
{
if ((!update && _g == -1) || update)
{
// only update if g hasn't been calculated or if forced
Tile currentParent = getParent(), currentTile = this;
int gCost = 0;
// follow path back to start
while ((currentParent = currentTile.getParent()) != null)
{
int dx = currentTile.getX() - currentParent.getX(), dy = currentTile.getY() - currentParent.getY(), dz = currentTile.getZ() - currentParent.getZ();
dx = abs(dx);
dy = abs(dy);
dz = abs(dz);
if (dx == 1 && dy == 1 && dz == 1)
{
gCost += 1.7;
} else if (((dx == 1 || dz == 1) && dy == 1) || ((dx == 1 || dz == 1) && dy == 0))
{
gCost += 1.4;
}
else
{
gCost += 1.0;
}
// move backwards a tile
currentTile = currentParent;
}
_g = gCost;
}
}
public double getG()
{
return _g;
}
public double getH()
{
return _h;
}
public double getF()
{
// f = h + g
return (_h + _g);
}
private double getEuclideanDistance(int sx, int sy, int sz, int ex, int ey, int ez)
{
double dx = sx - ex, dy = sy - ey, dz = sz - ez;
return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz));
}
private int abs(int i)
{
return (i < 0 ? -i : i);
}
}

View File

@ -211,7 +211,7 @@ public class ClansRegions extends MiniPlugin
if (_manager.getClaimMap().containsKey(chunkStr))
{
System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying.
// System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying.
continue;
}

View File

@ -10,7 +10,7 @@ public class WorldEventCommand extends MultiCommandBase<WorldEventManager>
{
public WorldEventCommand(WorldEventManager plugin)
{
super(plugin, Rank.EVENT, "worldevent", "we", "event");
super(plugin, Rank.CMOD, "worldevent", "we", "event");
AddCommand(new StartCommand(Plugin));
AddCommand(new ClearCommand(Plugin));

View File

@ -6,6 +6,7 @@ import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -41,27 +42,29 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.weight.Weight;
import mineplex.core.common.weight.WeightSet;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.core.common.weight.Weight;
import mineplex.core.common.weight.WeightSet;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent;
@ -164,7 +167,6 @@ public class Gameplay extends MiniPlugin
}
}
}
@EventHandler
public void BucketEmpty(PlayerBucketEmptyEvent event)
{
@ -444,46 +446,125 @@ public class Gameplay extends MiniPlugin
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void replantTree(BlockBreakEvent event)
@EventHandler(priority = EventPriority.HIGHEST)
public void disableSaplings(BlockPlaceEvent event)
{
final Block block = event.getBlock();
if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null)
if (!event.getItemInHand().getType().equals(Material.SAPLING))
{
return;
}
if (!UtilItem.isLog(block.getType()))
Block block = event.getBlock();
ClanInfo clan = _clansManager.getClanUtility().getClanByPlayer(event.getPlayer());
for (int cX = -32; cX < 32; cX++)
{
return;
}
if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType()))
{
return;
}
if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType()))
{
return;
}
if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS)
{
return;
}
final byte data = block.getData();
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
public void run()
for (int cZ = -32; cZ < 32; cZ++)
{
block.setType(Material.SAPLING);
block.setData(data);
ClanTerritory claim = _clansManager.getClanUtility().getClaim(block.getLocation().add(cX, 0, cZ));
if (claim != null && (clan == null || !claim.Owner.equals(clan.getName())))
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place saplings near other clan's claims."));
event.setCancelled(true);
return;
}
}
}, 20 * 5);
}
if (clan == null || (!clan.equals(_clansManager.getClanUtility().getOwner(block.getLocation()))))
{
if (UtilBlock.getInRadius(block, 10)
.keySet()
.stream()
.filter(other -> other.getType().equals(Material.SAPLING))
.filter(other -> !other.getLocation().equals(block.getLocation()))
.toArray().length > 0)
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place this block close to any other saplings, unless in your territory."));
event.setCancelled(true);
return;
}
}
if (!Recharge.Instance.use(event.getPlayer(), "Place Sapling", 20 * 60 * 1000, true, false))
{
event.setCancelled(true);
return;
}
}
@EventHandler
public void blockDispenser(BlockDispenseEvent event)
{
// Block bonemeal
if (event.getItem().getType() == Material.INK_SACK && ((Dye) event.getItem().getData()).getColor() == DyeColor.WHITE)
{
event.setCancelled(true);
}
// Block flint-and-steal
if (event.getItem().getType() == Material.FLINT_AND_STEEL)
{
event.setCancelled(true);
}
if (event.getItem().getType() == Material.FIREWORK_CHARGE)
{
event.setCancelled(true);
}
if (event.getItem().getType() == Material.SAPLING)
{
event.setCancelled(true);
}
if (event.getItem().getType() == Material.TNT)
{
event.setCancelled(true);
}
}
// @EventHandler(priority = EventPriority.LOWEST)
// public void replantTree(BlockBreakEvent event)
// {
// final Block block = event.getBlock();
//
// if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null)
// {
// return;
// }
//
// if (!UtilItem.isLog(block.getType()))
// {
// return;
// }
//
// if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType()))
// {
// return;
// }
//
// if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType()))
// {
// return;
// }
//
// if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS)
// {
// return;
// }
//
// final byte data = block.getData();
//
// UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
// public void run()
// {
// block.setType(Material.SAPLING);
// block.setData(data);
// }
// }, 20 * 5);
// }
@EventHandler
public void killRain(WeatherChangeEvent event)

View File

@ -1,15 +1,19 @@
package mineplex.game.clans.gameplay.safelog;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFile;
import mineplex.core.common.util.UtilFile.ChunkType;
@ -47,6 +51,12 @@ public class SafeLog extends MiniPlugin
isSafeLog = true;
}
if (_flying.contains(player.getName()))
{
_flying.remove(player.getName());
return;
}
if (!isSafeLog)
{
NPCManager.getInstance().spawnLogoutNpc(player);
@ -92,17 +102,34 @@ public class SafeLog extends MiniPlugin
}
}
@EventHandler
private List<String> _flying = new ArrayList<>();
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent event)
{
event.setQuitMessage(F.sys("Quit", event.getPlayer().getName()));
onPlayerQuit(event.getPlayer());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void flyCheck(PlayerKickEvent event)
{
if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getItemMeta() != null && (C.cGold + "Wind Blade").equals(event.getPlayer().getItemInHand().getItemMeta().getDisplayName()))
if (event.getReason().contains("flying is not enabled"))
return;
_flying.add(event.getPlayer().getName());
}
@EventHandler
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerKicked(PlayerKickEvent event)
{
if (event.isCancelled()) return;
if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getItemMeta() != null && (C.cGold + "Wind Blade").equals(event.getPlayer().getItemInHand().getItemMeta().getDisplayName()))
if (event.getReason().contains("flying is not enabled"))
return;
event.setLeaveMessage(F.sys("Quit", event.getPlayer().getName()));
onPlayerQuit(event.getPlayer());

View File

@ -4,6 +4,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
@ -15,6 +16,7 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.metadata.FixedMetadataValue;
import mineplex.core.MiniPlugin;
import mineplex.core.hologram.HologramManager;
@ -82,7 +84,7 @@ public class NPCManager extends MiniPlugin
{
for (LivingEntity entity : Spawn.getSpawnWorld().getLivingEntities())
{
if (entity.hasMetadata("CombatLogNPC"))
if (entity.hasMetadata("CombatLogNPC") && ((FixedMetadataValue) entity.getMetadata("CombatLogNPC").get(0)).asString().equals(event.getPlayer().getUniqueId().toString()))
{
entity.remove();
}
@ -209,15 +211,22 @@ public class NPCManager extends MiniPlugin
{
CombatLogNPC npc = iterator.next();
if (Bukkit.getPlayer(npc.getPlayerInfo().getPlayerName()) != null)
{
System.out.println("{NPCMANAGER} ORIGINAL PLAYER ALIVE AND DESPAWNING");
npc.despawn();
iterator.remove();
}
if (!npc.isAlive())
{
System.out.println("NOT ALIVE AND REMOVING");
System.out.println("{NPCMANAGER} NOT ALIVE AND REMOVING");
npc.remove();
iterator.remove();
}
else if (npc.getAliveDuation() > COMBAT_LOG_DURATION)
{
System.out.println("DESPAWNING");
System.out.println("{NPCMANAGER} DESPAWNING");
npc.despawn();
iterator.remove();
}

View File

@ -64,9 +64,6 @@ public class PlayerGear
if (legendary.OriginalOwner == null)
{
legendary.OriginalOwner = getPlayer().getUniqueId().toString();
UtilServer.broadcast(F.main("Clans", F.elem(getPlayer().getName()) + " has picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.mBody + "."));
UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + ".", 20, 60, 20);
getPlayer().setItemInHand(legendary.toItemStack());
}
}

View File

@ -5,11 +5,9 @@ import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.entity.Entity;
public class InverseAttribute extends ItemAttribute
{
private static ValueDistribution knockbackGen = generateDistribution(-0.5d, 1.0d);
private static ValueDistribution knockbackGen = generateDistribution(0.d, 1.d);
private double _knockbackModifier;
@ -29,7 +27,7 @@ private static ValueDistribution knockbackGen = generateDistribution(-0.5d, 1.0d
@Override
public String getDescription()
{
return String.format("Reverse knockback and modify amount to %.2f percent", (1.0d + _knockbackModifier) * 100d);
return String.format("Reverse knockback and modify amount to %.2f percent", (.5d + _knockbackModifier) * 100d);
}
@Override

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.items.attributes.bow;
import mineplex.core.common.util.UtilMath;
import mineplex.game.clans.items.attributes.AttributeType;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
@ -45,6 +46,6 @@ public class LeechingAttribute extends ItemAttribute
private void heal(Player player, double healAmount)
{
player.setHealth(player.getHealth() + healAmount);
player.setHealth(UtilMath.clamp(player.getHealth() + healAmount, 0, 20));
}
}

View File

@ -62,7 +62,7 @@ public class GiantsBroadsword extends LegendaryItem
private void buffPlayer(Player player)
{
grantPotionEffect(player, PotionEffectType.SLOW, 40, 10);
grantPotionEffect(player, PotionEffectType.REGENERATION, 40, 10);
grantPotionEffect(player, PotionEffectType.SLOW, 40, 43);
grantPotionEffect(player, PotionEffectType.REGENERATION, 2, 43);
}
}

View File

@ -15,6 +15,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilItem;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.core.common.util.F;
import mineplex.core.updater.event.UpdateEvent;
@ -156,6 +157,10 @@ public class Flash extends SkillActive
if(aboveTargetData <= 7) aboveTargetSlabIsBottom = true;
}
// Doors
if (UtilItem.is(newTarget.getBlock(), UtilItem.ItemCategory.DOOR))
break;
if ((!newTargetSlabIsBottom && UtilBlock.fullSolid(newTarget.getBlock())) || (!aboveTargetSlabIsBottom && UtilBlock.fullSolid(aboveTarget.getBlock())))
break;

View File

@ -1,33 +1,33 @@
package mineplex.minecraft.game.classcombat.Skill.Assassin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.minecraft.game.classcombat.Skill.Skill;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.minecraft.game.classcombat.Skill.Skill;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
public class Recall extends Skill
{
private HashMap<Player, LinkedList<Location>> _locMap = new HashMap<Player, LinkedList<Location>>();
@ -111,7 +111,19 @@ public class Recall extends Skill
current = current.add(UtilAlg.getTrajectory(current, target).multiply(0.1));
}
}
@EventHandler
public void closeInv(InventoryCloseEvent event)
{
if (getLevel(event.getPlayer()) == 0)
{
return;
}
event.getPlayer().getInventory().addItem(event.getPlayer().getItemOnCursor());
event.getPlayer().setItemOnCursor(null);
}
@EventHandler
public void storeLocation(UpdateEvent event)
{

View File

@ -62,7 +62,14 @@ public class BlockToss extends SkillCharge implements IThrown
Material.BURNING_FURNACE,
Material.WORKBENCH,
Material.WATER,
Material.LAVA
Material.LAVA,
Material.STONE_PLATE,
Material.WOOD_PLATE,
Material.GOLD_PLATE,
Material.IRON_PLATE,
Material.STONE_BUTTON,
Material.WOOD_BUTTON,
Material.LEVER,
};
public BlockToss(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels)
@ -127,8 +134,10 @@ public class BlockToss extends SkillCharge implements IThrown
//Blacklist
for (Material mat : _blacklist)
if (mat == grab.getType())
{
UtilPlayer.message(player, F.main("Game", "You cannot grab this block."));
return;
}
//Usable
if (UtilBlock.usable(grab))
return;

View File

@ -332,8 +332,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
}
});
task.setBlocksPerTick(_isArcade ? 2000000 : 1000); // TODO: CHANGE THIS
// BACK
task.setBlocksPerTick(_isArcade ? 2000000 : 1000);
task.start();
}

View File

@ -113,7 +113,7 @@ public class Utility
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxWaitMillis(1000);
jedisPoolConfig.setMinIdle(5);
jedisPoolConfig.setTestOnBorrow(true);
// jedisPoolConfig.setTestOnBorrow(true);
jedisPoolConfig.setMaxTotal(20);
jedisPoolConfig.setBlockWhenExhausted(true);

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
@ -23,7 +24,6 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -1137,7 +1137,7 @@ public class Bridge extends TeamGame implements OreObsfucation
// Reveal ore that are inside the explosion
_ore.Explosion(event);
NautHashMap<Block, Material> lootDrops = new NautHashMap<Block, Material>();
NautHashMap<Block, HashSet<ItemStack>> lootDrops = new NautHashMap<Block, HashSet<ItemStack>>();
// Handle block ownership for explosion
if (event.getOwner() != null)
@ -1152,16 +1152,9 @@ public class Bridge extends TeamGame implements OreObsfucation
cur.getType() == Material.DIAMOND_ORE)
{
event.GetBlocks().remove(cur);
switch (cur.getType())
{
case DIAMOND_ORE:
lootDrops.put(cur, Material.DIAMOND);
case COAL_ORE:
lootDrops.put(cur, Material.COAL);
default:
lootDrops.put(cur, cur.getType());
}
lootDrops.put(cur, new HashSet<ItemStack>());
lootDrops.get(cur).addAll(cur.getDrops());
}
}
}
@ -1176,22 +1169,16 @@ public class Bridge extends TeamGame implements OreObsfucation
block.setType(Material.AIR);
Location drop = block.getLocation().clone().add(.5, .5, .5);
Item item = block.getWorld().dropItem(drop, new ItemStack(lootDrops.remove(block)));
item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getOwner().getUniqueId()));
for (ItemStack stack : lootDrops.remove(block))
{
Item item = block.getWorld().dropItem(drop, stack);
item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getOwner().getUniqueId()));
}
}
}
}, 1);
}
@EventHandler(priority = EventPriority.MONITOR)
public void OreReveal(BlockBreakEvent event)
{
if (event.isCancelled())
return;
_ore.BlockBreak(event);
}
@EventHandler(priority = EventPriority.LOW)
public void BlockPlace(BlockPlaceEvent event)
{
@ -1314,7 +1301,6 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void dropItem(BlockBreakEvent event)
{
@ -1329,29 +1315,30 @@ public class Bridge extends TeamGame implements OreObsfucation
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
Material drop = null;
byte data = (byte) 0;
List<ItemStack> drops = new ArrayList<ItemStack>();
for (Material mat : PLAYER_DROP_DELAY_MATERIALS)
{
if (event.getBlock().getType() == mat)
{
drop = mat;
data = event.getBlock().getData();
drops.addAll(event.getBlock().getDrops());
break;
}
}
if (drop == null)
if (drops.isEmpty())
return;
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
Location loc = event.getBlock().getLocation().clone().add(.5, .5, .5);
Item item = loc.getWorld().dropItem(loc, new ItemBuilder(drop, data).build());
item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId()));
for (ItemStack item : drops)
{
Item drop = loc.getWorld().dropItem(loc, item);
drop.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId()));
}
}
@EventHandler

View File

@ -42,7 +42,7 @@
<repositories>
<repository>
<id>mineplex</id>
<url>http://mineplex:sZhnBKND9c@dev.mineplex.com:8081/nexus/content/groups/public/</url>
<url>http://dev.mineplex.com:8081/nexus/content/groups/public/</url>
</repository>
</repositories>

18
Plugins/settings.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
User-specific configuration for maven. Includes things that should not
be distributed with the pom.xml file, such as developer identity, along with
local settings, like proxy information. The default location for the
settings file is ~/.m2/settings.xml
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>mineplex</id>
<username>mineplex</username>
<password>sZhnBKND9c</password>
</server>
</servers>
</settings>