mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-31 18:21:51 +02:00
Fix changeDisplayname and related code
This commit is contained in:
@@ -31,4 +31,10 @@ public interface IPlugin extends Plugin {
|
|||||||
Location callRespawnEvent(Player player, Location loc, boolean bedSpawn);
|
Location callRespawnEvent(Player player, Location loc, boolean bedSpawn);
|
||||||
|
|
||||||
void callSuicideEvent(Player player);
|
void callSuicideEvent(Player player);
|
||||||
|
|
||||||
|
public boolean isModuleEnabled(String name);
|
||||||
|
|
||||||
|
public void onPluginEnable(Plugin plugin);
|
||||||
|
|
||||||
|
public void onPluginDisable(Plugin plugin);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
package net.ess3.bukkit;
|
package net.ess3.bukkit;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import net.ess3.Essentials;
|
import net.ess3.Essentials;
|
||||||
import static net.ess3.I18n._;
|
import static net.ess3.I18n._;
|
||||||
@@ -21,15 +24,17 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
|
|
||||||
|
|
||||||
public class BukkitPlugin extends JavaPlugin implements IPlugin
|
public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||||
{
|
{
|
||||||
private Essentials ess;
|
private Essentials ess;
|
||||||
|
private Map<String, Plugin> modules = Collections.synchronizedMap(new HashMap<String, Plugin>());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
@@ -75,7 +80,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
|||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(ess);
|
final EssentialsPluginListener serverListener = new EssentialsPluginListener(ess);
|
||||||
pm.registerEvents(serverListener, this);
|
pm.registerEvents(serverListener, this);
|
||||||
ess.addReloadListener(serverListener);
|
ess.addReloadListener(serverListener);
|
||||||
@@ -89,7 +94,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
|||||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(ess);
|
final EssentialsEntityListener entityListener = new EssentialsEntityListener(ess);
|
||||||
pm.registerEvents(entityListener, this);
|
pm.registerEvents(entityListener, this);
|
||||||
|
|
||||||
|
|
||||||
final MetricsStarter metricsStarter = new MetricsStarter(ess);
|
final MetricsStarter metricsStarter = new MetricsStarter(ess);
|
||||||
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
||||||
{
|
{
|
||||||
@@ -116,7 +121,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
|||||||
{
|
{
|
||||||
return ess.getCommandHandler().handleCommand(sender, command, label, args);
|
return ess.getCommandHandler().handleCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||||
{
|
{
|
||||||
@@ -128,7 +133,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
|||||||
{
|
{
|
||||||
return getServer().getScheduler().scheduleSyncDelayedTask(this, run);
|
return getServer().getScheduler().scheduleSyncDelayedTask(this, run);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int scheduleAsyncDelayedTask(final Runnable run, final long delay)
|
public int scheduleAsyncDelayedTask(final Runnable run, final long delay)
|
||||||
{
|
{
|
||||||
@@ -179,7 +184,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location callRespawnEvent(Player player, Location loc, boolean bedSpawn)
|
public Location callRespawnEvent(final Player player, final Location loc, final boolean bedSpawn)
|
||||||
{
|
{
|
||||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, loc, bedSpawn);
|
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, loc, bedSpawn);
|
||||||
getServer().getPluginManager().callEvent(pre);
|
getServer().getPluginManager().callEvent(pre);
|
||||||
@@ -187,7 +192,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callSuicideEvent(Player player)
|
public void callSuicideEvent(final Player player)
|
||||||
{
|
{
|
||||||
EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000);
|
EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000);
|
||||||
getServer().getPluginManager().callEvent(ede);
|
getServer().getPluginManager().callEvent(ede);
|
||||||
@@ -198,4 +203,33 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
|||||||
{
|
{
|
||||||
return ess;
|
return ess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isModuleEnabled(final String name)
|
||||||
|
{
|
||||||
|
return modules.containsKey(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginEnable(final Plugin plugin)
|
||||||
|
{
|
||||||
|
if (plugin.getName().equals(this.getName())
|
||||||
|
|| !plugin.getName().startsWith("Essentials"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Remove "Essentials" from name
|
||||||
|
modules.put(plugin.getName().substring(10), plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginDisable(final Plugin plugin)
|
||||||
|
{
|
||||||
|
if (plugin.getName().equals(this.getName())
|
||||||
|
|| !plugin.getName().startsWith("Essentials"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modules.remove(plugin.getName().substring(10));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ public class Commandafk extends EssentialsCommand
|
|||||||
|
|
||||||
private void toggleAfk(IUser user)
|
private void toggleAfk(IUser user)
|
||||||
{
|
{
|
||||||
user.setDisplayNick();
|
|
||||||
if (!user.toggleAfk())
|
if (!user.toggleAfk())
|
||||||
{
|
{
|
||||||
//user.sendMessage(_("markedAsNotAway"));
|
//user.sendMessage(_("markedAsNotAway"));
|
||||||
|
@@ -17,7 +17,6 @@ public class Commandhelpop extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
user.setDisplayNick();
|
|
||||||
final String message = _("helpOp", user.getPlayer().getDisplayName(), FormatUtil.stripFormat(getFinalArg(args, 0)));
|
final String message = _("helpOp", user.getPlayer().getDisplayName(), FormatUtil.stripFormat(getFinalArg(args, 0)));
|
||||||
logger.log(Level.INFO, message);
|
logger.log(Level.INFO, message);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
@@ -106,7 +106,6 @@ public class Commandlist extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
groupString.append(_("listHiddenTag"));
|
groupString.append(_("listHiddenTag"));
|
||||||
}
|
}
|
||||||
user.setDisplayNick();
|
|
||||||
groupString.append(user.getPlayer().getDisplayName());
|
groupString.append(user.getPlayer().getDisplayName());
|
||||||
groupString.append("§f");
|
groupString.append("§f");
|
||||||
}
|
}
|
||||||
@@ -155,7 +154,6 @@ public class Commandlist extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
onlineUsers.append(_("listHiddenTag"));
|
onlineUsers.append(_("listHiddenTag"));
|
||||||
}
|
}
|
||||||
user.setDisplayNick();
|
|
||||||
onlineUsers.append(user.getPlayer().getDisplayName());
|
onlineUsers.append(user.getPlayer().getDisplayName());
|
||||||
onlineUsers.append("§f");
|
onlineUsers.append("§f");
|
||||||
}
|
}
|
||||||
|
@@ -26,12 +26,11 @@ public class Commandme extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
message = FormatUtil.replaceFormat(message);
|
message = FormatUtil.replaceFormat(message);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
message = FormatUtil.stripColor(message);
|
message = FormatUtil.stripColor(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
user.setDisplayNick();
|
|
||||||
ess.broadcastMessage(user, _("action", user.getPlayer().getDisplayName(), message));
|
ess.broadcastMessage(user, _("action", user.getPlayer().getDisplayName(), message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,6 @@ public class Commandrealname extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
u.setDisplayNick();
|
|
||||||
final String displayName = FormatUtil.stripFormat(u.getPlayer().getDisplayName()).toLowerCase(Locale.ENGLISH);
|
final String displayName = FormatUtil.stripFormat(u.getPlayer().getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||||
if (!whois.equals(displayName)
|
if (!whois.equals(displayName)
|
||||||
&& !displayName.equals(FormatUtil.stripFormat(settings.getData().getChat().getNicknamePrefix()) + whois)
|
&& !displayName.equals(FormatUtil.stripFormat(settings.getData().getChat().getNicknamePrefix()) + whois)
|
||||||
|
@@ -12,7 +12,6 @@ public class Commandsuicide extends EssentialsCommand
|
|||||||
ess.getPlugin().callSuicideEvent(user.getPlayer());
|
ess.getPlugin().callSuicideEvent(user.getPlayer());
|
||||||
user.getPlayer().damage(Short.MAX_VALUE);
|
user.getPlayer().damage(Short.MAX_VALUE);
|
||||||
user.sendMessage(_("suicideMessage"));
|
user.sendMessage(_("suicideMessage"));
|
||||||
user.setDisplayNick();
|
|
||||||
ess.broadcastMessage(user,_("suicideSuccess", user.getPlayer().getDisplayName()));
|
ess.broadcastMessage(user,_("suicideSuccess", user.getPlayer().getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,6 @@ public class Commandwhois extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
foundPlayer = true;
|
foundPlayer = true;
|
||||||
sender.sendMessage(_("whoisTop", user.getName()));
|
sender.sendMessage(_("whoisTop", user.getName()));
|
||||||
user.setDisplayNick();
|
|
||||||
sender.sendMessage(_("whoisIs", user.getPlayer().getDisplayName(), user.getName()));
|
sender.sendMessage(_("whoisIs", user.getPlayer().getDisplayName(), user.getName()));
|
||||||
sender.sendMessage(_("whoisHealth", user.getPlayer().getHealth()));
|
sender.sendMessage(_("whoisHealth", user.getPlayer().getHealth()));
|
||||||
sender.sendMessage(_("whoisExp", SetExpFix.getTotalExperience(user.getPlayer()), user.getPlayer().getLevel()));
|
sender.sendMessage(_("whoisExp", SetExpFix.getTotalExperience(user.getPlayer()), user.getPlayer().getLevel()));
|
||||||
|
@@ -31,7 +31,7 @@ public class EssentialsPluginListener implements Listener, IReload
|
|||||||
public void onPluginEnable(final PluginEnableEvent event)
|
public void onPluginEnable(final PluginEnableEvent event)
|
||||||
{
|
{
|
||||||
checkGroups();
|
checkGroups();
|
||||||
//ess.getPermissionsHandler().checkPermissions();
|
ess.getPlugin().onPluginEnable(event.getPlugin());
|
||||||
ess.getCommandHandler().addPlugin(event.getPlugin());
|
ess.getCommandHandler().addPlugin(event.getPlugin());
|
||||||
if (!Methods.hasMethod() && Methods.setMethod(ess.getServer().getPluginManager()))
|
if (!Methods.hasMethod() && Methods.setMethod(ess.getServer().getPluginManager()))
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ public class EssentialsPluginListener implements Listener, IReload
|
|||||||
public void onPluginDisable(final PluginDisableEvent event)
|
public void onPluginDisable(final PluginDisableEvent event)
|
||||||
{
|
{
|
||||||
checkGroups();
|
checkGroups();
|
||||||
//ess.getPermissionsHandler().checkPermissions();
|
ess.getPlugin().onPluginDisable(event.getPlugin());
|
||||||
ess.getCommandHandler().removePlugin(event.getPlugin());
|
ess.getCommandHandler().removePlugin(event.getPlugin());
|
||||||
// Check to see if the plugin thats being disabled is the one we are using
|
// Check to see if the plugin thats being disabled is the one we are using
|
||||||
if (Methods.hasMethod() && Methods.checkDisabled(event.getPlugin()))
|
if (Methods.hasMethod() && Methods.checkDisabled(event.getPlugin()))
|
||||||
|
@@ -17,7 +17,7 @@ public class Chat implements StorageObject
|
|||||||
"Disable this if you have any other plugin, that modifies the displayname of a user.",
|
"Disable this if you have any other plugin, that modifies the displayname of a user.",
|
||||||
"If it is not set, it will be enabled if EssentialsChat is installed, otherwise not."
|
"If it is not set, it will be enabled if EssentialsChat is installed, otherwise not."
|
||||||
})
|
})
|
||||||
private Boolean changeDisplayname = true;
|
private Boolean changeDisplayname;
|
||||||
private String displaynameFormat = "{PREFIX}{NICKNAMEPREFIX}{NAME}{SUFFIX}";
|
private String displaynameFormat = "{PREFIX}{NICKNAMEPREFIX}{NAME}{SUFFIX}";
|
||||||
@Comment(
|
@Comment(
|
||||||
{
|
{
|
||||||
|
@@ -40,8 +40,8 @@ public class User extends UserBase implements IUser
|
|||||||
private transient long lastOnlineActivity;
|
private transient long lastOnlineActivity;
|
||||||
private transient long lastActivity = System.currentTimeMillis();
|
private transient long lastActivity = System.currentTimeMillis();
|
||||||
/*@Getter
|
/*@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private boolean hidden = false;*/
|
private boolean hidden = false;*/
|
||||||
@Getter
|
@Getter
|
||||||
private transient boolean vanished;
|
private transient boolean vanished;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -211,15 +211,15 @@ public class User extends UserBase implements IUser
|
|||||||
|
|
||||||
if (displayname.contains("{PREFIX}"))
|
if (displayname.contains("{PREFIX}"))
|
||||||
{
|
{
|
||||||
displayname = displayname.replace("{PREFIX}", groups.getPrefix(this));
|
displayname = displayname.replace("{PREFIX}", addprefixsuffix ? groups.getPrefix(this) : "");
|
||||||
}
|
}
|
||||||
if (displayname.contains("{SUFFIX}"))
|
if (displayname.contains("{SUFFIX}"))
|
||||||
{
|
{
|
||||||
displayname = displayname.replace("{SUFFIX}", groups.getSuffix(this));
|
displayname = displayname.replace("{SUFFIX}", addprefixsuffix ? groups.getSuffix(this) : "");
|
||||||
}
|
}
|
||||||
displayname = displayname.replace("{WORLDNAME}", this.getPlayer().getWorld().getName());
|
displayname = displayname.replace("{WORLDNAME}", this.getPlayer().getWorld().getName());
|
||||||
displayname = displayname.replace('&', '\u00a7');
|
displayname = displayname.replace('&', '\u00a7');
|
||||||
displayname = displayname.concat("\u00a7f");
|
displayname = displayname.concat("\u00a7r");
|
||||||
|
|
||||||
return displayname;
|
return displayname;
|
||||||
}
|
}
|
||||||
@@ -250,8 +250,9 @@ public class User extends UserBase implements IUser
|
|||||||
@Override
|
@Override
|
||||||
public void updateDisplayName()
|
public void updateDisplayName()
|
||||||
{
|
{
|
||||||
final ISettings settings = ess.getSettings();
|
final Boolean changeDisplayname = ess.getSettings().getData().getChat().getChangeDisplayname();
|
||||||
if (isOnline() && settings.getData().getChat().getChangeDisplayname())
|
|
||||||
|
if (isOnline() && (changeDisplayname == true || (changeDisplayname == null && ess.getPlugin().isModuleEnabled("Chat"))));
|
||||||
{
|
{
|
||||||
setDisplayNick();
|
setDisplayNick();
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,6 @@ public class KeywordReplacer implements IText
|
|||||||
if (sender instanceof IUser)
|
if (sender instanceof IUser)
|
||||||
{
|
{
|
||||||
final IUser user = (IUser)sender;
|
final IUser user = (IUser)sender;
|
||||||
user.setDisplayNick();
|
|
||||||
displayName = user.getPlayer().getDisplayName();
|
displayName = user.getPlayer().getDisplayName();
|
||||||
userName = user.getPlayer().getName();
|
userName = user.getPlayer().getName();
|
||||||
ipAddress = user.getPlayer().getAddress() == null || user.getPlayer().getAddress().getAddress() == null ? "" : user.getPlayer().getAddress().getAddress().toString();
|
ipAddress = user.getPlayer().getAddress() == null || user.getPlayer().getAddress().getAddress() == null ? "" : user.getPlayer().getAddress().getAddress().toString();
|
||||||
|
Reference in New Issue
Block a user