Skip to content

Commit

Permalink
Merge branch '1.14' into 1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Thutmose committed May 7, 2020
2 parents ef74001 + b0643bc commit fd710d6
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 17 deletions.
11 changes: 11 additions & 0 deletions src/main/java/thut/perms/commands/EditGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.arguments.GameProfileArgument;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.server.permission.DefaultPermissionLevel;
import net.minecraftforge.server.permission.PermissionAPI;
import thut.perms.Perms;
Expand Down Expand Up @@ -129,6 +130,9 @@ private static int executeAddGroup(final CommandSource source, final String grou
{
Perms.savePerms();
Perms.config.sendFeedback(source, "thutperms.group.added", true, name, groupName);
final ServerPlayerEntity player = source.getServer().getPlayerList().getPlayerByUUID(profile
.getId());
if (player != null) source.getServer().getCommandManager().send(player);
}
else Perms.config.sendFeedback(source, "thutperms.group.already_in", true, name, groupName);
}
Expand Down Expand Up @@ -157,6 +161,9 @@ private static int executeRemoveGroup(final CommandSource source, final String g
{
Perms.savePerms();
Perms.config.sendFeedback(source, "thutperms.group.removed", true, name, groupName);
final ServerPlayerEntity player = source.getServer().getPlayerList().getPlayerByUUID(profile
.getId());
if (player != null) source.getServer().getCommandManager().send(player);
}
else Perms.config.sendFeedback(source, "thutperms.group.not_in", true, name, groupName);
}
Expand All @@ -178,6 +185,7 @@ private static int executeAddPerm(final CommandSource source, final String perm,
if (!EditGroup.valid(perm)) Perms.config.sendError(source, "thutperms.perm.unknownperm", perm);

g.allowedCommands.add(perm);
g.onUpdated(source.getServer());
Perms.savePerms();
Perms.config.sendFeedback(source, "thutperms.perm.added", true, groupName, perm);
return 0;
Expand All @@ -194,6 +202,7 @@ private static int executeRemovePerm(final CommandSource source, final String pe
if (!EditGroup.valid(perm)) Perms.config.sendError(source, "thutperms.perm.unknownperm", perm);

g.allowedCommands.remove(perm);
g.onUpdated(source.getServer());
Perms.savePerms();
Perms.config.sendFeedback(source, "thutperms.perm.removed", true, groupName, perm);
return 0;
Expand All @@ -210,6 +219,7 @@ private static int executeDenyPerm(final CommandSource source, final String perm
if (!EditGroup.valid(perm)) Perms.config.sendError(source, "thutperms.perm.unknownperm", perm);

g.bannedCommands.add(perm);
g.onUpdated(source.getServer());
Perms.savePerms();
Perms.config.sendFeedback(source, "thutperms.perm.denied", true, groupName, perm);
return 0;
Expand All @@ -226,6 +236,7 @@ private static int executeUnDenyPerm(final CommandSource source, final String pe
if (!EditGroup.valid(perm)) Perms.config.sendError(source, "thutperms.perm.unknownperm", perm);

g.bannedCommands.remove(perm);
g.onUpdated(source.getServer());
Perms.savePerms();
Perms.config.sendFeedback(source, "thutperms.perm.undenied", true, groupName, perm);
return 0;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/thut/perms/commands/EditPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ private static int executeAddPerm(final CommandSource source, final String perm,
{
final Player p = GroupManager.get_instance()._manager.getPlayer(profile.getId());
p.allowedCommands.add(perm);
p.onUpdated(source.getServer());
Perms.config.sendFeedback(source, "thutperms.perm.added", true, profile.getName(), perm);
}
return 0;
Expand All @@ -180,6 +181,7 @@ private static int executeRemovePerm(final CommandSource source, final String pe
{
final Player p = GroupManager.get_instance()._manager.getPlayer(profile.getId());
p.allowedCommands.remove(perm);
p.onUpdated(source.getServer());
Perms.config.sendFeedback(source, "thutperms.perm.removed", true, profile.getName(), perm);
}
return 0;
Expand All @@ -193,6 +195,7 @@ private static int executeDenyPerm(final CommandSource source, final String perm
{
final Player p = GroupManager.get_instance()._manager.getPlayer(profile.getId());
p.bannedCommands.add(perm);
p.onUpdated(source.getServer());
Perms.config.sendFeedback(source, "thutperms.perm.denied", true, profile.getName(), perm);
}
return 0;
Expand All @@ -206,6 +209,7 @@ private static int executeUnDenyPerm(final CommandSource source, final String pe
{
final Player p = GroupManager.get_instance()._manager.getPlayer(profile.getId());
p.bannedCommands.remove(perm);
p.onUpdated(source.getServer());
Perms.config.sendFeedback(source, "thutperms.perm.undenied", true, profile.getName(), perm);
}
return 0;
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/thut/perms/commands/Reload.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ private static int execute(final CommandSource source) throws CommandSyntaxExcep
final MinecraftServer server = source.getServer();
Perms.loadPerms();
GroupManager.get_instance()._server = server;
// Reload player names, to apply the tags if they exist

// Refresh things for the players
for (final ServerPlayerEntity player : server.getPlayerList().getPlayers())
{
// Reload player names, to apply the tags if they exist
GroupManager.get_instance().updateName(player);
// Update their command lists
server.getCommandManager().send(player);
}
return 0;
}
}
16 changes: 13 additions & 3 deletions src/main/java/thut/perms/management/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@

import com.google.common.collect.Sets;

import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;

public class Group extends PermissionsHolder
{
public String name;
public String prefix = "";
public String suffix = "";
public Set<UUID> members = Sets.newHashSet();

public Group(final String name)
{
this.name = name;
}

@Override
public void onUpdated(final MinecraftServer server)
{
for (final UUID id : this.members)
{
final ServerPlayerEntity player = server.getPlayerList().getPlayerByUUID(id);
if (player != null) server.getCommandManager().send(player);
}
}
}
20 changes: 14 additions & 6 deletions src/main/java/thut/perms/management/PermissionsHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@

import com.google.common.collect.Lists;

import net.minecraft.server.MinecraftServer;
import net.minecraftforge.server.permission.DefaultPermissionLevel;
import thut.perms.Perms;

public abstract class PermissionsHolder
{
public boolean all = false;
public boolean all_non_op = true;
public List<String> allowedCommands = Lists.newArrayList();
public List<String> bannedCommands = Lists.newArrayList();
public String parentName = null;
public String name = "";
public String prefix = "";
public String suffix = "";
public boolean all = false;
public boolean all_non_op = true;
public String parentName = null;

public List<String> allowedCommands = Lists.newArrayList();
public List<String> bannedCommands = Lists.newArrayList();

public PermissionsHolder _parent;
protected List<String> _whiteWildCards;
protected List<String> _blackWildCards;
public boolean _init = false;
public boolean _init = false;

private void init()
{
Expand All @@ -34,6 +40,8 @@ private void init()
else if (s.startsWith("*")) this._blackWildCards.add(s.substring(1));
}

public abstract void onUpdated(MinecraftServer server);

public List<String> getAllowedCommands()
{
if (this.allowedCommands == null) this.allowedCommands = Lists.newArrayList();
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/thut/perms/management/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

import com.google.common.collect.Lists;

import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;

public class Player extends PermissionsHolder
{
public UUID id;
public String name = "";
public String prefix = "";
public String suffix = "";
public UUID id;

public List<String> groups = Lists.newArrayList();
public List<Group> _groups = Lists.newArrayList();

Expand Down Expand Up @@ -55,4 +56,11 @@ public boolean isAll_non_op()
{
return false;
}

@Override
public void onUpdated(final MinecraftServer server)
{
final ServerPlayerEntity player = server.getPlayerList().getPlayerByUUID(this.id);
if (player != null) server.getCommandManager().send(player);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/thutperms/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"thutperms.group.removed": "§aRemoved §6%1$s§a from group §6%2$s",

"thutperms.suffix.set": "§6%1$s§a was given the suffix §6%2$s",
"thutperms.prefix.set": "§6%1$s§a was given the prefix §6%2$s"
"thutperms.prefix.set": "§6%1$s§a was given the prefix §6%2$s",

"_comment": "error messages",

Expand All @@ -36,6 +36,6 @@

"thutperms.reloaded": "§aReloaded permissions from file",

"thutperms.perms.logged": "§aA Table of all known permissions was saved to thutperms.log",
"thutperms.perms.logged": "§aA Table of all known permissions was saved to thutperms.log"

}
2 changes: 1 addition & 1 deletion src/main/resources/assets/thutperms/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@

"thutperms.reloaded": "§a重载权限",

"thutperms.perms.logged": "§a所有权限节点已被存储至 thutperms.log",
"thutperms.perms.logged": "§a所有权限节点已被存储至 thutperms.log"

}

0 comments on commit fd710d6

Please sign in to comment.