-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Mineaurion/feature-reload.command
Feature reload.command
- Loading branch information
Showing
44 changed files
with
641 additions
and
677 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 35 additions & 68 deletions
103
bukkit/src/main/java/com/mineaurion/aurionchat/bukkit/AurionChat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,64 @@ | ||
package com.mineaurion.aurionchat.bukkit; | ||
|
||
import com.mineaurion.aurionchat.bukkit.channel.ChatService; | ||
import com.mineaurion.aurionchat.bukkit.command.ChatCommand; | ||
import com.mineaurion.aurionchat.bukkit.listeners.ChatListener; | ||
import com.mineaurion.aurionchat.bukkit.listeners.CommandListener; | ||
import com.mineaurion.aurionchat.bukkit.listeners.LoginListener; | ||
import com.mineaurion.aurionchat.common.LuckPermsUtils; | ||
import net.luckperms.api.LuckPerms; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import com.mineaurion.aurionchat.common.AbstractAurionChat; | ||
import com.mineaurion.aurionchat.common.logger.JavaPluginLogger; | ||
import com.mineaurion.aurionchat.common.logger.PluginLogger; | ||
import org.bukkit.plugin.PluginManager; | ||
import org.bukkit.plugin.RegisteredServiceProvider; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeoutException; | ||
public class AurionChat extends AbstractAurionChat<AurionChatPlayer> { | ||
|
||
public static final String ID = "aurionchat"; | ||
|
||
public class AurionChat extends JavaPlugin { | ||
public static Config config; | ||
public static Map<UUID, AurionChatPlayer> aurionChatPlayers = new HashMap<>(); | ||
public static LuckPermsUtils luckPermsUtils = null; | ||
public static Utils utils = new Utils(); | ||
public ChatService getChatService() { | ||
return chatService; | ||
} | ||
|
||
public void setChatService(ChatService chatService) { | ||
this.chatService = chatService; | ||
} | ||
private ChatService chatService; | ||
public final JavaPlugin plugin; | ||
|
||
public boolean isErrorRabbitmq() { | ||
return errorRabbitmq; | ||
public AurionChat(JavaPlugin plugin){ | ||
this.plugin = plugin; | ||
} | ||
|
||
public void setErrorRabbitmq(boolean errorRabbitmq) { | ||
this.errorRabbitmq = errorRabbitmq; | ||
public void onEnable(){ | ||
getlogger().info("AurionChat Initializing"); | ||
config = new Config(this.plugin); | ||
this.enable( | ||
config.rabbitmq.uri, | ||
config.rabbitmq.serverName, | ||
config.options.spy, | ||
config.options.autoMessage, | ||
true | ||
); | ||
} | ||
|
||
private boolean errorRabbitmq = false; | ||
public void onDisable() { | ||
this.disable(); | ||
} | ||
|
||
|
||
@Override | ||
public void onEnable(){ | ||
sendConsoleMessage("&8[&eAurionChat&8]&e - Initializing..."); | ||
sendConsoleMessage("&8[&eAurionChat&8]&e - Checking for Vault..."); | ||
RegisteredServiceProvider<LuckPerms> luckPermsprovider = Bukkit.getServicesManager().getRegistration(LuckPerms.class); | ||
if(luckPermsprovider != null) { | ||
luckPermsUtils = new LuckPermsUtils(luckPermsprovider.getProvider()); | ||
} | ||
config = new Config(this); | ||
sendConsoleMessage("&8[&eAurionChat&8]&e - Config Loaded."); | ||
sendConsoleMessage("&8[&eAurionChat&8]&e - Connecting to RabbitMQ"); | ||
|
||
try { | ||
this.setChatService(new ChatService(config.rabbitmq.uri, config.rabbitmq.serverName)); | ||
} catch (IOException | TimeoutException e){ | ||
Bukkit.getPluginManager().disablePlugin(this); | ||
this.setErrorRabbitmq(true); | ||
sendConsoleMessage("&8[&eAurionChat&8]&e - &ccan't connect to rabbitmq, disabling."); | ||
getLogger().warning(e.getMessage()); | ||
} | ||
sendConsoleMessage("&8[&eAurionChat&8]&e - Registering Listeners"); | ||
setupListener(this); | ||
this.getCommand("chat").setExecutor(new ChatCommand()); | ||
protected void registerPlatformListeners() { | ||
PluginManager pluginManager = this.plugin.getServer().getPluginManager(); | ||
pluginManager.registerEvents(new LoginListener(this), this.plugin); | ||
pluginManager.registerEvents(new CommandListener(this), this.plugin); | ||
pluginManager.registerEvents(new ChatListener(this), this.plugin); | ||
} | ||
|
||
private void setupListener(AurionChat plugin){ | ||
PluginManager pluginManager = getServer().getPluginManager(); | ||
pluginManager.registerEvents(new LoginListener(), this); | ||
pluginManager.registerEvents(new ChatListener(plugin), this); | ||
pluginManager.registerEvents(new CommandListener(plugin), this); | ||
@Override | ||
protected void registerCommands() { | ||
this.plugin.getCommand("chat").setExecutor(new ChatCommand(this)); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
if(!this.isErrorRabbitmq()){ | ||
try{ | ||
if(this.getChatService() != null){ | ||
this.getChatService().close(); | ||
} | ||
} | ||
catch(IOException|TimeoutException e){ | ||
sendConsoleMessage("&8[&eAurionChat&8]&e - Error when communication closed"); | ||
sendConsoleMessage(e.getMessage()); | ||
} | ||
} | ||
protected void disablePlugin() { | ||
this.plugin.getServer().getPluginManager().disablePlugin(this.plugin); | ||
} | ||
|
||
public void sendConsoleMessage(String message){ | ||
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', message)); | ||
@Override | ||
public PluginLogger getlogger() { | ||
return new JavaPluginLogger(this.plugin.getServer().getLogger()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
bukkit/src/main/java/com/mineaurion/aurionchat/bukkit/PluginLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.mineaurion.aurionchat.bukkit; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class PluginLoader extends JavaPlugin { | ||
|
||
private final AurionChat plugin; | ||
|
||
public PluginLoader(){ | ||
this.plugin = new AurionChat(this); | ||
} | ||
|
||
@Override | ||
public void onEnable(){ | ||
this.plugin.onEnable(); | ||
} | ||
|
||
@Override | ||
public void onDisable(){ | ||
this.plugin.onDisable(); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
bukkit/src/main/java/com/mineaurion/aurionchat/bukkit/Utils.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
bukkit/src/main/java/com/mineaurion/aurionchat/bukkit/channel/ChatService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.