Serious tweaks to gameplay and begin documentation
This commit is contained in:
parent
0ecdce4edc
commit
6f0d21120e
@ -1,3 +1,3 @@
|
|||||||
name: Clans
|
name: Clans
|
||||||
main: mineplex.game.clans.Clans
|
main: mineplex.game.clans.Clans
|
||||||
version: 0.1
|
version: 1.0
|
@ -63,7 +63,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
|||||||
|
|
||||||
public class Clans extends JavaPlugin
|
public class Clans extends JavaPlugin
|
||||||
{
|
{
|
||||||
public static final String VERSION = "Beta 1.0";
|
public static final String MAP = "Map 1";
|
||||||
private String WEB_CONFIG = "webServer";
|
private String WEB_CONFIG = "webServer";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
@ -201,8 +201,8 @@ public class Clans extends JavaPlugin
|
|||||||
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
|
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String version()
|
public static String getMap()
|
||||||
{
|
{
|
||||||
return VERSION;
|
return MAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,27 +0,0 @@
|
|||||||
package mineplex.game.clans.clans;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.task.TaskManager;
|
|
||||||
import mineplex.game.clans.Clans;
|
|
||||||
|
|
||||||
public class ClansBetaManager extends MiniPlugin
|
|
||||||
{
|
|
||||||
public ClansBetaManager(ClansManager manager, TaskManager taskManager)
|
|
||||||
{
|
|
||||||
super("Clans Beta", manager.getPlugin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans " + Clans.VERSION);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -230,12 +230,6 @@ public class ClansGame extends MiniPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_clans.getWarManager().allowFromInvade(event.getBlock().getLocation(), event.getPlayer()))
|
|
||||||
{
|
|
||||||
// Allow because of invasion
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disallow
|
// Disallow
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
@ -287,12 +281,6 @@ public class ClansGame extends MiniPlugin
|
|||||||
Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation();
|
Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation();
|
||||||
if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation();
|
if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation();
|
||||||
|
|
||||||
if (_clans.getWarManager().allowFromInvade(loc, event.getPlayer()))
|
|
||||||
{
|
|
||||||
// Allow because of invasion
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Borderlands
|
// Borderlands
|
||||||
if (player.getGameMode() != GameMode.CREATIVE && player.getItemInHand() != null && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) && _clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation()))
|
if (player.getGameMode() != GameMode.CREATIVE && player.getItemInHand() != null && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) && _clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation()))
|
||||||
{
|
{
|
||||||
@ -565,12 +553,6 @@ public class ClansGame extends MiniPlugin
|
|||||||
ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation());
|
ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation());
|
||||||
if (clan == null) return;
|
if (clan == null) return;
|
||||||
|
|
||||||
if (_clans.getWarManager().isBeingInvaded(clan))
|
|
||||||
{
|
|
||||||
// Allow because of invasion
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clan.isProtected())
|
if (!clan.isProtected())
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
else
|
else
|
||||||
|
@ -325,8 +325,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
new ClanEnergyTracker(plugin, this);
|
new ClanEnergyTracker(plugin, this);
|
||||||
// new StuckManager(this);
|
// new StuckManager(this);
|
||||||
|
|
||||||
new ClansBetaManager(this, _taskManager);
|
|
||||||
|
|
||||||
new PotatoManager(plugin, this);
|
new PotatoManager(plugin, this);
|
||||||
|
|
||||||
new Weapon(plugin, energy);
|
new Weapon(plugin, energy);
|
||||||
@ -451,8 +449,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
for (Location location : welcomeHolograms)
|
for (Location location : welcomeHolograms)
|
||||||
{
|
{
|
||||||
Hologram hologram = new Hologram(hologramManager, location,
|
Hologram hologram = new Hologram(hologramManager, location,
|
||||||
C.cGreenB + "Welcome to Clans Beta",
|
C.cGreenB + "Welcome to Clans!",
|
||||||
C.cWhite + "Please be aware there may be bugs",
|
|
||||||
C.cWhite + "Type " + C.cYellow + "/clan" + C.cWhite + " to get started!"
|
C.cWhite + "Type " + C.cYellow + "/clan" + C.cWhite + " to get started!"
|
||||||
);
|
);
|
||||||
hologram.start();
|
hologram.start();
|
||||||
@ -663,6 +660,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
public void Join(PlayerJoinEvent event)
|
public void Join(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
|
UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans!");
|
||||||
|
|
||||||
if (_incognitoManager.Get(event.getPlayer()).Status)
|
if (_incognitoManager.Get(event.getPlayer()).Status)
|
||||||
{
|
{
|
||||||
@ -801,7 +799,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is on version: " + F.elem(Clans.version())));
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is running Mineplex Clans version " + _plugin.getDescription().getVersion() + "!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1221,8 +1219,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
|
|
||||||
if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
|
if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon");
|
||||||
event.setKickMessage("Clans Beta is full! Try again soon");
|
event.setKickMessage("This Clans server is full! Try again soon");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1245,7 +1243,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
{
|
{
|
||||||
if (event.getMessage().toLowerCase().equals("/lobby") || event.getMessage().toLowerCase().equals("/hub") || event.getMessage().toLowerCase().equals("/leave"))
|
if (event.getMessage().toLowerCase().equals("/lobby") || event.getMessage().toLowerCase().equals("/hub") || event.getMessage().toLowerCase().equals("/leave"))
|
||||||
{
|
{
|
||||||
Portal.getInstance().sendPlayerToServer(event.getPlayer(), "Lobby");
|
Portal.getInstance().sendPlayerToServer(event.getPlayer(), "ClansHub");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,18 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.game.clans.clans.ClanInfo;
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.clans.banners.command.BannerCommand;
|
import mineplex.game.clans.clans.banners.command.BannerCommand;
|
||||||
|
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -91,11 +95,21 @@ public class BannerManager extends MiniPlugin
|
|||||||
|
|
||||||
public void placeBanner(Player placing, ClanBanner banner)
|
public void placeBanner(Player placing, ClanBanner banner)
|
||||||
{
|
{
|
||||||
|
if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Block block = placing.getLocation().getBlock();
|
Block block = placing.getLocation().getBlock();
|
||||||
BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, false);
|
BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, true);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled())
|
if (!event.isCancelled())
|
||||||
{
|
{
|
||||||
|
ClanTerritory claim = ClansManager.getInstance().getClanUtility().getClaim(block.getLocation());
|
||||||
|
if (claim != null && !claim.Owner.equals(banner.getClan().getName()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
ClansManager.getInstance().getBlockRestore().restore(block);
|
ClansManager.getInstance().getBlockRestore().restore(block);
|
||||||
if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)))
|
if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)))
|
||||||
{
|
{
|
||||||
@ -106,6 +120,11 @@ public class BannerManager extends MiniPlugin
|
|||||||
state.update();
|
state.update();
|
||||||
_placedBanners.put(block, System.currentTimeMillis());
|
_placedBanners.put(block, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +349,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Plugin.getTutorial().inTutorial(caller))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You cannot invite others while in a tutorial."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee."));
|
UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee."));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package mineplex.game.clans.clans.nether;
|
package mineplex.game.clans.clans.nether;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.Comparator;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -40,8 +39,6 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.WorldBorder;
|
import org.bukkit.WorldBorder;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -55,6 +52,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.event.player.PlayerPortalEvent;
|
import org.bukkit.event.player.PlayerPortalEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@ -64,12 +63,11 @@ public class NetherManager extends MiniPlugin
|
|||||||
private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand";
|
private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand";
|
||||||
private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"};
|
private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"};
|
||||||
private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build();
|
private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build();
|
||||||
|
private PortalRepository _repo;
|
||||||
private NetherMinibossManager _miniboss;
|
private NetherMinibossManager _miniboss;
|
||||||
private World _netherWorld;
|
private World _netherWorld;
|
||||||
public List<NetherPortal> Portals = Lists.newArrayList();
|
private List<NetherPortal> _portals = Lists.newArrayList();
|
||||||
private List<NetherPortal> _returnPortals = Lists.newArrayList();
|
private List<NetherPortal> _returnPortals = Lists.newArrayList();
|
||||||
private File _portalCfg;
|
|
||||||
private YamlConfiguration _portalConfig;
|
|
||||||
public HashMap<Player, Long> InNether = new HashMap<>();
|
public HashMap<Player, Long> InNether = new HashMap<>();
|
||||||
public HashMap<Player, Location> OverworldOrigins = new HashMap<>();
|
public HashMap<Player, Location> OverworldOrigins = new HashMap<>();
|
||||||
public HashMap<Player, ClaimData> Claiming = new HashMap<>();
|
public HashMap<Player, ClaimData> Claiming = new HashMap<>();
|
||||||
@ -78,21 +76,6 @@ public class NetherManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
super("Nether", manager.getPlugin());
|
super("Nether", manager.getPlugin());
|
||||||
|
|
||||||
_portalCfg = new File(UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "portals.yml");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_portalCfg.exists())
|
|
||||||
{
|
|
||||||
_portalCfg.createNewFile();
|
|
||||||
}
|
|
||||||
_portalConfig = YamlConfiguration.loadConfiguration(_portalCfg);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
begin();
|
begin();
|
||||||
_miniboss = new NetherMinibossManager(this);
|
_miniboss = new NetherMinibossManager(this);
|
||||||
addCommand(new PortalCommand(this));
|
addCommand(new PortalCommand(this));
|
||||||
@ -108,59 +91,24 @@ public class NetherManager extends MiniPlugin
|
|||||||
Bukkit.createWorld(creator);
|
Bukkit.createWorld(creator);
|
||||||
}
|
}
|
||||||
_netherWorld = Bukkit.getWorld("nether");
|
_netherWorld = Bukkit.getWorld("nether");
|
||||||
|
_netherWorld.setSpawnLocation(43, 135, 113);
|
||||||
WorldBorder worldBorder = _netherWorld.getWorldBorder();
|
WorldBorder worldBorder = _netherWorld.getWorldBorder();
|
||||||
worldBorder.setCenter(0, 0);
|
worldBorder.setCenter(0, 0);
|
||||||
worldBorder.setSize(200 * 2);
|
worldBorder.setSize(800 * 2);
|
||||||
|
|
||||||
|
_repo = new PortalRepository(getPlugin(), this);
|
||||||
loadPortals();
|
loadPortals();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadPortals()
|
private void loadPortals()
|
||||||
{
|
{
|
||||||
try
|
_repo.loadPortals();
|
||||||
{
|
|
||||||
if (!_portalConfig.isInt("PortalCount"))
|
|
||||||
{
|
|
||||||
_portalConfig.set("PortalCount", 0);
|
|
||||||
_portalConfig.save(_portalCfg);
|
|
||||||
}
|
|
||||||
|
|
||||||
log("Loading " + _portalConfig.getInt("PortalCount") + " Nether Portals!");
|
|
||||||
ConfigurationSection portalSection = _portalConfig.getConfigurationSection("Portals");
|
|
||||||
for (String portalSectionPath : portalSection.getKeys(false))
|
|
||||||
{
|
|
||||||
ConfigurationSection portal = portalSection.getConfigurationSection(portalSectionPath);
|
|
||||||
Location firstCorner = UtilWorld.strToLoc(portal.getString("CornerOne"));
|
|
||||||
Location secondCorner = UtilWorld.strToLoc(portal.getString("CornerTwo"));
|
|
||||||
boolean returnPortal = portal.getBoolean("ReturnPortal");
|
|
||||||
|
|
||||||
NetherPortal netherPortal = new NetherPortal(firstCorner, secondCorner, returnPortal);
|
|
||||||
Portals.add(netherPortal);
|
|
||||||
if (returnPortal)
|
|
||||||
{
|
|
||||||
_returnPortals.add(netherPortal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable()
|
public void disable()
|
||||||
{
|
{
|
||||||
closePortals();
|
closePortals();
|
||||||
try
|
|
||||||
{
|
|
||||||
savePortals();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
for (Player player : InNether.keySet())
|
for (Player player : InNether.keySet())
|
||||||
{
|
{
|
||||||
player.teleport(Spawn.getNorthSpawn());
|
player.teleport(Spawn.getNorthSpawn());
|
||||||
@ -188,14 +136,55 @@ public class NetherManager extends MiniPlugin
|
|||||||
return OverworldOrigins.getOrDefault(player, Spawn.getNorthSpawn());
|
return OverworldOrigins.getOrDefault(player, Spawn.getNorthSpawn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NetherPortal getPortal(int id)
|
||||||
|
{
|
||||||
|
for (NetherPortal portal : _portals)
|
||||||
|
{
|
||||||
|
if (portal.getId() == id)
|
||||||
|
{
|
||||||
|
return portal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPortal(NetherPortal portal)
|
||||||
|
{
|
||||||
|
_portals.add(portal);
|
||||||
|
if (portal.isReturnPortal())
|
||||||
|
{
|
||||||
|
_returnPortals.add(portal);
|
||||||
|
}
|
||||||
|
_portals.sort(new Comparator<NetherPortal>()
|
||||||
|
{
|
||||||
|
public int compare(NetherPortal o1, NetherPortal o2)
|
||||||
|
{
|
||||||
|
if (o1.getId() > o2.getId())
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePortal(NetherPortal portal)
|
||||||
|
{
|
||||||
|
portal.close();
|
||||||
|
_portals.remove(portal);
|
||||||
|
_returnPortals.remove(portal);
|
||||||
|
_repo.deletePortal(portal.getId());
|
||||||
|
}
|
||||||
|
|
||||||
public void spawnPortal(long duration)
|
public void spawnPortal(long duration)
|
||||||
{
|
{
|
||||||
if (Portals.isEmpty() || _returnPortals.isEmpty())
|
if (_portals.isEmpty() || _returnPortals.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<NetherPortal> available = Lists.newArrayList();
|
List<NetherPortal> available = Lists.newArrayList();
|
||||||
available.addAll(Portals);
|
available.addAll(_portals);
|
||||||
for (NetherPortal remove : _returnPortals)
|
for (NetherPortal remove : _returnPortals)
|
||||||
{
|
{
|
||||||
available.remove(remove);
|
available.remove(remove);
|
||||||
@ -228,28 +217,13 @@ public class NetherManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClaimData data = Claiming.remove(creator);
|
ClaimData data = Claiming.remove(creator);
|
||||||
NetherPortal portal = new NetherPortal(data.getFirstCorner().getLocation(), data.getSecondCorner().getLocation(), returnPortal);
|
_repo.addPortal(UtilWorld.locToStr(data.getFirstCorner().getLocation()), UtilWorld.locToStr(data.getSecondCorner().getLocation()), returnPortal);
|
||||||
Portals.add(portal);
|
|
||||||
if (returnPortal)
|
|
||||||
{
|
|
||||||
_returnPortals.add(portal);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
savePortals();
|
|
||||||
UtilPlayer.message(creator, F.main(getName(), "Portal successfully created!"));
|
UtilPlayer.message(creator, F.main(getName(), "Portal successfully created!"));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(creator, F.main(getName(), "An error occurred while creating that portal! Please report this immediately!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closePortals()
|
public void closePortals()
|
||||||
{
|
{
|
||||||
for (NetherPortal portal : Portals)
|
for (NetherPortal portal : _portals)
|
||||||
{
|
{
|
||||||
portal.close();
|
portal.close();
|
||||||
}
|
}
|
||||||
@ -258,12 +232,9 @@ public class NetherManager extends MiniPlugin
|
|||||||
public void showPortalList(Player player)
|
public void showPortalList(Player player)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main(getName(), "Portal List:"));
|
UtilPlayer.message(player, F.main(getName(), "Portal List:"));
|
||||||
for (int i = 0; i < Portals.size(); i++)
|
for (NetherPortal portal : _portals)
|
||||||
{
|
{
|
||||||
int id = i + 1;
|
UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + portal.getId() + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", "")));
|
||||||
NetherPortal portal = Portals.get(i);
|
|
||||||
|
|
||||||
UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + id + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", "")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,22 +244,6 @@ public class NetherManager extends MiniPlugin
|
|||||||
UtilPlayer.message(player, F.main(getName(), "You have been given a Portal Claim Wand!"));
|
UtilPlayer.message(player, F.main(getName(), "You have been given a Portal Claim Wand!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void savePortals() throws IOException
|
|
||||||
{
|
|
||||||
_portalConfig.set("PortalCount", Portals.size());
|
|
||||||
_portalConfig.set("Portals", null);
|
|
||||||
_portalConfig.createSection("Portals");
|
|
||||||
for (int i = 0; i < Portals.size(); i++)
|
|
||||||
{
|
|
||||||
Integer id = i + 1;
|
|
||||||
_portalConfig.set("Portals." + id.toString() + ".CornerOne", UtilWorld.locToStr(Portals.get(i).getCorners()[0]));
|
|
||||||
_portalConfig.set("Portals." + id.toString() + ".CornerTwo", UtilWorld.locToStr(Portals.get(i).getCorners()[1]));
|
|
||||||
_portalConfig.set("Portals." + id.toString() + ".ReturnPortal", Portals.get(i).isReturnPortal());
|
|
||||||
}
|
|
||||||
|
|
||||||
_portalConfig.save(_portalCfg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void breakBlock(BlockBreakEvent event)
|
public void breakBlock(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
@ -342,6 +297,7 @@ public class NetherManager extends MiniPlugin
|
|||||||
InNether.remove(event.getPlayer());
|
InNether.remove(event.getPlayer());
|
||||||
event.getPlayer().teleport(getReturnLocation(event.getPlayer()));
|
event.getPlayer().teleport(getReturnLocation(event.getPlayer()));
|
||||||
OverworldOrigins.remove(event.getPlayer());
|
OverworldOrigins.remove(event.getPlayer());
|
||||||
|
event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
|
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
@ -368,9 +324,18 @@ public class NetherManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
player.teleport(getReturnLocation(player));
|
player.teleport(getReturnLocation(player));
|
||||||
OverworldOrigins.remove(player);
|
OverworldOrigins.remove(player);
|
||||||
|
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!"));
|
UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!player.hasPotionEffect(PotionEffectType.NIGHT_VISION))
|
||||||
|
{
|
||||||
|
int ticks = (int)((InNether.get(player) - System.currentTimeMillis()) / 1000) * 20;
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, ticks, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilServer.getPlayersCollection()
|
UtilServer.getPlayersCollection()
|
||||||
@ -391,12 +356,13 @@ public class NetherManager extends MiniPlugin
|
|||||||
InNether.remove(event.getPlayer());
|
InNether.remove(event.getPlayer());
|
||||||
event.getPlayer().teleport(getReturnLocation(event.getPlayer()));
|
event.getPlayer().teleport(getReturnLocation(event.getPlayer()));
|
||||||
OverworldOrigins.remove(event.getPlayer());
|
OverworldOrigins.remove(event.getPlayer());
|
||||||
|
event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
}
|
}
|
||||||
Claiming.remove(event.getPlayer());
|
Claiming.remove(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onQuit(PlayerDeathEvent event)
|
public void onDie(PlayerDeathEvent event)
|
||||||
{
|
{
|
||||||
InNether.remove(event.getEntity());
|
InNether.remove(event.getEntity());
|
||||||
OverworldOrigins.remove(event.getEntity());
|
OverworldOrigins.remove(event.getEntity());
|
||||||
|
@ -23,12 +23,15 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
|||||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||||
import org.bukkit.event.entity.EntityPortalEvent;
|
import org.bukkit.event.entity.EntityPortalEvent;
|
||||||
import org.bukkit.event.player.PlayerPortalEvent;
|
import org.bukkit.event.player.PlayerPortalEvent;
|
||||||
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class NetherPortal implements Listener
|
public class NetherPortal implements Listener
|
||||||
{
|
{
|
||||||
private static final int SECONDS_UNTIL_PORTAL = 5;
|
private static final int SECONDS_UNTIL_PORTAL = 5;
|
||||||
|
private int _id;
|
||||||
private List<Block> _frame = Lists.newArrayList();
|
private List<Block> _frame = Lists.newArrayList();
|
||||||
private List<Block> _portal = Lists.newArrayList();
|
private List<Block> _portal = Lists.newArrayList();
|
||||||
private Location _loc;
|
private Location _loc;
|
||||||
@ -39,8 +42,9 @@ public class NetherPortal implements Listener
|
|||||||
public boolean Open = false;
|
public boolean Open = false;
|
||||||
public long Expire = -1;
|
public long Expire = -1;
|
||||||
|
|
||||||
public NetherPortal(Location firstCorner, Location secondCorner, boolean returnPortal)
|
public NetherPortal(int id, Location firstCorner, Location secondCorner, boolean returnPortal)
|
||||||
{
|
{
|
||||||
|
_id = id;
|
||||||
int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX());
|
int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX());
|
||||||
int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX());
|
int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX());
|
||||||
int maxY = Math.max(firstCorner.getBlockY(), secondCorner.getBlockY());
|
int maxY = Math.max(firstCorner.getBlockY(), secondCorner.getBlockY());
|
||||||
@ -99,6 +103,11 @@ public class NetherPortal implements Listener
|
|||||||
return _frame.contains(block) || _portal.contains(block);
|
return _frame.contains(block) || _portal.contains(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId()
|
||||||
|
{
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
public Location getLocation()
|
public Location getLocation()
|
||||||
{
|
{
|
||||||
return _loc;
|
return _loc;
|
||||||
@ -148,7 +157,6 @@ public class NetherPortal implements Listener
|
|||||||
{
|
{
|
||||||
Open = false;
|
Open = false;
|
||||||
Expire = -1;
|
Expire = -1;
|
||||||
HandlerList.unregisterAll(this);
|
|
||||||
for (Block block : _portal)
|
for (Block block : _portal)
|
||||||
{
|
{
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
@ -157,6 +165,7 @@ public class NetherPortal implements Listener
|
|||||||
{
|
{
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -204,6 +213,7 @@ public class NetherPortal implements Listener
|
|||||||
ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity());
|
ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity());
|
||||||
event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getReturnLocation((Player)event.getEntity()));
|
event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getReturnLocation((Player)event.getEntity()));
|
||||||
ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity());
|
ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity());
|
||||||
|
((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
|
UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -241,4 +251,13 @@ public class NetherPortal implements Listener
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onUnload(ChunkUnloadEvent event)
|
||||||
|
{
|
||||||
|
if (event.getChunk().getX() == _loc.getChunk().getX() && event.getChunk().getZ() == _loc.getChunk().getZ())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
package mineplex.game.clans.clans.nether;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
|
import mineplex.core.database.MinecraftRepository;
|
||||||
|
import mineplex.serverdata.database.DBPool;
|
||||||
|
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||||
|
import mineplex.serverdata.database.column.ColumnInt;
|
||||||
|
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class PortalRepository extends MinecraftRepository
|
||||||
|
{
|
||||||
|
private static final String CREATE = "CREATE TABLE IF NOT EXISTS clansNetherPortals (id INT NOT NULL AUTO_INCREMENT,"
|
||||||
|
+ "cornerOne VARCHAR(30),"
|
||||||
|
+ "cornerTwo VARCHAR(30),"
|
||||||
|
+ "returnPortal BOOL,"
|
||||||
|
+ "PRIMARY KEY (id));";
|
||||||
|
|
||||||
|
private static final String GET_PORTALS = "SELECT * FROM clansNetherPortals;";
|
||||||
|
private static final String INSERT_PORTAL = "INSERT INTO clansNetherPortals (cornerOne, cornerTwo, returnPortal) VALUES (?, ?, ?);";
|
||||||
|
private static final String DELETE_PORTAL = "DELETE FROM clansNetherPortals WHERE id=?;";
|
||||||
|
|
||||||
|
private NetherManager _nether;
|
||||||
|
|
||||||
|
public PortalRepository(JavaPlugin plugin, NetherManager portalManager)
|
||||||
|
{
|
||||||
|
super(plugin, DBPool.getAccount());
|
||||||
|
|
||||||
|
_nether = portalManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadPortals()
|
||||||
|
{
|
||||||
|
_nether.runAsync(() ->
|
||||||
|
{
|
||||||
|
executeQuery(GET_PORTALS, resultSet ->
|
||||||
|
{
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
final int id = resultSet.getInt("id");
|
||||||
|
final String cornerOne = resultSet.getString("cornerOne");
|
||||||
|
final String cornerTwo = resultSet.getString("cornerTwo");
|
||||||
|
final boolean returnPortal = resultSet.getBoolean("returnPortal");
|
||||||
|
|
||||||
|
_nether.runSync(() ->
|
||||||
|
{
|
||||||
|
NetherPortal portal = new NetherPortal(id, UtilWorld.strToLoc(cornerOne), UtilWorld.strToLoc(cornerTwo), returnPortal);
|
||||||
|
_nether.addPortal(portal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPortal(final String cornerOne, final String cornerTwo, final boolean returnPortal)
|
||||||
|
{
|
||||||
|
_nether.runAsync(() ->
|
||||||
|
{
|
||||||
|
executeInsert(INSERT_PORTAL, resultSet ->
|
||||||
|
{
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
final int id = resultSet.getInt(1);
|
||||||
|
_nether.runSync(() ->
|
||||||
|
{
|
||||||
|
NetherPortal portal = new NetherPortal(id, UtilWorld.strToLoc(cornerOne), UtilWorld.strToLoc(cornerTwo), returnPortal);
|
||||||
|
_nether.addPortal(portal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, new ColumnVarChar("cornerOne", 30, cornerOne), new ColumnVarChar("cornerTwo", 30, cornerTwo), new ColumnBoolean("returnPortal", returnPortal));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePortal(final int id)
|
||||||
|
{
|
||||||
|
_nether.runAsync(() ->
|
||||||
|
{
|
||||||
|
executeUpdate(DELETE_PORTAL, new ColumnInt("id", id));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initialize()
|
||||||
|
{
|
||||||
|
executeUpdate(CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import mineplex.core.common.Rank;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.game.clans.clans.nether.NetherManager;
|
import mineplex.game.clans.clans.nether.NetherManager;
|
||||||
|
import mineplex.game.clans.clans.nether.NetherPortal;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -27,21 +28,13 @@ public class DeleteCommand extends CommandBase<NetherManager>
|
|||||||
id = Integer.parseInt(args[0]);
|
id = Integer.parseInt(args[0]);
|
||||||
}
|
}
|
||||||
catch (Exception e) {}
|
catch (Exception e) {}
|
||||||
if (id == null || id > Plugin.Portals.size() || id < 1)
|
if (id == null || Plugin.getPortal(id) == null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " <ID>")));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " <ID>")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
NetherPortal portal = Plugin.getPortal(id);
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Deleting the " + F.clansNether("Nether Portal") + " with ID " + id + "!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Deleting the " + F.clansNether("Nether Portal") + " with ID " + id + "!"));
|
||||||
Plugin.Portals.remove(id - 1);
|
Plugin.deletePortal(portal);
|
||||||
try
|
|
||||||
{
|
|
||||||
Plugin.savePortals();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while deleting that portal! Please report this immediately!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,12 +4,15 @@ import mineplex.core.command.CommandBase;
|
|||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.clans.nether.NetherManager;
|
import mineplex.game.clans.clans.nether.NetherManager;
|
||||||
import mineplex.game.clans.spawn.Spawn;
|
import mineplex.game.clans.spawn.Spawn;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command to artificially portal
|
* Command to artificially portal
|
||||||
@ -38,6 +41,7 @@ public class ForceTeleportCommand extends CommandBase<NetherManager>
|
|||||||
Plugin.InNether.remove(caller);
|
Plugin.InNether.remove(caller);
|
||||||
caller.teleport(Plugin.getReturnLocation(caller));
|
caller.teleport(Plugin.getReturnLocation(caller));
|
||||||
Plugin.OverworldOrigins.remove(caller);
|
Plugin.OverworldOrigins.remove(caller);
|
||||||
|
caller.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
|
UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -49,7 +53,7 @@ public class ForceTeleportCommand extends CommandBase<NetherManager>
|
|||||||
{
|
{
|
||||||
if (natural)
|
if (natural)
|
||||||
{
|
{
|
||||||
Plugin.InNether.put(caller, System.currentTimeMillis());
|
Plugin.InNether.put(caller, System.currentTimeMillis() + UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
|
||||||
Plugin.OverworldOrigins.put(caller, caller.getLocation());
|
Plugin.OverworldOrigins.put(caller, caller.getLocation());
|
||||||
caller.teleport(Plugin.getNetherWorld().getSpawnLocation());
|
caller.teleport(Plugin.getNetherWorld().getSpawnLocation());
|
||||||
ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, caller);
|
ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, caller);
|
||||||
|
@ -44,8 +44,8 @@ public class MinibossFireball implements Listener
|
|||||||
{
|
{
|
||||||
double range = hitMap.get(cur);
|
double range = hitMap.get(cur);
|
||||||
|
|
||||||
ClansManager.getInstance().getCondition().Factory().Ignite("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0)), 7 * range, false, false);
|
ClansManager.getInstance().getCondition().Factory().Ignite("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 7 * range, false, false);
|
||||||
ClansManager.getInstance().getCondition().Factory().Falling("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0)), 10, false, true);
|
ClansManager.getInstance().getCondition().Factory().Falling("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 10, false, true);
|
||||||
UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()),
|
UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()),
|
||||||
1.6 * range, false, 0, 0.8 * range, 1.2, true);
|
1.6 * range, false, 0, 0.8 * range, 1.2, true);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
package mineplex.game.clans.clans.nether.miniboss;
|
package mineplex.game.clans.clans.nether.miniboss;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.game.clans.clans.nether.NetherManager;
|
import mineplex.game.clans.clans.nether.NetherManager;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
@ -19,23 +21,60 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
public class NetherMinibossManager implements Listener
|
public class NetherMinibossManager implements Listener
|
||||||
{
|
{
|
||||||
private static final long TIME_BETWEEN_MINIBOSS_TARGET_PLAYER = 10000;
|
private static final long MINIBOSS_SPAWN_RATE = 10000;
|
||||||
private NetherManager _manager;
|
private NetherManager _manager;
|
||||||
|
private HashMap<Location, NetherMinibossType> _spawns = new HashMap<>();
|
||||||
|
private long _lastSpawned;
|
||||||
private boolean _allowSpawn = false;
|
private boolean _allowSpawn = false;
|
||||||
|
|
||||||
public NetherMinibossManager(NetherManager manager)
|
public NetherMinibossManager(NetherManager manager)
|
||||||
{
|
{
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
new MinibossFireball();
|
new MinibossFireball();
|
||||||
|
manager.runSyncLater(() ->
|
||||||
|
{
|
||||||
|
List<Location> sort = Lists.newArrayList();
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), -18, 142, 61));
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), -39, 133, -25));
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), -102, 133, -99));
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), -27, 141, -140));
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), 32, 143, -95));
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), 43, 134, 22));
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), 102, 141, -31));
|
||||||
|
sort.add(new Location(manager.getNetherWorld(), 151, 136, 34));
|
||||||
|
sort.sort(new Comparator<Location>()
|
||||||
|
{
|
||||||
|
public int compare(Location o1, Location o2)
|
||||||
|
{
|
||||||
|
if (UtilMath.offset2d(o1, manager.getNetherWorld().getSpawnLocation()) < UtilMath.offset(o2, manager.getNetherWorld().getSpawnLocation()))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
_spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.ARCHER);
|
||||||
|
}
|
||||||
|
for (int i = 3; i < 6; i++)
|
||||||
|
{
|
||||||
|
_spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.WARRIOR);
|
||||||
|
}
|
||||||
|
for (int i = 6; i < 8; i++)
|
||||||
|
{
|
||||||
|
_spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.GHAST);
|
||||||
|
}
|
||||||
Bukkit.getPluginManager().registerEvents(this, manager.getPlugin());
|
Bukkit.getPluginManager().registerEvents(this, manager.getPlugin());
|
||||||
|
}, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnAttacker(Player player)
|
private void spawnAttacker(Location loc)
|
||||||
{
|
{
|
||||||
NetherMinibossType bossType = NetherMinibossType.values()[UtilMath.r(NetherMinibossType.values().length)];
|
NetherMinibossType bossType = _spawns.get(loc);
|
||||||
|
|
||||||
_allowSpawn = true;
|
_allowSpawn = true;
|
||||||
bossType.getNewInstance(player.getLocation());
|
bossType.getNewInstance(loc);
|
||||||
_allowSpawn = false;
|
_allowSpawn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,18 +98,12 @@ public class NetherMinibossManager implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Player> targets = Lists.newArrayList();
|
if (!_manager.InNether.isEmpty() && UtilTime.elapsed(_lastSpawned, MINIBOSS_SPAWN_RATE))
|
||||||
targets.addAll(_manager.InNether.keySet());
|
|
||||||
|
|
||||||
for (Player player : targets)
|
|
||||||
{
|
{
|
||||||
if (player.isDead() || !player.isValid())
|
_lastSpawned = System.currentTimeMillis();
|
||||||
|
for (Location spawn : _spawns.keySet())
|
||||||
{
|
{
|
||||||
continue;
|
spawnAttacker(spawn);
|
||||||
}
|
|
||||||
if (_manager.isInNether(player) && Recharge.Instance.use(player, "Nether Miniboss Spawn", TIME_BETWEEN_MINIBOSS_TARGET_PLAYER, false, false))
|
|
||||||
{
|
|
||||||
spawnAttacker(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,21 @@ package mineplex.game.clans.clans.nether.miniboss.bosses;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.clans.nether.miniboss.MinibossFireball;
|
import mineplex.game.clans.clans.nether.miniboss.MinibossFireball;
|
||||||
import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss;
|
import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss;
|
||||||
import mineplex.game.clans.items.runes.RuneManager.RuneAttribute;
|
import mineplex.game.clans.items.runes.RuneManager.RuneAttribute;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Ghast;
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -80,18 +84,27 @@ public class GhastMiniboss extends NetherMiniBoss<Ghast>
|
|||||||
@Override
|
@Override
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
|
Player target = null;
|
||||||
|
for (Player test : UtilPlayer.getInRadius(getEntity().getLocation(), 25).keySet())
|
||||||
|
{
|
||||||
|
if (test.getGameMode() == GameMode.SURVIVAL && !ClansManager.getInstance().getIncognitoManager().Get(test).Hidden)
|
||||||
|
{
|
||||||
|
target = test;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
UtilEnt.LookAt(getEntity(), target.getLocation());
|
||||||
tryFireballVolley();
|
tryFireballVolley();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onShoot(ProjectileLaunchEvent event)
|
public void onShoot(ProjectileLaunchEvent event)
|
||||||
{
|
{
|
||||||
if (event.getEntity().getShooter() != null && event.getEntity().getShooter().equals(getEntity()))
|
if (event.getEntity().getShooter() != null && event.getEntity().getShooter().equals(getEntity()))
|
||||||
{
|
{
|
||||||
if (!MinibossFireball.isFireball(event.getEntity()))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
ClansManager.getInstance().runSyncLater(() ->
|
ClansManager.getInstance().runSyncLater(() ->
|
||||||
{
|
{
|
||||||
if (event.getEntity() == null || event.getEntity().isDead() || !event.getEntity().isValid())
|
if (event.getEntity() == null || event.getEntity().isDead() || !event.getEntity().isValid())
|
||||||
|
@ -44,7 +44,7 @@ public class ClansScoreboardManager extends ScoreboardManager
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setTitle("Clans " + Clans.VERSION);
|
setTitle("Clans " + Clans.getMap());
|
||||||
|
|
||||||
ScoreboardData data = getData("default", true);
|
ScoreboardData data = getData("default", true);
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package mineplex.game.clans.clans.scoreboard.elements;
|
package mineplex.game.clans.clans.scoreboard.elements;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.scoreboard.ScoreboardManager;
|
import mineplex.core.scoreboard.ScoreboardManager;
|
||||||
@ -12,6 +9,10 @@ import mineplex.core.scoreboard.elements.ScoreboardElement;
|
|||||||
import mineplex.game.clans.clans.ClanInfo;
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class ScoreboardElementClan implements ScoreboardElement
|
public class ScoreboardElementClan implements ScoreboardElement
|
||||||
{
|
{
|
||||||
private ClansManager _clansManager;
|
private ClansManager _clansManager;
|
||||||
@ -24,22 +25,28 @@ public class ScoreboardElementClan implements ScoreboardElement
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||||
{
|
{
|
||||||
List<String> output = new ArrayList<String>();
|
List<String> output = Lists.newArrayList();
|
||||||
|
|
||||||
ClanInfo clanInfo = _clansManager.getClan(player);
|
ClanInfo clanInfo = _clansManager.getClan(player);
|
||||||
|
|
||||||
if (clanInfo != null)
|
if (clanInfo != null)
|
||||||
{
|
{
|
||||||
output.add(C.cYellow + "Clan " + C.cWhite + clanInfo.getName());
|
output.add(C.cYellowB + "Clan");
|
||||||
output.add(C.cYellow + "Online " + C.cWhite + clanInfo.getOnlinePlayers().size() + "/" + clanInfo.getMembers().size());
|
output.add(_clansManager.getClanUtility().mRel(_clansManager.getRelation(player, player), clanInfo.getName(), false));
|
||||||
|
output.add(" ");
|
||||||
// Energy
|
// Energy
|
||||||
if (clanInfo.getEnergyCostPerMinute() > 0)
|
if (clanInfo.getEnergyCostPerMinute() > 0)
|
||||||
output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT));
|
{
|
||||||
|
output.add(C.cYellowB + "Clan Energy");
|
||||||
|
output.add(C.cGreen + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT));
|
||||||
|
output.add(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output.add(C.cYellow + "You are not in a Clan");
|
output.add(C.cYellowB + "Clan");
|
||||||
|
output.add("No Clan");
|
||||||
|
output.add(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.scoreboard.ScoreboardManager;
|
import mineplex.core.scoreboard.ScoreboardManager;
|
||||||
@ -25,11 +27,14 @@ public class ScoreboardElementPlayer implements ScoreboardElement
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||||
{
|
{
|
||||||
List<String> output = new ArrayList<String>();
|
List<String> output = Lists.newArrayList();
|
||||||
output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD) + "");
|
output.add(C.cYellowB + "Gold");
|
||||||
String regionString = C.xWilderness + "Wilderness";
|
output.add(C.cGold + manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD));
|
||||||
|
|
||||||
output.add(" ");
|
output.add(" ");
|
||||||
|
|
||||||
|
output.add(C.cYellowB + "Territory");
|
||||||
|
String regionString = C.xWilderness + "Wilderness";
|
||||||
ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation());
|
ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation());
|
||||||
if (claim != null)
|
if (claim != null)
|
||||||
{
|
{
|
||||||
@ -41,14 +46,15 @@ public class ScoreboardElementPlayer implements ScoreboardElement
|
|||||||
|
|
||||||
//Trust
|
//Trust
|
||||||
if (relation == ClansUtility.ClanRelation.ALLY_TRUST)
|
if (relation == ClansUtility.ClanRelation.ALLY_TRUST)
|
||||||
|
{
|
||||||
regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")";
|
regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (_clansManager.getNetherManager().isInNether(player))
|
if (_clansManager.getNetherManager().isInNether(player))
|
||||||
// {
|
{
|
||||||
// regionString = C.cRed + "The Nether";
|
regionString = C.cClansNether + "The Nether";
|
||||||
// }
|
}
|
||||||
|
|
||||||
output.add(regionString);
|
output.add(regionString);
|
||||||
|
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
package mineplex.game.clans.clans.siege;
|
package mineplex.game.clans.clans.siege;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Slime;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
@ -21,6 +11,7 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.clans.siege.command.GiveWeaponCommand;
|
||||||
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
|
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
|
||||||
import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository;
|
import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository;
|
||||||
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
|
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
|
||||||
@ -30,6 +21,16 @@ import mineplex.game.clans.core.repository.ClanTerritory;
|
|||||||
import mineplex.game.clans.spawn.Spawn;
|
import mineplex.game.clans.spawn.Spawn;
|
||||||
import net.minecraft.server.v1_8_R3.Material;
|
import net.minecraft.server.v1_8_R3.Material;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
public class SiegeManager extends MiniPlugin
|
public class SiegeManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
private ClansManager _clansManager;
|
private ClansManager _clansManager;
|
||||||
@ -79,6 +80,8 @@ public class SiegeManager extends MiniPlugin
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
addCommand(new GiveWeaponCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -222,12 +225,12 @@ public class SiegeManager extends MiniPlugin
|
|||||||
|
|
||||||
public boolean trySpawnCannon(Player player, Location location)
|
public boolean trySpawnCannon(Player player, Location location)
|
||||||
{
|
{
|
||||||
// if (_clansManager.getNetherManager().isInNether(player))
|
if (_clansManager.getNetherManager().isInNether(player))
|
||||||
// {
|
{
|
||||||
// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
_clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
||||||
//
|
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (!_clansManager.isInClan(player))
|
if (!_clansManager.isInClan(player))
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package mineplex.game.clans.clans.siege.command;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||||
|
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
||||||
|
|
||||||
|
public class GiveWeaponCommand extends CommandBase<SiegeManager>
|
||||||
|
{
|
||||||
|
public GiveWeaponCommand(SiegeManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ADMIN, "giveweapon", "siegeweapon", "givecannon");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
UtilInv.insert(caller, Cannon.CANNON_ITEM.clone());
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have been given a cannon!"));
|
||||||
|
}
|
||||||
|
}
|
@ -1,95 +1,24 @@
|
|||||||
package mineplex.game.clans.clans.siege.weapon.projectile;
|
package mineplex.game.clans.clans.siege.weapon.projectile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.Chest;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilBlock;
|
|
||||||
import mineplex.core.common.util.UtilItem;
|
|
||||||
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.UtilServer;
|
|
||||||
import mineplex.core.updater.UpdateType;
|
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
|
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
|
||||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||||
import net.minecraft.server.v1_8_R3.Explosion;
|
|
||||||
|
|
||||||
public class Crater implements Listener
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class Crater
|
||||||
{
|
{
|
||||||
public static final Material CHARRED_TYPE = Material.OBSIDIAN;
|
|
||||||
|
|
||||||
private final SiegeWeapon _weapon;
|
private final SiegeWeapon _weapon;
|
||||||
private final Location _origin;
|
private final Location _origin;
|
||||||
|
|
||||||
private final long _birthTime;
|
|
||||||
|
|
||||||
private final List<CraterBlock> _blocks;
|
|
||||||
|
|
||||||
public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin)
|
public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin)
|
||||||
{
|
{
|
||||||
_weapon = weapon;
|
_weapon = weapon;
|
||||||
_origin = origin;
|
_origin = origin;
|
||||||
|
|
||||||
_birthTime = System.currentTimeMillis();
|
|
||||||
_blocks = new ArrayList<>();
|
|
||||||
|
|
||||||
UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin());
|
|
||||||
|
|
||||||
createExplosion();
|
createExplosion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void updateEffects(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (event.getType() != UpdateType.TICK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_blocks.stream().filter(block -> block.Type == CHARRED_TYPE).forEach(block -> {
|
|
||||||
long lifetime = System.currentTimeMillis() - _birthTime;
|
|
||||||
|
|
||||||
long max = 80000;
|
|
||||||
|
|
||||||
if (block.Location.getBlock().getType() != CHARRED_TYPE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Water touching the charred blocks
|
|
||||||
if (UtilBlock.getInRadius(block.Location, 1.6).keySet().stream().filter(water -> water.getType() == Material.WATER).iterator().hasNext())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lifetime < max)
|
|
||||||
{
|
|
||||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, block.Location.clone().add(.5, 1, .5), new Vector(0, 0, 0), .0f, 3, ViewDist.MAX);
|
|
||||||
UtilParticle.PlayParticleToAll(lifetime >= max / 1.4 ? ParticleType.SMOKE : ParticleType.LARGE_SMOKE, block.Location.clone().add(.5, .8, .5), new Vector(0, 0, 0), .0f, 1, ViewDist.MAX);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HandlerList.unregisterAll(this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createExplosion()
|
private void createExplosion()
|
||||||
{
|
{
|
||||||
ClanTerritory terr = _weapon.getClans().getClanUtility().getClaim(_origin);
|
ClanTerritory terr = _weapon.getClans().getClanUtility().getClaim(_origin);
|
||||||
@ -98,58 +27,12 @@ public class Crater implements Listener
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ClanInfo clan = ClansManager.getInstance().getClanUtility().getOwner(terr);
|
||||||
boolean explosion = _origin.getWorld().createExplosion(_origin, 2.6f);
|
if (clan != null && !ClansManager.getInstance().getWarManager().isBeingBesiegedBy(clan, _weapon.getOwner()))
|
||||||
|
|
||||||
boolean floating = _origin.distance(UtilBlock.nearestFloor(_origin)) > 0.6;
|
|
||||||
|
|
||||||
if (explosion)
|
|
||||||
{
|
{
|
||||||
for (Block block : UtilBlock.getInRadius(_origin.getBlock(), 2.6f).keySet())
|
return;
|
||||||
{
|
|
||||||
boolean charred = false;
|
|
||||||
double dist = block.getLocation().distance(_origin);
|
|
||||||
|
|
||||||
if (floating)
|
|
||||||
{
|
|
||||||
if (!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
|
|
||||||
&& !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
|
|
||||||
&& Math.random() > 0.79)
|
|
||||||
{
|
|
||||||
charred = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR)
|
|
||||||
&& !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
|
|
||||||
&& !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
|
|
||||||
&& Math.random() > 0.79)
|
|
||||||
{
|
|
||||||
charred = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.getType().equals(Material.SMOOTH_BRICK))
|
_origin.getWorld().createExplosion(_origin, 2.6f);
|
||||||
{
|
|
||||||
charred = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (block.getType().equals(Material.BEDROCK))
|
|
||||||
{
|
|
||||||
charred = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (charred)
|
|
||||||
{
|
|
||||||
CraterBlock charredBlock = new CraterBlock(block.getLocation(), dist, CHARRED_TYPE, (byte) 0);
|
|
||||||
|
|
||||||
charredBlock.set();
|
|
||||||
|
|
||||||
_blocks.add(charredBlock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -7,12 +7,6 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
@ -31,10 +25,18 @@ import mineplex.game.clans.clans.ClansUtility;
|
|||||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||||
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
|
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
|
||||||
import mineplex.game.clans.clans.war.command.WarPointsCommand;
|
import mineplex.game.clans.clans.war.command.WarPointsCommand;
|
||||||
import mineplex.game.clans.clans.war.event.WarInvasionEndEvent;
|
import mineplex.game.clans.clans.war.event.WarSiegeEndEvent;
|
||||||
import mineplex.game.clans.clans.war.event.WarInvasionStartEvent;
|
import mineplex.game.clans.clans.war.event.WarSiegeStartEvent;
|
||||||
import mineplex.game.clans.core.war.ClanWarData;
|
import mineplex.game.clans.core.war.ClanWarData;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class WarManager extends MiniPlugin implements ScoreboardElement
|
public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||||
{
|
{
|
||||||
public static final int WAR_START_POINTS = 0;
|
public static final int WAR_START_POINTS = 0;
|
||||||
@ -45,18 +47,17 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
|||||||
private final ClansManager _clansManager;
|
private final ClansManager _clansManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of the active war invasions. This is indexed by the clan that is being invaded on
|
* Map of the active war sieges. This is indexed by the clan that is being besieged
|
||||||
* We will need to access this when blocks are broken in the invaded on clan's land!
|
|
||||||
*/
|
*/
|
||||||
private Map<String, List<WarInvasion>> _invadedMap;
|
private Map<String, List<WarSiege>> _besiegedMap;
|
||||||
private Map<String, List<WarInvasion>> _invaderMap;
|
private Map<String, List<WarSiege>> _besiegerMap;
|
||||||
|
|
||||||
public WarManager(JavaPlugin plugin, ClansManager clansManager)
|
public WarManager(JavaPlugin plugin, ClansManager clansManager)
|
||||||
{
|
{
|
||||||
super("ClanWar Manager", plugin);
|
super("ClanWar Manager", plugin);
|
||||||
_clansManager = clansManager;
|
_clansManager = clansManager;
|
||||||
_invadedMap = new HashMap<String, List<WarInvasion>>();
|
_besiegedMap = new HashMap<>();
|
||||||
_invaderMap = new HashMap<String, List<WarInvasion>>();
|
_besiegerMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClansManager getClansManager()
|
public ClansManager getClansManager()
|
||||||
@ -64,40 +65,37 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
|||||||
return _clansManager;
|
return _clansManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WarInvasion> getInvasionsOn(ClanInfo invaded)
|
public List<WarSiege> getSiegesOn(ClanInfo besieged)
|
||||||
{
|
{
|
||||||
return _invadedMap.get(invaded.getName());
|
return _besiegedMap.get(besieged.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WarInvasion> getInvasionsFor(ClanInfo invader)
|
public List<WarSiege> getSiegesFor(ClanInfo besieger)
|
||||||
{
|
{
|
||||||
return _invaderMap.get(invader.getName());
|
return _besiegerMap.get(besieger.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBeingInvaded(ClanInfo clanInfo)
|
public boolean isBeingBesieged(ClanInfo clanInfo)
|
||||||
{
|
{
|
||||||
List<WarInvasion> invasions = _invadedMap.get(clanInfo.getName());
|
List<WarSiege> sieges = _besiegedMap.get(clanInfo.getName());
|
||||||
return invasions != null && !invasions.isEmpty();
|
return sieges != null && !sieges.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInvading(ClanInfo clanInfo)
|
public boolean isBesieging(ClanInfo clanInfo)
|
||||||
{
|
{
|
||||||
List<WarInvasion> invasions = _invaderMap.get(clanInfo.getName());
|
List<WarSiege> sieges = _besiegerMap.get(clanInfo.getName());
|
||||||
return invasions != null && !invasions.isEmpty();
|
return sieges != null && !sieges.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowFromInvade(Location location, Player player)
|
public boolean isBeingBesiegedBy(ClanInfo besieged, ClanInfo besieger)
|
||||||
{
|
{
|
||||||
ClanInfo clanInfo = _clansManager.getClanUtility().getOwner(location);
|
List<WarSiege> sieges = _besiegedMap.get(besieged.getName());
|
||||||
ClanInfo playerClan = _clansManager.getClan(player);
|
if (sieges != null && !sieges.isEmpty())
|
||||||
if (clanInfo != null)
|
|
||||||
{
|
{
|
||||||
List<WarInvasion> invasions = _invadedMap.get(clanInfo.getName());
|
for (WarSiege siege : sieges)
|
||||||
if (invasions != null)
|
|
||||||
{
|
{
|
||||||
for (WarInvasion invasion : invasions)
|
if (siege.getBesiegingClan().equals(besieger.getName()))
|
||||||
{
|
{
|
||||||
if (invasion.getInvaderClan().equals(playerClan.getName()))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,14 +104,6 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear all invasions against clan. This is typically used for when a clan is deleted
|
|
||||||
*/
|
|
||||||
// public void clearInvasions(String clan)
|
|
||||||
// {
|
|
||||||
// List<WarInvasion> invasions =
|
|
||||||
// }
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleDeath(final ClansPlayerDeathEvent event)
|
public void handleDeath(final ClansPlayerDeathEvent event)
|
||||||
{
|
{
|
||||||
@ -184,106 +174,107 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
|||||||
|
|
||||||
private void checkWarComplete(ClanWarData war)
|
private void checkWarComplete(ClanWarData war)
|
||||||
{
|
{
|
||||||
String invaderClan = null;
|
String besiegerClan = null;
|
||||||
String invadedClan = null;
|
String besiegedClan = null;
|
||||||
|
|
||||||
if (war.getClanAPoints() >= WAR_FINISH_POINTS)
|
if (war.getClanAPoints() >= WAR_FINISH_POINTS)
|
||||||
{
|
{
|
||||||
// Clan A invades Clan B
|
besiegerClan = war.getClanA();
|
||||||
invaderClan = war.getClanA();
|
besiegedClan = war.getClanB();
|
||||||
invadedClan = war.getClanB();
|
|
||||||
}
|
}
|
||||||
else if (war.getClanBPoints() >= WAR_FINISH_POINTS)
|
else if (war.getClanBPoints() >= WAR_FINISH_POINTS)
|
||||||
{
|
{
|
||||||
// Clan B invades Clan A
|
besiegerClan = war.getClanB();
|
||||||
invaderClan = war.getClanB();
|
besiegedClan = war.getClanA();
|
||||||
invadedClan = war.getClanA();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invadedClan != null && invaderClan != null)
|
if (besiegedClan != null && besiegerClan != null)
|
||||||
{
|
{
|
||||||
// Reset War to 0:0
|
// Reset War to 0:0
|
||||||
war.resetPoints();
|
war.resetPoints();
|
||||||
war.setCooldown(WAR_COOLDOWN);
|
war.setCooldown(WAR_COOLDOWN);
|
||||||
|
|
||||||
WarInvasion invasion = new WarInvasion(invadedClan, invaderClan);
|
WarSiege siege = new WarSiege(besiegedClan, besiegerClan);
|
||||||
startInvasion(invasion);
|
startSiege(siege);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startInvasion(WarInvasion invasion)
|
private void startSiege(WarSiege siege)
|
||||||
{
|
{
|
||||||
String invaded = invasion.getInvadedClan();
|
String besieged = siege.getBesiegedClan();
|
||||||
String invader = invasion.getInvaderClan();
|
String besieger = siege.getBesiegingClan();
|
||||||
|
|
||||||
addInvasion(invaded, invasion, _invadedMap);
|
addSiege(besieged, siege, _besiegedMap);
|
||||||
addInvasion(invader, invasion, _invaderMap);
|
addSiege(besieger, siege, _besiegerMap);
|
||||||
|
|
||||||
WarInvasionStartEvent event = new WarInvasionStartEvent(invasion);
|
WarSiegeStartEvent event = new WarSiegeStartEvent(siege);
|
||||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addInvasion(String name, WarInvasion invasion, Map<String, List<WarInvasion>> invasionMap)
|
private void addSiege(String name, WarSiege siege, Map<String, List<WarSiege>> siegeMap)
|
||||||
{
|
{
|
||||||
if (invasionMap.containsKey(name))
|
if (siegeMap.containsKey(name))
|
||||||
{
|
{
|
||||||
invasionMap.get(name).add(invasion);
|
siegeMap.get(name).add(siege);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LinkedList<WarInvasion> invasions = new LinkedList<WarInvasion>();
|
LinkedList<WarSiege> sieges = new LinkedList<>();
|
||||||
invasions.add(invasion);
|
sieges.add(siege);
|
||||||
invasionMap.put(name, invasions);
|
siegeMap.put(name, sieges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void clearInvasions(UpdateEvent event)
|
public void clearSieges(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.SEC)
|
if (event.getType() != UpdateType.SEC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
Iterator<Map.Entry<String, List<WarInvasion>>> iterator = _invadedMap.entrySet().iterator();
|
Iterator<Map.Entry<String, List<WarSiege>>> iterator = _besiegedMap.entrySet().iterator();
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
{
|
{
|
||||||
List<WarInvasion> invasions = iterator.next().getValue();
|
List<WarSiege> sieges = iterator.next().getValue();
|
||||||
Iterator<WarInvasion> invasionIterator = invasions.iterator();
|
Iterator<WarSiege> siegeIterator = sieges.iterator();
|
||||||
while (invasionIterator.hasNext())
|
while (siegeIterator.hasNext())
|
||||||
{
|
{
|
||||||
WarInvasion invasion = invasionIterator.next();
|
WarSiege siege = siegeIterator.next();
|
||||||
if (currentTime >= invasion.getEndTime())
|
if (currentTime >= siege.getEndTime())
|
||||||
{
|
{
|
||||||
WarInvasionEndEvent endEvent = new WarInvasionEndEvent(invasion);
|
WarSiegeEndEvent endEvent = new WarSiegeEndEvent(siege);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(endEvent);
|
Bukkit.getServer().getPluginManager().callEvent(endEvent);
|
||||||
|
|
||||||
List<WarInvasion> invaderList = _invaderMap.get(invasion.getInvaderClan());
|
List<WarSiege> besiegerList = _besiegerMap.get(siege.getBesiegingClan());
|
||||||
if (invaderList != null)
|
if (besiegerList != null)
|
||||||
{
|
{
|
||||||
invaderList.remove(invasion);
|
besiegerList.remove(siege);
|
||||||
if (invaderList.isEmpty()) _invaderMap.remove(invasion.getInvaderClan());
|
if (besiegerList.isEmpty())
|
||||||
}
|
{
|
||||||
|
_besiegerMap.remove(siege.getBesiegingClan());
|
||||||
invasionIterator.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invasions.isEmpty())
|
siegeIterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sieges.isEmpty())
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInvasionStart(WarInvasionStartEvent event)
|
public void onSiegeStart(WarSiegeStartEvent event)
|
||||||
{
|
{
|
||||||
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + " can now invade " + F.elem(event.getWarInvasion().getInvadedClan())));
|
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarSiege().getBesiegingClan()) + " can now besiege " + F.elem(event.getWarSiege().getBesiegedClan())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInvasionEnd(WarInvasionEndEvent event)
|
public void onSiegeEnd(WarSiegeEndEvent event)
|
||||||
{
|
{
|
||||||
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvadedClan()) + " has ended."));
|
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarSiege().getBesiegingClan()) + "'s siege against " + F.elem(event.getWarSiege().getBesiegedClan()) + " has ended."));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,9 +288,29 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
|||||||
public void cancelDisband(ClanDisbandedEvent event)
|
public void cancelDisband(ClanDisbandedEvent event)
|
||||||
{
|
{
|
||||||
ClanInfo clan = event.getClan();
|
ClanInfo clan = event.getClan();
|
||||||
if (isBeingInvaded(clan) || isInvading(clan))
|
if (isBeingBesieged(clan) || isBesieging(clan))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(event.getDisbander(), F.main("Clans", "Clans cannot be disbanded in the middle of a siege"));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlaceTNT(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (event.getBlockPlaced().getType() == Material.TNT)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.setBuild(false);
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "TNT cannot be used outside of a siege cannon!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onTNTDispense(BlockDispenseEvent event)
|
||||||
|
{
|
||||||
|
if (event.getItem().getType() == Material.TNT)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(event.getDisbander(), F.main("Clans", "Clans cannot be disbanded in the middle of an invasion"));
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,28 +324,28 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
|||||||
|
|
||||||
if (clan != null)
|
if (clan != null)
|
||||||
{
|
{
|
||||||
List<WarInvasion> invadedList = _invadedMap.get(clan.getName());
|
List<WarSiege> besiegedList = _besiegedMap.get(clan.getName());
|
||||||
List<WarInvasion> invaderList = _invaderMap.get(clan.getName());
|
List<WarSiege> besiegerList = _besiegerMap.get(clan.getName());
|
||||||
|
|
||||||
if (invaderList != null && !invaderList.isEmpty())
|
if (besiegerList != null && !besiegerList.isEmpty())
|
||||||
{
|
{
|
||||||
for (WarInvasion invasion : invaderList)
|
for (WarSiege siege : besiegerList)
|
||||||
{
|
{
|
||||||
element.add(" ");
|
element.add(" ");
|
||||||
element.add(C.cPurpleB + "Invading");
|
element.add(C.cPurpleB + "Besieging");
|
||||||
element.add(" " + invasion.getInvadedClan());
|
element.add(" " + siege.getBesiegedClan());
|
||||||
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
element.add(" " + UtilTime.convertString(siege.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invadedList != null && !invadedList.isEmpty())
|
if (besiegedList != null && !besiegedList.isEmpty())
|
||||||
{
|
{
|
||||||
for (WarInvasion invasion : invadedList)
|
for (WarSiege siege : besiegedList)
|
||||||
{
|
{
|
||||||
element.add(" ");
|
element.add(" ");
|
||||||
element.add(C.cRedB + "Invaded");
|
element.add(C.cRedB + "Besieged");
|
||||||
element.add(" " + invasion.getInvaderClan());
|
element.add(" " + siege.getBesiegingClan());
|
||||||
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
element.add(" " + UtilTime.convertString(siege.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package mineplex.game.clans.clans.war;
|
package mineplex.game.clans.clans.war;
|
||||||
|
|
||||||
public class WarInvasion
|
public class WarSiege
|
||||||
{
|
{
|
||||||
private String _invadedClan;
|
private String _besiegedClan;
|
||||||
private String _invaderClan;
|
private String _besiegingClan;
|
||||||
private long _startTime;
|
private long _startTime;
|
||||||
private long _endTime;
|
private long _endTime;
|
||||||
|
|
||||||
public WarInvasion(String invadedClan, String invaderClan)
|
public WarSiege(String besiegedClan, String besiegingClan)
|
||||||
{
|
{
|
||||||
_invadedClan = invadedClan;
|
_besiegedClan = besiegedClan;
|
||||||
_invaderClan = invaderClan;
|
_besiegingClan = besiegingClan;
|
||||||
_startTime = System.currentTimeMillis();
|
_startTime = System.currentTimeMillis();
|
||||||
_endTime = _startTime + WarManager.INVADE_LENGTH;
|
_endTime = _startTime + WarManager.INVADE_LENGTH;
|
||||||
}
|
}
|
||||||
@ -20,14 +20,14 @@ public class WarInvasion
|
|||||||
return _endTime - System.currentTimeMillis();
|
return _endTime - System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInvadedClan()
|
public String getBesiegedClan()
|
||||||
{
|
{
|
||||||
return _invadedClan;
|
return _besiegedClan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInvaderClan()
|
public String getBesiegingClan()
|
||||||
{
|
{
|
||||||
return _invaderClan;
|
return _besiegingClan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStartTime()
|
public long getStartTime()
|
@ -1,25 +1,25 @@
|
|||||||
package mineplex.game.clans.clans.war.event;
|
package mineplex.game.clans.clans.war.event;
|
||||||
|
|
||||||
|
import mineplex.game.clans.clans.war.WarSiege;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import mineplex.game.clans.clans.war.WarInvasion;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a war invasion is ended
|
* Called when a war siege is ended
|
||||||
*/
|
*/
|
||||||
public class WarInvasionEndEvent extends Event
|
public class WarSiegeEndEvent extends Event
|
||||||
{
|
{
|
||||||
private WarInvasion _warInvasion;
|
private WarSiege _warSiege;
|
||||||
|
|
||||||
public WarInvasionEndEvent(WarInvasion warInvasion)
|
public WarSiegeEndEvent(WarSiege warSiege)
|
||||||
{
|
{
|
||||||
_warInvasion = warInvasion;
|
_warSiege = warSiege;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WarInvasion getWarInvasion()
|
public WarSiege getWarSiege()
|
||||||
{
|
{
|
||||||
return _warInvasion;
|
return _warSiege;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bukkit event stuff
|
// Bukkit event stuff
|
@ -1,25 +1,25 @@
|
|||||||
package mineplex.game.clans.clans.war.event;
|
package mineplex.game.clans.clans.war.event;
|
||||||
|
|
||||||
|
import mineplex.game.clans.clans.war.WarSiege;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import mineplex.game.clans.clans.war.WarInvasion;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a war invasion is started
|
* Called when a war siege is started
|
||||||
*/
|
*/
|
||||||
public class WarInvasionStartEvent extends Event
|
public class WarSiegeStartEvent extends Event
|
||||||
{
|
{
|
||||||
private WarInvasion _warInvasion;
|
private WarSiege _warSiege;
|
||||||
|
|
||||||
public WarInvasionStartEvent(WarInvasion warInvasion)
|
public WarSiegeStartEvent(WarSiege warSiege)
|
||||||
{
|
{
|
||||||
_warInvasion = warInvasion;
|
_warSiege = warSiege;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WarInvasion getWarInvasion()
|
public WarSiege getWarSiege()
|
||||||
{
|
{
|
||||||
return _warInvasion;
|
return _warSiege;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bukkit event stuff
|
// Bukkit event stuff
|
@ -1,75 +1,75 @@
|
|||||||
package mineplex.game.clans.clans.worldevent;
|
package mineplex.game.clans.clans.worldevent;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import mineplex.core.common.util.EnclosedObject;
|
import com.google.common.collect.Lists;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
import mineplex.core.common.util.UtilWorld;
|
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
|
||||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
|
||||||
|
|
||||||
public class EventTerrainFinder
|
public class EventTerrainFinder
|
||||||
{
|
{
|
||||||
private WorldEventManager _eventManager;
|
private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(3, TimeUnit.HOURS, TimeUnit.MILLISECONDS);
|
||||||
private ClansManager _clansManager;
|
private ClansManager _clansManager;
|
||||||
private ClansRegions _clansRegions;
|
|
||||||
|
|
||||||
public EventTerrainFinder(WorldEventManager eventManager, ClansManager clansManager, ClansRegions clansRegions)
|
public EventTerrainFinder(ClansManager clansManager)
|
||||||
{
|
{
|
||||||
_eventManager = eventManager;
|
|
||||||
_clansManager = clansManager;
|
_clansManager = clansManager;
|
||||||
_clansRegions = clansRegions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double posNeg()
|
public Location findAreaInBorderlands(boolean force)
|
||||||
|
{
|
||||||
|
List<EventLocation> locs = Lists.newArrayList();
|
||||||
|
locs.addAll(Arrays.asList(EventLocation.values()));
|
||||||
|
locs.sort(new Comparator<EventLocation>()
|
||||||
|
{
|
||||||
|
public int compare(EventLocation loc1, EventLocation loc2)
|
||||||
|
{
|
||||||
|
if (!UtilTime.elapsed(loc1.getLastUsed(), EVENT_AREA_COOLDOWN))
|
||||||
{
|
{
|
||||||
if (Math.random() > 0.5) return -1;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (!UtilTime.elapsed(loc2.getLastUsed(), EVENT_AREA_COOLDOWN))
|
||||||
public Location findAreaInBorderlands(World world, int size, int vert)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 150; i++)
|
return -1;
|
||||||
{
|
}
|
||||||
EnclosedObject<Location> loc = new EnclosedObject<>();
|
int[] rand = new int[] {1, -1};
|
||||||
|
return rand[new Random().nextInt(rand.length)];
|
||||||
if (_clansManager.getClanUtility().getClanByClanName("Borderlands") == null)
|
|
||||||
{
|
|
||||||
System.out.println("[WORLD EVENT] FATAL ERROR: CLAN BORDERLANDS NOT FOUND.");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_clansManager.getClanUtility().getClanByClanName("Borderlands").getClaimSet().stream().filter(claim -> Math.random() > .5).filter(claim -> Math.random() > .5).filter(claim -> Math.random() > .3).filter(claim -> Math.random() > .7).limit(1).forEach(claim -> {
|
|
||||||
Chunk chunk = UtilWorld.strToChunk(claim);
|
|
||||||
|
|
||||||
loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size * 2, vert, size * 2), loc.Get().clone().add(size * 2, vert, size * 2)))
|
for (EventLocation loc : locs)
|
||||||
|
{
|
||||||
|
if (!UtilTime.elapsed(loc.getLastUsed(), EVENT_AREA_COOLDOWN))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (_clansManager.getClanUtility().getClaim(loc.getLocation()) == null || _clansManager.getClanUtility().getClaim(loc.getLocation()).Owner.contains("Borderlands"))
|
||||||
if (loc.Get() == null)
|
|
||||||
{
|
{
|
||||||
continue;
|
loc.use();
|
||||||
|
return loc.getLocation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Done finding area... [success]");
|
if (force && !locs.isEmpty())
|
||||||
|
{
|
||||||
// Success
|
EventLocation loc = locs.get(UtilMath.r(locs.size()));
|
||||||
return loc.Get();
|
loc.use();
|
||||||
|
return loc.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Failed to find area...");
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,4 +129,47 @@ public class EventTerrainFinder
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static enum EventLocation
|
||||||
|
{
|
||||||
|
NORTH_1("world", -495, 73, -1028),
|
||||||
|
NORTH_2("world", 197, 66, -1018),
|
||||||
|
NORTH_3("world", 948, 71, -959),
|
||||||
|
EAST_1("world", 1109, 66, -753),
|
||||||
|
EAST_2("world", 1141, 68, 31),
|
||||||
|
EAST_3("world", 1044, 71, 603),
|
||||||
|
SOUTH_1("world", 690, 71, 895),
|
||||||
|
SOUTH_2("world", 144, 66, 1012),
|
||||||
|
SOUTH_3("world", -1093, 71, 895),
|
||||||
|
WEST_1("world", -937, 71, 559),
|
||||||
|
WEST_2("world", -1092, 67, -9),
|
||||||
|
WEST_3("world", -969, 71, -441);
|
||||||
|
|
||||||
|
private String _world;
|
||||||
|
private double _x, _y, _z;
|
||||||
|
private long _last = 0;
|
||||||
|
|
||||||
|
private EventLocation(String worldName, double x, double y, double z)
|
||||||
|
{
|
||||||
|
_world = worldName;
|
||||||
|
_x = x;
|
||||||
|
_y = y;
|
||||||
|
_z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation()
|
||||||
|
{
|
||||||
|
return new Location(UtilWorld.getWorld(_world), _x, _y, _z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLastUsed()
|
||||||
|
{
|
||||||
|
return _last;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void use()
|
||||||
|
{
|
||||||
|
_last = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package mineplex.game.clans.clans.worldevent;
|
package mineplex.game.clans.clans.worldevent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,6 +8,7 @@ import java.util.Random;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.scoreboard.ScoreboardManager;
|
import mineplex.core.scoreboard.ScoreboardManager;
|
||||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||||
@ -35,8 +35,11 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
||||||
{
|
{
|
||||||
|
private static final double ARENA_RADIUS = 40;
|
||||||
private final List<WorldEvent> _runningEvents;
|
private final List<WorldEvent> _runningEvents;
|
||||||
|
|
||||||
private Random _random;
|
private Random _random;
|
||||||
@ -55,7 +58,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
super("World Event", plugin);
|
super("World Event", plugin);
|
||||||
|
|
||||||
_random = new Random();
|
_random = new Random();
|
||||||
_terrainFinder = new EventTerrainFinder(this, clansManager, clansRegions);
|
_terrainFinder = new EventTerrainFinder(clansManager);
|
||||||
_clansManager = clansManager;
|
_clansManager = clansManager;
|
||||||
_damageManager = damageManager;
|
_damageManager = damageManager;
|
||||||
_lootManager = lootManager;
|
_lootManager = lootManager;
|
||||||
@ -86,7 +89,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
{
|
{
|
||||||
for (WorldEvent event : _runningEvents)
|
for (WorldEvent event : _runningEvents)
|
||||||
{
|
{
|
||||||
if (event.isInBounds(location))
|
if (UtilMath.offset2d(location, event.getCenterLocation()) <= ARENA_RADIUS)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -102,7 +105,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
{
|
{
|
||||||
for (WorldEvent e : _runningEvents)
|
for (WorldEvent e : _runningEvents)
|
||||||
{
|
{
|
||||||
if (e.isInBounds(event.GetPlayer().getLocation()))
|
if (isInEvent(event.GetPlayer().getLocation()))
|
||||||
{
|
{
|
||||||
event.SetCancelled(true);
|
event.SetCancelled(true);
|
||||||
}
|
}
|
||||||
@ -189,7 +192,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
{
|
{
|
||||||
WorldEventType[] types = WorldEventType.values();
|
WorldEventType[] types = WorldEventType.values();
|
||||||
WorldEventType type = types[_random.nextInt(types.length)];
|
WorldEventType type = types[_random.nextInt(types.length)];
|
||||||
Location location = _terrainFinder.findAreaInBorderlands(Bukkit.getWorlds().get(0), type.getAreaNeeded(), type.getAreaNeeded());
|
Location location = _terrainFinder.findAreaInBorderlands(false);
|
||||||
if (location != null)
|
if (location != null)
|
||||||
{
|
{
|
||||||
initializeEvent(type.createInstance(this, location, _skillFactory));
|
initializeEvent(type.createInstance(this, location, _skillFactory));
|
||||||
@ -228,10 +231,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public WorldEvent startEventFromType(Location location, WorldEventType eventType)
|
public WorldEvent startEventFromType(WorldEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != null)
|
if (eventType != null)
|
||||||
{
|
{
|
||||||
|
Location location = _terrainFinder.findAreaInBorderlands(true);
|
||||||
WorldEvent event = eventType.createInstance(this, location, _skillFactory);
|
WorldEvent event = eventType.createInstance(this, location, _skillFactory);
|
||||||
if (event != null)
|
if (event != null)
|
||||||
{
|
{
|
||||||
@ -287,7 +291,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||||
{
|
{
|
||||||
List<String> output = new ArrayList<String>();
|
List<String> output = Lists.newArrayList();
|
||||||
|
|
||||||
Iterator<WorldEvent> iterator = _runningEvents.iterator();
|
Iterator<WorldEvent> iterator = _runningEvents.iterator();
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
|
@ -27,7 +27,7 @@ public class StartCommand extends CommandBase<WorldEventManager>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
WorldEventType eventType = WorldEventType.valueOf(args[0]);
|
WorldEventType eventType = WorldEventType.valueOf(args[0]);
|
||||||
WorldEvent event = Plugin.startEventFromType(caller.getLocation(), eventType);
|
WorldEvent event = Plugin.startEventFromType(eventType);
|
||||||
|
|
||||||
if (event == null)
|
if (event == null)
|
||||||
{
|
{
|
||||||
@ -35,7 +35,7 @@ public class StartCommand extends CommandBase<WorldEventManager>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Started WorldEvent " + F.elem(args[0]) + " at your current location"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Started WorldEvent " + F.elem(args[0]) + "!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e)
|
catch (IllegalArgumentException e)
|
||||||
|
@ -6,7 +6,8 @@ import mineplex.core.common.util.UtilEvent;
|
|||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
import mineplex.core.common.util.UtilGear;
|
import mineplex.core.common.util.UtilGear;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.projectile.IThrown;
|
import mineplex.core.projectile.IThrown;
|
||||||
import mineplex.core.projectile.ProjectileUser;
|
import mineplex.core.projectile.ProjectileUser;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
@ -155,7 +156,7 @@ public abstract class ItemUsable extends Item implements IThrown
|
|||||||
if (_throwExpire >= 0)
|
if (_throwExpire >= 0)
|
||||||
expire = _throwExpire;
|
expire = _throwExpire;
|
||||||
|
|
||||||
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(GetType()));
|
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), new ItemBuilder(GetType()).setTitle(UtilMath.random.nextDouble() + "").build());
|
||||||
UtilAction.velocity(ent, player.getLocation().getDirection(), _throwPower, false, 0, 0.2, 10, false);
|
UtilAction.velocity(ent, player.getLocation().getDirection(), _throwPower, false, 0, 0.2, 10, false);
|
||||||
Factory.Throw().AddThrow(ent, player, this, expire, _throwPlayer, _throwPlayer, _throwBlock, _throwIdle, _throwPickup, 0.5f);
|
Factory.Throw().AddThrow(ent, player, this, expire, _throwPlayer, _throwPlayer, _throwBlock, _throwIdle, _throwPickup, 0.5f);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class GolemBoss extends WorldEvent
|
|||||||
{
|
{
|
||||||
public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation)
|
public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation)
|
||||||
{
|
{
|
||||||
super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation, "schematic/Golem.schematic");
|
super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +56,7 @@ public class GolemDeadlyTremor extends BossAbility<GolemCreature, IronGolem>
|
|||||||
@Override
|
@Override
|
||||||
public void tick()
|
public void tick()
|
||||||
{
|
{
|
||||||
for (Player player : UtilPlayer.getInRadius(getLocation(), 40).keySet())
|
for (Player player : UtilPlayer.getInRadius(getLocation(), 30).keySet())
|
||||||
{
|
{
|
||||||
player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f);
|
player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f);
|
||||||
|
|
||||||
|
@ -20,8 +20,7 @@ public class SkeletonBoss extends WorldEvent
|
|||||||
|
|
||||||
public SkeletonBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation)
|
public SkeletonBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation)
|
||||||
{
|
{
|
||||||
super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation,
|
super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation);
|
||||||
"schematic/Golem.schematic");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -210,7 +210,6 @@ public class SkeletonCreature extends EventCreature<Skeleton>
|
|||||||
{
|
{
|
||||||
if (getHealth() <= test)
|
if (getHealth() <= test)
|
||||||
{
|
{
|
||||||
Bukkit.broadcastMessage(test + "Verified");
|
|
||||||
wraithUse = test;
|
wraithUse = test;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user