Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from Refrac/master
Browse files Browse the repository at this point in the history
Fixed user and group parents, version push
  • Loading branch information
BGHDDevelopment authored Sep 27, 2021
2 parents 2e09a57 + 95465a6 commit 8641b91
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>me.AsVaidas.LuckPermsGUI</groupId>
<artifactId>LuckPermsGUI</artifactId>
<version>3.1</version>
<version>4.1</version>
<packaging>jar</packaging>

<name>LuckPermsGUI</name>
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/me/AsVaidas/LuckPemsGUI/groups/Parents.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.luckperms.api.model.group.Group;
import net.luckperms.api.node.Node;
import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.types.InheritanceNode;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand Down Expand Up @@ -92,15 +93,15 @@ public static void open(Player p, Group group, int page) {
int from = 45*page-1;
int to = 45*(page+1)-1;
for (Node permission : group.getDistinctNodes()) {
if (permission.getType() != NodeType.META) continue;
if (permission.getType() != NodeType.INHERITANCE) continue;
if (from <= sk && sk < to) {


InheritanceNode parent = ((InheritanceNode)permission);
String expiration = permission.hasExpiry() ? Tools.getTime(permission.getExpiry().toEpochMilli()) : "Never";
String server = permission.getContexts().getAnyValue(DefaultContextKeys.SERVER_KEY).orElse("global");
String world = permission.getContexts().getAnyValue(DefaultContextKeys.WORLD_KEY).orElse("global");
ItemStack item = Tools.button(Material.TNT,
"&6"+group.getName(),
"&6"+parent.getGroupName(),
Arrays.asList(
"&cID: &e"+sk,
"&cExpires in: &e"+expiration,
Expand Down Expand Up @@ -154,16 +155,18 @@ public void onInventoryClickEvent(InventoryClickEvent e) {

int sk = 0;
for (Node permission : g.getDistinctNodes()) {
if (permission.getType() != NodeType.META) continue;
if (permission.getType() != NodeType.INHERITANCE) continue;

InheritanceNode parent = ((InheritanceNode)permission);

String server = permission.getContexts().getAnyValue(DefaultContextKeys.SERVER_KEY).orElse("global");
String world = permission.getContexts().getAnyValue(DefaultContextKeys.WORLD_KEY).orElse("global");

if (sk == id) {
if (permission.hasExpiry())
Tools.sendCommand(p, "lp group "+g.getName()+" parent removetemp "+'"'+permission.getKey()+'"'+" "+server+" "+world);
Tools.sendCommand(p, "lp group "+g.getName()+" parent removetemp "+'"'+parent.getGroupName()+'"'+" "+server+" "+world);
else
Tools.sendCommand(p, "lp group "+g.getName()+" parent remove "+'"'+permission.getKey()+'"'+" "+server+" "+world);
Tools.sendCommand(p, "lp group "+g.getName()+" parent remove "+'"'+parent.getGroupName()+'"'+" "+server+" "+world);
break;
}
sk++;
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/me/AsVaidas/LuckPemsGUI/users/Parents.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.luckperms.api.model.user.User;
import net.luckperms.api.node.Node;
import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.types.InheritanceNode;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand Down Expand Up @@ -95,13 +96,14 @@ public static void open(Player p, User user, int page) {
int from = 45*page-1;
int to = 45*(page+1)-1;
for (Node permission : user.getDistinctNodes()) {
if (permission.getType() != NodeType.META) continue;
if (permission.getType() != NodeType.INHERITANCE) continue;
if (from <= sk && sk < to) {
InheritanceNode parent = ((InheritanceNode)permission);
String expiration = permission.hasExpiry() ? Tools.getTime(permission.getExpiry().toEpochMilli()) : "Never";
String server = permission.getContexts().getAnyValue(DefaultContextKeys.SERVER_KEY).orElse("global");
String world = permission.getContexts().getAnyValue(DefaultContextKeys.WORLD_KEY).orElse("global");
ItemStack item = Tools.button(Material.TNT,
"&6"+permission.getKey(),
"&6"+parent.getGroupName(),
Arrays.asList(
"&cID: &e"+sk,
"&cExpires in: &e"+expiration,
Expand Down Expand Up @@ -155,16 +157,18 @@ public void onInventoryClickEvent(InventoryClickEvent e) {

int sk = 0;
for (Node permission : g.getDistinctNodes()) {
if (permission.getType() != NodeType.META) continue;
if (permission.getType() != NodeType.INHERITANCE) continue;

InheritanceNode parent = ((InheritanceNode)permission);

String server = permission.getContexts().getAnyValue(DefaultContextKeys.SERVER_KEY).orElse("global");
String world = permission.getContexts().getAnyValue(DefaultContextKeys.WORLD_KEY).orElse("global");

if (sk == id) {
if (permission.hasExpiry())
Tools.sendCommand(p, "lp user " + g.getUsername() + " parent removetemp " + '"' + permission.getKey() + '"' + " " + server + " " + world);
Tools.sendCommand(p, "lp user " + g.getUsername() + " parent removetemp " + '"' + parent.getGroupName() + '"' + " " + server + " " + world);
else
Tools.sendCommand(p, "lp user " + g.getUsername() + " parent remove " + '"' + permission.getKey() + '"' + " " + server + " " + world);
Tools.sendCommand(p, "lp user " + g.getUsername() + " parent remove " + '"' + parent.getGroupName() + '"' + " " + server + " " + world);
break;
}
sk++;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/AsVaidas/LuckPemsGUI/util/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public class Settings {
public static String SUPPORT_DISCORD_URL = "https://bghddevelopment.com/discord";
public static String FEEDBACK = "https://feedback.bghddevelopment.com";
public static String WIKI = "https://wiki.bghddevelopment.com";
public static String VERSION = "3.5";
public static String VERSION = "4.1";
public static String NAME = "LuckPermsGUI";
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: LuckPermsGUI
main: me.AsVaidas.LuckPemsGUI.Main
version: 4.0
version: 4.1
author: BGHDDevelopment
website: https://bghddevelopment.com
depend: [LuckPerms]
Expand Down

0 comments on commit 8641b91

Please sign in to comment.