outposts work (grr git is weird trying to switch over to clans/beta)

This commit is contained in:
NewGarbo 2016-01-12 07:02:03 +00:00
parent c873b6b886
commit d3452772ed
8 changed files with 221 additions and 31 deletions

View File

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

View File

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

View File

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

View File

@ -630,6 +630,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}, 20L);
}
@EventHandler
public void disableFlyKick(PlayerKickEvent event)
{
if (event.getReason().toLowerCase().contains("flying is not enabled on this server"))
{
event.setCancelled(true);
}
}
@EventHandler
public void denyBow(EntityShootBowEvent event)
{

View File

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

View File

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

View File

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

View File

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