mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Permission stuff
This commit is contained in:
parent
e314f46c47
commit
4acf88e09d
@ -62,6 +62,7 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -119,6 +120,7 @@ public class DebugExec extends SubCommand {
|
||||
scope.put("BlockManager", BlockManager.manager);
|
||||
scope.put("SetupUtils", SetupUtils.manager);
|
||||
scope.put("EventUtil", EventUtil.manager);
|
||||
scope.put("EconHandler", EconHandler.manager);
|
||||
scope.put("UUIDHandler", UUIDHandler.implementation);
|
||||
scope.put("DBFunc", DBFunc.dbManager);
|
||||
scope.put("HybridUtils", HybridUtils.manager);
|
||||
|
@ -16,7 +16,6 @@ public abstract class EconHandler {
|
||||
public abstract void withdrawMoney(PlotPlayer player, double amount);
|
||||
public abstract void depositMoney(PlotPlayer player, double amount);
|
||||
public abstract void depositMoney(OfflinePlotPlayer player, double amount);
|
||||
public abstract void setPermission(PlotPlayer player, String perm, boolean value);
|
||||
// public abstract void setPermission(OfflinePlotPlayer player, String perm, boolean value);
|
||||
// public abstract void getPermission(OfflinePlotPlayer player, String perm);
|
||||
public abstract void setPermission(String player, String perm, boolean value);
|
||||
public abstract boolean hasPermission(String player, String perm);
|
||||
}
|
||||
|
@ -635,6 +635,15 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
manager.startPlotMerge(plotworld, plotIds);
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PS.get().getPlots(world).get(id);
|
||||
if (removeRoads) {
|
||||
removeSign(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final boolean lx = x < pos2.x;
|
||||
@ -642,9 +651,6 @@ public class MainUtil {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PS.get().getPlots(world).get(id);
|
||||
Plot plot2 = null;
|
||||
if (removeRoads) {
|
||||
removeSign(plot);
|
||||
}
|
||||
if (lx) {
|
||||
if (ly) {
|
||||
if (!plot.getSettings().getMerged(1) || !plot.getSettings().getMerged(2)) {
|
||||
|
@ -31,6 +31,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
private long last = 0;
|
||||
public HashSet<String> hasPerm = new HashSet<>();
|
||||
public HashSet<String> noPerm = new HashSet<>();
|
||||
public boolean offline;
|
||||
|
||||
/**
|
||||
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects.
|
||||
@ -40,6 +41,11 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public BukkitPlayer(final Player player, boolean offline) {
|
||||
this.player = player;
|
||||
this.offline = offline;
|
||||
}
|
||||
|
||||
public long getPreviousLogin() {
|
||||
if (last == 0) {
|
||||
last = player.getLastPlayed();
|
||||
@ -78,6 +84,9 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
this.hasPerm.add(perm);
|
||||
return true;
|
||||
}
|
||||
if (offline && EconHandler.manager != null) {
|
||||
return EconHandler.manager.hasPermission(getName(), perm);
|
||||
}
|
||||
return this.player.hasPermission(perm);
|
||||
}
|
||||
|
||||
@ -106,7 +115,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return this.player.isOnline();
|
||||
return !offline && this.player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,7 +132,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void setAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
EconHandler.manager.setPermission(this, key, true);
|
||||
EconHandler.manager.setPermission(getName(), key, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -141,7 +150,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void removeAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
EconHandler.manager.setPermission(this, key, false);
|
||||
EconHandler.manager.setPermission(getName(), key, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,8 +4,10 @@ import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
@ -68,12 +70,17 @@ public class BukkitEconHandler extends EconHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermission(PlotPlayer player, String perm, boolean value) {
|
||||
public void setPermission(String player, String perm, boolean value) {
|
||||
if (value) {
|
||||
perms.playerAdd(((BukkitPlayer) player).player, perm);
|
||||
perms.playerAdd((World) null, player, perm);
|
||||
}
|
||||
else {
|
||||
perms.playerRemove(((BukkitPlayer) player).player, perm);
|
||||
perms.playerRemove((World) null, player, perm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String player, String perm) {
|
||||
return perms.playerHas((String) null, Bukkit.getOfflinePlayer(player), perm);
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public class BukkitUtil extends BlockManager {
|
||||
}
|
||||
Player player = OfflinePlayerUtil.loadPlayer(op);
|
||||
player.loadData();
|
||||
return new BukkitPlayer(player);
|
||||
return new BukkitPlayer(player, true);
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(final Player player) {
|
||||
|
@ -141,7 +141,7 @@ public class SpongePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void setAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
EconHandler.manager.setPermission(this, key, true);
|
||||
EconHandler.manager.setPermission(getName(), key, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,7 +156,7 @@ public class SpongePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void removeAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
EconHandler.manager.setPermission(this, key, false);
|
||||
EconHandler.manager.setPermission(getName(), key, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,30 @@ Need to script something quick with PlotSquared?
|
||||
/plot debugexec runasync automerge.js <removeroads>
|
||||
|
||||
This is an example script that will auto merge all plots
|
||||
|
||||
The following utility classes are usable:
|
||||
- PS
|
||||
- TaskManager
|
||||
- TitleManager
|
||||
- ConsolePlayer
|
||||
- SchematicHandler
|
||||
- ChunkManager
|
||||
- BlockManager
|
||||
- SetupUtils
|
||||
- EventUtil
|
||||
- UUIDHandler
|
||||
- DBFunc
|
||||
- HybridUtils
|
||||
- IMP ( BukkitMain or SpongeMain)
|
||||
- MainCommand
|
||||
- MainUtil
|
||||
- Settings
|
||||
- StringMan
|
||||
- MathMan
|
||||
- C ( use C_ )
|
||||
- Permissions ( use Permissions_ )
|
||||
|
||||
For more information see: https://github.com/IntellectualSites/PlotSquared/wiki/Scripting
|
||||
*/
|
||||
var plots = PS.sortPlots(PS.getPlots());
|
||||
PS.log("Attempting to auto merge " + plots.size() + " plots");
|
||||
|
Loading…
Reference in New Issue
Block a user