Small permissions handling update.
Core GM support removed, depends on FakePermissions if you use GM. Fixed Permissions, will work with GroupManager, Permissions 2.0, or Permissions 2.1 Left-clicking to activate a stargate works again
This commit is contained in:
parent
3c914dec9b
commit
a7f6d37c53
7
README
7
README
@ -81,6 +81,13 @@ gate-folder - The folder containing your .gate files
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.18]
|
||||||
|
- Small permissions handling update.
|
||||||
|
[Version 0.17]
|
||||||
|
- Core GM support removed, depends on FakePermissions if you use GM.
|
||||||
|
[Version 0.16]
|
||||||
|
- Fixed Permissions, will work with GroupManager, Permissions 2.0, or Permissions 2.1
|
||||||
|
- Left-clicking to activate a stargate works again
|
||||||
[Version 0.15]
|
[Version 0.15]
|
||||||
- Built against b424jnks -- As such nothing lower is supported at the moment.
|
- Built against b424jnks -- As such nothing lower is supported at the moment.
|
||||||
- Moved gate destruction code to onBlockBreak since onBlockDamage no longer handles breaking blocks.
|
- Moved gate destruction code to onBlockBreak since onBlockDamage no longer handles breaking blocks.
|
||||||
|
@ -351,7 +351,7 @@ public class Portal {
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activate(Player player) {
|
public void activate(Player player, Stargate stargate) {
|
||||||
destinations.clear();
|
destinations.clear();
|
||||||
destination = "";
|
destination = "";
|
||||||
drawSign();
|
drawSign();
|
||||||
@ -362,7 +362,7 @@ public class Portal {
|
|||||||
// Not fixed, not this portal, and visible to this player.
|
// Not fixed, not this portal, and visible to this player.
|
||||||
if ( (!portal.isFixed()) &&
|
if ( (!portal.isFixed()) &&
|
||||||
(!dest.equalsIgnoreCase(getName())) && // Not this portal
|
(!dest.equalsIgnoreCase(getName())) && // Not this portal
|
||||||
(!portal.isHidden() || Stargate.hasPerm(player, "stargate.hidden", player.isOp()) || portal.getOwner().equals(player.getName()))
|
(!portal.isHidden() || stargate.hasPerm(player, "stargate.hidden", player.isOp()) || portal.getOwner().equals(player.getName()))
|
||||||
) {
|
) {
|
||||||
destinations.add(portal.getName());
|
destinations.add(portal.getName());
|
||||||
}
|
}
|
||||||
@ -396,9 +396,9 @@ public class Portal {
|
|||||||
return openTime;
|
return openTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cycleDestination(Player player) {
|
public void cycleDestination(Player player, Stargate stargate) {
|
||||||
if (!isActive() || getActivePlayer() != player) {
|
if (!isActive() || getActivePlayer() != player) {
|
||||||
activate(player);
|
activate(player, stargate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destinations.size() > 0) {
|
if (destinations.size() > 0) {
|
||||||
|
@ -7,7 +7,6 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockDamageLevel;
|
import org.bukkit.block.BlockDamageLevel;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -31,7 +30,6 @@ import org.bukkit.event.world.WorldEvent;
|
|||||||
import org.bukkit.event.world.WorldListener;
|
import org.bukkit.event.world.WorldListener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginLoader;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
@ -46,9 +44,10 @@ import com.nijikokun.bukkit.Permissions.Permissions;
|
|||||||
*/
|
*/
|
||||||
public class Stargate extends JavaPlugin {
|
public class Stargate extends JavaPlugin {
|
||||||
// Permissions
|
// Permissions
|
||||||
public static Permissions Permissions = null;
|
private Permissions permissions = null;
|
||||||
|
private double permVersion = 0;
|
||||||
|
|
||||||
private final bListener blockListener = new bListener();
|
private final bListener blockListener = new bListener(this);
|
||||||
private final pListener playerListener = new pListener();
|
private final pListener playerListener = new pListener();
|
||||||
private final vListener vehicleListener = new vListener();
|
private final vListener vehicleListener = new vListener();
|
||||||
private final wListener worldListener = new wListener();
|
private final wListener worldListener = new wListener();
|
||||||
@ -92,7 +91,12 @@ public class Stargate extends JavaPlugin {
|
|||||||
this.reloadConfig();
|
this.reloadConfig();
|
||||||
this.migrate();
|
this.migrate();
|
||||||
this.reloadGates();
|
this.reloadGates();
|
||||||
this.setupPermissions();
|
if (!this.setupPermissions()) {
|
||||||
|
log.info("[Stargate] Permissions not loaded, using defaults");
|
||||||
|
} else {
|
||||||
|
if (permissions != null)
|
||||||
|
log.info("[Stargate] Using Permissions " + permVersion + " (" + Permissions.version + ") for permissions");
|
||||||
|
}
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
@ -207,13 +211,41 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupPermissions() {
|
/*
|
||||||
Plugin perm = pm.getPlugin("Permissions");
|
* Find what Permissions plugin we're using and enable it.
|
||||||
|
*/
|
||||||
|
private boolean setupPermissions() {
|
||||||
|
Plugin perm;
|
||||||
|
// Apparently GM isn't a new permissions plugin, it's Permissions "2.0.1"
|
||||||
|
// API change broke my plugin.
|
||||||
|
perm = pm.getPlugin("Permissions");
|
||||||
|
// We're running Permissions
|
||||||
if (perm != null) {
|
if (perm != null) {
|
||||||
Stargate.Permissions = ((Permissions)perm);
|
if (!perm.isEnabled()) {
|
||||||
|
pm.enablePlugin(perm);
|
||||||
|
}
|
||||||
|
permissions = (Permissions)perm;
|
||||||
|
try {
|
||||||
|
String[] permParts = Permissions.version.split("\\.");
|
||||||
|
permVersion = Double.parseDouble(permParts[0] + "." + permParts[1]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("Could not determine Permissions version: " + Permissions.version);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Permissions not loaded
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether the player has the given permissions.
|
||||||
|
*/
|
||||||
|
public boolean hasPerm(Player player, String perm, boolean def) {
|
||||||
|
if (permissions != null) {
|
||||||
|
return permissions.getHandler().has(player, perm);
|
||||||
} else {
|
} else {
|
||||||
log.info("[" + this.getDescription().getName() + "] Permission system not enabled.");
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +305,12 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class bListener extends BlockListener {
|
private class bListener extends BlockListener {
|
||||||
|
Stargate stargate;
|
||||||
|
|
||||||
|
bListener(Stargate stargate) {
|
||||||
|
this.stargate = stargate;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
// Stop player from placing a block touching a portals controls
|
// Stop player from placing a block touching a portals controls
|
||||||
@ -288,7 +326,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
// Initialize a stargate
|
// Initialize a stargate
|
||||||
if (Stargate.hasPerm(player, "stargate.create", player.isOp())) {
|
if (hasPerm(player, "stargate.create", player.isOp())) {
|
||||||
SignPost sign = new SignPost(new Blox(block));
|
SignPost sign = new SignPost(new Blox(block));
|
||||||
// Set sign text so we can create a gate with it.
|
// Set sign text so we can create a gate with it.
|
||||||
sign.setText(0, event.getLine(0));
|
sign.setText(0, event.getLine(0));
|
||||||
@ -319,9 +357,9 @@ public class Stargate extends JavaPlugin {
|
|||||||
Portal portal = Portal.getByBlock(block);
|
Portal portal = Portal.getByBlock(block);
|
||||||
// Cycle through a stargates locations
|
// Cycle through a stargates locations
|
||||||
if (portal != null) {
|
if (portal != null) {
|
||||||
if (Stargate.hasPerm(player, "stargate.use", true)) {
|
if (hasPerm(player, "stargate.use", true)) {
|
||||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||||
portal.cycleDestination(player);
|
portal.cycleDestination(player, stargate);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!denyMsg.isEmpty()) {
|
if (!denyMsg.isEmpty()) {
|
||||||
@ -333,7 +371,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
|
|
||||||
// Implement right-click to toggle a stargate, gets around spawn protection problem.
|
// Implement right-click to toggle a stargate, gets around spawn protection problem.
|
||||||
if ((block.getType() == Material.STONE_BUTTON)) {
|
if ((block.getType() == Material.STONE_BUTTON)) {
|
||||||
if (Stargate.hasPerm(player, "stargate.use", true)) {
|
if (hasPerm(player, "stargate.use", true)) {
|
||||||
Portal portal = Portal.getByBlock(block);
|
Portal portal = Portal.getByBlock(block);
|
||||||
if (portal != null) {
|
if (portal != null) {
|
||||||
onButtonPressed(player, portal);
|
onButtonPressed(player, portal);
|
||||||
@ -347,8 +385,8 @@ public class Stargate extends JavaPlugin {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
// Check if we're pushing a button.
|
// Check if we're pushing a button.
|
||||||
if (block.getType() == Material.STONE_BUTTON && event.getDamageLevel() == BlockDamageLevel.STOPPED) {
|
if (block.getType() == Material.STONE_BUTTON && event.getDamageLevel() == BlockDamageLevel.STARTED) {
|
||||||
if (Stargate.hasPerm(player, "stargate.use", true)) {
|
if (hasPerm(player, "stargate.use", true)) {
|
||||||
Portal portal = Portal.getByBlock(block);
|
Portal portal = Portal.getByBlock(block);
|
||||||
if (portal != null) {
|
if (portal != null) {
|
||||||
onButtonPressed(player, portal);
|
onButtonPressed(player, portal);
|
||||||
@ -368,7 +406,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
Portal portal = Portal.getByBlock(block);
|
Portal portal = Portal.getByBlock(block);
|
||||||
if (portal == null) return;
|
if (portal == null) return;
|
||||||
|
|
||||||
if (!Stargate.hasPerm(player, "stargate.destroy", player.isOp())) {
|
if (!hasPerm(player, "stargate.destroy", player.isOp())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -404,13 +442,6 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
|
||||||
public static Boolean hasPerm(Player player, String perm, Boolean def) {
|
|
||||||
if (Permissions != null)
|
|
||||||
return Permissions.Security.permission(player, perm);
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SGThread implements Runnable {
|
private class SGThread implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
long time = System.currentTimeMillis() / 1000;
|
long time = System.currentTimeMillis() / 1000;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.15
|
version: 0.18
|
||||||
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