mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-30 09:49: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);
|
||||
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import net.ess3.Essentials;
|
||||
import static net.ess3.I18n._;
|
||||
@@ -21,15 +24,17 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
|
||||
|
||||
public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||
{
|
||||
{
|
||||
private Essentials ess;
|
||||
|
||||
private Map<String, Plugin> modules = Collections.synchronizedMap(new HashMap<String, Plugin>());
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
@@ -75,7 +80,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(ess);
|
||||
pm.registerEvents(serverListener, this);
|
||||
ess.addReloadListener(serverListener);
|
||||
@@ -89,7 +94,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(ess);
|
||||
pm.registerEvents(entityListener, this);
|
||||
|
||||
|
||||
|
||||
final MetricsStarter metricsStarter = new MetricsStarter(ess);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
@@ -128,7 +133,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||
{
|
||||
return getServer().getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
@@ -179,7 +184,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||
}
|
||||
|
||||
@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);
|
||||
getServer().getPluginManager().callEvent(pre);
|
||||
@@ -187,7 +192,7 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callSuicideEvent(Player player)
|
||||
public void callSuicideEvent(final Player player)
|
||||
{
|
||||
EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000);
|
||||
getServer().getPluginManager().callEvent(ede);
|
||||
@@ -198,4 +203,33 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
|
||||
{
|
||||
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)
|
||||
{
|
||||
user.setDisplayNick();
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
//user.sendMessage(_("markedAsNotAway"));
|
||||
|
@@ -17,7 +17,6 @@ public class Commandhelpop extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
user.setDisplayNick();
|
||||
final String message = _("helpOp", user.getPlayer().getDisplayName(), FormatUtil.stripFormat(getFinalArg(args, 0)));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
|
@@ -106,7 +106,6 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
groupString.append(_("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
groupString.append(user.getPlayer().getDisplayName());
|
||||
groupString.append("§f");
|
||||
}
|
||||
@@ -155,7 +154,6 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
onlineUsers.append(_("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
onlineUsers.append(user.getPlayer().getDisplayName());
|
||||
onlineUsers.append("§f");
|
||||
}
|
||||
|
@@ -26,12 +26,11 @@ public class Commandme extends EssentialsCommand
|
||||
{
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
message = FormatUtil.stripColor(message);
|
||||
}
|
||||
|
||||
|
||||
user.setDisplayNick();
|
||||
ess.broadcastMessage(user, _("action", user.getPlayer().getDisplayName(), message));
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,6 @@ public class Commandrealname extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
u.setDisplayNick();
|
||||
final String displayName = FormatUtil.stripFormat(u.getPlayer().getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
if (!whois.equals(displayName)
|
||||
&& !displayName.equals(FormatUtil.stripFormat(settings.getData().getChat().getNicknamePrefix()) + whois)
|
||||
|
@@ -12,7 +12,6 @@ public class Commandsuicide extends EssentialsCommand
|
||||
ess.getPlugin().callSuicideEvent(user.getPlayer());
|
||||
user.getPlayer().damage(Short.MAX_VALUE);
|
||||
user.sendMessage(_("suicideMessage"));
|
||||
user.setDisplayNick();
|
||||
ess.broadcastMessage(user,_("suicideSuccess", user.getPlayer().getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,6 @@ public class Commandwhois extends EssentialsCommand
|
||||
}
|
||||
foundPlayer = true;
|
||||
sender.sendMessage(_("whoisTop", user.getName()));
|
||||
user.setDisplayNick();
|
||||
sender.sendMessage(_("whoisIs", user.getPlayer().getDisplayName(), user.getName()));
|
||||
sender.sendMessage(_("whoisHealth", user.getPlayer().getHealth()));
|
||||
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)
|
||||
{
|
||||
checkGroups();
|
||||
//ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getPlugin().onPluginEnable(event.getPlugin());
|
||||
ess.getCommandHandler().addPlugin(event.getPlugin());
|
||||
if (!Methods.hasMethod() && Methods.setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
@@ -46,7 +46,7 @@ public class EssentialsPluginListener implements Listener, IReload
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
checkGroups();
|
||||
//ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getPlugin().onPluginDisable(event.getPlugin());
|
||||
ess.getCommandHandler().removePlugin(event.getPlugin());
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
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.",
|
||||
"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}";
|
||||
@Comment(
|
||||
{
|
||||
|
@@ -40,8 +40,8 @@ public class User extends UserBase implements IUser
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
/*@Getter
|
||||
@Setter
|
||||
private boolean hidden = false;*/
|
||||
@Setter
|
||||
private boolean hidden = false;*/
|
||||
@Getter
|
||||
private transient boolean vanished;
|
||||
@Getter
|
||||
@@ -211,15 +211,15 @@ public class User extends UserBase implements IUser
|
||||
|
||||
if (displayname.contains("{PREFIX}"))
|
||||
{
|
||||
displayname = displayname.replace("{PREFIX}", groups.getPrefix(this));
|
||||
displayname = displayname.replace("{PREFIX}", addprefixsuffix ? groups.getPrefix(this) : "");
|
||||
}
|
||||
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('&', '\u00a7');
|
||||
displayname = displayname.concat("\u00a7f");
|
||||
displayname = displayname.concat("\u00a7r");
|
||||
|
||||
return displayname;
|
||||
}
|
||||
@@ -250,8 +250,9 @@ public class User extends UserBase implements IUser
|
||||
@Override
|
||||
public void updateDisplayName()
|
||||
{
|
||||
final ISettings settings = ess.getSettings();
|
||||
if (isOnline() && settings.getData().getChat().getChangeDisplayname())
|
||||
final Boolean changeDisplayname = ess.getSettings().getData().getChat().getChangeDisplayname();
|
||||
|
||||
if (isOnline() && (changeDisplayname == true || (changeDisplayname == null && ess.getPlugin().isModuleEnabled("Chat"))));
|
||||
{
|
||||
setDisplayNick();
|
||||
}
|
||||
|
@@ -37,7 +37,6 @@ public class KeywordReplacer implements IText
|
||||
if (sender instanceof IUser)
|
||||
{
|
||||
final IUser user = (IUser)sender;
|
||||
user.setDisplayNick();
|
||||
displayName = user.getPlayer().getDisplayName();
|
||||
userName = user.getPlayer().getName();
|
||||
ipAddress = user.getPlayer().getAddress() == null || user.getPlayer().getAddress().getAddress() == null ? "" : user.getPlayer().getAddress().getAddress().toString();
|
||||
|
Reference in New Issue
Block a user