Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
Signed-off-by: Zoey <[email protected]>
  • Loading branch information
Zoey2936 committed Jan 20, 2024
1 parent 4c5fe4e commit 2dd9300
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
- name: Change config.yml if stable
if: github.ref_name == 'stable' && github.event_name != 'pull_request'
run: |
sed -i "s|updateChannel:.*|updateChannel: \"stable\"|g" src/main/resources/config.yml
sed -i "s|updateChannel:.*|updateChannel: stable|g" src/main/resources/config.yml
- name: Change config.yml if dev
if: github.ref_name == 'dev' && github.event_name != 'pull_request'
run: |
sed -i "s|updateChannel:.*|updateChannel: \"dev\"|g" src/main/resources/config.yml
sed -i "s|updateChannel:.*|updateChannel: dev|g" src/main/resources/config.yml
- name: Change config.yml if stable/dev
if: github.ref_name == 'stable' || github.ref_name == 'dev'
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(!player.isEmpty() && loadConfig.throwable()) {
event.setCancelled(true);
Player passenger = (Player) player.getPassengers().get(0);
main.getThrown().add(passenger);
player.eject();
passenger.setVelocity(player.getEyeLocation().getDirection().setY(1));
main.getVelocity().put(passenger, player.getEyeLocation().getDirection().setY(1));
}
}
}
12 changes: 10 additions & 2 deletions src/main/java/de/zoeyvid/stacker/Listener/PlayerMoveListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ public class PlayerMoveListener implements Listener {

@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(!loadConfig.throwfalldamage()) return;
Player player = event.getPlayer();
if(main.getVelocity().containsKey(player)) {
player.setVelocity(main.getVelocity().get(player).multiply(50));
player.sendMessage("Velocity set: " + main.getVelocity().get(player).getX() + " " + main.getVelocity().get(player).getY() + " " + main.getVelocity().get(player).getZ());
main.getThrown().add(player);
main.getVelocity().remove(player);
}
if(main.getVelocity().containsKey(player) && player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR && player.getFallDistance() == 0) {
main.getVelocity().remove(player);
}
if(main.getThrown().contains(player) && player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR && player.getFallDistance() == 0) {
main.getThrown().remove(player);
main.getThrown().remove(player);
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/de/zoeyvid/stacker/loadLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static String joinStackmodeSelf() {

public static String leaveImmuneOther() {
if (lang.isString("leaveImmuneOther")) {
return lang.getString("leaveImmmuneOther");
return lang.getString("leaveImmuneOther");
} else {
lang.set("leaveImmuneOther", "The Player %player% is not longer immune!");
saveLanguage();
Expand All @@ -189,7 +189,7 @@ public static String leaveImmuneOther() {

public static String joinImmuneOther() {
if (lang.isString("joinImmuneOther")) {
return lang.getString("joinImmmuneOther");
return lang.getString("joinImmuneOther");
} else {
lang.set("joinImmuneOther", "The Player %player% is now immune!");
saveLanguage();
Expand All @@ -199,7 +199,7 @@ public static String joinImmuneOther() {

public static String leaveImmuneSelf() {
if (lang.isString("leaveImmuneSelf")) {
return lang.getString("leaveImmmuneSelf");
return lang.getString("leaveImmuneSelf");
} else {
lang.set("leaveImmuneSelf", "You are not longer immune!");
saveLanguage();
Expand All @@ -209,7 +209,7 @@ public static String leaveImmuneSelf() {

public static String joinImmuneSelf() {
if (lang.isString("joinImmuneSelf")) {
return lang.getString("joinImmmuneSelf");
return lang.getString("joinImmuneSelf");
} else {
lang.set("joinImmuneSelf", "You are now immune!");
saveLanguage();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/de/zoeyvid/stacker/main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.util.Vector;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.ArrayList;

public final class main extends JavaPlugin {
Expand All @@ -19,6 +21,7 @@ public final class main extends JavaPlugin {
private static final ArrayList stackmode = new ArrayList<Player>();
private static final ArrayList disabled = new ArrayList<Player>();
private static final ArrayList thrown = new ArrayList<Player>();
private static final HashMap<Player, Vector> velocity = new HashMap<Player, Vector>();
private final int langVersion = 2;
private FileConfiguration cfg;
private FileConfiguration lang;
Expand All @@ -39,6 +42,10 @@ public static ArrayList getThrown() {
return thrown;
}

public static HashMap<Player, Vector> getVelocity() {
return velocity;
}

private void listenerRegistration() {
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new JoinListener(), this);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ throwable: true
# Should the thrown Player be protected from fall damage?
throwfalldamage: true
#
# Language (Available Languages: https://github.com/ZoeyVid/Stacker/tree/master/languages)
languageFile: "en"
# Language (Available Languages: https://github.com/ZoeyVid/Stacker/tree/stable/languages)
languageFile: en
#
# Should the plugin automatically update?
autoUpdate: false
#
# Update Channel (Available Channels: stable & dev) - Downloaded from our ci (https://ci.zvcdn.de)
updateChannel: "dev"
updateChannel: dev
#
# Should the plugin automatically update the Language File? (This will delete your custom changes)
autoUpdateLanguage: true

0 comments on commit 2dd9300

Please sign in to comment.