mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2025-06-26 19:44:27 +00:00
AdminChat
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.datura;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.datura.punishment.Cager;
|
||||
import me.totalfreedom.datura.punishment.Halter;
|
||||
import me.totalfreedom.datura.punishment.Locker;
|
||||
@ -20,19 +20,19 @@ public class Datura extends JavaPlugin
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
CommonsBase.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.addModule(this);
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.addModule(this);
|
||||
|
||||
CommonsBase.getInstance()
|
||||
.getRegistrations()
|
||||
.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.syncService(this, locker));
|
||||
CommonsBase.getInstance()
|
||||
.getRegistrations()
|
||||
.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.syncService(this, cager));
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.syncService(this, locker));
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.syncService(this, cager));
|
||||
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(halter, this);
|
||||
|
@ -0,0 +1,31 @@
|
||||
package me.totalfreedom.datura.cmd;
|
||||
|
||||
import me.totalfreedom.command.Commander;
|
||||
import me.totalfreedom.command.annotation.Base;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AdminChatCommand extends Commander
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes this command object. The provided {@link JavaPlugin} should be the plugin which contains the
|
||||
* command.
|
||||
* <p>
|
||||
* This constructor will automatically register all subcommands and completions for this command. It will also
|
||||
* automatically infer all required information from the provided {@link Info} and {@link Permissive} annotations.
|
||||
*
|
||||
* @param plugin The plugin which contains this command.
|
||||
*/
|
||||
protected AdminChatCommand(@NotNull final JavaPlugin plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Base
|
||||
public void onAdminChat(final CommandSender sender) {
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.datura.perms;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.security.Group;
|
||||
import me.totalfreedom.security.Node;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -41,7 +41,7 @@ public class FreedomGroup implements Group
|
||||
this.isDefault = isDefault;
|
||||
this.isHidden = isHidden;
|
||||
this.permissions = new HashSet<>();
|
||||
this.attachment = new PermissionAttachment(CommonsBase.getInstance(), this);
|
||||
this.attachment = new PermissionAttachment(Patchwork.getInstance(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.datura.perms;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.datura.Datura;
|
||||
import me.totalfreedom.datura.user.SimpleUserData;
|
||||
import me.totalfreedom.security.Node;
|
||||
@ -42,11 +42,11 @@ public class FreedomUser implements User
|
||||
this.permissions = new HashSet<>();
|
||||
this.displayName = player.displayName();
|
||||
|
||||
final Datura datura = CommonsBase.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.getProvider(Datura.class)
|
||||
.getModule();
|
||||
final Datura datura = Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.getProvider(Datura.class)
|
||||
.getModule();
|
||||
|
||||
UserData data = SimpleUserData.fromSQL(datura.getSQL(), uuid.toString());
|
||||
|
||||
@ -57,10 +57,10 @@ public class FreedomUser implements User
|
||||
|
||||
this.userData = data;
|
||||
|
||||
CommonsBase.getInstance()
|
||||
.getRegistrations()
|
||||
.getUserRegistry()
|
||||
.registerUserData(this, userData);
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getUserRegistry()
|
||||
.registerUserData(this, userData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,7 +96,7 @@ public class FreedomUser implements User
|
||||
@Override
|
||||
public boolean addPermission(final Node node)
|
||||
{
|
||||
final PermissionAttachment attachment = addAttachment(CommonsBase.getInstance(), node.key(), node.value());
|
||||
final PermissionAttachment attachment = addAttachment(Patchwork.getInstance(), node.key(), node.value());
|
||||
bukkitAttachments.put(node, attachment);
|
||||
return permissions().add(node);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.datura.punishment;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.service.Service;
|
||||
import me.totalfreedom.utils.ShapeUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -32,7 +32,7 @@ public class Cager extends Service
|
||||
this.cagedPlayers = new HashSet<>();
|
||||
this.cageLocations = new HashMap<>();
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(new CageListener(), CommonsBase.getInstance());
|
||||
.registerEvents(new CageListener(), Patchwork.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.datura.punishment;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.service.Service;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -35,10 +35,10 @@ public class Locker extends Service
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
lockedPlayers.removeIf(uuid -> !CommonsBase.getInstance()
|
||||
.getServer()
|
||||
.getOfflinePlayer(uuid)
|
||||
.isOnline());
|
||||
lockedPlayers.removeIf(uuid -> !Patchwork.getInstance()
|
||||
.getServer()
|
||||
.getOfflinePlayer(uuid)
|
||||
.isOnline());
|
||||
|
||||
for (final UUID uuid : lockedPlayers)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.datura.sql;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.sql.SQL;
|
||||
import me.totalfreedom.utils.container.Identity;
|
||||
|
||||
@ -75,9 +75,9 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to prepare statement: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
private CompletableFuture<Connection> getConnection()
|
||||
@ -92,9 +92,9 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to connect to the database: "
|
||||
+ url.toString() + "\n", ex);
|
||||
}
|
||||
}, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,9 +112,9 @@ public class MySQL implements SQL
|
||||
"Failed to retrieve a result set from query: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,9 +131,9 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to execute update: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -150,9 +150,9 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to execute statement: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -194,26 +194,26 @@ public class MySQL implements SQL
|
||||
ex);
|
||||
}
|
||||
return null;
|
||||
}, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> updateColumn(final String table, final String column, final Object value,
|
||||
final String key, final Identity identity)
|
||||
{
|
||||
return executeUpdate("UPDATE ? SET ? = ? WHERE ? = ?", table, column, value, key, identity.getId())
|
||||
.thenApplyAsync(result -> result > 0, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
.thenApplyAsync(result -> result > 0, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> deleteRow(final String table, final String key, final Identity identity)
|
||||
{
|
||||
return executeUpdate("DELETE FROM ? WHERE ? = ?", table, key, identity.getId())
|
||||
.thenApplyAsync(result -> result > 0, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
.thenApplyAsync(result -> result > 0, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> insertRow(final String table, final Object... values)
|
||||
|
@ -1,8 +1,9 @@
|
||||
package me.totalfreedom.datura.user;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.datura.event.UserDataUpdateEvent;
|
||||
import me.totalfreedom.datura.perms.FreedomUser;
|
||||
import me.totalfreedom.display.adminchat.AdminChatFormat;
|
||||
import me.totalfreedom.security.Group;
|
||||
import me.totalfreedom.sql.SQL;
|
||||
import me.totalfreedom.user.User;
|
||||
@ -29,6 +30,8 @@ public class SimpleUserData implements UserData
|
||||
private boolean canInteract;
|
||||
private AtomicLong balance;
|
||||
private boolean transactionsFrozen;
|
||||
private boolean hasCustomACFormat = false;
|
||||
private String customACFormat;
|
||||
|
||||
public SimpleUserData(final Player player)
|
||||
{
|
||||
@ -36,9 +39,9 @@ public class SimpleUserData implements UserData
|
||||
this.username = player.getName();
|
||||
this.user = new FreedomUser(player);
|
||||
|
||||
CommonsBase.getInstance()
|
||||
.getEventBus()
|
||||
.addEvent(event);
|
||||
Patchwork.getInstance()
|
||||
.getEventBus()
|
||||
.addEvent(event);
|
||||
}
|
||||
|
||||
private SimpleUserData(
|
||||
@ -59,6 +62,7 @@ public class SimpleUserData implements UserData
|
||||
this.canInteract = canInteract;
|
||||
this.balance = new AtomicLong(balance);
|
||||
this.transactionsFrozen = transactionsFrozen;
|
||||
this.customACFormat = AdminChatFormat.DEFAULT.serialize();
|
||||
}
|
||||
|
||||
public static SimpleUserData fromSQL(final SQL sql, final String uuid)
|
||||
@ -81,10 +85,10 @@ public class SimpleUserData implements UserData
|
||||
throw new IllegalStateException("Player should be online but they are not!");
|
||||
|
||||
final User user = new FreedomUser(player);
|
||||
final Group group = CommonsBase.getInstance()
|
||||
.getRegistrations()
|
||||
.getGroupRegistry()
|
||||
.getGroup(g);
|
||||
final Group group = Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getGroupRegistry()
|
||||
.getGroup(g);
|
||||
|
||||
final long playtime = result.getLong("playtime");
|
||||
final boolean canInteract = result.getBoolean("canInteract");
|
||||
@ -113,9 +117,9 @@ public class SimpleUserData implements UserData
|
||||
if (player == null) throw new IllegalStateException("Player should be online but they are not!");
|
||||
|
||||
return new SimpleUserData(player);
|
||||
}, CommonsBase.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync())
|
||||
}, Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.getAsync())
|
||||
.join();
|
||||
}
|
||||
|
||||
@ -219,4 +223,23 @@ public class SimpleUserData implements UserData
|
||||
{
|
||||
return balance.addAndGet(-amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomACFormat()
|
||||
{
|
||||
return hasCustomACFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomACFormat(final String format)
|
||||
{
|
||||
this.hasCustomACFormat = format.equals(AdminChatFormat.DEFAULT.serialize());
|
||||
this.customACFormat = format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdminChatFormat getCustomACFormat()
|
||||
{
|
||||
return AdminChatFormat.deserialize(customACFormat);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user