mirror of
https://github.com/5vl/CorePlugin.git
synced 2025-05-23 15:57:03 +00:00
1.0.3
1.0.3
This commit is contained in:
parent
6277e9b3c3
commit
4dd5a897ea
@ -9,3 +9,4 @@ Permissions:
|
||||
- /unban - core.unban
|
||||
- /kick - core.kick
|
||||
- /discord - none
|
||||
- /toggle - core.toggle
|
||||
|
@ -10,6 +10,9 @@ import coreplugin.coreplugin.commands.heal;
|
||||
import coreplugin.coreplugin.commands.punish.ban;
|
||||
import coreplugin.coreplugin.commands.punish.kick;
|
||||
import coreplugin.coreplugin.commands.punish.unban;
|
||||
import coreplugin.coreplugin.commands.toggle;
|
||||
import coreplugin.coreplugin.events.OnPlayerJoin;
|
||||
import coreplugin.coreplugin.events.OnPlayerLeave;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -22,6 +25,8 @@ public final class Core extends JavaPlugin {
|
||||
this.getConfig().options().copyDefaults();
|
||||
saveDefaultConfig();
|
||||
PluginManager plm = org.bukkit.Bukkit.getPluginManager();
|
||||
plm.registerEvents(new OnPlayerJoin(), this);
|
||||
plm.registerEvents(new OnPlayerLeave(), this);
|
||||
registerCMD();
|
||||
}
|
||||
public static Core getInstance() {
|
||||
@ -38,5 +43,6 @@ public final class Core extends JavaPlugin {
|
||||
getCommand("ban").setExecutor(new ban());
|
||||
getCommand("unban").setExecutor(new unban());
|
||||
getCommand("discord").setExecutor(new discord());
|
||||
getCommand("toggle").setExecutor(new toggle());
|
||||
}
|
||||
}
|
@ -13,9 +13,20 @@ public class discord implements CommandExecutor {
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String Discord = Core.getInstance().getConfig().getString("Discord");
|
||||
Player p = (Player) sender;
|
||||
p.sendMessage(color(Discord));
|
||||
boolean t;
|
||||
t = toggle.DiscordToggle;
|
||||
if (t) {
|
||||
if (label.equalsIgnoreCase("discord")) {
|
||||
String Discord = Core.getInstance().getConfig().getString("Discord");
|
||||
Player p = (Player) sender;
|
||||
p.sendMessage(color(Discord));
|
||||
}
|
||||
}
|
||||
else {
|
||||
String CommandDisabled = Core.getInstance().getConfig().getString("CommandDisabled");
|
||||
Player p = (Player) sender;
|
||||
p.sendMessage(color(CommandDisabled));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
69
java/coreplugin/coreplugin/commands/toggle.java
Normal file
69
java/coreplugin/coreplugin/commands/toggle.java
Normal file
@ -0,0 +1,69 @@
|
||||
package coreplugin.coreplugin.commands;
|
||||
|
||||
import coreplugin.coreplugin.Core;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class toggle implements CommandExecutor {
|
||||
|
||||
private String color(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
public static boolean DiscordToggle;
|
||||
public static boolean JoinToggle;
|
||||
public static boolean LeaveToggle;
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission("core.toggle")) {
|
||||
if (label.equalsIgnoreCase("toggle")){
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("discord")) {
|
||||
DiscordToggle = !DiscordToggle;
|
||||
if (DiscordToggle) {
|
||||
p.sendMessage(color("&aFeature enabled."));
|
||||
}
|
||||
else {
|
||||
p.sendMessage(color("&cFeature disabled."));
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("join")) {
|
||||
JoinToggle = !JoinToggle;
|
||||
if (JoinToggle) {
|
||||
p.sendMessage(color("&aFeature enabled."));
|
||||
}
|
||||
else {
|
||||
p.sendMessage(color("&cFeature disabled."));
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("leave")){
|
||||
LeaveToggle = !LeaveToggle;
|
||||
if (LeaveToggle) {
|
||||
p.sendMessage(color("&aFeature enabled."));
|
||||
}
|
||||
else {
|
||||
p.sendMessage(color("&cFeature disabled."));
|
||||
}
|
||||
}
|
||||
else {
|
||||
String InvalidArgument = Core.getInstance().getConfig().getString("InvalidArgument");
|
||||
p.sendMessage(color(InvalidArgument));
|
||||
}
|
||||
}
|
||||
else {
|
||||
String InvalidArgument = Core.getInstance().getConfig().getString("InvalidArgument");
|
||||
p.sendMessage(color(InvalidArgument));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
String MissingPermission = Core.getInstance().getConfig().getString("MissingPermission");
|
||||
p.sendMessage(color(MissingPermission));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
26
java/coreplugin/coreplugin/events/OnPlayerJoin.java
Normal file
26
java/coreplugin/coreplugin/events/OnPlayerJoin.java
Normal file
@ -0,0 +1,26 @@
|
||||
package coreplugin.coreplugin.events;
|
||||
|
||||
import coreplugin.coreplugin.Core;
|
||||
import coreplugin.coreplugin.commands.toggle;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class OnPlayerJoin implements Listener {
|
||||
private String color(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerJoin(PlayerJoinEvent event) {
|
||||
boolean t;
|
||||
t = toggle.JoinToggle;
|
||||
if (t) {
|
||||
Player p = event.getPlayer();
|
||||
String CustomJoin = Core.getInstance().getConfig().getString("CustomJoin");
|
||||
event.setJoinMessage(color(CustomJoin + " " + p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
26
java/coreplugin/coreplugin/events/OnPlayerLeave.java
Normal file
26
java/coreplugin/coreplugin/events/OnPlayerLeave.java
Normal file
@ -0,0 +1,26 @@
|
||||
package coreplugin.coreplugin.events;
|
||||
|
||||
import coreplugin.coreplugin.Core;
|
||||
import coreplugin.coreplugin.commands.toggle;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class OnPlayerLeave implements Listener {
|
||||
private String color(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerLeave(PlayerQuitEvent event){
|
||||
boolean t;
|
||||
t = toggle.LeaveToggle;
|
||||
if (t) {
|
||||
Player p = event.getPlayer();
|
||||
String CustomLeave = Core.getInstance().getConfig().getString("CustomLeave");
|
||||
event.setQuitMessage(color(CustomLeave + " " + p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
@ -38,9 +38,16 @@ BroadcastBan: 'has been banned for: &e' # Last color code is the color that the
|
||||
|
||||
BroadcastUnban: 'has been unbanned.'
|
||||
|
||||
# Other
|
||||
# Leave/Join messages.
|
||||
CustomJoin: '&7[&a+&7]&b'
|
||||
CustomLeave: '&7[&c-&7]&b'
|
||||
|
||||
# Errors
|
||||
CannotFindPlayer: '&4Error: Cannot find the specified player.'
|
||||
MissingPermission: '&4&lYou do not have permission to execute this command!'
|
||||
Console: '&cYou can only run this command as a player.'
|
||||
InvalidArgument: '&4Error: Invalid argument.'
|
||||
CommandDisabled: '&bThis command has been disabled.'
|
||||
|
||||
# Other
|
||||
Discord: '&bhttps://discord.gg/YourDiscordLinkHere' # Please put in your discord link.
|
@ -24,4 +24,6 @@ commands:
|
||||
unban:
|
||||
description: You can unban people with this!
|
||||
discord:
|
||||
description: Send your discord link in chat!
|
||||
description: Send your discord link in chat!
|
||||
toggle:
|
||||
description: You can toggle certain features with this!
|
Loading…
x
Reference in New Issue
Block a user