Skip to content

Commit

Permalink
Merge pull request #385 from AddstarMC/green_dev
Browse files Browse the repository at this point in the history
All dev changes from GreenSurvivors.. again!
  • Loading branch information
addstar committed Mar 6, 2024
2 parents 0e5300b + cf22602 commit 657057c
Show file tree
Hide file tree
Showing 104 changed files with 1,131 additions and 754 deletions.
22 changes: 16 additions & 6 deletions Minigames/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.5</version>
<version>1.0.7</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -132,6 +132,16 @@
<include>config.yml</include>
<include>*.properties</include>
<include>presets/*.yml</include>
</includes>
</resource>
<!-- With maven-resources-plugin(shipped with maven 3.9.0+
filtering binary / compressed data breaks since it assumes UTF-8.
We don't need filtering of it anyway.-->
<resource>
<targetPath>.</targetPath>
<filtering>false</filtering>
<directory>src/main/resources</directory>
<includes>
<include>resourcepack/*.zip</include>
</includes>
</resource>
Expand All @@ -152,7 +162,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.1</version>
<configuration>
<filters>
<filter>
Expand Down Expand Up @@ -200,7 +210,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -214,7 +224,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
<version>3.2.1</version>
<configuration>
<skipTests>true</skipTests>
<forkCount>1</forkCount>
Expand All @@ -224,12 +234,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.8.1</version>
<version>2.16.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
65 changes: 48 additions & 17 deletions Minigames/src/main/java/au/com/mineauz/minigames/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
Expand All @@ -48,7 +49,7 @@ public class Events implements Listener {
private final MinigameManager mdata = plugin.getMinigameManager();

@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerResourcePack(PlayerResourcePackStatusEvent event) {
public void onPlayerResourcePack(PlayerResourcePackStatusEvent event) { //todo 1.20.3 + add ressource pack not set
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
List<MinigamePlayer> required = plugin.getPlayerManager().getApplyingPack();
if (ply.isInMinigame()) {
Expand Down Expand Up @@ -177,7 +178,7 @@ public void onPlayerDisconnect(PlayerQuitEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply.isInMinigame()) {
if (ply.getPlayer().isDead()) {
ply.getOfflineMinigamePlayer().setLoginLocation(ply.getMinigame().getQuitPosition());
ply.getOfflineMinigamePlayer().setLoginLocation(ply.getMinigame().getQuitLocation());
ply.getOfflineMinigamePlayer().savePlayerData();
}
pdata.quitMinigame(pdata.getMinigamePlayer(event.getPlayer()), false);
Expand Down Expand Up @@ -243,7 +244,7 @@ public void onPlayerConnect(PlayerJoinEvent event) {
}

@EventHandler
public void playerInterract(PlayerInteractEvent event) {
public void playerInteract(PlayerInteractEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());

if (ply.isInMinigame() && !ply.canInteract()) {
Expand All @@ -252,11 +253,11 @@ public void playerInterract(PlayerInteractEvent event) {
}
if (ply.isInMenu() && ply.getNoClose() && ply.getManualEntry() != null) {
event.setCancelled(true);
ply.setNoClose(false);
if (event.getClickedBlock() != null) {
ply.setNoClose(false);
ply.getManualEntry().checkValidEntry(event.getClickedBlock().getBlockData().getAsString());
ply.setManualEntry(null);
}
ply.setManualEntry(null);
return;
}
if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.DRAGON_EGG) {
Expand All @@ -271,6 +272,7 @@ public void playerInterract(PlayerInteractEvent event) {
if (cblock.getState() instanceof Sign sign && sign.getSide(Side.FRONT).getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[Minigame]")) {
// wax signs automatically
sign.setWaxed(true);
sign.update();
if (event.getPlayer().hasPermission("minigame.sign.use.details")) {
if ((sign.getLine(1).equalsIgnoreCase(ChatColor.GREEN + "Join") || sign.getLine(1).equalsIgnoreCase(ChatColor.GREEN + "Bet")) && !ply.isInMinigame()) {
Minigame mgm = mdata.getMinigame(sign.getLine(2));
Expand Down Expand Up @@ -380,7 +382,6 @@ public void playerInterract(PlayerInteractEvent event) {
}
}


//Spectator disables:
if (ply.isInMinigame() && pdata.getMinigamePlayer(event.getPlayer()).getMinigame().isSpectator(pdata.getMinigamePlayer(event.getPlayer()))) {
event.setCancelled(true);
Expand Down Expand Up @@ -458,7 +459,11 @@ private void entityDamageEntity(EntityDamageByEntityEvent event) {
if (sb.getShooter() instanceof Player player) {
MinigamePlayer shooter = pdata.getMinigamePlayer(player);
Minigame mgm = ply.getMinigame();
if (shooter == null) return;

if (shooter == null) {
return;
}

if (shooter.isInMinigame() && shooter.getMinigame().equals(ply.getMinigame())) {
if (!shooter.canPvP()) {
event.setCancelled(true);
Expand Down Expand Up @@ -627,13 +632,14 @@ private void spectatorAttack(EntityDamageByEntityEvent event) {

@EventHandler(ignoreCancelled = true)
private void clickMenu(InventoryClickEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer((Player) event.getWhoClicked());
if (ply.isInMenu()) {
if (event.getRawSlot() < ply.getMenu().getSize()) {
if (!ply.getMenu().getAllowModify() || ply.getMenu().hasMenuItem(event.getRawSlot()))
MinigamePlayer mgPlayer = pdata.getMinigamePlayer(((Player) event.getWhoClicked()));
if (mgPlayer.isInMenu()) {
if (event.getRawSlot() < mgPlayer.getMenu().getSize()) {
if (!mgPlayer.getMenu().getAllowModify() || mgPlayer.getMenu().hasMenuItem(event.getRawSlot())) {
event.setCancelled(true);
}

MenuItem item = ply.getMenu().getClicked(event.getRawSlot());
MenuItem item = mgPlayer.getMenu().getClicked(event.getRawSlot());
if (item != null) {
ItemStack disItem = null;
switch (event.getClick()) {
Expand All @@ -651,12 +657,38 @@ private void clickMenu(InventoryClickEvent event) {

event.setCurrentItem(disItem);
}
/*
* Cancel special cases, where event.getRawSlot() is not in the Menu inventory,
* but the event modifies it anyway
*/
} else if (!mgPlayer.getMenu().getAllowModify()) {
Inventory topInv = event.getView().getTopInventory();
switch (event.getAction()) {
case PICKUP_ALL, PICKUP_SOME, PICKUP_HALF, PICKUP_ONE, DROP_ALL_SLOT, DROP_ONE_SLOT, HOTBAR_MOVE_AND_READD, // may take
PLACE_ALL, PLACE_SOME, PLACE_ONE, /*may place*/
SWAP_WITH_CURSOR, HOTBAR_SWAP /*may give and take*/ -> {
if (event.getClickedInventory() == topInv) {
event.setCancelled(true);
}
}
case COLLECT_TO_CURSOR -> { // may take complex
if (topInv.contains(event.getCursor().getType())) {
event.setCancelled(true);
}
}
case MOVE_TO_OTHER_INVENTORY -> {
event.setCancelled(true);
} // definitely one or the other
default -> {
} // do nothing for any other action
}
}
} else if (ply.isInMinigame()) {
if (!ply.getLoadout().allowOffHand() && event.getSlot() == 40) {

} else if (mgPlayer.isInMinigame()) {
if (!mgPlayer.getLoadout().allowOffHand() && event.getSlot() == 40) {
event.setCancelled(true);
} else if ((ply.getLoadout().isArmourLocked() && event.getSlot() >= 36 && event.getSlot() <= 39) ||
(ply.getLoadout().isInventoryLocked() && event.getSlot() >= 0 && event.getSlot() <= 35)) {
} else if ((mgPlayer.getLoadout().isArmourLocked() && event.getSlot() >= 36 && event.getSlot() <= 39) ||
(mgPlayer.getLoadout().isInventoryLocked() && event.getSlot() >= 0 && event.getSlot() <= 35)) {
event.setCancelled(true);
}
}
Expand Down Expand Up @@ -715,7 +747,6 @@ private void manualItemEntry(AsyncPlayerChatEvent event) {
ply.getManualEntry().checkValidEntry(event.getMessage());
ply.setManualEntry(null);
}

}

@EventHandler(ignoreCancelled = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public enum MinigameMessageType {
INFO,
WARN,
ERROR,
WIN,
LOSS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,9 @@ public static MinigameTool giveMinigameTool(MinigamePlayer player) {
*/
public static boolean hasMinigameTool(MinigamePlayer player) {
for (ItemStack i : player.getPlayer().getInventory().getContents()) {
if (i != null && i.getItemMeta() != null) {
if (i.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Minigame Tool")) {
return true;
}
if (i != null && i.getItemMeta() != null &&
i.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Minigame Tool")) {
return true;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package au.com.mineauz.minigames;

import au.com.mineauz.minigames.backend.BackendManager;
import au.com.mineauz.minigames.blockRecorder.BasicRecorder;
import au.com.mineauz.minigames.commands.CommandDispatcher;
import au.com.mineauz.minigames.config.MinigameSave;
import au.com.mineauz.minigames.display.DisplayManager;
Expand All @@ -14,6 +13,7 @@
import au.com.mineauz.minigames.minigame.reward.RewardsModule;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import au.com.mineauz.minigames.objects.ResourcePack;
import au.com.mineauz.minigames.recorder.BasicRecorder;
import au.com.mineauz.minigames.signs.SignBase;
import au.com.mineauz.minigames.stats.MinigameStats;
import au.com.mineauz.minigames.stats.StatValueField;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import au.com.mineauz.minigames.MinigameUtils;
import au.com.mineauz.minigames.Minigames;
import au.com.mineauz.minigames.blockRecorder.RecorderData;
import au.com.mineauz.minigames.minigame.Minigame;
import au.com.mineauz.minigames.minigame.MinigameState;
import au.com.mineauz.minigames.recorder.RecorderData;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

Expand Down Expand Up @@ -64,7 +64,7 @@ public boolean onCommand(CommandSender sender, Minigame minigame,
minigame = Minigames.getPlugin().getMinigameManager().getMinigame(args[0]);
if (!minigame.getRegenRegions().isEmpty()) {
if (args.length == 1) {
if (minigame.getPlayers().size() == 0) {
if (minigame.getPlayers().isEmpty()) {
minigame.setState(MinigameState.REGENERATING);
Minigames.getPlugin().getMinigameManager().addRegenDataToRecorder(minigame);
RecorderData d = minigame.getRecorderData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public static void registerCommand(ICommand command) {

public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
Player ply = null;
if (sender instanceof Player) {
ply = (Player) sender;
if (sender instanceof Player player) {
ply = player;
}

if (args != null && args.length > 0) {
Expand Down Expand Up @@ -222,11 +222,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
sender.sendMessage(ChatColor.RED + comd.getPermissionMessage());
sender.sendMessage(ChatColor.RED + comd.getPermission());
}
return true;
} else {
sender.sendMessage(ChatColor.RED + "You must be a player to execute this command!");
return true;
}
return true;
}
} else {
sender.sendMessage(ChatColor.GREEN + "Minigames");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,32 @@
import java.util.List;

public interface ICommand {
// public MinigamePlayerManager playerManager = Minigames.plugin.getPlayerData();
// public MinigameManager minigameManager = Minigames.plugin.getMinigameData();
Minigames plugin = Minigames.getPlugin();

/**
* get the name of this (sub) command
* the name get used as it's first parameter
* in case of the command /mg the set subcommand /mg set implements this interface,
* as well as every sub-subcommand of it. set is the name of this specific subcommand
* and the name of all the ones one layer down are its parameters.
*/
String getName();

/**
* Get the aliases to the name of this command.
* An alias is an alternative name that should also show up as a parameter
* but calls the same command.
*/
String[] getAliases();

/**
* If the command can be called from the console or if it is strictly only callable by a player
*/
boolean canBeConsole();

/**
* Used in help command to describe what this (sub)command does.
*/
String getDescription();

String[] getParameters();
Expand Down
Loading

0 comments on commit 657057c

Please sign in to comment.