Compare commits
9 Commits
56eaa1c8c4
...
free
| Author | SHA1 | Date | |
|---|---|---|---|
| 6966fe4485 | |||
| f6b043f3a5 | |||
| 0c72e4915d | |||
| e2e677f043 | |||
| bbee8650d3 | |||
|
|
cc86e130ea | ||
|
|
1b33b03c90 | ||
|
|
b50c6c07df | ||
|
|
cfc1eb27b9 |
11
.drone.yml
Normal file
11
.drone.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- free
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: maven:3-eclipse-temurin-17
|
||||||
|
commands:
|
||||||
|
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
||||||
|
- mvn test -B
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.idea/
|
||||||
|
target/
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>v1_17_R1</artifactId>
|
<artifactId>v1_17_R1</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
@@ -45,6 +44,12 @@
|
|||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>3.2.37</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -22,6 +22,11 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>datafixerupper</artifactId>
|
||||||
|
<version>1.0.20</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
@@ -44,6 +49,22 @@
|
|||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>3.2.37</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
<artifactId>fastutil</artifactId>
|
||||||
|
<version>8.5.8</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.mojang.authlib.Agent;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
@@ -201,7 +200,7 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
ChunkMap chunkMap = chunkSource.chunkMap;
|
ChunkMap chunkMap = chunkSource.chunkMap;
|
||||||
Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = chunkMap.entityMap;
|
Map<Integer, ChunkMap.TrackedEntity> entityMap = chunkMap.entityMap;
|
||||||
ChunkMap.TrackedEntity trackedEntity = entityMap.get(target.getEntityId());
|
ChunkMap.TrackedEntity trackedEntity = entityMap.get(target.getEntityId());
|
||||||
if (trackedEntity == null) {
|
if (trackedEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -136,6 +136,12 @@
|
|||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>3.2.37</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import me.libraryaddict.disguise.DisguiseConfig;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import org.bukkit.entity.Panda;
|
import org.bukkit.entity.Panda;
|
||||||
@@ -19,11 +20,22 @@ public class PandaWatcher extends AgeableWatcher {
|
|||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
if (DisguiseConfig.isRandomDisguises()) {
|
if (DisguiseConfig.isRandomDisguises()) {
|
||||||
|
// We don't do 'setGene' here so it's just as random as it would be as if it was natural.
|
||||||
setMainGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]);
|
setMainGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]);
|
||||||
setHiddenGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]);
|
setHiddenGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Panda.Gene getGene() {
|
||||||
|
return getMainGene();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RandomDefaultValue
|
||||||
|
public void setGene(Panda.Gene gene) {
|
||||||
|
setMainGene(gene);
|
||||||
|
setHiddenGene(gene);
|
||||||
|
}
|
||||||
|
|
||||||
public Panda.Gene getMainGene() {
|
public Panda.Gene getMainGene() {
|
||||||
int id = getData(MetaIndex.PANDA_MAIN_GENE);
|
int id = getData(MetaIndex.PANDA_MAIN_GENE);
|
||||||
|
|
||||||
@@ -38,7 +50,7 @@ public class PandaWatcher extends AgeableWatcher {
|
|||||||
return Panda.Gene.NORMAL;
|
return Panda.Gene.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@MethodOnlyUsedBy(value = {}) // Hide from command
|
||||||
public void setMainGene(Panda.Gene gene) {
|
public void setMainGene(Panda.Gene gene) {
|
||||||
setData(MetaIndex.PANDA_MAIN_GENE, (byte) gene.ordinal());
|
setData(MetaIndex.PANDA_MAIN_GENE, (byte) gene.ordinal());
|
||||||
sendData(MetaIndex.PANDA_MAIN_GENE);
|
sendData(MetaIndex.PANDA_MAIN_GENE);
|
||||||
@@ -58,7 +70,7 @@ public class PandaWatcher extends AgeableWatcher {
|
|||||||
return Panda.Gene.NORMAL;
|
return Panda.Gene.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@MethodOnlyUsedBy(value = {}) // Hide from command
|
||||||
public void setHiddenGene(Panda.Gene gene) {
|
public void setHiddenGene(Panda.Gene gene) {
|
||||||
setData(MetaIndex.PANDA_HIDDEN_GENE, (byte) gene.ordinal());
|
setData(MetaIndex.PANDA_HIDDEN_GENE, (byte) gene.ordinal());
|
||||||
sendData(MetaIndex.PANDA_HIDDEN_GENE);
|
sendData(MetaIndex.PANDA_HIDDEN_GENE);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class LibsPremium {
|
|||||||
* Returns true if this plugin is premium
|
* Returns true if this plugin is premium
|
||||||
*/
|
*/
|
||||||
public static Boolean isPremium() {
|
public static Boolean isPremium() {
|
||||||
return thisPluginIsPaidFor == null ? isPremium(getResourceID(), getUserID()) : thisPluginIsPaidFor;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -681,6 +681,8 @@ public class DisguiseParser {
|
|||||||
Entry<DisguisePerm, String> customDisguise = DisguiseConfig.getRawCustomDisguise(args[0]);
|
Entry<DisguisePerm, String> customDisguise = DisguiseConfig.getRawCustomDisguise(args[0]);
|
||||||
|
|
||||||
if (customDisguise != null) {
|
if (customDisguise != null) {
|
||||||
|
// TODO Doesn't this mean we can't add args to our custom disguise on /disguise?
|
||||||
|
// Need to add user defined args for the custom disguise
|
||||||
args = DisguiseUtilities.split(customDisguise.getValue());
|
args = DisguiseUtilities.split(customDisguise.getValue());
|
||||||
name = customDisguise.getKey().toReadable();
|
name = customDisguise.getKey().toReadable();
|
||||||
customName = true;
|
customName = true;
|
||||||
@@ -733,7 +735,6 @@ public class DisguiseParser {
|
|||||||
toSkip++;
|
toSkip++;
|
||||||
}
|
}
|
||||||
} else if (disguisePerm.isMob()) { // Its a mob, use the mob constructor
|
} else if (disguisePerm.isMob()) { // Its a mob, use the mob constructor
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
boolean adult = true;
|
boolean adult = true;
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public class DisguisePermissions {
|
|||||||
|
|
||||||
// If this refers to a specific disguise
|
// If this refers to a specific disguise
|
||||||
if (dPerm != null) {
|
if (dPerm != null) {
|
||||||
return new ParsedPermission(new DisguisePerm[]{dPerm}, options, (byte) 0, split[1].equals("*"));
|
return new ParsedPermission(new DisguisePerm[]{dPerm}, options, (byte) (options.containsKey("*") ? 1 : 0), split[1].equals("*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the disguise can't be found, it may be refering to a range
|
// If the disguise can't be found, it may be refering to a range
|
||||||
@@ -403,34 +403,34 @@ public class DisguisePermissions {
|
|||||||
|
|
||||||
if (permissionName.equals("ageable")) {
|
if (permissionName.equals("ageable")) {
|
||||||
if (Ageable.class.isAssignableFrom(disguiseType.getEntityClass())) {
|
if (Ageable.class.isAssignableFrom(disguiseType.getEntityClass())) {
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
} else if (permissionName.equals("monster") || permissionName.equals("monsters")) {
|
} else if (permissionName.equals("monster") || permissionName.equals("monsters")) {
|
||||||
if (Monster.class.isAssignableFrom(disguiseType.getEntityClass())) {
|
if (Monster.class.isAssignableFrom(disguiseType.getEntityClass())) {
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
} else if (permissionName.equals("animal") || permissionName.equals("animals")) {
|
} else if (permissionName.equals("animal") || permissionName.equals("animals")) {
|
||||||
if (Animals.class.isAssignableFrom(disguiseType.getEntityClass())) {
|
if (Animals.class.isAssignableFrom(disguiseType.getEntityClass())) {
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
} else if (permissionName.equals("mob")) {
|
} else if (permissionName.equals("mob")) {
|
||||||
if (disguiseType.isMob()) {
|
if (disguiseType.isMob()) {
|
||||||
return 3;
|
return 4;
|
||||||
}
|
}
|
||||||
} else if (permissionName.equals("misc")) {
|
} else if (permissionName.equals("misc")) {
|
||||||
if (disguiseType.isMisc()) {
|
if (disguiseType.isMisc()) {
|
||||||
return 3;
|
return 4;
|
||||||
}
|
}
|
||||||
} else if (permissionName.equals("custom")) {
|
} else if (permissionName.equals("custom")) {
|
||||||
if (disguisePerm.isCustomDisguise()) {
|
if (disguisePerm.isCustomDisguise()) {
|
||||||
return 3;
|
return 4;
|
||||||
}
|
}
|
||||||
} else if (permissionName.equals("vanilla")) {
|
} else if (permissionName.equals("vanilla")) {
|
||||||
if (!disguisePerm.isCustomDisguise()) {
|
if (!disguisePerm.isCustomDisguise()) {
|
||||||
return 4;
|
return 5;
|
||||||
}
|
}
|
||||||
} else if (permissionName.equals("*")) {
|
} else if (permissionName.equals("*")) {
|
||||||
return 5;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.utilities.parser;
|
package me.libraryaddict.disguise.utilities.parser;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import org.bukkit.permissions.Permissible;
|
import org.bukkit.permissions.Permissible;
|
||||||
@@ -213,6 +215,33 @@ public class DisguisePermissionsTest {
|
|||||||
DisguisePermissions.hasPermissionOption(disguiseOptions, "setBlock", "DIRT"));
|
DisguisePermissions.hasPermissionOption(disguiseOptions, "setBlock", "DIRT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Test
|
||||||
|
public void testCustomDisguisePermissions() {
|
||||||
|
DisguiseConfig.getCustomDisguises().put(new DisguisePerm(DisguiseType.BEE, "babybee"), "bee setbaby");
|
||||||
|
|
||||||
|
DisguisePermissions permissions = createPermissions("disguise", false, "libsdisguises.disguise.bee.-*", "libsdisguises.disguise.babybee.nooptions");
|
||||||
|
|
||||||
|
Assert.assertNotNull("The custom disguise babybee should exist", DisguiseParser.getDisguisePerm("babybee"));
|
||||||
|
|
||||||
|
Assert.assertTrue("They should be allowed to disguise as a bee", permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE)));
|
||||||
|
|
||||||
|
Assert.assertFalse("They should not be allowed to disguise as a bee and call setbaby",
|
||||||
|
permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE), Collections.singletonList("setbaby")));
|
||||||
|
|
||||||
|
Assert.assertFalse("They should not be allowed to disguise as a burning bee",
|
||||||
|
permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE), Collections.singletonList("setburning")));
|
||||||
|
|
||||||
|
Assert.assertFalse("They should not be allowed to disguise as a slime", permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.SLIME)));
|
||||||
|
|
||||||
|
Assert.assertTrue("They should be allowed to disguise as babybee", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("babybee")));
|
||||||
|
|
||||||
|
Assert.assertFalse("They should not be allowed to disguise as babybee and use setbaby",
|
||||||
|
permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("babybee"), Collections.singletonList("setbaby")));
|
||||||
|
|
||||||
|
DisguiseAPI.removeCustomDisguise("babybee");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExplictPermissions() {
|
public void testExplictPermissions() {
|
||||||
DisguiseConfig.setExplicitDisguisePermissions(true);
|
DisguiseConfig.setExplicitDisguisePermissions(true);
|
||||||
@@ -256,7 +285,6 @@ public class DisguisePermissionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Permissible createPermissionsHolder(boolean isOp, String... perms) {
|
private Permissible createPermissionsHolder(boolean isOp, String... perms) {
|
||||||
|
|
||||||
List<String> permitted = new ArrayList<>();
|
List<String> permitted = new ArrayList<>();
|
||||||
List<String> negated = new ArrayList<>();
|
List<String> negated = new ArrayList<>();
|
||||||
Set<PermissionAttachmentInfo> attachments = new HashSet<>();
|
Set<PermissionAttachmentInfo> attachments = new HashSet<>();
|
||||||
|
|||||||
11
pom.xml
11
pom.xml
@@ -53,6 +53,12 @@
|
|||||||
<version>${spigot.version}</version>
|
<version>${spigot.version}</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>3.2.37</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@@ -72,6 +78,11 @@
|
|||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>velocity</id>
|
||||||
|
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
<!-- Lumine is a repo hosted by the creators of MythicCraft -->
|
<!-- Lumine is a repo hosted by the creators of MythicCraft -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>lumine</id>
|
<id>lumine</id>
|
||||||
|
|||||||
@@ -32,6 +32,12 @@
|
|||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>3.2.37</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
Reference in New Issue
Block a user