Skip to content

Commit

Permalink
Worked on #117
Browse files Browse the repository at this point in the history
Added /removename
  • Loading branch information
JustBru00 committed Sep 9, 2022
1 parent 1dcfbbc commit ea9803c
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/justb/Documents/Coding/Test_Server_1.17/plugins/Vault.jar"/>
<classpathentry kind="lib" path="C:/Users/justb/Documents/Coding/Test_Server_1.17/spigot-1.17.1.jar">
<attributes>
Expand Down
1 change: 1 addition & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=1.8
85 changes: 85 additions & 0 deletions src/com/gmail/justbru00/epic/rename/commands/v3/RemoveName.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* @author Justin "JustBru00" Brubaker
*
* This is licensed under the MPL Version 2.0. See license info in LICENSE.txt
*/
package com.gmail.justbru00.epic.rename.commands.v3;

import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.ItemMeta;

import com.gmail.justbru00.epic.rename.enums.v3.EpicRenameCommands;
import com.gmail.justbru00.epic.rename.main.v3.Main;
import com.gmail.justbru00.epic.rename.utils.v3.Blacklists;
import com.gmail.justbru00.epic.rename.utils.v3.MaterialPermManager;
import com.gmail.justbru00.epic.rename.utils.v3.Messager;
import com.gmail.justbru00.epic.rename.utils.v3.RenameUtil;
import com.gmail.justbru00.epic.rename.utils.v3.WorldChecker;

public class RemoveName implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (command.getName().equalsIgnoreCase("removename")) {
if (sender.hasPermission("epicrename.removename")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (WorldChecker.checkWorld(player)) {

// Check Material Permissions
if (!MaterialPermManager.checkPerms(EpicRenameCommands.REMOVENAME, RenameUtil.getInHand(player), player)) {
Messager.msgPlayer(Main.getMsgFromConfig("removename.no_permission_for_material"), player);
return true;
}

// Check Blacklist
if (!Blacklists.checkMaterialBlacklist(RenameUtil.getInHand(player).getType(), player)) {
Messager.msgPlayer(Main.getMsgFromConfig("removename.blacklisted_material_found"), player);
return true;
}

// Check Existing Name Blacklist
if (!Blacklists.checkExistingName(player)) {
Messager.msgPlayer(Main.getMsgFromConfig("removename.blacklisted_existing_name_found"), player);
return true;
}

// Check Existing Lore Blacklist
if (!Blacklists.checkExistingLore(player)) {
Messager.msgPlayer(Main.getMsgFromConfig("removename.blacklisted_existing_lore_found"), player);
return true;
}

if (RenameUtil.getInHand(player).getType() == Material.AIR) {
Messager.msgPlayer(Main.getMsgFromConfig("removename.cannot_edit_air"), player);
return true;
}
ItemMeta im = RenameUtil.getInHand(player).getItemMeta();
im.setDisplayName(null);
RenameUtil.getInHand(player).setItemMeta(im);
Messager.msgPlayer(Main.getMsgFromConfig("removename.success"), player);
return true;

} else {
Messager.msgSender(Main.getMsgFromConfig("removename.disabled_world"), sender);
return true;
}
} else {
Messager.msgSender(Main.getMsgFromConfig("removename.wrong_sender"), sender);
return true;
}
} else {
Messager.msgSender(Main.getMsgFromConfig("removename.no_permission"), sender);
return true;
}
}

return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,17 @@ public static void updateMessagesYml() {
"&aYou confirmed that it is okay to post your item(s) publicly. You can now use /export normally until the next server restart.");
updateMessagesYmlString("export.no_air", "&cYou cannot export nothing.");

// /removename
updateMessagesYmlString("removename.no_permission", "&cSorry you don''t have permission to perform that command.");
updateMessagesYmlString("removename.wrong_sender", "&cSorry only a player can use that command.");
updateMessagesYmlString("removename.disabled_world", "&cYou are in a disabled world.");
updateMessagesYmlString("removename.blacklisted_material_found", "&cSorry that material is blacklisted.");
updateMessagesYmlString("removename.blacklisted_existing_name_found", "&cSorry that item has an existing name that is blacklisted.");
updateMessagesYmlString("removename.blacklisted_existing_lore_found", "&cSorry that item has an existing line of lore that is blacklisted.");
updateMessagesYmlString("removename.cannot_edit_air", "&cSorry you can''t edit nothing.");
updateMessagesYmlString("removename.no_permission_for_material", "&cSorry you don''t have permission for that material.");
updateMessagesYmlString("removename.success", "&aRemoved the display name from the item successfully.");

// rename_character_limit
updateMessagesYmlString("rename_character_limit.name_too_long",
"&cSorry that name is too long. The character limit is {char}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/
public class ConfigurationManager {

public static final int CONFIG_VERSION = 10;
public static final int MESSAGES_VERSION = 15;
public static final int CONFIG_VERSION = 11;
public static final int MESSAGES_VERSION = 16;
private static FileConfiguration config = null;
private static PluginFile messages = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public enum EpicRenameCommands {

RENAME, LORE, EPICRENAME, SETLORELINE,
REMOVELORELINE, INSERTLORELINE, GLOW, REMOVEGLOW, ALIGN, EXPORT, IMPORT;
REMOVELORELINE, INSERTLORELINE, GLOW, REMOVEGLOW, ALIGN, EXPORT, IMPORT, REMOVENAME;


public static String getStringName(EpicRenameCommands e) {
Expand All @@ -24,6 +24,7 @@ public static String getStringName(EpicRenameCommands e) {
case ALIGN: {return "align";}
case EXPORT: {return "export";}
case IMPORT: {return "import";}
case REMOVENAME: {return "removename";}
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/gmail/justbru00/epic/rename/main/v3/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.gmail.justbru00.epic.rename.commands.v3.Lore;
import com.gmail.justbru00.epic.rename.commands.v3.RemoveGlow;
import com.gmail.justbru00.epic.rename.commands.v3.RemoveLoreLine;
import com.gmail.justbru00.epic.rename.commands.v3.RemoveName;
import com.gmail.justbru00.epic.rename.commands.v3.Rename;
import com.gmail.justbru00.epic.rename.commands.v3.SetLoreLine;
import com.gmail.justbru00.epic.rename.configuration.ConfigurationManager;
Expand Down Expand Up @@ -142,8 +143,7 @@ public void onEnable() {
getCommand("removeglow").setExecutor(new RemoveGlow());
getCommand("import").setExecutor(new Import());;
getCommand("export").setExecutor(new Export());

// Issue #161 - Removed MC Stats
getCommand("removename").setExecutor(new RemoveName());

// Start bstats
BStats bstats = new BStats(this, BSTATS_PLUGIN_ID);
Expand Down
4 changes: 2 additions & 2 deletions src/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#EpicRename by Justin Brubaker. https://www.spigotmc.org/resources/epicrename.4341/
#Version 3.8+
#Version 3.11+

#DO NOT CHANGE THIS PLEASE
config_version: 10
config_version: 11

#Plugin Prefix
prefix: '&8[&bEpic&fRename&8] &f'
Expand Down
17 changes: 14 additions & 3 deletions src/messages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#EpicRename messages.yml generated by version 3.10.3+
messages_yml_version: 15
#EpicRename messages.yml generated by version 3.11+
messages_yml_version: 16

epicrename:
no_permission: '&cSorry you don''t have permission to perform that command.'
Expand Down Expand Up @@ -147,7 +147,18 @@ export:
post_fail: '&cFailed to post to EpicRenameOnline: {error}'
confirmed: '&aYou confirmed that it is okay to post your item(s) publicly. You can now use /export normally until the next server restart.'
no_air: '&cYou cannot export nothing.'


removename:
no_permission: '&cSorry you don''t have permission to perform that command.'
wrong_sender: '&cSorry only a player can use that command.'
disabled_world: '&cYou are in a disabled world.'
blacklisted_material_found: '&cSorry that material is blacklisted.'
blacklisted_existing_name_found: '&cSorry that item has an existing name that is blacklisted.'
blacklisted_existing_lore_found: '&cSorry that item has an existing line of lore that is blacklisted.'
cannot_edit_air: '&cSorry you can''t edit nothing.'
no_permission_for_material: '&cSorry you don''t have permission for that material.'
success: '&aRemoved the display name from the item successfully.'

rename_character_limit:
name_too_long: '&cSorry that name is too long. The character limit is {char}.'
bypass_msg: '&aYou just bypassed the character limit of {char}.'
Expand Down
20 changes: 19 additions & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: EpicRename
main: com.gmail.justbru00.epic.rename.main.v3.Main
version: '3.10.3'
version: '3.11-INDEV'
description: Performs different item modifications with easy to use commands.
authors: [Justin Brubaker,JustBru00,jayoevans]
softdepend: [Vault]
Expand Down Expand Up @@ -37,6 +37,9 @@ commands:
export:
description: Exports items to EpicRenameOnline.
aliases: [epexport]
removename:
description: Removes the display name from an item.
aliases: [epremovename]

permissions:
epicrename.epicrename:
Expand Down Expand Up @@ -276,6 +279,13 @@ permissions:

epicrename.export:
description: Allows access to the /export command. This command allows the player to export their items to be used on another server with EpicRename installed with just a link.

epicrename.removename:
description: Basic permission for the /removename command.
epicrename.removename.material.MATERIAL_HERE:
description: Placeholder permission. Use an actual bukkit material for this permission to work. Ex. epicrename.removename.material.STONE
epicrename.removename.material.*:
description: Allows all materials for the /removename command.

epicrename.bypass.charlimit:
description: Allows the user to bypass the character limit set for /rename.
Expand Down Expand Up @@ -421,6 +431,7 @@ permissions:
epicrename.removeglow.*: true
epicrename.import: true
epicrename.export: true
epicrename.removename.*: true

epicrename.poweruser:
description: Provides the user permission for all materials and all formatting codes for all commands except for /import, /epicrename reload, or /epicrename debug. Does not provide bypass permissions. Use epicrename.bypass.* for that.
Expand All @@ -434,6 +445,7 @@ permissions:
epicrename.glow.*: true
epicrename.removeglow.*: true
epicrename.export: true
epicrename.removename.*: true

epicrename.rename.*:
description: Provides the user permission for all materials and all formatting codes for /rename. Also provides basic permission epicrename.rename.
Expand Down Expand Up @@ -462,6 +474,12 @@ permissions:
epicrename.removeloreline: true
epicrename.removeloreline.material.*: true

epicrename.removename.*:
description: Provides the user permission for all materials for /removename. Also provides basic permission epicrename.removename.
children:
epicrename.removename: true
epicrename.removename.material.*: true

epicrename.insertloreline.*:
description: Provides the user permission for all materials and all formatting codes for /insertloreline. Also provides basic permission epicrename.insertloreline.
children:
Expand Down

0 comments on commit ea9803c

Please sign in to comment.