Left-click to scroll signs up
Show "(Not Connected)" on fixed-gates with a non-existant destination Added "maxgates" option Removed debug message Started work on disabling damage for lava gates, too much work to finish with the current implementation of EntityDamageByBlock
This commit is contained in:
parent
d22a4b0871
commit
85a98d87ef
7
README
7
README
@ -125,10 +125,17 @@ networkfilter - Whether or not to disallow users access to a network if they don
|
|||||||
worldfilter - Whether or not to disallow users access to a network if they don't have the 'stargate.world.{worldname}' permission.
|
worldfilter - Whether or not to disallow users access to a network if they don't have the 'stargate.world.{worldname}' permission.
|
||||||
toowner - Whether the money from gate-use goes to the owner or nobody
|
toowner - Whether the money from gate-use goes to the owner or nobody
|
||||||
debug - Whether to show massive debug output for gate creation
|
debug - Whether to show massive debug output for gate creation
|
||||||
|
maxgates - If non-zero, will define the maximum amount of gates allowed on a network.
|
||||||
|
|
||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.4.9]
|
||||||
|
- Left-click to scroll signs up
|
||||||
|
- Show "(Not Connected)" on fixed-gates with a non-existant destination
|
||||||
|
- Added "maxgates" option
|
||||||
|
- Removed debug message
|
||||||
|
- Started work on disabling damage for lava gates, too much work to finish with the current implementation of EntityDamageByBlock
|
||||||
[Version 0.4.8]
|
[Version 0.4.8]
|
||||||
- Added chargefreedestination option
|
- Added chargefreedestination option
|
||||||
- Added freegatesgreen option
|
- Added freegatesgreen option
|
||||||
|
@ -399,15 +399,20 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cycleDestination(Player player) {
|
public void cycleDestination(Player player) {
|
||||||
|
cycleDestination(player, 1);
|
||||||
|
}
|
||||||
|
public void cycleDestination(Player player, int dir) {
|
||||||
if (!isActive() || getActivePlayer() != player) {
|
if (!isActive() || getActivePlayer() != player) {
|
||||||
activate(player);
|
activate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destinations.size() > 0) {
|
if (destinations.size() > 0) {
|
||||||
int index = destinations.indexOf(destination);
|
int index = destinations.indexOf(destination);
|
||||||
if (++index >= destinations.size()) {
|
index += dir;
|
||||||
|
if (index >= destinations.size())
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
else if (index < 0)
|
||||||
|
index = destinations.size() - 1;
|
||||||
destination = destinations.get(index);
|
destination = destinations.get(index);
|
||||||
}
|
}
|
||||||
openTime = System.currentTimeMillis() / 1000;
|
openTime = System.currentTimeMillis() / 1000;
|
||||||
@ -427,6 +432,10 @@ public class Portal {
|
|||||||
if (isFixed()) {
|
if (isFixed()) {
|
||||||
id.setText(++done, "To: " + destination);
|
id.setText(++done, "To: " + destination);
|
||||||
id.setText(++done, " (" + network + ") ");
|
id.setText(++done, " (" + network + ") ");
|
||||||
|
Portal dest = Portal.getByName(destination, network);
|
||||||
|
if (dest == null) {
|
||||||
|
id.setText(++done, "(Not Connected)");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int index = destinations.indexOf(destination);
|
int index = destinations.indexOf(destination);
|
||||||
|
|
||||||
@ -554,9 +563,11 @@ public class Portal {
|
|||||||
|
|
||||||
for (String originName : allPortalsNet.get(getNetwork().toLowerCase())) {
|
for (String originName : allPortalsNet.get(getNetwork().toLowerCase())) {
|
||||||
Portal origin = Portal.getByName(originName, getNetwork());
|
Portal origin = Portal.getByName(originName, getNetwork());
|
||||||
if ((origin != null) && (origin.isAlwaysOn()) && (origin.getDestinationName().equalsIgnoreCase(getName())) && (origin.isVerified())) {
|
if (origin == null) continue;
|
||||||
origin.close(true);
|
if (!origin.getDestinationName().equalsIgnoreCase(getName())) continue;
|
||||||
}
|
if (!origin.isVerified()) continue;
|
||||||
|
if (origin.isFixed()) origin.drawSign();
|
||||||
|
if (origin.isAlwaysOn()) origin.close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAllGates(getWorld());
|
saveAllGates(getWorld());
|
||||||
@ -646,6 +657,13 @@ public class Portal {
|
|||||||
createPersonal = true;
|
createPersonal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if there are too many gates in this network
|
||||||
|
ArrayList<String> netList = allPortalsNet.get(network);
|
||||||
|
if (Stargate.maxGates > 0 && netList != null && netList.size() >= Stargate.maxGates) {
|
||||||
|
player.sendMessage(ChatColor.RED + "[Stargate]" + ChatColor.WHITE + " This network is full.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the user can create gates on this network.
|
// Check if the user can create gates on this network.
|
||||||
if (!createPersonal && !Stargate.hasPerm(player, "stargate.network." + network, player.isOp())) {
|
if (!createPersonal && !Stargate.hasPerm(player, "stargate.network." + network, player.isOp())) {
|
||||||
player.sendMessage(ChatColor.RED + "[Stargate]" + ChatColor.WHITE + " You don't have access to that network");
|
player.sendMessage(ChatColor.RED + "[Stargate]" + ChatColor.WHITE + " You don't have access to that network");
|
||||||
@ -753,15 +771,20 @@ public class Portal {
|
|||||||
// Open always on gate
|
// Open always on gate
|
||||||
if (portal.isAlwaysOn()) {
|
if (portal.isAlwaysOn()) {
|
||||||
Portal dest = Portal.getByName(destName, portal.getNetwork());
|
Portal dest = Portal.getByName(destName, portal.getNetwork());
|
||||||
if (dest != null)
|
if (dest != null) {
|
||||||
portal.open(true);
|
portal.open(true);
|
||||||
|
dest.drawSign();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open any always on gate pointing at this gate
|
// Open any always on gate pointing at this gate
|
||||||
for (String originName : allPortalsNet.get(portal.getNetwork().toLowerCase())) {
|
for (String originName : allPortalsNet.get(portal.getNetwork().toLowerCase())) {
|
||||||
Portal origin = Portal.getByName(originName, portal.getNetwork());
|
Portal origin = Portal.getByName(originName, portal.getNetwork());
|
||||||
if (origin != null && origin.isAlwaysOn() && origin.getDestinationName().equalsIgnoreCase(portal.getName()) && origin.isVerified())
|
if (origin == null) continue;
|
||||||
origin.open(true);
|
if (!origin.getDestinationName().equalsIgnoreCase(portal.getName())) continue;
|
||||||
|
if (!origin.isVerified()) continue;
|
||||||
|
if (origin.isFixed()) origin.drawSign();
|
||||||
|
if (origin.isAlwaysOn()) origin.open(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAllGates(portal.getWorld());
|
saveAllGates(portal.getWorld());
|
||||||
@ -905,7 +928,6 @@ public class Portal {
|
|||||||
|
|
||||||
// Open any always-on gates. Do this here as it should be more efficient than in the loop.
|
// Open any always-on gates. Do this here as it should be more efficient than in the loop.
|
||||||
int OpenCount = 0;
|
int OpenCount = 0;
|
||||||
//for (Portal portal : allPortals) {
|
|
||||||
for (Iterator<Portal> iter = allPortals.iterator(); iter.hasNext(); ) {
|
for (Iterator<Portal> iter = allPortals.iterator(); iter.hasNext(); ) {
|
||||||
Portal portal = iter.next();
|
Portal portal = iter.next();
|
||||||
if (portal == null) continue;
|
if (portal == null) continue;
|
||||||
@ -928,6 +950,7 @@ public class Portal {
|
|||||||
Portal dest = portal.getDestination();
|
Portal dest = portal.getDestination();
|
||||||
if (dest != null) {
|
if (dest != null) {
|
||||||
portal.open(true);
|
portal.open(true);
|
||||||
|
dest.drawSign();
|
||||||
OpenCount++;
|
OpenCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,7 @@ public class SignPost {
|
|||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
final Sign sign = findSign();
|
final Sign sign = findSign();
|
||||||
if (sign == null) {
|
if (sign == null) return;
|
||||||
Stargate.log.info("[Stargate::SignPost::update] Sign null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
|
Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -25,6 +25,9 @@ import org.bukkit.event.block.BlockFromToEvent;
|
|||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
import org.bukkit.event.entity.EntityListener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@ -83,6 +86,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
private static boolean destroyExplosion = false;
|
private static boolean destroyExplosion = false;
|
||||||
public static boolean networkFilter = false;
|
public static boolean networkFilter = false;
|
||||||
public static boolean worldFilter = false;
|
public static boolean worldFilter = false;
|
||||||
|
public static int maxGates = 0;
|
||||||
private static int activeLimit = 10;
|
private static int activeLimit = 10;
|
||||||
private static int openLimit = 10;
|
private static int openLimit = 10;
|
||||||
|
|
||||||
@ -124,15 +128,18 @@ public class Stargate extends JavaPlugin {
|
|||||||
iConomyHandler.iconomy = (iConomy)checkPlugin("iConomy");
|
iConomyHandler.iconomy = (iConomy)checkPlugin("iConomy");
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this);
|
|
||||||
pm.registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this);
|
||||||
|
|
||||||
|
pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.WORLD_LOAD, worldListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.WORLD_LOAD, worldListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
||||||
|
//pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this);
|
||||||
|
//pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
||||||
|
|
||||||
// Dependency Loading
|
// Dependency Loading
|
||||||
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
|
||||||
@ -155,6 +162,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
destroyExplosion = config.getBoolean("destroyexplosion", destroyExplosion);
|
destroyExplosion = config.getBoolean("destroyexplosion", destroyExplosion);
|
||||||
networkFilter = config.getBoolean("networkfilter", networkFilter);
|
networkFilter = config.getBoolean("networkfilter", networkFilter);
|
||||||
worldFilter = config.getBoolean("worldfilter", worldFilter);
|
worldFilter = config.getBoolean("worldfilter", worldFilter);
|
||||||
|
maxGates = config.getInt("maxgates", maxGates);
|
||||||
// Debug
|
// Debug
|
||||||
debug = config.getBoolean("debug", debug);
|
debug = config.getBoolean("debug", debug);
|
||||||
// iConomy
|
// iConomy
|
||||||
@ -183,6 +191,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
config.setProperty("destroyexplosion", destroyExplosion);
|
config.setProperty("destroyexplosion", destroyExplosion);
|
||||||
config.setProperty("networkfilter", networkFilter);
|
config.setProperty("networkfilter", networkFilter);
|
||||||
config.setProperty("worldfilter", worldFilter);
|
config.setProperty("worldfilter", worldFilter);
|
||||||
|
config.setProperty("maxgates", maxGates);
|
||||||
// iConomy
|
// iConomy
|
||||||
config.setProperty("useiconomy", iConomyHandler.useiConomy);
|
config.setProperty("useiconomy", iConomyHandler.useiConomy);
|
||||||
config.setProperty("createcost", iConomyHandler.createCost);
|
config.setProperty("createcost", iConomyHandler.createCost);
|
||||||
@ -462,6 +471,24 @@ public class Stargate extends JavaPlugin {
|
|||||||
|
|
||||||
// Left click
|
// Left click
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
// Check if we're scrolling a sign
|
||||||
|
if (block.getType() == Material.WALL_SIGN) {
|
||||||
|
Portal portal = Portal.getByBlock(block);
|
||||||
|
// Cycle through a stargates locations
|
||||||
|
if (portal != null) {
|
||||||
|
if (!hasPerm(player, "stargate.use", true) ||
|
||||||
|
(networkFilter && !hasPerm(player, "stargate.network." + portal.getNetwork(), player.isOp()))) {
|
||||||
|
if (!denyMsg.isEmpty()) {
|
||||||
|
player.sendMessage(denyMsg);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||||
|
portal.cycleDestination(player, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Check if we're pushing a button.
|
// Check if we're pushing a button.
|
||||||
if (block.getType() == Material.STONE_BUTTON) {
|
if (block.getType() == Material.STONE_BUTTON) {
|
||||||
if (hasPerm(player, "stargate.use", true)) {
|
if (hasPerm(player, "stargate.use", true)) {
|
||||||
@ -598,6 +625,88 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Going to leave this commented out until they fix EntityDamagebyBlock
|
||||||
|
/*
|
||||||
|
@Override
|
||||||
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
if (!(event instanceof EntityDamageByBlockEvent)) return;
|
||||||
|
EntityDamageByBlockEvent bEvent = (EntityDamageByBlockEvent)event;
|
||||||
|
Player player = (Player)bEvent.getEntity();
|
||||||
|
Block block = bEvent.getDamager();
|
||||||
|
// Fucking null blocks, we'll do it live! This happens for lava only, as far as I know.
|
||||||
|
// So we're "borrowing" the code from World.java used to determine if we're intersecting a lava block
|
||||||
|
if (block == null) {
|
||||||
|
CraftEntity ce = (CraftEntity)event.getEntity();
|
||||||
|
net.minecraft.server.Entity entity = ce.getHandle();
|
||||||
|
AxisAlignedBB axisalignedbb = entity.boundingBox.b(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D);
|
||||||
|
int minx = MathHelper.floor(axisalignedbb.a);
|
||||||
|
int maxx = MathHelper.floor(axisalignedbb.d + 1.0D);
|
||||||
|
int miny = MathHelper.floor(axisalignedbb.b);
|
||||||
|
int maxy = MathHelper.floor(axisalignedbb.e + 1.0D);
|
||||||
|
int minz = MathHelper.floor(axisalignedbb.c);
|
||||||
|
int maxz = MathHelper.floor(axisalignedbb.f + 1.0D);
|
||||||
|
|
||||||
|
for (int x = minx; x < maxx; ++x) {
|
||||||
|
for (int y = miny; y < maxy; ++y) {
|
||||||
|
for (int z = minz; z < maxz; ++z) {
|
||||||
|
int blockType = player.getWorld().getBlockTypeIdAt(x, y, z);
|
||||||
|
if (blockType == Material.LAVA.getId() || blockType == Material.STATIONARY_LAVA.getId()) {
|
||||||
|
block = player.getWorld().getBlockAt(x, y, z);
|
||||||
|
log.info("Found block! " + block);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (block != null) break;
|
||||||
|
}
|
||||||
|
if (block != null) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (block == null) return;
|
||||||
|
Portal portal = Portal.getByEntrance(block);
|
||||||
|
if (portal == null) return;
|
||||||
|
log.info("Found portal");
|
||||||
|
bEvent.setDamage(0);
|
||||||
|
bEvent.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntityCombust(EntityCombustEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
Player player = (Player)event.getEntity();
|
||||||
|
// WHY DOESN'T THIS CANCEL IF YOU CANCEL LAVA DAMAGE?!
|
||||||
|
Block block = null;
|
||||||
|
CraftEntity ce = (CraftEntity)event.getEntity();
|
||||||
|
net.minecraft.server.Entity entity = ce.getHandle();
|
||||||
|
AxisAlignedBB axisalignedbb = entity.boundingBox.b(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D);
|
||||||
|
int minx = MathHelper.floor(axisalignedbb.a);
|
||||||
|
int maxx = MathHelper.floor(axisalignedbb.d + 1.0D);
|
||||||
|
int miny = MathHelper.floor(axisalignedbb.b);
|
||||||
|
int maxy = MathHelper.floor(axisalignedbb.e + 1.0D);
|
||||||
|
int minz = MathHelper.floor(axisalignedbb.c);
|
||||||
|
int maxz = MathHelper.floor(axisalignedbb.f + 1.0D);
|
||||||
|
|
||||||
|
for (int x = minx; x < maxx; ++x) {
|
||||||
|
for (int y = miny; y < maxy; ++y) {
|
||||||
|
for (int z = minz; z < maxz; ++z) {
|
||||||
|
int blockType = player.getWorld().getBlockTypeIdAt(x, y, z);
|
||||||
|
if (blockType == Material.LAVA.getId() || blockType == Material.STATIONARY_LAVA.getId()) {
|
||||||
|
block = player.getWorld().getBlockAt(x, y, z);
|
||||||
|
log.info("Found block! " + block);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (block != null) break;
|
||||||
|
}
|
||||||
|
if (block != null) break;
|
||||||
|
}
|
||||||
|
if (block == null) return;
|
||||||
|
log.info("What? " + block);
|
||||||
|
Portal portal = Portal.getByEntrance(block);
|
||||||
|
if (portal == null) return;
|
||||||
|
log.info("What2?");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private class sListener extends ServerListener {
|
private class sListener extends ServerListener {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.4.8
|
version: 0.4.9
|
||||||
description: Stargate mod for Bukkit
|
description: Stargate mod for Bukkit
|
||||||
author: Drakia
|
author: Drakia
|
||||||
website: http://www.thedgtl.net
|
website: http://www.thedgtl.net
|
||||||
|
Loading…
Reference in New Issue
Block a user