mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-10-31 21:47:10 +00:00
Fixed some dumb shit
This commit is contained in:
parent
71fe940049
commit
6566c7f305
@ -1,13 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.earth2me.essentials.commands.PlayerNotFoundException;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.rank.Hierarchy;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -148,34 +146,22 @@ public class Command_mbconfig extends FreedomCommand
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
try
|
||||
Player player = getPlayer(args[1]);
|
||||
PlayerData data = plugin.pl.getData(args[1]);
|
||||
|
||||
if (player == null || data == null || !data.isMasterBuilder())
|
||||
{
|
||||
OfflinePlayer player = getOfflinePlayer(args[1]);
|
||||
PlayerData data = plugin.pl.getData(args[1]);
|
||||
|
||||
if (data == null || !data.isMasterBuilder())
|
||||
{
|
||||
msgNew("Master Builder not found: <arg>", arg(args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
|
||||
Hierarchy.getHierarchy().dropUserFromAll(Hierarchy.getHierarchy().builder(), player);
|
||||
data.setMasterBuilder(false);
|
||||
plugin.pl.save(data);
|
||||
|
||||
if (player.isOnline())
|
||||
{
|
||||
// This is not null because the player is online, so we can safely call this method.
|
||||
plugin.rm.updateDisplay(player.getPlayer());
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (PlayerNotFoundException e)
|
||||
{
|
||||
msgNew("Player not found: <arg>", arg(args[1]));
|
||||
msgNew("Master Builder not found: <arg>", arg(args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
|
||||
Hierarchy.getHierarchy().dropUserFromAll(Hierarchy.getHierarchy().builder(), player);
|
||||
data.setMasterBuilder(false);
|
||||
plugin.pl.save(data);
|
||||
plugin.rm.updateDisplay(player);
|
||||
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.model.user.UserManager;
|
||||
import net.luckperms.api.platform.PlayerAdapter;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -17,11 +16,11 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class UserWrapper
|
||||
{
|
||||
private final UserManager manager;
|
||||
private final PlayerAdapter<OfflinePlayer> playerAdapter;
|
||||
private final PlayerAdapter<Player> playerAdapter;
|
||||
private final Set<User> userSet;
|
||||
private final Set<UserData> userDataSet;
|
||||
|
||||
public UserWrapper(UserManager manager, PlayerAdapter<OfflinePlayer> adapter)
|
||||
public UserWrapper(UserManager manager, PlayerAdapter<Player> adapter)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.userSet = manager.getLoadedUsers();
|
||||
@ -29,7 +28,7 @@ public class UserWrapper
|
||||
this.userDataSet = new HashSet<>();
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> addUserData(OfflinePlayer player)
|
||||
public CompletableFuture<Void> addUserData(Player player)
|
||||
{
|
||||
User user = playerAdapter.getUser(player);
|
||||
CachedPermissionData permissionData = playerAdapter.getPermissionData(player);
|
||||
@ -41,7 +40,7 @@ public class UserWrapper
|
||||
return CompletableFuture.runAsync(() -> userDataSet.add(userData));
|
||||
}
|
||||
|
||||
public CompletableFuture<User> getUser(OfflinePlayer player)
|
||||
public CompletableFuture<User> getUser(Player player)
|
||||
{
|
||||
if (!manager.isLoaded(player.getUniqueId()) || !userSet.contains(manager.getUser(player.getUniqueId())))
|
||||
{
|
||||
@ -51,7 +50,7 @@ public class UserWrapper
|
||||
return CompletableFuture.supplyAsync(() -> manager.getUser(player.getUniqueId()));
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> removeUser(OfflinePlayer player)
|
||||
public CompletableFuture<Void> removeUser(Player player)
|
||||
{
|
||||
return getUser(player).thenAccept(a ->
|
||||
{
|
||||
@ -60,7 +59,7 @@ public class UserWrapper
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<UserData> getUserData(OfflinePlayer player)
|
||||
public CompletableFuture<UserData> getUserData(Player player)
|
||||
{
|
||||
return getUser(player).thenApply(user ->
|
||||
{
|
||||
@ -75,12 +74,12 @@ public class UserWrapper
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> removeUserData(OfflinePlayer player)
|
||||
public CompletableFuture<Void> removeUserData(Player player)
|
||||
{
|
||||
return getUserData(player).thenAccept(userDataSet::remove);
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> updateUserData(OfflinePlayer player)
|
||||
public CompletableFuture<Void> updateUserData(Player player)
|
||||
{
|
||||
return getUserData(player).thenApply(userData ->
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
||||
import net.luckperms.api.track.DemotionResult;
|
||||
import net.luckperms.api.track.PromotionResult;
|
||||
import net.luckperms.api.track.Track;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@ -29,7 +29,7 @@ public class Hierarchy
|
||||
this.groupWrapper = new GroupWrapper(TotalFreedomMod.getPlugin().lpb.getAPI().getGroupManager());
|
||||
this.trackWrapper = new TrackWrapper(TotalFreedomMod.getPlugin().lpb.getAPI().getTrackManager());
|
||||
this.userWrapper = new UserWrapper(TotalFreedomMod.getPlugin().lpb.getAPI().getUserManager(),
|
||||
TotalFreedomMod.getPlugin().lpb.getAPI().getPlayerAdapter(OfflinePlayer.class));
|
||||
TotalFreedomMod.getPlugin().lpb.getAPI().getPlayerAdapter(Player.class));
|
||||
}
|
||||
|
||||
public static Hierarchy getHierarchy()
|
||||
@ -37,7 +37,7 @@ public class Hierarchy
|
||||
return hierarchy;
|
||||
}
|
||||
|
||||
public boolean isUserOnAdminTrack(OfflinePlayer player)
|
||||
public boolean isUserOnAdminTrack(Player player)
|
||||
{
|
||||
AtomicBoolean isOnAdminTrack = new AtomicBoolean(false);
|
||||
userWrapper.getUser(player).thenAccept(user ->
|
||||
@ -95,7 +95,8 @@ public class Hierarchy
|
||||
});
|
||||
}
|
||||
|
||||
public Group getGroup(String name) {
|
||||
public Group getGroup(String name)
|
||||
{
|
||||
return groupWrapper.getGroup(name).join();
|
||||
}
|
||||
|
||||
@ -114,19 +115,19 @@ public class Hierarchy
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<PromotionResult> promoteUser(Track track, OfflinePlayer player)
|
||||
public CompletableFuture<PromotionResult> promoteUser(Track track, Player player)
|
||||
{
|
||||
return userWrapper.getUserData(player).thenApply(data ->
|
||||
track.promote(data.getUser(), data.getContextSet()));
|
||||
}
|
||||
|
||||
public CompletableFuture<DemotionResult> demoteUser(Track track, OfflinePlayer player)
|
||||
public CompletableFuture<DemotionResult> demoteUser(Track track, Player player)
|
||||
{
|
||||
return userWrapper.getUserData(player).thenApply(data ->
|
||||
track.demote(data.getUser(), data.getContextSet()));
|
||||
track.demote(data.getUser(), data.getContextSet()));
|
||||
}
|
||||
|
||||
public void addUserToGroup(DisplayableGroup group, OfflinePlayer player)
|
||||
public void addUserToGroup(DisplayableGroup group, Player player)
|
||||
{
|
||||
userWrapper.getUserData(player).thenAccept(user ->
|
||||
{
|
||||
@ -147,7 +148,7 @@ public class Hierarchy
|
||||
});
|
||||
}
|
||||
|
||||
public void dropUserFromAll(Track track, OfflinePlayer player)
|
||||
public void dropUserFromAll(Track track, Player player)
|
||||
{
|
||||
userWrapper.getUserData(player).thenAccept(data ->
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user