-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add permission type selection and permission modification screens
- Loading branch information
1 parent
e730429
commit 65b406f
Showing
18 changed files
with
252 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/com/cjburkey/claimchunk/gui/screens/PermModifyMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.cjburkey.claimchunk.gui.screens; | ||
|
||
import com.cjburkey.claimchunk.ClaimChunk; | ||
import com.cjburkey.claimchunk.ClaimChunkConfig; | ||
import com.cjburkey.claimchunk.gui.GuiMenuScreen; | ||
import com.cjburkey.claimchunk.i18n.V2JsonMessages; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.Inventory; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
public class PermModifyMenu extends GuiMenuScreen { | ||
|
||
public final boolean isAllChunks; | ||
|
||
public PermModifyMenu( | ||
@NotNull ClaimChunk claimChunk, @NotNull Player player, boolean isAllChunks) { | ||
// Offset to make it 6 tall so that we can have the top row be a menu bar. | ||
super(claimChunk, player, 4, claimChunk.getMessages().guiPermSelectMenuTitle); | ||
|
||
this.isAllChunks = isAllChunks; | ||
} | ||
|
||
@Override | ||
public void onOpen(@NotNull Inventory inventory) { | ||
V2JsonMessages messages = claimChunk.getMessages(); | ||
ClaimChunkConfig config = claimChunk.getConfigHandler(); | ||
Material allowItem = materialFromStr(config.getGuiPermSelectMenuItem()); | ||
Material denyItem = materialFromStr(config.getGuiPermSelectMenuItem()); | ||
|
||
// Back button | ||
addInteractiveButton( | ||
inventory, | ||
0, | ||
materialFromStr(config.getGuiMenuBackButtonItem()), | ||
messages.guiMenuBackButtonName, | ||
splitLineLore(messages.guiMenuBackButtonDesc), | ||
(clickType, stack) -> openGui(new PermSelectMenu(claimChunk, getPlayer()))); | ||
|
||
// Add permission buttons | ||
// TODO: WE HAVE TO ADD DEFAULT PERMISSIONS TO CHUNK DATA! | ||
Map<String, Boolean> permissions = | ||
isAllChunks | ||
? claimChunk | ||
.getPlayerHandler() | ||
.getDefaultPermissions(getPlayer().getUniqueId()) | ||
: null; | ||
if (permissions == null) { | ||
return; | ||
} | ||
int slot = 0; | ||
for (Map.Entry<String, Boolean> permission : permissions.entrySet()) { | ||
addInteractiveButton( | ||
inventory, | ||
9 + slot, | ||
permission.getValue() ? allowItem : denyItem, | ||
"&r&f" + permission.getKey(), | ||
splitLineLore(messages.guiPermModifyPermDesc), | ||
(clickType, stack) -> {}); | ||
slot++; | ||
} | ||
} | ||
|
||
@Override | ||
public @NotNull String getName() { | ||
V2JsonMessages messages = claimChunk.getMessages(); | ||
return isAllChunks | ||
? messages.guiPermModifyAllMenuTitle | ||
: messages.guiPermModifyThisMenuTitle; | ||
} | ||
} |
Oops, something went wrong.