mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2025-02-19 02:21:33 +01:00
Fix sponge context group permission check.
* Fix GDEntityType getEnumCreatureType.
This commit is contained in:
parent
6bd5bcf2c4
commit
a51c954c78
@ -83,6 +83,10 @@ public void registerDefaults() {
|
||||
SPAWN_TYPES.put("monster", EnumCreatureType.MONSTER);
|
||||
}
|
||||
|
||||
public void registerAdditionalCatalog(EntityType type) {
|
||||
this.entityTypeMappings.put(type.getId(), new GDEntityType(type));
|
||||
}
|
||||
|
||||
private static final class Holder {
|
||||
|
||||
static final EntityTypeRegistryModule INSTANCE = new EntityTypeRegistryModule();
|
||||
|
@ -27,6 +27,7 @@
|
||||
import com.griefdefender.api.CatalogType;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.entity.EntityType;
|
||||
import org.spongepowered.common.entity.SpongeEntityType;
|
||||
|
||||
@ -61,7 +62,7 @@ public String getModId() {
|
||||
|
||||
@Nullable
|
||||
public String getEnumCreatureTypeId() {
|
||||
if (this.creatureType == null) {
|
||||
if (this.getEnumCreatureType() == null) {
|
||||
return null;
|
||||
}
|
||||
switch (this.creatureType) {
|
||||
@ -95,6 +96,12 @@ public Context getEnumCreatureTypeContext(boolean isSource) {
|
||||
|
||||
@Nullable
|
||||
public EnumCreatureType getEnumCreatureType() {
|
||||
if (this.creatureType == null) {
|
||||
final SpongeEntityType spongeEntityType = ((SpongeEntityType) Sponge.getRegistry().getType(EntityType.class, this.getId()).orElse(null));
|
||||
if (spongeEntityType != null) {
|
||||
this.creatureType = spongeEntityType.getEnumCreatureType();
|
||||
}
|
||||
}
|
||||
return this.creatureType;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ public boolean onEntityMove(MoveEntityEvent event, Location<World> fromLocation,
|
||||
fromClaim = this.storage.getClaimAt(fromLocation);
|
||||
}
|
||||
|
||||
if (GDFlags.ENTER_CLAIM && !enterBlacklisted && user != null && user.getInternalPlayerData().lastClaim != null) {
|
||||
if (player != null && GDFlags.ENTER_CLAIM && !enterBlacklisted && user.getInternalPlayerData().lastClaim != null) {
|
||||
final GDClaim lastClaim = (GDClaim) user.getInternalPlayerData().lastClaim.get();
|
||||
if (lastClaim != null && lastClaim != fromClaim) {
|
||||
if (GDPermissionManager.getInstance().getFinalPermission(event, toLocation, toClaim, GDPermissions.ENTER_CLAIM, targetEntity, targetEntity, player, TrustTypes.ACCESSOR, false) == Tristate.FALSE) {
|
||||
@ -220,28 +220,30 @@ public boolean onEntityMove(MoveEntityEvent event, Location<World> fromLocation,
|
||||
} else {
|
||||
final boolean showGpPrefix = GriefDefenderPlugin.getGlobalConfig().getConfig().message.enterExitShowGdPrefix;
|
||||
user.getInternalPlayerData().lastClaim = new WeakReference<>(toClaim);
|
||||
TextComponent welcomeMessage = (TextComponent) gpEvent.getEnterMessage().orElse(null);
|
||||
if (welcomeMessage != null && !welcomeMessage.equals(TextComponent.empty()) && !welcomeMessage.content().equals("")) {
|
||||
ChatType chatType = gpEvent.getEnterMessageChatType();
|
||||
if (showGpPrefix) {
|
||||
TextAdapter.sendComponent(player, TextComponent.builder("")
|
||||
.append(enterClanTag != null ? enterClanTag : GriefDefenderPlugin.GD_TEXT)
|
||||
.append(welcomeMessage).build(), SpongeUtil.getSpongeChatType(chatType));
|
||||
} else {
|
||||
TextAdapter.sendComponent(player, enterClanTag != null ? enterClanTag : welcomeMessage, SpongeUtil.getSpongeChatType(chatType));
|
||||
if (player != null) {
|
||||
TextComponent welcomeMessage = (TextComponent) gpEvent.getEnterMessage().orElse(null);
|
||||
if (welcomeMessage != null && !welcomeMessage.equals(TextComponent.empty()) && !welcomeMessage.content().equals("")) {
|
||||
ChatType chatType = gpEvent.getEnterMessageChatType();
|
||||
if (showGpPrefix) {
|
||||
TextAdapter.sendComponent(player, TextComponent.builder("")
|
||||
.append(enterClanTag != null ? enterClanTag : GriefDefenderPlugin.GD_TEXT)
|
||||
.append(welcomeMessage).build(), SpongeUtil.getSpongeChatType(chatType));
|
||||
} else {
|
||||
TextAdapter.sendComponent(player, enterClanTag != null ? enterClanTag : welcomeMessage, SpongeUtil.getSpongeChatType(chatType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component farewellMessage = gpEvent.getExitMessage().orElse(null);
|
||||
if (farewellMessage != null && !farewellMessage.equals(Text.of())) {
|
||||
ChatType chatType = gpEvent.getExitMessageChatType();
|
||||
if (showGpPrefix) {
|
||||
TextAdapter.sendComponent(player, TextComponent.builder("")
|
||||
.append(exitClanTag != null ? exitClanTag : GriefDefenderPlugin.GD_TEXT)
|
||||
.append(farewellMessage)
|
||||
.build(), SpongeUtil.getSpongeChatType(chatType));
|
||||
} else {
|
||||
TextAdapter.sendComponent(player, exitClanTag != null ? exitClanTag : farewellMessage, SpongeUtil.getSpongeChatType(chatType));
|
||||
|
||||
Component farewellMessage = gpEvent.getExitMessage().orElse(null);
|
||||
if (farewellMessage != null && !farewellMessage.equals(Text.of())) {
|
||||
ChatType chatType = gpEvent.getExitMessageChatType();
|
||||
if (showGpPrefix) {
|
||||
TextAdapter.sendComponent(player, TextComponent.builder("")
|
||||
.append(exitClanTag != null ? exitClanTag : GriefDefenderPlugin.GD_TEXT)
|
||||
.append(farewellMessage)
|
||||
.build(), SpongeUtil.getSpongeChatType(chatType));
|
||||
} else {
|
||||
TextAdapter.sendComponent(player, exitClanTag != null ? exitClanTag : farewellMessage, SpongeUtil.getSpongeChatType(chatType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
import com.griefdefender.configuration.category.BanCategory;
|
||||
import com.griefdefender.event.GDCauseStackManager;
|
||||
import com.griefdefender.event.GDFlagPermissionEvent;
|
||||
import com.griefdefender.internal.registry.EntityTypeRegistryModule;
|
||||
import com.griefdefender.internal.registry.GDEntityType;
|
||||
import com.griefdefender.internal.util.BlockUtil;
|
||||
import com.griefdefender.internal.util.NMSUtil;
|
||||
@ -106,7 +107,6 @@
|
||||
import org.spongepowered.api.world.Location;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.common.SpongeImplHooks;
|
||||
import org.spongepowered.common.registry.type.entity.EntityTypeRegistryModule;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -632,6 +632,16 @@ public Set<Context> getPermissionContexts(GDClaim claim, Object obj, boolean isS
|
||||
}
|
||||
}
|
||||
|
||||
GDEntityType type = EntityTypeRegistryModule.getInstance().getById(targetEntity.getType().getId()).orElse(null);
|
||||
if (type == null) {
|
||||
EntityTypeRegistryModule.getInstance().registerAdditionalCatalog(targetEntity.getType());
|
||||
type = EntityTypeRegistryModule.getInstance().getById(targetEntity.getType().getId()).orElse(null);
|
||||
}
|
||||
|
||||
if (type != null && !(targetEntity instanceof Player)) {
|
||||
addCustomEntityTypeContexts(targetEntity, contexts, type, isSource);
|
||||
}
|
||||
|
||||
if (this.isObjectIdBanned(claim, id, BanType.ENTITY)) {
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user