1.2.1
This commit is contained in:
@ -49,15 +49,14 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
//this.dplug = new DitPluginManager(this);
|
||||
this.log.info(this.getPrefix()+"Started running.");
|
||||
this.log.info(ChatColor.stripColor(this.getPrefix())+"Started running.");
|
||||
}
|
||||
|
||||
|
||||
private void Init() throws Exception {
|
||||
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1)){
|
||||
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.19.3 to run this plugin.");
|
||||
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.20.1 to run this plugin.");
|
||||
}
|
||||
if (this.Reload()){
|
||||
|
||||
@ -73,7 +72,7 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
||||
getServer().getPluginManager().registerEvents(new LogConnect(this), this);
|
||||
if (this.config.isSet("CustomAdvancement.enabled") && this.config.getBoolean("CustomAdvancement.enabled")){
|
||||
getServer().getPluginManager().registerEvents(new ChatEvents(this), this);
|
||||
this.log.info(this.getPrefix()+"Custom Advancement Messages enabled!");
|
||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Custom Advancement Messages enabled!");
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new TPS(), 0, 1);
|
||||
|
||||
@ -154,6 +153,6 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
||||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
System.out.println(this.getPrefix()+" stopped.");
|
||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Started running.");
|
||||
}
|
||||
}
|
||||
|
@ -87,13 +87,18 @@ public class DitCmd implements CommandExecutor {
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.DARK_RED+"Invalid arguments!");
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("load")) {
|
||||
//PluginCmd.handleLoad(sender,args);
|
||||
PluginCmd.LoadPlugin(sender,args);
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("unload")) {
|
||||
//PluginCmd.handleUnload(sender,args);
|
||||
PluginCmd.UnloadPlugin(sender, args);
|
||||
if (config.getBoolean("PluginManager.enabled")) {
|
||||
if (args[1].equalsIgnoreCase("load")) {
|
||||
//PluginCmd.handleLoad(sender,args);
|
||||
PluginCmd.LoadPlugin(sender,args);
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("unload")) {
|
||||
//PluginCmd.handleUnload(sender,args);
|
||||
PluginCmd.UnloadPlugin(sender, args);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.DARK_RED+"Plugin manager commands are disabled in the config!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,7 +106,7 @@ public class DitCmd implements CommandExecutor {
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("save-all") && sender.hasPermission("st.save")){
|
||||
this.addToCoolDown(sender);
|
||||
return SaveCmd.Run(sender);
|
||||
return SaveCmd.Run();
|
||||
}
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("ping") && sender.hasPermission("st.ping")){
|
||||
|
@ -3,10 +3,14 @@ package hu.ditservices.commands;
|
||||
import hu.ditservices.STPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class SaveCmd {
|
||||
public static boolean Run(CommandSender sender){
|
||||
/**
|
||||
* Saves all worlds and players data.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean Run(){
|
||||
STPlugin plugin = STPlugin.getInstance();
|
||||
String p = plugin.config.getString("Saving.broadcastMsgProgress").replace("{PREFIX}",plugin.getPrefix());
|
||||
String d = plugin.config.getString("Saving.broadcastMsgDone").replace("{PREFIX}",plugin.getPrefix());
|
||||
|
@ -1,33 +1,10 @@
|
||||
package hu.ditservices.handlers;
|
||||
|
||||
import hu.ditservices.STPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import hu.ditservices.commands.SaveCmd;
|
||||
|
||||
public class SaveHandler implements Runnable{
|
||||
STPlugin plugin = STPlugin.getInstance();
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String p = plugin.config.isSet("Saving.broadcastMsgProgress") ? plugin.config.getString("Saving.broadcastMsgProgress").replace("{PREFIX}",plugin.getPrefix()) : plugin.getPrefix()+"Auto save in progress..";
|
||||
String d = plugin.config.isSet("Saving.broadcastMsgDone") ? plugin.config.getString("Saving.broadcastMsgDone").replace("{PREFIX}",plugin.getPrefix()) : plugin.getPrefix()+"Auto save done.";
|
||||
if (Bukkit.getOnlinePlayers().size()>0){
|
||||
for (Player player : Bukkit.getOnlinePlayers()){
|
||||
player.sendMessage(p);
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info(p);
|
||||
for(World w : Bukkit.getServer().getWorlds()){
|
||||
w.save();
|
||||
}
|
||||
Bukkit.savePlayers();
|
||||
if (Bukkit.getOnlinePlayers().size()>0){
|
||||
for (Player player : Bukkit.getOnlinePlayers()){
|
||||
player.sendMessage(d);
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info(d);
|
||||
|
||||
SaveCmd.Run();
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ public class TabHandler {
|
||||
msg = msg.replace("{MOTD}", plugin.getServer().getMotd()); //LegacyComponentSerializer.legacyAmpersand().serialize(plugin.getServer().motd().asComponent())
|
||||
}
|
||||
if (msg.contains("{TPS}")){
|
||||
msg = msg.replace("{TPS}",String.format("%.2f", TPS.getTPS()));
|
||||
msg = msg.replace("{TPS}",String.valueOf(java.lang.Math.round(TPS.getTPS())));
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&',msg);
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ import hu.ditservices.utils.AdvancementHelper;
|
||||
public class ChatEvents implements Listener {
|
||||
private STPlugin plugin;
|
||||
private FileConfiguration config;
|
||||
|
||||
public ChatEvents(STPlugin instance){
|
||||
this.plugin = instance;
|
||||
this.config = plugin.config;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAdvance(PlayerAdvancementDoneEvent e){
|
||||
if (config.isSet("CustomAdvancement.enabled") && config.getBoolean("CustomAdvancement.enabled")){
|
||||
|
@ -1,6 +1,7 @@
|
||||
package hu.ditservices.utils;
|
||||
|
||||
import hu.ditservices.STPlugin;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -115,24 +116,26 @@ public class AdvancementHelper {
|
||||
if (config.isSet("CustomAdvancement.formats.challenge")) {
|
||||
out_type[2] = config.getString("CustomAdvancement.formats.challenge");
|
||||
}
|
||||
String disablemsg = plugin.getPrefix()+"Disabling vanilla advancement messages for ";
|
||||
List<World> worlds = this.plugin.getServer().getWorlds();
|
||||
Method setRuleMethod, getRuleMethod;
|
||||
|
||||
try {
|
||||
String disableMsg = ChatColor.stripColor(plugin.getPrefix()) + "Disabling vanilla advancement messages for ";
|
||||
List<World> worlds = this.plugin.getServer().getWorlds();
|
||||
Method setRuleMethod, getRuleMethod;
|
||||
|
||||
for (World w : worlds) {
|
||||
if (Version.ServerVersion.isCurrentEqualOrLower(Version.ServerVersion.v1_12_R1)){
|
||||
getRuleMethod = w.getClass().getDeclaredMethod("getGameRuleValue", String.class);
|
||||
if (getRuleMethod.invoke(w,"announceAdvancements")=="true"){
|
||||
setRuleMethod = w.getClass().getDeclaredMethod("setGameRuleValue", String.class, String.class);
|
||||
setRuleMethod.invoke(w,"announceAdvancements", "false");
|
||||
this.plugin.getLogger().info(disablemsg + w.getName());
|
||||
this.plugin.getLogger().info(disableMsg + w.getName());
|
||||
}
|
||||
}else{
|
||||
getRuleMethod = w.getClass().getDeclaredMethod("getGameRuleValue", GameRule.class);
|
||||
if ((boolean)getRuleMethod.invoke(w,GameRule.ANNOUNCE_ADVANCEMENTS)){
|
||||
setRuleMethod = w.getClass().getDeclaredMethod("setGameRule", GameRule.class, Object.class);
|
||||
setRuleMethod.invoke(w,GameRule.ANNOUNCE_ADVANCEMENTS,false);
|
||||
this.plugin.getLogger().info(disablemsg + w.getName());
|
||||
this.plugin.getLogger().info(disableMsg + w.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ public class Version {
|
||||
v1_18_R1,
|
||||
v1_18_R2,
|
||||
v1_19_R1,
|
||||
v1_19_R2;
|
||||
v1_19_R2,
|
||||
v1_20_R1;
|
||||
|
||||
private int value;
|
||||
|
||||
|
@ -80,6 +80,12 @@ Cooldown:
|
||||
# The time must be passed between using this plugin commands.
|
||||
seconds: 2 #The command cooldown in seconds
|
||||
Msg: '{PREFIX} Please wait {SECONDS} seconds!' # The message when the user spamming a command
|
||||
|
||||
#
|
||||
# Plugin Manager - Enable/Disable plugins without server restart
|
||||
# Attention! It may cause errors in other plugins if you use this feature, not recommended!
|
||||
# If this is set to 'true' you can use the /st pmanager commands. Set it to 'false' to prevent its use.
|
||||
#
|
||||
PluginManager:
|
||||
enabled: false
|
||||
# Miscellaneous
|
||||
Prefix: '&a[&fSimplify&7Tools&2] &4- &f'
|
||||
Prefix: '&a[&fSimplify&7Tools&2] &4- &f' # The prefix which is inserted to the beginning of every plugin message.
|
||||
|
Reference in New Issue
Block a user