Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Code] Ajout de la commande /prout #21

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/fr/communaywen/core/AywenCraftPlugin.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package fr.communaywen.core;

import fr.communaywen.core.commands.ProutCommand;
import fr.communaywen.core.utils.MOTDChanger;
import fr.communaywen.core.commands.VersionCommand;
import fr.communaywen.core.utils.PermissionCategory;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

public final class AywenCraftPlugin extends JavaPlugin {

Expand All @@ -21,6 +26,10 @@ public void onEnable() {


this.getCommand("version").setExecutor(new VersionCommand(this));

final @Nullable PluginCommand proutCommand = super.getCommand("prout");
if (proutCommand != null)
proutCommand.setExecutor(new ProutCommand());
}

@Override
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/fr/communaywen/core/commands/ProutCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package fr.communaywen.core.commands;

import fr.communaywen.core.utils.PermissionCategory;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* THE Prout command.
*
* Usage: /prout
* Permission: PREFIX.command.prout
*/
public final class ProutCommand implements CommandExecutor {

@Override
public boolean onCommand(final @NotNull CommandSender sender,
final @NotNull Command command,
final @NotNull String args,
final @NotNull String[] strings) {
if (sender instanceof Player player) {
player.sendMessage("§2Beuuurk, ça pue !");

// Make the player jump
final Vector currentVelocity = player.getVelocity();
currentVelocity.setY(0.55d);

player.setVelocity(currentVelocity);

// Spawn some cloud particles
final Location location = player.getLocation();
final @Nullable World world = location.getWorld();

if (world != null) {
world.spawnParticle(org.bukkit.Particle.CLOUD, location, 3, 0.02d, -0.04d, 0.02d, 0.09d);

// Funny sound!
world.playSound(location, org.bukkit.Sound.ENTITY_VILLAGER_NO, 0.8f, 2.3f);
world.playSound(location, Sound.ENTITY_GOAT_EAT, 0.7f, 0.2f);
}
}

return true;
}
}
6 changes: 6 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ commands:
description: Affiche la version du plugin.
permission: ayw.version
permission-message: "Vous n'avez pas la permission d'utiliser cette commande."
prout:
description: Prout !
permission: ayw.command.prout

permissions:
ayw.admin.version:
description: Permission pour utiliser la commande /version
default: op
ayw.command.prout:
description: 'Prout !'
default: true
Loading