mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-25 12:45:48 +01:00
Add perm check when changing claim type to town.
* sponge: Fix expiration cleanup interval not being passed to task.
This commit is contained in:
parent
80964978bc
commit
c1e5843482
@ -1961,6 +1961,11 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
|
||||
isAdmin = true;
|
||||
}
|
||||
|
||||
GDPermissionUser user = null;
|
||||
if (newOwnerUUID != null) {
|
||||
user = PermissionHolderCache.getInstance().getOrCreateUser(newOwnerUUID);
|
||||
}
|
||||
|
||||
if (type == ClaimTypes.ADMIN) {
|
||||
if (!isAdmin) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CHANGE_NOT_ADMIN,
|
||||
@ -1995,14 +2000,14 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
|
||||
if (this.parent == null) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CREATE_DENY,
|
||||
ImmutableMap.of(
|
||||
"type", TextComponent.of("SUBDIVISION", TextColor.AQUA),
|
||||
"type", this.getFriendlyNameType(true),
|
||||
"target_type", TextComponent.of("WILDERNESS", TextColor.GREEN)));
|
||||
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
|
||||
}
|
||||
if (this.isAdminClaim() && newOwnerUUID == null) {
|
||||
return new GDClaimResult(ClaimResultType.REQUIRES_OWNER, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_REQUIRES_OWNER,
|
||||
ImmutableMap.of(
|
||||
"type", TextComponent.of("ADMIN", TextColor.RED),
|
||||
"type", this.getFriendlyNameType(true),
|
||||
"target_type", TextComponent.of("SUBDIVISION", TextColor.AQUA))));
|
||||
}
|
||||
} else if (type == ClaimTypes.TOWN) {
|
||||
@ -2011,6 +2016,13 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
|
||||
ImmutableMap.of("type", TextComponent.of("TOWN").color(TextColor.GREEN)));
|
||||
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
|
||||
}
|
||||
if (!isAdmin && user != null && !PermissionUtil.getInstance().holderHasPermission(user, GDPermissions.CLAIM_CREATE_TOWN)) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CREATE_DENY,
|
||||
ImmutableMap.of(
|
||||
"type", this.getFriendlyNameType(true),
|
||||
"target_type", TextComponent.of("TOWN", TextColor.GREEN)));
|
||||
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
|
||||
}
|
||||
} else if (type == ClaimTypes.WILDERNESS) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CHANGE_DENY,
|
||||
ImmutableMap.of("type", TextComponent.of("WILDERNESS").color(TextColor.GREEN)));
|
||||
|
@ -574,7 +574,7 @@ public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
||||
int cleanupTaskInterval = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.expirationCleanupInterval;
|
||||
if (cleanupTaskInterval > 0) {
|
||||
ClaimCleanupTask cleanupTask = new ClaimCleanupTask();
|
||||
Sponge.getScheduler().createTaskBuilder().interval(10, TimeUnit.SECONDS).execute(cleanupTask)
|
||||
Sponge.getScheduler().createTaskBuilder().interval(cleanupTaskInterval, TimeUnit.SECONDS).execute(cleanupTask)
|
||||
.submit(GDBootstrap.getInstance());
|
||||
}
|
||||
}
|
||||
|
@ -1978,6 +1978,11 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
|
||||
isAdmin = true;
|
||||
}
|
||||
|
||||
GDPermissionUser user = null;
|
||||
if (newOwnerUUID != null) {
|
||||
user = PermissionHolderCache.getInstance().getOrCreateUser(newOwnerUUID);
|
||||
}
|
||||
|
||||
if (type == ClaimTypes.ADMIN) {
|
||||
if (!isAdmin) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CHANGE_NOT_ADMIN,
|
||||
@ -2012,14 +2017,14 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
|
||||
if (this.parent == null) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CREATE_DENY,
|
||||
ImmutableMap.of(
|
||||
"type", TextComponent.of("SUBDIVISION", TextColor.AQUA),
|
||||
"type", this.getFriendlyNameType(true),
|
||||
"target_type", TextComponent.of("WILDERNESS", TextColor.GREEN)));
|
||||
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
|
||||
}
|
||||
if (this.isAdminClaim() && newOwnerUUID == null) {
|
||||
return new GDClaimResult(ClaimResultType.REQUIRES_OWNER, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_REQUIRES_OWNER,
|
||||
ImmutableMap.of(
|
||||
"type", TextComponent.of("ADMIN", TextColor.RED),
|
||||
"type", this.getFriendlyNameType(true),
|
||||
"target_type", TextComponent.of("SUBDIVISION", TextColor.AQUA))));
|
||||
}
|
||||
} else if (type == ClaimTypes.TOWN) {
|
||||
@ -2028,6 +2033,13 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
|
||||
ImmutableMap.of("type", TextComponent.of("TOWN").color(TextColor.GREEN)));
|
||||
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
|
||||
}
|
||||
if (!isAdmin && user != null && !PermissionUtil.getInstance().holderHasPermission(user, GDPermissions.CLAIM_CREATE_TOWN)) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CREATE_DENY,
|
||||
ImmutableMap.of(
|
||||
"type", this.getFriendlyNameType(true),
|
||||
"target_type", TextComponent.of("TOWN", TextColor.GREEN)));
|
||||
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
|
||||
}
|
||||
} else if (type == ClaimTypes.WILDERNESS) {
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CHANGE_DENY,
|
||||
ImmutableMap.of("type", TextComponent.of("WILDERNESS").color(TextColor.GREEN)));
|
||||
|
Loading…
Reference in New Issue
Block a user