Skip to content

Commit

Permalink
UPDATE & FEATURE | Add 1.18 support and make the command name changeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Xapu1337 committed Jan 23, 2022
1 parent e6ea4e5 commit ad2a335
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.xapu1337.recodes</groupId>
<artifactId>trollgui</artifactId>
<version>2.0</version>
<version>2.01</version>
<packaging>jar</packaging>

<name>TrollGUI</name>
Expand Down Expand Up @@ -103,13 +103,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>8.4.0</version>
<version>8.6.0.0.1</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
Expand All @@ -120,7 +120,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<version>22.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ public static boolean isNumeric(String str) { // Surely not stolen.... xd
}

public TrollCommand(CommandMap commandMap, JavaPlugin plugin) {
super(plugin, "troll");
super(plugin, Core.instance.utils.getString("Variables.commands.troll.name", "ms3").replaceAll("\\s", ""));
Arrays.asList("Messages", "Variables", "MenuTitles", "MenuItems").forEach(keys::remove);

addDescription("");
// addUsage("");
if(Core.instance.getConfig().getBoolean("Variables.commands.troll.alias.enabled"))
addAliases(Arrays.stream(Core.instance.getConfig().getStringList("Variables.commands.troll.alias.aliases").toArray(new String[0])).map(a -> a.replaceAll("\\s", "")).toArray(String[]::new));
addPermission("ms3.use");
addPermissionMessage(Objects.requireNonNull(Core.instance.utils.getConfigPath("Messages.missingPermissions", true)));
registerCommand(commandMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,6 @@ public void onInventoryClicked(InventoryClickEvent event) {
case 32:
new ThunderPlayerTroll(caller, victim).execute();
break;





case 53:
caller.openInventory(new PlayerSelector(caller).getInventory());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ItemStack createItem(final XMaterial xMat, final Boolean isEnchanted , fi

meta.setDisplayName(name);
if(isEnchanted){
meta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, true);
meta.addEnchant(XEnchantment.DURABILITY.getEnchant(), 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
// Set the lore of the ite
Expand All @@ -38,6 +38,13 @@ public String getConfigPath(String path){
return ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Core.instance.getConfig().getString(path)));
}


public String getString(String path, String defaultString){
String configString = Core.instance.getConfig().getString(path);
if(configString == null || configString.length() == 0 ) return defaultString;
else return configString;
}

public String getConfigPath(String path, boolean withPrefix){
return ChatColor.translateAlternateColorCodes('&', (withPrefix ? ( getConfigPath("Variables.prefix") + getConfigPath(path)) : (getConfigPath(path))));
}
Expand Down
38 changes: 25 additions & 13 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# /$$$$$$$$/$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$ /$$ /$$$$$$
# |__ $$__/ $$__ $$ /$$__ $$| $$ | $$ /$$__ $$| $$ | $$|_ $$_/
# | $$__/ $$__ $$ /$$__ $$| $$ | $$ /$$__ $$| $$ | $$|_ $$_/
# | $$ | $$ \ $$| $$ \ $$| $$ | $$ | $$ \__/| $$ | $$ | $$
# | $$ | $$$$$$$/| $$ | $$| $$ | $$ | $$ /$$$$| $$ | $$ | $$
# | $$ | $$__ $$| $$ | $$| $$ | $$ | $$|_ $$| $$ | $$ | $$
Expand All @@ -13,13 +13,25 @@ Variables:
prefix: '&9&lMS3 &8| &7'
enableSneakRightClickSelection: false # Allows shift right-clicking a player to open the troll menu.
advancedPermission:
# Basically, this is a check that doesn't have to check if the player has the permission "ms3.use"
# Basically, this is a check that doesn't have to check if the player has the permission 'ms3.use'
# It checks if the player name has the name then it allows it. Useful if you want to limit the TrollGUI just for you.
name: 'Steve' # If your server is in offline mode then the player must join before
enabled: false
# Used for the commands names (e.g. /troll)
# Note: Try not to use commands that are already used this will cause either errors or just use the plugin that loads firstly
# Note: If the name is invalid it will fallback to "ms3"
commands:
troll:
name: 'ms3'
# Used for additional command names that do the same thing
alias:
enabled: false
aliases:
- 'mysystem3'


MenuTitles:
trollGUI: "&8x &9&lMS3&8 - &7%VICTIM% &8x" # Possible placeholders: %PLAYER% - Player that opened the menu, %VICTIM% - The player that is being trolled.
trollGUI: '&8x &9&lMS3&8 - &7%VICTIM% &8x' # Possible placeholders: %PLAYER% - Player that opened the menu, %VICTIM% - The player that is being trolled.
selectPlayer: '&8x &9Select a player &8x'
settings: '&8x &9Select settings &8x'

Expand All @@ -28,9 +40,9 @@ Messages:
missingPermissions: '&cYou''re missing the permissions "ms3.use"'
reloaded: '&cReloaded the configuration successfully.'
noItemInHand: '&7Player &b%PLAYER%&7 isn''t holding an item in their hand.'
alreadyOnFirstPage: "&cYou are already on the first page."
alreadyOnLastPage: "&cYou are already on the last page."
playerNotAvaliable: "&cPlayer either disconnected or is not available"
alreadyOnFirstPage: '&cYou are already on the first page.'
alreadyOnLastPage: '&cYou are already on the last page.'
playerNotAvaliable: '&cPlayer either disconnected or is not available'

MenuItems:
trollMenu:
Expand Down Expand Up @@ -109,16 +121,16 @@ MenuItems:
settingsMenu:
reload:
name: '&cReload the current configuration.'
lore: '&7Reload the current config, Without needing to reload the server.'
lore: '&7Reload the current config, Without needing to reload the server. (Note: If you change command names you MUST reload the server to make them work)'
playerSelector:
close:
name: "&cCLOSE"
lore: "&7Close this menu"
name: '&cCLOSE'
lore: '&7Close this menu'
left:
name: "&8← &7BACK"
lore: "&7Go one back"
name: '&8← &7BACK'
lore: '&7Go one back'
right:
name: "&7NEXT &8→"
lore: "&7Go to the next page"
name: '&7NEXT &8→'
lore: '&7Go to the next page'
extras:
hasOP: '&7This player is &coperator&7.'

0 comments on commit ad2a335

Please sign in to comment.