Skip to content

Commit

Permalink
Fixed rewards and some other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Despical committed Jun 24, 2023
1 parent b26b939 commit 422d57a
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The project isn't in the Central Repository yet, so specifying a repository is n
<dependency>
<groupId>com.github.Despical</groupId>
<artifactId>OITC</artifactId>
<version>2.3.9</version>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -56,7 +56,7 @@ repositories {
```
```
dependencies {
compileOnly group: "com.github.Despical", name: "OITC", version: "2.3.9";
compileOnly group: "com.github.Despical", name: "OITC", version: "2.4.0";
}
```
</details>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<outputDirectory>C:\Users\berke\OneDrive\Masaüstü\Server\plugins</outputDirectory>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/despical/oitc/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public void run() {
teleportToEndLocation(player);
doBarAction(0, player);

plugin.getRewardsFactory().performReward(plugin.getUserManager().getUser(player), Reward.RewardType.END_GAME);
plugin.getUserManager().getUser(player).performReward(Reward.RewardType.END_GAME);
}


Expand Down
6 changes: 2 additions & 4 deletions src/main/java/me/despical/oitc/arena/ArenaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,15 @@ public static void stopGame(boolean quickStop, Arena arena) {

if (topPlayerName.equals(player.getName())) {
user.addStat(StatsStorage.StatisticType.WINS, 1);
user.performReward(Reward.RewardType.WIN);

Titles.sendTitle(player, chatManager.message("in_game.messages.game_end_messages.titles.win"), chatManager.message("in_game.messages.game_end_messages.subtitles.win").replace("%winner%", topPlayerName));

plugin.getRewardsFactory().performReward(user, Reward.RewardType.WIN);
} else {
Titles.sendTitle(player, chatManager.message("in_game.messages.game_end_messages.titles.lose"), chatManager.message("in_game.messages.game_end_messages.subtitles.lose").replace("%winner%", topPlayerName));

if (!user.isSpectator()) {
user.addStat(StatsStorage.StatisticType.LOSES, 1);

plugin.getRewardsFactory().performReward(user, Reward.RewardType.LOSE);
user.performReward(Reward.RewardType.LOSE);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/me/despical/oitc/events/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ public void onDamageEntity(EntityDamageByEntityEvent e) {
if (ArenaRegistry.isInArena(player) && ArenaRegistry.isInArena(shooter)) {
if (!player.getUniqueId().equals(shooter.getUniqueId())) {
e.setDamage(100.0);

plugin.getRewardsFactory().performReward(plugin.getUserManager().getUser(player), Reward.RewardType.DEATH);
} else {
e.setCancelled(true);
}
Expand Down Expand Up @@ -329,11 +327,13 @@ public void onDeath(PlayerDeathEvent e) {
victimUser.setStat(StatsStorage.StatisticType.LOCAL_KILL_STREAK, 0);
victimUser.addStat(StatsStorage.StatisticType.LOCAL_DEATHS, 1);
victimUser.addStat(StatsStorage.StatisticType.DEATHS, 1);
victimUser.performReward(Reward.RewardType.DEATH);

User killerUser = userManager.getUser(victim.getKiller());
killerUser.addStat(StatsStorage.StatisticType.LOCAL_KILL_STREAK, 1);
killerUser.addStat(StatsStorage.StatisticType.LOCAL_KILLS, 1);
killerUser.addStat(StatsStorage.StatisticType.KILLS, 1);
killerUser.performReward(Reward.RewardType.KILL);

if (killerUser.getStat(StatsStorage.StatisticType.LOCAL_KILL_STREAK) == 1) {
arena.broadcastMessage(chatManager.prefixedFormattedMessage(arena, chatManager.message("in_game.messages.death").replace("%killer%", victim.getKiller().getName()), victim));
Expand All @@ -344,8 +344,6 @@ public void onDeath(PlayerDeathEvent e) {
ItemPosition.addItem(victim.getKiller(), ItemPosition.ARROW, ItemPosition.ARROW.getItem());
plugin.getServer().getScheduler().runTaskLater(plugin, () -> victim.spigot().respawn(), 5);

plugin.getRewardsFactory().performReward(victimUser, Reward.RewardType.KILL);

if (StatsStorage.getUserStats(victim.getKiller(), StatsStorage.StatisticType.LOCAL_KILLS) == plugin.getConfig().getInt("Winning-Score", 25)) {
ArenaManager.stopGame(false, arena);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/me/despical/oitc/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import me.despical.oitc.arena.Arena;
import me.despical.oitc.arena.ArenaRegistry;
import me.despical.oitc.handlers.items.GameItem;
import me.despical.oitc.handlers.rewards.Reward;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

Expand Down Expand Up @@ -130,4 +131,8 @@ public void resetStats() {
setStat(statistic, 0);
}
}

public void performReward(final Reward.RewardType rewardType) {
plugin.getRewardsFactory().performReward(this, rewardType);
}
}
5 changes: 1 addition & 4 deletions src/main/java/me/despical/oitc/util/ItemPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ public enum ItemPosition {

ItemPosition(int itemPosition, ItemBuilder itemBuilder) {
this.itemPosition = itemPosition;

if (ReflectionUtils.supportsPatch(9)) itemBuilder.unbreakable(true);

this.itemStack = itemBuilder.build();
this.itemStack = ReflectionUtils.supports(9) ? itemBuilder.unbreakable(true).build() : itemBuilder.build();
}

public static void addItem(Player player, ItemPosition itemPosition, ItemStack itemStack) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ Scoreboard:

# Has usage only when boss bar is enabled in config.yml
Boss-Bar:
Main-Title: "&a&lOne in the Chamber &f&l- &6&lDespical"
Main-Title: "&e&lPLAYING &f&lONE IN THE CHAMBER &e&lby &b&lDespical"
Starting-In: "&f&lStarting in: &e&l%time%"
Waiting-For-Players: "&4&lWaiting for more players..."
Waiting-For-Players: "&e&lPLAYING &f&lONE IN THE CHAMBER &e&lby &b&lDespical"
In-Game-Info: "&e&lPlaying &f&lONE IN THE CHAMBER &e&lby &b&lDESPICAL"
Game-Ended: "&c&lGame has ended! You were playing &b&lOITC"

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/rewards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Rewards-Enabled: true
rewards:
# Commands performed when game is finished
endgame:
- p:say %mapname% has ended!
- p:say %map_name% has ended!
- p:say Ooh and there were playing %players% players
# Commands executed when player kills someone
kill:
Expand Down

0 comments on commit 422d57a

Please sign in to comment.