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:
Drakia 2011-06-12 16:37:38 -07:00
parent d22a4b0871
commit 85a98d87ef
5 changed files with 152 additions and 16 deletions

7
README
View File

@ -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.
toowner - Whether the money from gate-use goes to the owner or nobody
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
=============
[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]
- Added chargefreedestination option
- Added freegatesgreen option

View File

@ -399,15 +399,20 @@ public class Portal {
}
public void cycleDestination(Player player) {
cycleDestination(player, 1);
}
public void cycleDestination(Player player, int dir) {
if (!isActive() || getActivePlayer() != player) {
activate(player);
}
if (destinations.size() > 0) {
int index = destinations.indexOf(destination);
if (++index >= destinations.size()) {
index += dir;
if (index >= destinations.size())
index = 0;
}
else if (index < 0)
index = destinations.size() - 1;
destination = destinations.get(index);
}
openTime = System.currentTimeMillis() / 1000;
@ -427,6 +432,10 @@ public class Portal {
if (isFixed()) {
id.setText(++done, "To: " + destination);
id.setText(++done, " (" + network + ") ");
Portal dest = Portal.getByName(destination, network);
if (dest == null) {
id.setText(++done, "(Not Connected)");
}
} else {
int index = destinations.indexOf(destination);
@ -554,9 +563,11 @@ public class Portal {
for (String originName : allPortalsNet.get(getNetwork().toLowerCase())) {
Portal origin = Portal.getByName(originName, getNetwork());
if ((origin != null) && (origin.isAlwaysOn()) && (origin.getDestinationName().equalsIgnoreCase(getName())) && (origin.isVerified())) {
origin.close(true);
}
if (origin == null) continue;
if (!origin.getDestinationName().equalsIgnoreCase(getName())) continue;
if (!origin.isVerified()) continue;
if (origin.isFixed()) origin.drawSign();
if (origin.isAlwaysOn()) origin.close(true);
}
saveAllGates(getWorld());
@ -646,6 +657,13 @@ public class Portal {
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.
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");
@ -753,15 +771,20 @@ public class Portal {
// Open always on gate
if (portal.isAlwaysOn()) {
Portal dest = Portal.getByName(destName, portal.getNetwork());
if (dest != null)
if (dest != null) {
portal.open(true);
dest.drawSign();
}
}
// Open any always on gate pointing at this gate
for (String originName : allPortalsNet.get(portal.getNetwork().toLowerCase())) {
Portal origin = Portal.getByName(originName, portal.getNetwork());
if (origin != null && origin.isAlwaysOn() && origin.getDestinationName().equalsIgnoreCase(portal.getName()) && origin.isVerified())
origin.open(true);
if (origin == null) continue;
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());
@ -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.
int OpenCount = 0;
//for (Portal portal : allPortals) {
for (Iterator<Portal> iter = allPortals.iterator(); iter.hasNext(); ) {
Portal portal = iter.next();
if (portal == null) continue;
@ -928,6 +950,7 @@ public class Portal {
Portal dest = portal.getDestination();
if (dest != null) {
portal.open(true);
dest.drawSign();
OpenCount++;
}
}

View File

@ -62,10 +62,7 @@ public class SignPost {
public void update() {
final Sign sign = findSign();
if (sign == null) {
Stargate.log.info("[Stargate::SignPost::update] Sign null");
return;
}
if (sign == null) return;
Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
public void run() {

View File

@ -25,6 +25,9 @@ import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
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.EntityListener;
import org.bukkit.event.player.PlayerInteractEvent;
@ -83,6 +86,7 @@ public class Stargate extends JavaPlugin {
private static boolean destroyExplosion = false;
public static boolean networkFilter = false;
public static boolean worldFilter = false;
public static int maxGates = 0;
private static int activeLimit = 10;
private static int openLimit = 10;
@ -124,15 +128,18 @@ public class Stargate extends JavaPlugin {
iConomyHandler.iconomy = (iConomy)checkPlugin("iConomy");
pm.registerEvent(Event.Type.PLAYER_MOVE, 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.VEHICLE_MOVE, vehicleListener, 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.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
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
@ -155,6 +162,7 @@ public class Stargate extends JavaPlugin {
destroyExplosion = config.getBoolean("destroyexplosion", destroyExplosion);
networkFilter = config.getBoolean("networkfilter", networkFilter);
worldFilter = config.getBoolean("worldfilter", worldFilter);
maxGates = config.getInt("maxgates", maxGates);
// Debug
debug = config.getBoolean("debug", debug);
// iConomy
@ -183,6 +191,7 @@ public class Stargate extends JavaPlugin {
config.setProperty("destroyexplosion", destroyExplosion);
config.setProperty("networkfilter", networkFilter);
config.setProperty("worldfilter", worldFilter);
config.setProperty("maxgates", maxGates);
// iConomy
config.setProperty("useiconomy", iConomyHandler.useiConomy);
config.setProperty("createcost", iConomyHandler.createCost);
@ -462,6 +471,24 @@ public class Stargate extends JavaPlugin {
// Left click
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.
if (block.getType() == Material.STONE_BUTTON) {
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 {

View File

@ -1,6 +1,6 @@
name: Stargate
main: net.TheDgtl.Stargate.Stargate
version: 0.4.8
version: 0.4.9
description: Stargate mod for Bukkit
author: Drakia
website: http://www.thedgtl.net