Skip to content

Commit

Permalink
Merge pull request #104 from rogermiranda1000/feature/comment-config
Browse files Browse the repository at this point in the history
Feature/comment config
  • Loading branch information
miranda1000 authored Sep 24, 2023
2 parents e8d2a99 + 89c2720 commit c6dee27
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 166 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.rogermiranda1000</groupId>
<artifactId>PortalGun</artifactId>
<version>3.1</version>
<version>3.1.1</version>
<name>PortalGun</name>
<url>https://www.spigotmc.org/resources/portalgun-1-8-1-19.44746/</url>
<packaging>jar</packaging>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rogermiranda1000/portalgun/PortalGun.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void postOnEnable() {
ResetBlocks.getInstance().updateAllBlocks(); // @pre super.onEnable()

// Load portals
if (Config.PERSISTENT.getBoolean()) {
if (Config.getInstance().portals.save) {
getLogger().info("Loading portals...");
File file = new File(getDataFolder(), "portals.yml");
if(file.exists()) {
Expand Down Expand Up @@ -252,7 +252,7 @@ public void postOnDisable() {
ThermalBeams.getInstance().removeAllBlocksArtificially(); // as they may re-activate the block again, disable them first
ThermalReceivers.getInstance().unpowerAll();

if (Config.PERSISTENT.getBoolean()) {
if (Config.getInstance().portals.save) {
getLogger().info("Saving portals...");
File file = new File(getDataFolder(), "portals.yml");
BufferedWriter bw = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class onDead implements Listener {
@EventHandler
public void onDead(PlayerDeathEvent e) {
Player p = (Player)e.getEntity();
if(!Config.DELETE_ON_DEATH.getBoolean()) return;
if(!Config.getInstance().portals.removeOnDeath) return;

if(Portal.removePortal(p)) p.sendMessage(PortalGun.plugin.getErrorPrefix() + Language.USER_DEATH.getText());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class onLeave implements Listener {
@EventHandler
public void onLeave(PlayerQuitEvent event) {
onPortalgunEntity.removeEntity(event.getPlayer());
if (!Config.REMOVE_ON_LEAVE.getBoolean()) return;
if (!Config.getInstance().portals.removeOnLeave) return;

Portal.removePortal(event.getPlayer().getUniqueId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.rogermiranda1000.portalgun.files.Config;
import com.rogermiranda1000.portalgun.portals.Portal;
import com.rogermiranda1000.portalgun.portals.WallPortal;
import com.rogermiranda1000.versioncontroller.VersionController;

import com.rogermiranda1000.versioncontroller.entities.EntityWrapper;
import org.bukkit.Location;
Expand Down Expand Up @@ -41,7 +40,7 @@ public void onMoveMListener(PlayerMoveEvent e) {
Portal portal = Portal.getPortal(loc);
if (portal == null) return;

if (Config.ONLY_YOUR_PORTALS.getBoolean() && !player.equals(portal.getOwner())) return;
if (Config.getInstance().portals.useOnlyYours && !player.equals(portal.getOwner())) return;

Location destiny = portal.getDestiny(portal.getLocationIndex(loc));
// TODO: player velocity??
Expand All @@ -64,7 +63,7 @@ public void onMoveMListener(PlayerMoveEvent e) {
synchronized (PortalGun.teleportedEntities) {
PortalGun.teleportedEntities.put(player, destiny);
}
player.playSound(player.getLocation(), Config.TELEPORT_SOUND.getSound(), 3.0F, 0.5F);
player.playSound(player.getLocation(), Config.getInstance().portals.teleportSound, 3.0F, 0.5F);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import org.bukkit.event.player.PlayerJoinEvent;

public class onPlayerJoin implements Listener {
private static String PROVIDED = "PROVIDED";

/**
* Given a GET argument 'tool', 'damage'/'custom_model_data' and the pack_format 'format', it generates a resourcepack
*/
private static final String RESOURCEPACK_BASE_URL = "http://rogermiranda1000.com/portalgun-v2/index.php"; // TODO add endpoint to config file
public static String RESOURCEPACK_BASE_URL = "http://rogermiranda1000.com/portalgun-v2/index.php";

private static String getUrl() {
String identifierKey = null, identifierValue = "";
Expand Down Expand Up @@ -44,6 +46,7 @@ else if (VersionController.version.compareTo(Version.MC_1_9) >= 0) {
* 12 1.19.3
* 13 1.19.4
* 15 1.20-1.20.1
* 18 1.20.2
* @author <a href="https://minecraft.fandom.com/wiki/Pack_format">Minecraft pack_format</a>
* @return pack_format
*/
Expand All @@ -59,12 +62,14 @@ private static short getPackFormat() {
else if (VersionController.version.compareTo(Version.MC_1_19_3) < 0) return 9; // between 1.19 and 1.19.2
else if (VersionController.version.compareTo(Version.MC_1_19_4) < 0) return 12; // 1.19.3
else if (VersionController.version.compareTo(Version.MC_1_20) < 0) return 13; // 1.19.4
else return 15; // Version >= 1.20
else if (VersionController.version.compareTo(new Version(1,20,2)) < 0) return 15; // between 1.20 and 1.20.1
else return 18; // Version >= 1.20.2
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
if (!PortalGun.useResourcePack) return;
if (RESOURCEPACK_BASE_URL.toUpperCase().equals(PROVIDED)) return; // already managed by the server
Bukkit.getScheduler().runTaskLater(PortalGun.plugin, ()->e.getPlayer().setResourcePack(getUrl()), 20L);
}
}
Loading

0 comments on commit c6dee27

Please sign in to comment.