Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
66c1b1b14f | |||
496af97e1c | |||
6ec63b5ae7 | |||
ea7520d99a | |||
|
47461d49c2 | ||
7120e3c40e | |||
|
c6b2dc3443 | ||
4e58ddd475 | |||
5c83b923da | |||
83b5f1fec4 | |||
|
59ccc55f98 | ||
f92cc773c1 | |||
2a008906f4 | |||
9fb35eb6cc | |||
66be5ab0dc |
16 changed files with 65 additions and 157 deletions
2
ButtonProcessor/pom.xml
Executable file → Normal file
2
ButtonProcessor/pom.xml
Executable file → Normal file
|
@ -11,7 +11,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>1.21</version>
|
<version>1.32</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -119,13 +119,9 @@
|
||||||
<id>ess-repo</id>
|
<id>ess-repo</id>
|
||||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>Votifier</id>
|
|
||||||
<url>https://dl.bintray.com/nuvotifier/maven/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>Multiverse-Core</id>
|
<id>Multiverse-Core</id>
|
||||||
<url>http://repo.onarandombox.com/content/repositories/multiverse/</url>
|
<url>https://repo.onarandombox.com/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>minecraft-repo</id>
|
<id>minecraft-repo</id>
|
||||||
|
@ -136,7 +132,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.reflections</groupId>
|
<groupId>org.reflections</groupId>
|
||||||
<artifactId>reflections</artifactId>
|
<artifactId>reflections</artifactId>
|
||||||
<version>0.9.10</version>
|
<version>0.10.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -161,12 +157,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.javassist</groupId>
|
<groupId>org.javassist</groupId>
|
||||||
<artifactId>javassist</artifactId>
|
<artifactId>javassist</artifactId>
|
||||||
<version>3.20.0-GA</version>
|
<version>3.28.0-GA</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>4.2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
||||||
|
@ -180,22 +176,23 @@
|
||||||
<version>2.17.1</version>
|
<version>2.17.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.github.NuVotifier.NuVotifier/nuvotifier-bukkit -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.vexsoftware</groupId>
|
<groupId>com.github.NuVotifier.NuVotifier</groupId>
|
||||||
<artifactId>nuvotifier-universal</artifactId>
|
<artifactId>nuvotifier-bukkit</artifactId>
|
||||||
<version>2.3.4</version>
|
<version>v2.7.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.onarandombox.multiversecore</groupId>
|
<groupId>com.onarandombox.multiversecore</groupId>
|
||||||
<artifactId>Multiverse-Core</artifactId>
|
<artifactId>Multiverse-Core</artifactId>
|
||||||
<version>4.0.1</version>
|
<version>4.3.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko</groupId>
|
<groupId>me.lucko</groupId>
|
||||||
<artifactId>commodore</artifactId>
|
<artifactId>commodore</artifactId>
|
||||||
<version>1.8</version>
|
<version>1.11</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -219,7 +216,7 @@
|
||||||
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
|
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
|
||||||
<github.global.server>github</github.global.server>
|
<github.global.server>github</github.global.server>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<noprefix.version>1.0.0</noprefix.version>
|
<noprefix.version>1.0.1</noprefix.version>
|
||||||
</properties>
|
</properties>
|
||||||
<scm>
|
<scm>
|
||||||
<url>https://github.com/TBMCPlugins/mvn-repo</url>
|
<url>https://github.com/TBMCPlugins/mvn-repo</url>
|
||||||
|
|
|
@ -8,7 +8,6 @@ import buttondevteam.core.component.randomtp.RandomTPComponent;
|
||||||
import buttondevteam.core.component.restart.RestartComponent;
|
import buttondevteam.core.component.restart.RestartComponent;
|
||||||
import buttondevteam.core.component.spawn.SpawnComponent;
|
import buttondevteam.core.component.spawn.SpawnComponent;
|
||||||
import buttondevteam.core.component.towny.TownyComponent;
|
import buttondevteam.core.component.towny.TownyComponent;
|
||||||
import buttondevteam.core.component.votifier.VotifierComponent;
|
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.architecture.ButtonPlugin;
|
import buttondevteam.lib.architecture.ButtonPlugin;
|
||||||
import buttondevteam.lib.architecture.Component;
|
import buttondevteam.lib.architecture.Component;
|
||||||
|
@ -85,7 +84,6 @@ public class MainPlugin extends ButtonPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pluginEnable() {
|
public void pluginEnable() {
|
||||||
// Logs "Plugin Enabled", registers commands
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
PluginDescriptionFile pdf = getDescription();
|
PluginDescriptionFile pdf = getDescription();
|
||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
|
@ -102,8 +100,8 @@ public class MainPlugin extends ButtonPlugin {
|
||||||
Component.registerComponent(this, new SpawnComponent());
|
Component.registerComponent(this, new SpawnComponent());
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("Towny")) //It fails to load the component class otherwise
|
if (Bukkit.getPluginManager().isPluginEnabled("Towny")) //It fails to load the component class otherwise
|
||||||
Component.registerComponent(this, new TownyComponent());
|
Component.registerComponent(this, new TownyComponent());
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("Votifier") && economy != null)
|
/*if (Bukkit.getPluginManager().isPluginEnabled("Votifier") && economy != null)
|
||||||
Component.registerComponent(this, new VotifierComponent(economy));
|
Component.registerComponent(this, new VotifierComponent(economy));*/
|
||||||
ComponentManager.enableComponents();
|
ComponentManager.enableComponents();
|
||||||
registerCommand(new ComponentCommand());
|
registerCommand(new ComponentCommand());
|
||||||
registerCommand(new ChromaCommand());
|
registerCommand(new ChromaCommand());
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package buttondevteam.core;
|
package buttondevteam.core;
|
||||||
|
|
||||||
import buttondevteam.core.component.towny.TownyComponent;
|
|
||||||
import buttondevteam.lib.*;
|
import buttondevteam.lib.*;
|
||||||
import buttondevteam.lib.architecture.ButtonPlugin;
|
import buttondevteam.lib.architecture.ButtonPlugin;
|
||||||
import buttondevteam.lib.chat.ChatMessage;
|
import buttondevteam.lib.chat.ChatMessage;
|
||||||
|
@ -31,12 +30,12 @@ public class PlayerListener implements Listener {
|
||||||
public void OnPlayerJoin(PlayerJoinEvent event) {
|
public void OnPlayerJoin(PlayerJoinEvent event) {
|
||||||
var p = event.getPlayer();
|
var p = event.getPlayer();
|
||||||
TBMCPlayer player = TBMCPlayerBase.getPlayer(p.getUniqueId(), TBMCPlayer.class);
|
TBMCPlayer player = TBMCPlayerBase.getPlayer(p.getUniqueId(), TBMCPlayer.class);
|
||||||
if (player.PlayerName.get() == null) {
|
String pname = player.PlayerName.get();
|
||||||
|
if (pname.length() == 0) {
|
||||||
player.PlayerName.set(p.getName());
|
player.PlayerName.set(p.getName());
|
||||||
MainPlugin.Instance.getLogger().info("Player name saved: " + player.PlayerName.get());
|
MainPlugin.Instance.getLogger().info("Player name saved: " + player.PlayerName.get());
|
||||||
} else if (!p.getName().equals(player.PlayerName.get())) {
|
} else if (!p.getName().equals(pname)) {
|
||||||
TownyComponent.renameInTowny(player.PlayerName.get(), p.getName());
|
MainPlugin.Instance.getLogger().info(pname + " renamed to " + p.getName());
|
||||||
MainPlugin.Instance.getLogger().info(player.PlayerName.get() + " renamed to " + p.getName());
|
|
||||||
player.PlayerName.set(p.getName());
|
player.PlayerName.set(p.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,10 +68,6 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
private void handlePreprocess(CommandSender sender, String message, Cancellable event) {
|
private void handlePreprocess(CommandSender sender, String message, Cancellable event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
/*val cg = Optional.ofNullable(ChromaGamerBase.getFromSender(sender));
|
|
||||||
val ch = cg.map(ChromaGamerBase::channel).map(ChannelPlayerData::get);
|
|
||||||
val rtr = ch.map(c -> c.getRTR(sender)).orElseGet(() -> new Channel.RecipientTestResult("Failed to get user"));
|
|
||||||
val ev = new TBMCCommandPreprocessEvent(sender, ch.orElse(Channel.GlobalChat), message, rtr.score, rtr.groupID);*/
|
|
||||||
val cg = ChromaGamerBase.getFromSender(sender);
|
val cg = ChromaGamerBase.getFromSender(sender);
|
||||||
if (cg == null) throw new RuntimeException("Couldn't get user from sender for " + sender.getName() + "!");
|
if (cg == null) throw new RuntimeException("Couldn't get user from sender for " + sender.getName() + "!");
|
||||||
val ev = new TBMCCommandPreprocessEvent(sender, cg.channel.get(), message, sender);
|
val ev = new TBMCCommandPreprocessEvent(sender, cg.channel.get(), message, sender);
|
||||||
|
|
|
@ -57,19 +57,13 @@ public class RestartComponent extends Component<MainPlugin> implements Listener
|
||||||
private int syncStart(int hour) {
|
private int syncStart(int hour) {
|
||||||
var now = ZonedDateTime.now(ZoneId.ofOffset("", ZoneOffset.UTC));
|
var now = ZonedDateTime.now(ZoneId.ofOffset("", ZoneOffset.UTC));
|
||||||
int secs = now.getHour() * 3600 + now.getMinute() * 60 + now.getSecond();
|
int secs = now.getHour() * 3600 + now.getMinute() * 60 + now.getSecond();
|
||||||
//System.out.println("now: " + secs / 3600.);
|
|
||||||
int diff = secs - hour * 3600;
|
int diff = secs - hour * 3600;
|
||||||
//System.out.println("diff: " + diff / 3600.);
|
|
||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
diff += 24 * 3600;
|
diff += 24 * 3600;
|
||||||
}
|
}
|
||||||
//System.out.println("diff: " + diff / 3600.);
|
|
||||||
int count = diff / (24 * 3600);
|
int count = diff / (24 * 3600);
|
||||||
//System.out.println("count: " + count);
|
|
||||||
int intervalPart = diff - count * 24 * 3600;
|
int intervalPart = diff - count * 24 * 3600;
|
||||||
//System.out.println("intervalPart: " + intervalPart / 3600.);
|
|
||||||
int remaining = 24 * 3600 - intervalPart;
|
int remaining = 24 * 3600 - intervalPart;
|
||||||
//System.out.println("remaining: " + remaining / 3600.);
|
|
||||||
return remaining * 20;
|
return remaining * 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,20 +45,20 @@ public class ScheduledRestartCommand extends ICommand2MC {
|
||||||
}
|
}
|
||||||
final int restarttime = restartCounter = seconds * 20;
|
final int restarttime = restartCounter = seconds * 20;
|
||||||
restartbar = Bukkit.createBossBar("Server restart in " + seconds + "s", BarColor.RED, BarStyle.SOLID,
|
restartbar = Bukkit.createBossBar("Server restart in " + seconds + "s", BarColor.RED, BarStyle.SOLID,
|
||||||
BarFlag.DARKEN_SKY);
|
BarFlag.DARKEN_SKY);
|
||||||
restartbar.setProgress(1);
|
restartbar.setProgress(1);
|
||||||
Bukkit.getOnlinePlayers().forEach(p -> restartbar.addPlayer(p));
|
Bukkit.getOnlinePlayers().forEach(p -> restartbar.addPlayer(p));
|
||||||
sender.sendMessage("Scheduled restart in " + seconds);
|
sender.sendMessage("Scheduled restart in " + seconds);
|
||||||
ScheduledServerRestartEvent e = new ScheduledServerRestartEvent(restarttime, this);
|
ScheduledServerRestartEvent e = new ScheduledServerRestartEvent(restarttime, this);
|
||||||
Bukkit.getPluginManager().callEvent(e);
|
Bukkit.getPluginManager().callEvent(e);
|
||||||
restarttask = Bukkit.getScheduler().runTaskTimer(MainPlugin.Instance, () -> {
|
restarttask = Bukkit.getScheduler().runTaskTimer(MainPlugin.Instance, () -> {
|
||||||
if (restartCounter < 0) {
|
if (restartCounter < 0) {
|
||||||
restarttask.cancel();
|
restarttask.cancel();
|
||||||
restartbar.getPlayers().forEach(p -> restartbar.removePlayer(p));
|
restartbar.getPlayers().forEach(p -> restartbar.removePlayer(p));
|
||||||
Bukkit.spigot().restart();
|
Bukkit.spigot().restart();
|
||||||
}
|
}
|
||||||
if (restartCounter % 200 == 0 && Bukkit.getOnlinePlayers().size()>0)
|
if (restartCounter % 200 == 0 && Bukkit.getOnlinePlayers().size() > 0)
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, "§c-- The server is restarting in " + restartCounter / 20 + " seconds! (/press)", component.getRestartBroadcast());
|
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, "§c-- The server is restarting in " + restartCounter / 20 + " seconds!", component.getRestartBroadcast());
|
||||||
restartbar.setProgress(restartCounter / (double) restarttime);
|
restartbar.setProgress(restartCounter / (double) restarttime);
|
||||||
restartbar.setTitle(String.format("Server restart in %.2f", restartCounter / 20f));
|
restartbar.setTitle(String.format("Server restart in %.2f", restartCounter / 20f));
|
||||||
restartCounter--;
|
restartCounter--;
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
package buttondevteam.core.component.towny;
|
package buttondevteam.core.component.towny;
|
||||||
|
|
||||||
import buttondevteam.core.ComponentManager;
|
|
||||||
import buttondevteam.core.MainPlugin;
|
import buttondevteam.core.MainPlugin;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
|
||||||
import buttondevteam.lib.architecture.Component;
|
import buttondevteam.lib.architecture.Component;
|
||||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically renames Towny players if they changed their Minecraft name
|
* Provides a command to remove invalid Towny residents.
|
||||||
*/
|
*/
|
||||||
public class TownyComponent extends Component<MainPlugin> {
|
public class TownyComponent extends Component<MainPlugin> {
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,35 +15,4 @@ public class TownyComponent extends Component<MainPlugin> {
|
||||||
@Override
|
@Override
|
||||||
protected void disable() {
|
protected void disable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Only renames the resident if this component is enabled. Used to handle name changes.
|
|
||||||
*
|
|
||||||
* @param oldName The player's old name as known by us
|
|
||||||
* @param newName The player's new name
|
|
||||||
*/
|
|
||||||
public static void renameInTowny(String oldName, String newName) {
|
|
||||||
var component = ComponentManager.getIfEnabled(TownyComponent.class);
|
|
||||||
if (component == null)
|
|
||||||
return;
|
|
||||||
component.log("Renaming " + oldName + " in Towny to " + newName);
|
|
||||||
TownyUniverse tu = TownyUniverse.getInstance();
|
|
||||||
try {
|
|
||||||
Resident resident = tu.getDataSource().getResident(oldName);
|
|
||||||
if (resident == null) {
|
|
||||||
component.logWarn("Resident not found - couldn't rename in Towny.");
|
|
||||||
TBMCCoreAPI.sendDebugMessage("Resident not found - couldn't rename in Towny.");
|
|
||||||
} else if (tu.getDataSource().hasResident(newName)) {
|
|
||||||
component.logWarn("Target resident name is already in use.");
|
|
||||||
TBMCCoreAPI.sendDebugMessage("Target resident name is already in use. (" + oldName + " -> " + newName + ")");
|
|
||||||
} else {
|
|
||||||
tu.getDataSource().renamePlayer(resident, newName); //Fixed in Towny 0.91.1.2
|
|
||||||
component.log("Renaming done.");
|
|
||||||
}
|
|
||||||
} catch (AlreadyRegisteredException e) {
|
|
||||||
TBMCCoreAPI.SendException("Failed to rename resident, there's already one with this name.", e, component);
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
TBMCCoreAPI.SendException("Failed to rename resident, the resident isn't registered.", e, component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
package buttondevteam.core.component.votifier;
|
|
||||||
|
|
||||||
import buttondevteam.core.MainPlugin;
|
|
||||||
import buttondevteam.lib.architecture.Component;
|
|
||||||
import buttondevteam.lib.architecture.ComponentMetadata;
|
|
||||||
import buttondevteam.lib.architecture.ConfigData;
|
|
||||||
import com.vexsoftware.votifier.model.Vote;
|
|
||||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do not use (EULA)
|
|
||||||
*/
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@ComponentMetadata(enabledByDefault = false)
|
|
||||||
public class VotifierComponent extends Component<MainPlugin> {
|
|
||||||
private final Economy economy;
|
|
||||||
|
|
||||||
private final ConfigData<Double> rewardAmount = getConfig().getData("rewardAmount", 0.0);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void enable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void disable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void onVotifierEvent(VotifierEvent event) {
|
|
||||||
Vote vote = event.getVote();
|
|
||||||
log("Vote: " + vote);
|
|
||||||
org.bukkit.OfflinePlayer op = Bukkit.getOfflinePlayer(vote.getUsername());
|
|
||||||
Player p = Bukkit.getPlayer(vote.getUsername());
|
|
||||||
/*if (op != null) {
|
|
||||||
economy.depositPlayer(op, rewardAmount().get());
|
|
||||||
}
|
|
||||||
if (p != null) {
|
|
||||||
p.sendMessage("§bThanks for voting! $50 was added to your account.");
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,6 +10,7 @@ import org.yaml.snakeyaml.representer.Representer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -174,7 +175,7 @@ public class CommentedConfiguration extends YamlConfiguration {
|
||||||
while (newContents.toString().startsWith(" " + System.getProperty("line.separator"))) {
|
while (newContents.toString().startsWith(" " + System.getProperty("line.separator"))) {
|
||||||
newContents = new StringBuilder(newContents.toString().replaceFirst(" " + System.getProperty("line.separator"), ""));
|
newContents = new StringBuilder(newContents.toString().replaceFirst(" " + System.getProperty("line.separator"), ""));
|
||||||
}
|
}
|
||||||
Files.write(file.toPath(), newContents.toString().getBytes());
|
Files.write(file.toPath(), newContents.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public abstract class Component<TP extends JavaPlugin> {
|
||||||
* @param component The component to unregister
|
* @param component The component to unregister
|
||||||
* @return Whether the component is unregistered successfully (it also got disabled)
|
* @return Whether the component is unregistered successfully (it also got disabled)
|
||||||
*/
|
*/
|
||||||
public static <T extends ButtonPlugin> boolean unregisterComponent(T plugin, Component<T> component) {
|
public static <T extends JavaPlugin> boolean unregisterComponent(T plugin, Component<T> component) {
|
||||||
return registerUnregisterComponent(plugin, component, false);
|
return registerUnregisterComponent(plugin, component, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,13 @@ public final class IHaveConfig {
|
||||||
val ms = obj.getClass().getDeclaredMethods();
|
val ms = obj.getClass().getDeclaredMethods();
|
||||||
for (val m : ms) {
|
for (val m : ms) {
|
||||||
if (!m.getReturnType().getName().equals(ConfigData.class.getName())) continue;
|
if (!m.getReturnType().getName().equals(ConfigData.class.getName())) continue;
|
||||||
|
final String mName;
|
||||||
|
{
|
||||||
|
var name = m.getName();
|
||||||
|
var ind = name.lastIndexOf('$');
|
||||||
|
if (ind == -1) mName = name;
|
||||||
|
else mName = name.substring(ind + 1);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
List<ConfigData<?>> configList;
|
List<ConfigData<?>> configList;
|
||||||
|
@ -213,7 +220,7 @@ public final class IHaveConfig {
|
||||||
try {
|
try {
|
||||||
return (ConfigData<?>) m.invoke(obj, kv.getValue());
|
return (ConfigData<?>) m.invoke(obj, kv.getValue());
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
String msg = "Failed to pregenerate " + m.getName() + " for " + obj + " using config " + kv.getKey() + "!";
|
String msg = "Failed to pregenerate " + mName + " for " + obj + " using config " + kv.getKey() + "!";
|
||||||
if (obj instanceof Component<?>)
|
if (obj instanceof Component<?>)
|
||||||
TBMCCoreAPI.SendException(msg, e, (Component<?>) obj);
|
TBMCCoreAPI.SendException(msg, e, (Component<?>) obj);
|
||||||
else if (obj instanceof JavaPlugin)
|
else if (obj instanceof JavaPlugin)
|
||||||
|
@ -225,18 +232,18 @@ public final class IHaveConfig {
|
||||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
if (TBMCCoreAPI.IsTestServer())
|
if (TBMCCoreAPI.IsTestServer())
|
||||||
MainPlugin.Instance.getLogger().warning("Method " + m.getName() + " returns a config but its parameters are unknown: " + Arrays.toString(m.getParameterTypes()));
|
MainPlugin.Instance.getLogger().warning("Method " + mName + " returns a config but its parameters are unknown: " + Arrays.toString(m.getParameterTypes()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (val c : configList) {
|
for (val c : configList) {
|
||||||
if (c.getPath().length() == 0)
|
if (c.getPath().length() == 0)
|
||||||
c.setPath(m.getName());
|
c.setPath(mName);
|
||||||
else if (!c.getPath().equals(m.getName()))
|
else if (!c.getPath().equals(mName))
|
||||||
MainPlugin.Instance.getLogger().warning("Config name does not match: " + c.getPath() + " instead of " + m.getName());
|
MainPlugin.Instance.getLogger().warning("Config name does not match: " + c.getPath() + " instead of " + mName);
|
||||||
c.get(); //Saves the default value if needed - also checks validity
|
c.get(); //Saves the default value if needed - also checks validity
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = "Failed to pregenerate " + m.getName() + " for " + obj + "!";
|
String msg = "Failed to pregenerate " + mName + " for " + obj + "!";
|
||||||
if (obj instanceof Component<?>)
|
if (obj instanceof Component<?>)
|
||||||
TBMCCoreAPI.SendException(msg, e, (Component<?>) obj);
|
TBMCCoreAPI.SendException(msg, e, (Component<?>) obj);
|
||||||
else if (obj instanceof JavaPlugin)
|
else if (obj instanceof JavaPlugin)
|
||||||
|
|
|
@ -6,12 +6,22 @@ import lombok.RequiredArgsConstructor;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public enum Color implements TellrawSerializableEnum {
|
public enum Color implements TellrawSerializableEnum {
|
||||||
Black("black", 0, 0, 0), DarkBlue("dark_blue", 0, 0, 170), DarkGreen("dark_green", 0, 170, 0), DarkAqua("dark_aqua",
|
Black("black", 0, 0, 0),
|
||||||
0, 170, 170), DarkRed("dark_red", 170, 0, 0), DarkPurple("dark_purple", 0, 170, 0), Gold("gold", 255, 170,
|
DarkBlue("dark_blue", 0, 0, 170),
|
||||||
0), Gray("gray", 170, 170, 170), DarkGray("dark_gray", 85, 85, 85), Blue("blue", 85, 85,
|
DarkGreen("dark_green", 0, 170, 0),
|
||||||
255), Green("green", 85, 255, 85), Aqua("aqua", 85, 255, 255), Red("red", 255, 85,
|
DarkAqua("dark_aqua", 0, 170, 170),
|
||||||
85), LightPurple("light_purple", 255, 85,
|
DarkRed("dark_red", 170, 0, 0),
|
||||||
255), Yellow("yellow", 255, 255, 85), White("white", 255, 255, 255);
|
DarkPurple("dark_purple", 0, 170, 0),
|
||||||
|
Gold("gold", 255, 170,0),
|
||||||
|
Gray("gray", 170, 170, 170),
|
||||||
|
DarkGray("dark_gray", 85, 85, 85),
|
||||||
|
Blue("blue", 85, 85, 255),
|
||||||
|
Green("green", 85, 255, 85),
|
||||||
|
Aqua("aqua", 85, 255, 255),
|
||||||
|
Red("red", 255, 85,85),
|
||||||
|
LightPurple("light_purple", 255, 85, 255),
|
||||||
|
Yellow("yellow", 255, 255, 85),
|
||||||
|
White("white", 255, 255, 255);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int red;
|
private final int red;
|
||||||
|
|
|
@ -119,7 +119,7 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
|
||||||
protected final HashMap<String, SubcommandData<TC>> subcommands = new HashMap<>();
|
protected final HashMap<String, SubcommandData<TC>> subcommands = new HashMap<>();
|
||||||
protected final HashMap<Class<?>, ParamConverter<?>> paramConverters = new HashMap<>();
|
protected final HashMap<Class<?>, ParamConverter<?>> paramConverters = new HashMap<>();
|
||||||
|
|
||||||
private ArrayList<String> commandHelp = new ArrayList<>(); //Mainly needed by Discord
|
private final ArrayList<String> commandHelp = new ArrayList<>(); //Mainly needed by Discord
|
||||||
|
|
||||||
private char commandChar;
|
private char commandChar;
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
|
||||||
}
|
}
|
||||||
val conv = paramConverters.get(cl);
|
val conv = paramConverters.get(cl);
|
||||||
if (conv == null)
|
if (conv == null)
|
||||||
throw new Exception("No suitable converter found for parameter type '" + cl.getCanonicalName() + "' for command '" + sd.method.toString() + "'");
|
throw new Exception("No suitable converter found for parameter type '" + cl.getCanonicalName() + "' for command '" + sd.method + "'");
|
||||||
val cparam = conv.converter.apply(param);
|
val cparam = conv.converter.apply(param);
|
||||||
if (cparam == null) {
|
if (cparam == null) {
|
||||||
sender.sendMessage(conv.errormsg); //Param conversion failed - ex. plugin not found
|
sender.sendMessage(conv.errormsg); //Param conversion failed - ex. plugin not found
|
||||||
|
@ -355,7 +355,7 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
|
||||||
if (ht.length > 0)
|
if (ht.length > 0)
|
||||||
ht[0] = "§6---- " + ht[0] + " ----";
|
ht[0] = "§6---- " + ht[0] + " ----";
|
||||||
YamlConfiguration yc = YamlConfiguration.loadConfiguration(new InputStreamReader(str)); //Generated by ButtonProcessor
|
YamlConfiguration yc = YamlConfiguration.loadConfiguration(new InputStreamReader(str)); //Generated by ButtonProcessor
|
||||||
val ccs = yc.getConfigurationSection(method.getDeclaringClass().getCanonicalName());
|
val ccs = yc.getConfigurationSection(method.getDeclaringClass().getCanonicalName().replace('$', '.'));
|
||||||
if (ccs != null) {
|
if (ccs != null) {
|
||||||
val cs = ccs.getConfigurationSection(method.getName());
|
val cs = ccs.getConfigurationSection(method.getName());
|
||||||
if (cs != null) {
|
if (cs != null) {
|
||||||
|
@ -371,7 +371,7 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
|
||||||
for (int j = 0; j < paramArray.length && j < parameters.length; j++)
|
for (int j = 0; j < paramArray.length && j < parameters.length; j++)
|
||||||
parameters[j] = paramArray[j];
|
parameters[j] = paramArray[j];
|
||||||
} else
|
} else
|
||||||
TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("Method '" + method.toString() + "' != " + mname + " or params is " + params), MainPlugin.Instance);
|
TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("Method '" + method + "' != " + mname + " or params is " + params), MainPlugin.Instance);
|
||||||
} else
|
} else
|
||||||
MainPlugin.Instance.getLogger().warning("Failed to get command data for " + method + " (cs is null)! Make sure to use 'clean install' when building the project.");
|
MainPlugin.Instance.getLogger().warning("Failed to get command data for " + method + " (cs is null)! Make sure to use 'clean install' when building the project.");
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -193,11 +193,6 @@ public class Command2MC extends Command2<ICommand2MC, Command2MCSender> implemen
|
||||||
int i = commandline.indexOf(' ');
|
int i = commandline.indexOf(' ');
|
||||||
String mainpath = commandline.substring(1, i == -1 ? commandline.length() : i); //Without the slash
|
String mainpath = commandline.substring(1, i == -1 ? commandline.length() : i); //Without the slash
|
||||||
PluginCommand pcmd;
|
PluginCommand pcmd;
|
||||||
/*System.out.println("Command line: " + commandline);
|
|
||||||
System.out.println("Prioritize: " + MainPlugin.Instance.prioritizeCustomCommands().get());
|
|
||||||
System.out.println("PCMD: " + (pcmd = Bukkit.getPluginCommand(mainpath)));
|
|
||||||
if (pcmd != null)
|
|
||||||
System.out.println("ButtonPlugin: " + (pcmd.getPlugin() instanceof ButtonPlugin));*/
|
|
||||||
if (!checkPlugin
|
if (!checkPlugin
|
||||||
|| MainPlugin.Instance.prioritizeCustomCommands.get()
|
|| MainPlugin.Instance.prioritizeCustomCommands.get()
|
||||||
|| (pcmd = Bukkit.getPluginCommand(mainpath)) == null //Our commands aren't PluginCommands
|
|| (pcmd = Bukkit.getPluginCommand(mainpath)) == null //Our commands aren't PluginCommands
|
||||||
|
@ -249,7 +244,6 @@ public class Command2MC extends Command2<ICommand2MC, Command2MCSender> implemen
|
||||||
sender.sendMessage("§cAn internal error occurred.");
|
sender.sendMessage("§cAn internal error occurred.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//System.out.println("Executing " + label + " which is actually " + command.getName());
|
|
||||||
handleCommand(new Command2MCSender(sender, user.channel.get(), sender),
|
handleCommand(new Command2MCSender(sender, user.channel.get(), sender),
|
||||||
("/" + command.getName() + " " + String.join(" ", args)).trim(), false); ///trim(): remove space if there are no args
|
("/" + command.getName() + " " + String.join(" ", args)).trim(), false); ///trim(): remove space if there are no args
|
||||||
return true;
|
return true;
|
||||||
|
@ -267,13 +261,11 @@ public class Command2MC extends Command2<ICommand2MC, Command2MCSender> implemen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||||
//System.out.println("Correct tabcomplete queried");
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
|
||||||
//System.out.println("Correct tabcomplete queried");
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ import java.util.function.Supplier;
|
||||||
public abstract class ChromaGamerBase {
|
public abstract class ChromaGamerBase {
|
||||||
private static final String TBMC_PLAYERS_DIR = "TBMC/players/";
|
private static final String TBMC_PLAYERS_DIR = "TBMC/players/";
|
||||||
private static final ArrayList<Function<CommandSender, ? extends Optional<? extends ChromaGamerBase>>> senderConverters = new ArrayList<>();
|
private static final ArrayList<Function<CommandSender, ? extends Optional<? extends ChromaGamerBase>>> senderConverters = new ArrayList<>();
|
||||||
|
/**
|
||||||
|
* Holds data per user class
|
||||||
|
*/
|
||||||
private static final HashMap<Class<? extends ChromaGamerBase>, StaticUserData<?>> staticDataMap = new HashMap<>();
|
private static final HashMap<Class<? extends ChromaGamerBase>, StaticUserData<?>> staticDataMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,6 +59,7 @@ public abstract class ChromaGamerBase {
|
||||||
throw new RuntimeException("Class not registered as a user class! Use @UserClass or TBMCPlayerBase");
|
throw new RuntimeException("Class not registered as a user class! Use @UserClass or TBMCPlayerBase");
|
||||||
var sud = new StaticUserData<T>(folderName);
|
var sud = new StaticUserData<T>(folderName);
|
||||||
sud.getConstructors().put(cl, constructor);
|
sud.getConstructors().put(cl, constructor);
|
||||||
|
sud.getConstructors().put(userclass, constructor); // Alawys register abstract and prototype class (TBMCPlayerBase and TBMCPlayer)
|
||||||
staticDataMap.put(userclass, sud);
|
staticDataMap.put(userclass, sud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,6 @@ commands:
|
||||||
description: Schedules a restart for a given time.
|
description: Schedules a restart for a given time.
|
||||||
primerestart:
|
primerestart:
|
||||||
description: Restarts the server as soon as nobody is online.
|
description: Restarts the server as soon as nobody is online.
|
||||||
randomtp:
|
|
||||||
description: teleport player to random location within world border. Every five players teleport to the same general area, and then a new general area is randomly selected for the next five players.
|
|
||||||
member:
|
|
||||||
description: Add or remove a member
|
|
||||||
component:
|
component:
|
||||||
description: Enable or disable or list components
|
description: Enable or disable or list components
|
||||||
dontrunthiscmd:
|
dontrunthiscmd:
|
||||||
|
|
Loading…
Reference in a new issue