mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-28 11:19:24 +00:00
Send rewards, only update move if block changed, add /rpgregions add
This commit is contained in:
@@ -3,13 +3,43 @@ package net.islandearth.rpgregions.commands;
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import net.islandearth.rpgregions.RPGRegions;
|
||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@CommandAlias("rpgregions")
|
||||
public class RPGRegionsCommand extends BaseCommand {
|
||||
|
||||
|
||||
private final RPGRegions plugin;
|
||||
|
||||
public RPGRegionsCommand(RPGRegions plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
public void onDefault(Player player, String[] args) {
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("add")
|
||||
public void onAdd(Player player, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1: {
|
||||
String region = args[0];
|
||||
ConfiguredRegion configuredRegion = new ConfiguredRegion(region, new ArrayList<>());
|
||||
plugin.getManagers().getRegionsCache().addConfiguredRegion(configuredRegion);
|
||||
player.sendMessage(ChatColor.GREEN + "Added configured region " + region + "!");
|
||||
player.sendMessage(ChatColor.YELLOW + "" + ChatColor.ITALIC+ "Now use /rpgregions edit " + region + " to edit it!");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
player.sendMessage(ChatColor.RED + "Usage: /rpgregions add <region>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,12 @@ public class MoveListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent pme) {
|
||||
int x = pme.getTo().getBlockX();
|
||||
int z = pme.getTo().getBlockZ();
|
||||
int oldX = pme.getFrom().getBlockX();
|
||||
int oldZ = pme.getFrom().getBlockZ();
|
||||
if (x == oldX && z == oldZ) return;
|
||||
|
||||
plugin.getManagers().getIntegrationManager().handleMove(pme);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.islandearth.rpgregions.listener;
|
||||
import net.islandearth.rpgregions.RPGRegions;
|
||||
import net.islandearth.rpgregions.api.event.RegionDiscoverEvent;
|
||||
import net.islandearth.rpgregions.api.event.RegionsEnterEvent;
|
||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||
import net.islandearth.rpgregions.managers.data.region.Discovery;
|
||||
import net.islandearth.rpgregions.managers.data.region.WorldDiscovery;
|
||||
import net.islandearth.rpgregions.translation.Translations;
|
||||
@@ -51,21 +52,24 @@ public class RegionListener implements Listener {
|
||||
public void onDiscover(RegionDiscoverEvent rde) {
|
||||
Player player = rde.getPlayer();
|
||||
String region = rde.getRegion();
|
||||
player.sendTitle(
|
||||
Translations.DISCOVERED_TITLE.get(player, region),
|
||||
Translations.DISCOVERED_SUBTITLE.get(player, region),
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.title.fadein"),
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.title.stay"),
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.title.fadeout")
|
||||
);
|
||||
|
||||
player.playSound(
|
||||
player.getLocation(),
|
||||
Sound.valueOf(plugin.getConfig().getString("settings.server.discoveries.discovered.sound.name")),
|
||||
1,
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.sound.pitch")
|
||||
);
|
||||
if (plugin.getManagers().getRegionsCache().getConfiguredRegions().containsKey(region)) {
|
||||
player.sendTitle(
|
||||
Translations.DISCOVERED_TITLE.get(player, region),
|
||||
Translations.DISCOVERED_SUBTITLE.get(player, region),
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.title.fadein"),
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.title.stay"),
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.title.fadeout")
|
||||
);
|
||||
|
||||
//TODO give rewards
|
||||
player.playSound(
|
||||
player.getLocation(),
|
||||
Sound.valueOf(plugin.getConfig().getString("settings.server.discoveries.discovered.sound.name")),
|
||||
1,
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.sound.pitch")
|
||||
);
|
||||
|
||||
ConfiguredRegion configuredRegion = plugin.getManagers().getRegionsCache().getConfiguredRegion(region);
|
||||
configuredRegion.getRewards().forEach(reward -> reward.award(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user