Add configurable messages.
This commit is contained in:
parent
db1912445e
commit
4537a5caa3
@ -49,3 +49,12 @@ sit-effects:
|
||||
healing:
|
||||
amount: 1
|
||||
max-percent: 100
|
||||
messages:
|
||||
sitting: '&7You are now sitting.'
|
||||
standing: '&7You are no longer sitting.'
|
||||
occupied: '&7This seat is occupied by &6%PLAYER%&7!'
|
||||
reloaded: 'Chairs configuration reloaded.'
|
||||
no-permission: '&cYou do not have permission to do this!'
|
||||
enabled: '&7You have enabled chairs for yourself!'
|
||||
disabled: '&7You have disabled chairs for yourself!'
|
||||
|
@ -5,8 +5,8 @@
|
||||
package net.spoothie.chairs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.server.v1_5_R1.DataWatcher;
|
||||
import net.minecraft.server.v1_5_R1.WatchableObject;
|
||||
import net.minecraft.server.v1_5_R2.DataWatcher;
|
||||
import net.minecraft.server.v1_5_R2.WatchableObject;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -6,12 +6,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.v1_5_R1.Packet40EntityMetadata;
|
||||
import net.minecraft.server.v1_5_R2.Packet40EntityMetadata;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_5_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@ -40,6 +40,7 @@ public class Chairs extends JavaPlugin {
|
||||
static final Logger log = Logger.getLogger("Minecraft");
|
||||
public PluginManager pm;
|
||||
public static ChairsIgnoreList ignoreList;
|
||||
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -114,6 +115,14 @@ public class Chairs extends JavaPlugin {
|
||||
sitMaxHealth = getConfig().getInt("sit-effects.healing.max-percent",100);
|
||||
sitHealthPerInterval = getConfig().getInt("sit-effects.healing.amount",1);
|
||||
|
||||
msgSitting = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.sitting"));
|
||||
msgStanding = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.standing"));
|
||||
msgOccupied = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.occupied"));
|
||||
msgNoPerm = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.no-permission"));
|
||||
msgEnabled = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.enabled"));
|
||||
msgDisabled = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.disabled"));
|
||||
msgReloaded = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.reloaded"));
|
||||
|
||||
for (String s : getConfig().getStringList("allowed-blocks")) {
|
||||
String type;
|
||||
double sh = sittingHeight;
|
||||
@ -199,8 +208,8 @@ public class Chairs extends JavaPlugin {
|
||||
// Send stand packet to all online players
|
||||
public void sendStand(Player p) {
|
||||
if (sit.containsKey(p.getName())) {
|
||||
if (notifyplayer) {
|
||||
p.sendMessage(ChatColor.GRAY + "You are no longer sitting.");
|
||||
if (notifyplayer && !msgStanding.isEmpty()) {
|
||||
p.sendMessage(msgStanding);
|
||||
}
|
||||
sit.remove(p.getName());
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package net.spoothie.chairs;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -34,9 +33,13 @@ public class ChairsCommand implements CommandExecutor {
|
||||
plugin.reloadConfig();
|
||||
plugin.loadConfig();
|
||||
plugin.restartEffectsTask();
|
||||
sender.sendMessage("Chairs configuration file reloaded.");
|
||||
if (!plugin.msgReloaded.isEmpty()) {
|
||||
sender.sendMessage(plugin.msgReloaded);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GRAY + "No permission to do this!");
|
||||
if (!plugin.msgNoPerm.isEmpty()) {
|
||||
sender.sendMessage(plugin.msgNoPerm);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
@ -44,17 +47,25 @@ public class ChairsCommand implements CommandExecutor {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
||||
ignoreList.removePlayer(p.getName());
|
||||
p.sendMessage(ChatColor.GRAY + "You have enabled chairs for yourself!");
|
||||
if (!plugin.msgEnabled.isEmpty()) {
|
||||
p.sendMessage(plugin.msgEnabled);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(ChatColor.GRAY + "No permission to do this!");
|
||||
if (!plugin.msgNoPerm.isEmpty()) {
|
||||
p.sendMessage(plugin.msgNoPerm);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("off")) {
|
||||
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
||||
ignoreList.addPlayer(p.getName());
|
||||
p.sendMessage(ChatColor.GRAY + "You have disabled chairs for yourself!");
|
||||
if (!plugin.msgDisabled.isEmpty()) {
|
||||
p.sendMessage(plugin.msgDisabled);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(ChatColor.GRAY + "No permission to do this!");
|
||||
if (!plugin.msgNoPerm.isEmpty()) {
|
||||
p.sendMessage(plugin.msgNoPerm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -175,8 +174,8 @@ public class EventListener implements Listener {
|
||||
if (plugin.sit.containsKey(event.getPlayer().getName())) {
|
||||
plugin.sit.remove(player.getName());
|
||||
event.setCancelled(true);
|
||||
if (plugin.notifyplayer) {
|
||||
player.sendMessage(ChatColor.GRAY + "You are no longer sitting.");
|
||||
if (plugin.notifyplayer && !plugin.msgStanding.isEmpty()) {
|
||||
player.sendMessage(plugin.msgStanding);
|
||||
}
|
||||
plugin.sendStand(player);
|
||||
return;
|
||||
@ -237,7 +236,9 @@ public class EventListener implements Listener {
|
||||
if (!plugin.sit.isEmpty()) {
|
||||
for (String s : plugin.sit.keySet()) {
|
||||
if (plugin.sit.get(s).equals(block.getLocation())) {
|
||||
player.sendMessage(ChatColor.GRAY + "This seat is occupied by " + s + "!");
|
||||
if (!plugin.msgOccupied.isEmpty()) {
|
||||
player.sendMessage(plugin.msgOccupied.replaceAll("%PLAYER%", s));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -272,8 +273,8 @@ public class EventListener implements Listener {
|
||||
player.teleport(plocation.add(0.5D, (sh - 0.5D), 0.5D));
|
||||
}
|
||||
player.setSneaking(true);
|
||||
if (plugin.notifyplayer) {
|
||||
player.sendMessage(ChatColor.GRAY + "You are now sitting.");
|
||||
if (plugin.notifyplayer && !plugin.msgSitting.isEmpty()) {
|
||||
player.sendMessage(plugin.msgSitting);
|
||||
}
|
||||
plugin.sit.put(player.getName(), block.getLocation());
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: Chairs
|
||||
version: 1.20.0
|
||||
version: 1.21.0
|
||||
description: Let players sit on blocks.
|
||||
authors:
|
||||
- spoothie
|
||||
|
Loading…
Reference in New Issue
Block a user