Mostly fixed permissions (now it's recursing)

This commit is contained in:
Norbi Peti 2017-07-08 02:13:56 +02:00
parent 2aca1551ef
commit 9e85883e34
4 changed files with 118 additions and 34 deletions

18
pom.xml
View file

@ -13,7 +13,7 @@
<build> <build>
<!-- <sourceDirectory>target/generated-sources/delombok</sourceDirectory> <!-- <sourceDirectory>target/generated-sources/delombok</sourceDirectory>
<testSourceDirectory>target/generated-test-sources/delombok</testSourceDirectory> --> <testSourceDirectory>target/generated-test-sources/delombok</testSourceDirectory> -->
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
<resources> <resources>
<resource> <resource>
<directory>src</directory> <directory>src</directory>
@ -131,6 +131,10 @@
<id>projectlombok.org</id> <id>projectlombok.org</id>
<url>http://projectlombok.org/mavenrepo</url> <url>http://projectlombok.org/mavenrepo</url>
</repository> </repository>
<repository>
<id>pex-repo</id>
<url>http://pex-repo.aoeu.xyz</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -188,5 +192,17 @@
<version>1.16.16</version> <version>1.16.16</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>ru.tehkode</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.23.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -1,31 +1,19 @@
package buttondevteam.discordplugin.playerfaker; package buttondevteam.discordplugin.playerfaker;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.block.PistonMoveReaction; import org.bukkit.block.PistonMoveReaction;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.permissions.PermissibleBase;
import org.bukkit.permissions.ServerOperator;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import buttondevteam.discordplugin.DiscordSenderBase; import buttondevteam.discordplugin.DiscordSenderBase;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Delegate;
import sx.blah.discord.handle.obj.IChannel; import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IUser; import sx.blah.discord.handle.obj.IUser;
@ -40,12 +28,7 @@ public abstract class DiscordEntity extends DiscordSenderBase implements Entity
private HashMap<String, MetadataValue> metadata = new HashMap<String, MetadataValue>(); private HashMap<String, MetadataValue> metadata = new HashMap<String, MetadataValue>();
@Delegate private Location location = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
private PermissibleBase perm = new PermissibleBase(new ServerOperator() {
private @Getter @Setter boolean op;
});
private Location location;
private Vector velocity; private Vector velocity;
private final int entityId; private final int entityId;
private EntityDamageEvent lastDamageCause; private EntityDamageEvent lastDamageCause;

View file

@ -2,7 +2,6 @@ package buttondevteam.discordplugin.playerfaker;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.*; import java.util.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.advancement.Advancement; import org.bukkit.advancement.Advancement;
import org.bukkit.advancement.AdvancementProgress; import org.bukkit.advancement.AdvancementProgress;
@ -15,14 +14,23 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import buttondevteam.discordplugin.DiscordPlugin; import buttondevteam.discordplugin.DiscordPlugin;
import lombok.experimental.Delegate;
import sx.blah.discord.handle.obj.IChannel; import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IUser; import sx.blah.discord.handle.obj.IUser;
public class DiscordFakePlayer extends DiscordHumanEntity implements Player { public class DiscordFakePlayer extends DiscordHumanEntity implements Player {
protected DiscordFakePlayer(IUser user, IChannel channel, int entityId, UUID uuid) { protected DiscordFakePlayer(IUser user, IChannel channel, int entityId, UUID uuid) {
super(user, channel, entityId, uuid); super(user, channel, entityId, uuid);
/*
* try { perm = new PEXPermissible(this, (PermissionsExPlugin) Bukkit.getPluginManager().getPlugin("PermissionsEx")); } catch (ExecutionException | InterruptedException e) {
* e.printStackTrace(); }
*/
perm = new VaultPermissibleBase(this);
} }
@Delegate
private VaultPermissibleBase perm;
@Override @Override
public String getName() { public String getName() {
return user.getName(); return user.getName();
@ -120,7 +128,7 @@ public class DiscordFakePlayer extends DiscordHumanEntity implements Player {
@Override @Override
public String getDisplayName() { public String getDisplayName() {
return user.getNicknameForGuild(DiscordPlugin.mainServer); return user.getDisplayName(DiscordPlugin.mainServer);
} }
@Override @Override
@ -632,75 +640,64 @@ public class DiscordFakePlayer extends DiscordHumanEntity implements Player {
@Override @Override
public void spawnParticle(Particle particle, double x, double y, double z, int count) { public void spawnParticle(Particle particle, double x, double y, double z, int count) {
} }
@Override @Override
public <T> void spawnParticle(Particle particle, Location location, int count, T data) { public <T> void spawnParticle(Particle particle, Location location, int count, T data) {
} }
@Override @Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) { public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) {
} }
@Override @Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
double offsetZ) { double offsetZ) {
} }
@Override @Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
double offsetY, double offsetZ) { double offsetY, double offsetZ) {
} }
@Override @Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
double offsetZ, T data) { double offsetZ, T data) {
} }
@Override @Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
double offsetY, double offsetZ, T data) { double offsetY, double offsetZ, T data) {
} }
@Override @Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
double offsetZ, double extra) { double offsetZ, double extra) {
} }
@Override @Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
double offsetY, double offsetZ, double extra) { double offsetY, double offsetZ, double extra) {
} }
@Override @Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
double offsetZ, double extra, T data) { double offsetZ, double extra, T data) {
} }
@Override @Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
double offsetY, double offsetZ, double extra, T data) { double offsetY, double offsetZ, double extra, T data) {
} }
@Override @Override

View file

@ -0,0 +1,88 @@
package buttondevteam.discordplugin.playerfaker;
import java.util.Collections;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import buttondevteam.discordplugin.DiscordPlugin;
public class VaultPermissibleBase implements Permissible {
private Player player;
private OfflinePlayer op;
public VaultPermissibleBase(Player player) {
this.player = player;
op = Bukkit.getOfflinePlayer(player.getUniqueId());
}
@Override
public boolean isPermissionSet(String name) {
return DiscordPlugin.perms.playerHas(player, name);
}
@Override
public boolean isPermissionSet(Permission perm) {
return DiscordPlugin.perms.playerHas(player, perm.getName());
}
@Override
public boolean hasPermission(String inName) {
return DiscordPlugin.perms.playerHas(player, inName);
}
@Override
public boolean hasPermission(Permission perm) {
return DiscordPlugin.perms.playerHas(player, perm.getName());
}
@Override
public boolean isOp() {
return op.isOp();
}
@Override
public void setOp(boolean value) {
op.setOp(value);
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
return null;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin) {
return null;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
return null;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
return null;
}
@Override
public void removeAttachment(PermissionAttachment attachment) {
}
@Override
public void recalculatePermissions() {
}
@Override
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
return Collections.emptySet();
}
}