Take into account world/network restrictions for Vehicles

Properly teleport empty vehicles between worlds
Properly teleport StoreageMinecarts between worlds
Take into account vehicle type when teleporting
This commit is contained in:
Drakia 2011-07-10 17:43:49 -07:00
parent 6c2b9b00aa
commit 4968927528
4 changed files with 25 additions and 7 deletions

5
README
View File

@ -130,6 +130,11 @@ maxgates - If non-zero, will define the maximum amount of gates allowed on a net
=============
Changes
=============
[Version 0.5.1]
- Take into account world/network restrictions for Vehicles
- Properly teleport empty vehicles between worlds
- Properly teleport StoreageMinecarts between worlds
- Take into account vehicle type when teleporting
[Version 0.5.0]
- Updated the teleport method
- Remove always-open gates from lists

View File

@ -18,6 +18,7 @@ import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.StorageMinecart;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.material.Button;
@ -252,19 +253,23 @@ public class Portal {
final Entity passenger = vehicle.getPassenger();
if (passenger != null) {
final Vehicle v = exit.getWorld().spawn(exit, vehicle.getClass());
vehicle.eject();
vehicle.remove();
final Minecart mc = exit.getWorld().spawn(exit, Minecart.class);
passenger.teleport(exit);
Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
public void run() {
mc.setPassenger(passenger);
mc.setVelocity(newVelocity);
v.setPassenger(passenger);
v.setVelocity(newVelocity);
}
}, 1);
} else {
vehicle.teleport(exit);
vehicle.setVelocity(newVelocity);
Vehicle mc = exit.getWorld().spawn(exit, vehicle.getClass());
if (mc instanceof StorageMinecart) {
StorageMinecart smc = (StorageMinecart)mc;
smc.getInventory().setContents(((StorageMinecart)vehicle).getInventory().getContents());
}
vehicle.remove();
}
}

View File

@ -338,6 +338,15 @@ public class Stargate extends JavaPlugin {
Portal dest = portal.getDestination();
if (dest == null) return;
if ((networkFilter && !hasPerm(player, "stargate.network." + portal.getNetwork(), player.isOp())) ||
(worldFilter && !hasPerm(player, "stargate.world." + portal.getDestination().getWorld().getName(), player.isOp()))) {
if (!denyMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + denyMsg);
}
portal.close(false);
return;
}
boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
if (!iConomyHandler.chargeFreeDestination)
iConCharge = iConCharge && !dest.isFree();
@ -385,7 +394,6 @@ public class Stargate extends JavaPlugin {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
Block b = world.getBlockAt(cX + i, cY + j, cZ + k);
if (b.getType() != Material.PORTAL) continue;
Portal portal = Portal.getByEntrance(b);
if (portal != null) {
event.setCancelled(true);

View File

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