Skip to content

Commit

Permalink
Version 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
poqdavid committed Mar 18, 2022
1 parent 27271f8 commit aaf4066
Show file tree
Hide file tree
Showing 17 changed files with 432 additions and 118 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ A plugin for crazy cool effects.
NyxCore https://poqdavid.github.io/NyxCore/

## Commands
/nyxeffect <effect> <player>
/nyxeffectlist <option(more / all)>
/nyxeffectcheck <user>
/nyxeffectdisable <user>
/nyxeffect effect <effect> <player>
/nyxeffect list <option(more / all)>
/nyxeffect check <user>
/nyxeffect disable <user>
/nyxeffect particles
/nyxeffect reload

## Premissions
Expand All @@ -27,8 +28,11 @@ NyxCore https://poqdavid.github.io/NyxCore/
NyxCore.Effect.Command.List
NyxCore.Effect.Command.TaskOther
NyxCore.Effect.Command.Reload
NyxCore.Effect.Command.Particles
NyxCore.Effect.Effects.<effectid>

Thanks to [Varijon @ GitHub](https://github.com/Varijon) for helping me with spawning particles using Forge and Pixelmon also allowing me to use part of her code.

**Donate:**
<br/>**BTC Legacy:** 1Q2JQG3iCLZPT2iJfDLow1oQVGKmxheoAh
<br/>**BTC Segwit:** bc1q8gurls0wjkfe43ygmrqmu2pzmyjetnrvgws9sr
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ dependencies {

implementation("javax.validation:validation-api:2.0.1.Final")
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
compile fileTree(dir: 'libs', include: '*.jar')

implementation 'io.github.poqdavid.nyx:NyxCore'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ m_description=A plugin for crazy cool effects

## Version
m_major=1
m_minor=6
m_minor=7
m_api=S7.4
m_suffix=STABLE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

public class CheckCMD implements CommandExecutor {

public static String[] getAlias() {
return new String[]{"check"};
}

public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
final Optional<Player> target = args.getOne("target");
final Optional<String> targets = args.getOne("targets");
Expand All @@ -56,7 +60,7 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
for (String effect : pd) {
try {
final EffectsData ed = Tools.GetEffect(effect);
final Text texts = Text.builder(ed.getName() + " (" + ed.getId() + ")").color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect " + ed.getId()))).onClick(TextActions.runCommand("/nyxeffect " + ed.getId())).build();
final Text texts = Text.builder(ed.getName() + " (" + ed.getId() + ")").color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect effect " + ed.getId()))).onClick(TextActions.runCommand("/nyxeffect effect " + ed.getId())).build();
player.sendMessage(Text.of(TextColors.GOLD, "- ", texts));
} catch (Exception e) {

Expand All @@ -77,7 +81,7 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
for (String effect : pd) {
try {
final EffectsData ed = Tools.GetEffect(effect);
final Text texts = Text.builder(ed.getName() + " (" + ed.getId() + ")").color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect " + ed.getId() + " " + targ.getName()))).onClick(TextActions.runCommand("/nyxeffect " + ed.getId() + " " + targ.getName())).build();
final Text texts = Text.builder(ed.getName() + " (" + ed.getId() + ")").color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect effect " + ed.getId() + " " + targ.getName()))).onClick(TextActions.runCommand("/nyxeffect effect " + ed.getId() + " " + targ.getName())).build();
sender.sendMessage(Text.of(TextColors.GOLD, "- ", texts));
} catch (Exception e) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public class CommandManager {
public static CommandSpec helpCmd;
public static CommandSpec checkCmd;
public static CommandSpec disableCmd;
public static CommandSpec effectCmd;

public static CommandSpec mainCmd;
public static CommandSpec taskCmd;
public static CommandSpec reloadCmd;
public static CommandSpec listCmd;
public static CommandSpec particlesCmd;
private final Game game;
private final NyxEffect ne;

Expand All @@ -66,40 +68,51 @@ public void registerCommands() {
.executor(new ReloadCMD())
.build();

mainCmd = CommandSpec.builder()
.description(Text.of("To enable/disable magic particles"))
.arguments(GenericArguments.optional(GenericArguments.string(Text.of("effect"))), GenericArguments.optional(GenericArguments.playerOrSource(Text.of("player"))))
.executor(new MainCMD())
.child(helpCmd, HelpCMD.getAlias())
.child(reloadCmd, ReloadCMD.getAlias())
effectCmd = CommandSpec.builder()
.description(Text.of("/nyxeffect effect <effect> <player>"))
.arguments(GenericArguments.choices(Text.of("effect"), NyxEffect.EffectCMDs), GenericArguments.optional(GenericArguments.playerOrSource(Text.of("player"))))
.executor(new EffectCMD())
.build();

checkCmd = CommandSpec.builder()
.description(Text.of("nyxeffectcheck your particles status - helpful to see what enabled"))
.description(Text.of("/nyxeffect check your particles status - helpful to see what enabled"))
.arguments(GenericArguments.firstParsing(GenericArguments.flags().buildWith(GenericArguments.firstParsing(GenericArguments.optional(GenericArguments.player(Text.of("target"))), GenericArguments.optional(GenericArguments.string(Text.of("targets")))))))
.executor(new CheckCMD()).build();

disableCmd = CommandSpec.builder()
.description(Text.of("nyxeffectdisable disable your/other particles all of them"))
.description(Text.of("/nyxeffect disable disable your/other particles all of them"))
.arguments(GenericArguments.firstParsing(GenericArguments.flags().buildWith(GenericArguments.firstParsing(GenericArguments.optional(GenericArguments.player(Text.of("target"))), GenericArguments.optional(GenericArguments.string(Text.of("targets")))))))
.executor(new DisableCMD()).build();


taskCmd = CommandSpec.builder()
.description(Text.of("To restart/stop/start effect tasks"))
.description(Text.of("/nyxeffect task To restart/stop/start effect tasks"))
.arguments(GenericArguments.optional(GenericArguments.string(Text.of("task"))), GenericArguments.optional(GenericArguments.string(Text.of("action"))), GenericArguments.optional(GenericArguments.playerOrSource(Text.of("player"))))
.executor(new TaskCMD()).build();

listCmd = CommandSpec.builder()
.description(Text.of("Shows you a list of effects"))
.description(Text.of("/nyxeffect list Shows you a list of effects"))
.arguments(GenericArguments.optional(GenericArguments.string(Text.of("option"))))
.executor(new ListCMD()).build();

Sponge.getCommandManager().register(ne, mainCmd, "nyxeffect");
particlesCmd = CommandSpec.builder()
.description(Text.of("/nyxeffect particles Gives you a list of particles"))
.executor(new ParticlesCMD())
.build();

mainCmd = CommandSpec.builder()
.description(Text.of("/nyxeffect help"))
.executor(new MainCMD())
.child(helpCmd, HelpCMD.getAlias())
.child(reloadCmd, ReloadCMD.getAlias())
.child(effectCmd, EffectCMD.getAlias())
.child(checkCmd, CheckCMD.getAlias())
.child(disableCmd, DisableCMD.getAlias())
.child(listCmd, ListCMD.getAlias())
.child(taskCmd, TaskCMD.getAlias())
.child(particlesCmd, ParticlesCMD.getAlias())
.build();

Sponge.getCommandManager().register(ne, checkCmd, "nyxeffectcheck");
Sponge.getCommandManager().register(ne, disableCmd, "nyxeffectdisable");
Sponge.getCommandManager().register(ne, taskCmd, "nyxeffecttask");
Sponge.getCommandManager().register(ne, listCmd, "nyxeffectlist");
Sponge.getCommandManager().register(ne, mainCmd, "nyxeffect");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

public class DisableCMD implements CommandExecutor {

public static String[] getAlias() {
return new String[]{"disable"};
}

public CommandResult execute(CommandSource sender, CommandContext args) {
final Optional<Player> target = args.getOne("target");

Expand Down
112 changes: 112 additions & 0 deletions src/main/java/io/github/poqdavid/nyx/nyxeffect/Commands/EffectCMD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* This file is part of NyxEffect.
*
* NyxEffect is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NyxEffect is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NyxEffect. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (c) POQDavid <https://github.com/poqdavid/NyxEffect>
* Copyright (c) contributors
*/

package io.github.poqdavid.nyx.nyxeffect.Commands;

import io.github.poqdavid.nyx.nyxcore.Permissions.EffectPermission;
import io.github.poqdavid.nyx.nyxcore.Utils.CoreTools;
import io.github.poqdavid.nyx.nyxeffect.NyxEffect;
import io.github.poqdavid.nyx.nyxeffect.Utils.Data.EffectsData;
import io.github.poqdavid.nyx.nyxeffect.Utils.Tools;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandPermissionException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import org.spongepowered.api.text.format.TextStyles;


public class EffectCMD implements CommandExecutor {

public static String[] getAlias() {
return new String[]{"effect"};
}

public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
final Player player_cmd_src = CoreTools.getPlayer(src);
final Player player_args = args.<Player>getOne("player").orElse(null);
final String effect = args.<String>getOne("effect").orElse(null);


if (effect == null) {
throw new CommandException(Text.of("Sorry effect can't be empty"));
}

EffectsData effectOBJ;
try {
effectOBJ = Tools.GetEffect(effect);
} catch (Exception e) {
throw new CommandException(Text.of("Sorry effect " + effect + " is not available!"));
}

final String effectperm = EffectPermission.EFFECTS + "." + effectOBJ.getId();

if (player_args == null) {
if (player_cmd_src.hasPermission(EffectPermission.COMMAND_EFFECT)) {

if (!player_cmd_src.hasPermission(effectperm)) {
throw new CommandPermissionException(Text.of("You don't have permission to use this effect."));
}

NyxEffect.getInstance().ParticleSelfToggle(player_cmd_src, effectOBJ);
} else {
throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
}

return CommandResult.success();
}

if (player_cmd_src.getUniqueId().equals(player_args.getUniqueId())) {
if (player_cmd_src.hasPermission(EffectPermission.COMMAND_EFFECT)) {

if (!player_cmd_src.hasPermission(effectperm)) {
throw new CommandPermissionException(Text.of("You don't have permission to use this effect."));
}

NyxEffect.getInstance().ParticleSelfToggle(player_cmd_src, effectOBJ);
} else {
throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
}

return CommandResult.success();
} else {
if (src.hasPermission(EffectPermission.COMMAND_EFFECT_OTHER)) {

if (!player_args.hasPermission(effectperm)) {
src.sendMessage(Text.of(TextColors.GOLD, TextStyles.BOLD, "The user " + player_args.getName() + " doesn't have the permission to use this effect! (" + effectperm + ")"));
}

NyxEffect.getInstance().ParticleOtherToggle(src, player_args, effectOBJ);
return CommandResult.success();
} else {
throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
}
// return CommandResult.success();
}
//return CommandResult.success();
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
.contents(
Text.of(TextColors.BLUE, TextStyles.ITALIC, ""),
Text.of(TextColors.GREEN, TextStyles.BOLD, "Commands"),
Text.of("§6- /§7nyxeffect §6<§7effect§6>"),
Text.of("§6- /§7nyxeffectlist §6<§7option(more / all)§6>"),
Text.of("§6- /§7nyxeffectcheck §6<§7user§6>"),
Text.of("§6- /§7nyxeffectdisable §6<§7user§6>")
Text.of("§6- /§7nyxeffect effect §6<§7effect§6> §6<§7player§6>"),
Text.of("§6- /§7nyxeffect list §6<§7option(more / all)§6>"),
Text.of("§6- /§7nyxeffect check §6<§7user§6>"),
Text.of("§6- /§7nyxeffect disable §6<§7user§6>")
)
.padding(Text.of("="))
.sendTo(src);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
import java.util.List;

public class ListCMD implements CommandExecutor {
public static String[] getAlias() {
return new String[]{"list"};
}

public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
final String option = args.<String>getOne("option").orElse("*");

Expand All @@ -57,12 +61,12 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm

try {
if (pd_player.contains(effect.getEffectsData().getId())) {
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GREEN).onHover(TextActions.showText(Text.of("/nyxeffect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect " + effect.getEffectsData().getId())).build();
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GREEN).onHover(TextActions.showText(Text.of("/nyxeffect effect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect effect " + effect.getEffectsData().getId())).build();
} else {
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect " + effect.getEffectsData().getId())).build();
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect effect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect effect " + effect.getEffectsData().getId())).build();
}
} catch (Exception ex) {
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect " + effect.getEffectsData().getId())).build();
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect effect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect effect " + effect.getEffectsData().getId())).build();

}

Expand Down Expand Up @@ -91,9 +95,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
if (src.hasPermission(effectperm)) {
Text texts;
if (pd_player.contains(effect.getEffectsData().getId())) {
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GREEN).onHover(TextActions.showText(Text.of("/nyxeffect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect " + effect.getEffectsData().getId())).build();
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GREEN).onHover(TextActions.showText(Text.of("/nyxeffect effect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect effect " + effect.getEffectsData().getId())).build();
} else {
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect " + effect.getEffectsData().getId())).build();
texts = Text.builder(effect.getEffectsData().getName() + " (" + effect.getEffectsData().getId() + ")").style(TextStyles.BOLD).color(TextColors.GRAY).onHover(TextActions.showText(Text.of("/nyxeffect effect " + effect.getEffectsData().getId()))).onClick(TextActions.runCommand("/nyxeffect effect " + effect.getEffectsData().getId())).build();
}

src.sendMessage(Text.of(TextColors.GOLD, "- ", texts));
Expand Down
Loading

0 comments on commit aaf4066

Please sign in to comment.