Addressed requested changes

Signed-off-by: Paul Reilly <pawereus@gmail.com>
This commit is contained in:
Paul Reilly 2023-08-11 15:26:05 -05:00
parent bbaa325ad6
commit dd353b4429
5 changed files with 106 additions and 25 deletions

View File

@ -1,3 +1,26 @@
/*
* This file is part of Freedom-Network-Suite - https://github.com/AtlasMediaGroup/Freedom-Network-Suite
* Copyright (C) 2023 Total Freedom Server Network and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fns.cladis.command;
import fns.cladis.Cladis;
@ -8,6 +31,7 @@ import fns.patchwork.command.annotation.Completion;
import fns.patchwork.command.annotation.Info;
import fns.patchwork.command.annotation.Permissive;
import fns.patchwork.command.annotation.Subcommand;
import java.util.UUID;
import nl.chimpgamer.networkmanager.api.models.permissions.Group;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -41,6 +65,8 @@ public class DeopCommand extends Commander
@Subcommand(permission = "cladis.deop", args = {Player.class})
public void deop(final CommandSender sender, final Player player)
{
final UUID playerUUID = player.getUniqueId();
final NMLink nmLink = Shortcuts.provideModule(Cladis.class).getNMLink();
final Group opGroup = nmLink.deopGroup();
@ -50,13 +76,13 @@ public class DeopCommand extends Commander
return;
}
if (nmLink.isDeop(player.getUniqueId()))
if (nmLink.isDeop(playerUUID))
{
sender.sendPlainMessage("Player is not op.");
return;
}
nmLink.getPlayerGroups(player.getUniqueId()).remove(opGroup);
nmLink.getPlayerGroups(playerUUID).remove(opGroup);
sender.sendPlainMessage("Player deopped.");
player.sendPlainMessage("You have been deopped!");

View File

@ -1,3 +1,26 @@
/*
* This file is part of Freedom-Network-Suite - https://github.com/AtlasMediaGroup/Freedom-Network-Suite
* Copyright (C) 2023 Total Freedom Server Network and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fns.cladis.command;
import fns.cladis.Cladis;
@ -10,6 +33,7 @@ import fns.patchwork.command.annotation.Info;
import fns.patchwork.command.annotation.Permissive;
import fns.patchwork.command.annotation.Subcommand;
import java.util.Map;
import java.util.UUID;
import nl.chimpgamer.networkmanager.api.models.permissions.Group;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -119,9 +143,10 @@ public class ModStaffCommand extends Commander
@Subcommand(permission = "cladis.modstaff.modify", args = {String.class, Player.class, String.class})
public void modify(final CommandSender sender, final String arg, final Player target, final String group)
{
final UUID playerUUID = target.getUniqueId();
final NMLink nmLink = Shortcuts.provideModule(Cladis.class).getNMLink();
final nl.chimpgamer.networkmanager.api.models.player.Player nmPlayer =
nmLink.getPlayer(target.getUniqueId()).orElse(null);
nmLink.getPlayer(playerUUID).orElse(null);
if (nmPlayer == null)
{
@ -139,9 +164,9 @@ public class ModStaffCommand extends Commander
return;
}
if (sender instanceof Player player && (nmLink.getPermissionsPlayer(player.getUniqueId())
.getPrimaryGroup()
.getId() <= g.getKey()))
if (sender instanceof Player s && (nmLink.getPermissionsPlayer(s.getUniqueId())
.getPrimaryGroup()
.getId() <= g.getKey()))
{
sender.sendPlainMessage("You cannot modify a player to a higher rank than yourself!");
return;
@ -149,12 +174,12 @@ public class ModStaffCommand extends Commander
if (arg.equalsIgnoreCase("add"))
{
nmLink.getPermissionsPlayer(target.getUniqueId()).getGroups().add(g.getValue());
nmLink.getPlayerGroups(playerUUID).add(g.getValue());
sender.sendPlainMessage("Added " + target.getName() + " to " + group);
}
else if (arg.equalsIgnoreCase("remove"))
{
nmLink.getPermissionsPlayer(target.getUniqueId()).getGroups().remove(g.getValue());
nmLink.getPlayerGroups(playerUUID).remove(g.getValue());
sender.sendPlainMessage("Removed " + target.getName() + " from " + group);
}
else
@ -166,9 +191,10 @@ public class ModStaffCommand extends Commander
@Subcommand(permission = "cladis.modstaff.track", args = {String.class, Player.class})
public void track(final CommandSender sender, final String arg, final Player target)
{
final UUID playerUUID = target.getUniqueId();
final NMLink nmLink = Shortcuts.provideModule(Cladis.class).getNMLink();
final nl.chimpgamer.networkmanager.api.models.player.Player nmPlayer =
nmLink.getPlayer(target.getUniqueId()).orElse(null);
nmLink.getPlayer(playerUUID).orElse(null);
if (nmPlayer == null)
{
@ -176,7 +202,7 @@ public class ModStaffCommand extends Commander
return;
}
final Group primary = nmLink.getPermissionsPlayer(target.getUniqueId()).getPrimaryGroup();
final Group primary = nmLink.getPermissionsPlayer(playerUUID).getPrimaryGroup();
final int groupLevel = primary.getId();
if (arg.equalsIgnoreCase("promote"))
@ -188,10 +214,8 @@ public class ModStaffCommand extends Commander
return;
}
nmLink.getPermissionsPlayer(target.getUniqueId()).getGroups().remove(primary);
nmLink.getPermissionsPlayer(target.getUniqueId())
.getGroups()
.add(promo);
nmLink.getPlayerGroups(playerUUID).remove(primary);
nmLink.getPlayerGroups(playerUUID).add(promo);
sender.sendPlainMessage("Promoted " + target.getName());
}
else if (arg.equalsIgnoreCase("demote"))
@ -203,10 +227,8 @@ public class ModStaffCommand extends Commander
return;
}
nmLink.getPermissionsPlayer(target.getUniqueId()).getGroups().remove(primary);
nmLink.getPermissionsPlayer(target.getUniqueId())
.getGroups()
.add(demo);
nmLink.getPlayerGroups(playerUUID).remove(primary);
nmLink.getPlayerGroups(playerUUID).add(demo);
sender.sendPlainMessage("Demoted " + target.getName());
}
else

View File

@ -1,3 +1,26 @@
/*
* This file is part of Freedom-Network-Suite - https://github.com/AtlasMediaGroup/Freedom-Network-Suite
* Copyright (C) 2023 Total Freedom Server Network and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fns.cladis.command;
@ -9,6 +32,7 @@ import fns.patchwork.command.annotation.Completion;
import fns.patchwork.command.annotation.Info;
import fns.patchwork.command.annotation.Permissive;
import fns.patchwork.command.annotation.Subcommand;
import java.util.UUID;
import nl.chimpgamer.networkmanager.api.models.permissions.Group;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -43,6 +67,7 @@ public class OpCommand extends Commander
{
final NMLink nmLink = Shortcuts.provideModule(Cladis.class).getNMLink();
final Group opGroup = nmLink.locateGroup("fake_op").orElse(null);
final UUID playerUUID = player.getUniqueId();
if (opGroup == null)
{
@ -50,14 +75,14 @@ public class OpCommand extends Commander
return;
}
if (nmLink.isOp(player.getUniqueId()))
if (nmLink.isOp(playerUUID))
{
sender.sendPlainMessage("Player is already op.");
return;
}
nmLink.getPermissionsPlayer(player.getUniqueId()).getGroups().add(opGroup);
nmLink.getPlayerGroups(playerUUID).add(opGroup);
sender.sendPlainMessage("You have opped " + player.getName() + ".");
player.sendPlainMessage("You have been opped.");

View File

@ -23,6 +23,7 @@
package fns.datura;
import fns.datura.cmd.LockerCommand;
import fns.datura.features.CommandSpy;
import fns.datura.features.Fuckoff;
import fns.datura.punishment.Cager;
@ -30,6 +31,7 @@ import fns.datura.punishment.Halter;
import fns.datura.punishment.Locker;
import fns.datura.sql.MySQL;
import fns.patchwork.base.Registration;
import fns.patchwork.command.CommandHandler;
import fns.patchwork.service.SubscriptionProvider;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -55,17 +57,19 @@ public class Datura extends JavaPlugin
Registration.getServiceTaskRegistry()
.registerService(SubscriptionProvider.syncService(this, locker));
Registration.getServiceTaskRegistry()
.registerService(SubscriptionProvider.syncService(this, cager));
.registerService(SubscriptionProvider.syncService(this, cager));
Registration.getServiceTaskRegistry()
.registerService(SubscriptionProvider.syncService(this, fuckoff));
.registerService(SubscriptionProvider.syncService(this, fuckoff));
Bukkit.getPluginManager()
.registerEvents(halter, this);
Bukkit.getPluginManager()
.registerEvents(commandSpy, this);
new CommandHandler(this).registerCommands(LockerCommand.class);
Registration.getModuleRegistry()
.addModule(this);
.addModule(this);
}
public MySQL getSQL()

View File

@ -23,8 +23,10 @@
package fns.fossil;
import fns.fossil.cmd.CakeCommand;
import fns.fossil.trail.Trailer;
import fns.patchwork.base.Registration;
import fns.patchwork.command.CommandHandler;
import fns.patchwork.service.SubscriptionProvider;
import org.bukkit.plugin.java.JavaPlugin;
@ -36,9 +38,11 @@ public class Fossil extends JavaPlugin
{
Registration.getServiceTaskRegistry()
.registerService(
SubscriptionProvider.syncService(this, trailer));
SubscriptionProvider.syncService(this, trailer));
new CommandHandler(this).registerCommands(CakeCommand.class);
Registration.getModuleRegistry()
.addModule(this);
.addModule(this);
}
}