Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: organization/PmChair
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: Nukkit-coders/PmChair
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 19 commits
  • 11 files changed
  • 3 contributors

Commits on Feb 7, 2017

  1. Delete PmChair.php

    solo5star authored Feb 7, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    Turbo87 Tobias Bieniek
    Copy the full SHA
    84b888b View commit details
  2. Delete messages.yml

    solo5star authored Feb 7, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    Turbo87 Tobias Bieniek
    Copy the full SHA
    d3de676 View commit details
  3. Add files via upload

    solo5star authored Feb 7, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    Turbo87 Tobias Bieniek
    Copy the full SHA
    25ef88b View commit details
  4. remove debug

    solo5star authored Feb 7, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    Turbo87 Tobias Bieniek
    Copy the full SHA
    469f507 View commit details
  5. Create README.md

    solo5star authored Feb 7, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    Turbo87 Tobias Bieniek
    Copy the full SHA
    03d9a7d View commit details

Commits on Mar 14, 2018

  1. Delete plugin.yml

    PetteriM1 authored Mar 14, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    Turbo87 Tobias Bieniek
    Copy the full SHA
    d369fd8 View commit details
  2. Delete .buildpath

    PetteriM1 authored Mar 14, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    Turbo87 Tobias Bieniek
    Copy the full SHA
    2a37dca View commit details
  3. Copy the full SHA
    a7450a0 View commit details
  4. Update PmChair.java

    PetteriM1 authored Mar 14, 2018
    Copy the full SHA
    87dfa4a View commit details
  5. Update messages.yml

    PetteriM1 authored Mar 14, 2018
    Copy the full SHA
    fa6b556 View commit details

Commits on Sep 5, 2018

  1. Fix this plugin

    PetteriM1 committed Sep 5, 2018
    Copy the full SHA
    ca1cf14 View commit details

Commits on Jan 9, 2019

  1. Multiversion support

    PetteriM1 committed Jan 9, 2019
    Copy the full SHA
    61f1cf2 View commit details

Commits on Apr 7, 2019

  1. Update

    PetteriM1 committed Apr 7, 2019
    Copy the full SHA
    8f40158 View commit details
  2. Oops

    PetteriM1 committed Apr 7, 2019
    Copy the full SHA
    8067104 View commit details

Commits on Oct 13, 2019

  1. Copy the full SHA
    4fb26a4 View commit details

Commits on Apr 11, 2020

  1. Remove useless loop

    PetteriM1 committed Apr 11, 2020
    Copy the full SHA
    bd0b456 View commit details

Commits on Aug 4, 2020

  1. Copy the full SHA
    78bba12 View commit details

Commits on Mar 7, 2022

  1. Update

    PetteriM1 committed Mar 7, 2022
    Copy the full SHA
    8435f66 View commit details

Commits on Nov 9, 2024

  1. Use real entity for chairs

    PetteriM1 committed Nov 9, 2024
    Copy the full SHA
    8945a5e View commit details
Showing with 251 additions and 163 deletions.
  1. +0 −6 .buildpath
  2. +7 −0 .gitignore
  3. +0 −2 .settings/org.eclipse.php.core.prefs
  4. +0 −8 plugin.yml
  5. +48 −0 pom.xml
  6. +0 −9 resources/messages.yml
  7. +57 −0 src/main/java/maru/ChairEntity.java
  8. +117 −0 src/main/java/maru/PmChair.java
  9. +6 −0 src/main/resources/messages.yml
  10. +16 −0 src/main/resources/plugin.yml
  11. +0 −138 src/maru/PmChair.php
6 changes: 0 additions & 6 deletions .buildpath

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.settings
.classpath
.project
target/
.idea
.DS_Store
*.iml
2 changes: 0 additions & 2 deletions .settings/org.eclipse.php.core.prefs

This file was deleted.

8 changes: 0 additions & 8 deletions plugin.yml

This file was deleted.

48 changes: 48 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>maru</groupId>
<artifactId>PmChair</artifactId>
<version>2.1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>nukkitx</id>
<url>https://repo.opencollab.dev/main/</url>
</repository>
</repositories>
<build>
<finalName>${project.name}_Nukkit_v${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>cn.nukkit</groupId>
<artifactId>nukkit</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
9 changes: 0 additions & 9 deletions resources/messages.yml

This file was deleted.

57 changes: 57 additions & 0 deletions src/main/java/maru/ChairEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package maru;

import cn.nukkit.entity.Entity;
import cn.nukkit.entity.EntityRideable;
import cn.nukkit.entity.item.EntityMinecartEmpty;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.math.Vector3f;
import cn.nukkit.nbt.tag.CompoundTag;

import java.util.ArrayList;

public class ChairEntity extends Entity implements EntityRideable {

public ChairEntity(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
this.setDataFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_INVISIBLE, true, false);
}

@Override
public int getNetworkId() {
return EntityMinecartEmpty.NETWORK_ID;
}

@Override
public boolean onUpdate(int tick) {
return false;
}

@Override
public boolean canSaveToStorage() {
return false;
}

@Override
public boolean dismountEntity(Entity entity, boolean sendLinks) {
if (super.dismountEntity(entity, sendLinks)) {
this.close();
return true;
}
return false;
}

@Override
public Vector3f getMountedOffset(Entity entity) {
return new Vector3f(0.0f, 1.5f, 0.0f);
}

@Override
public void close() {
super.close();
if (!this.passengers.isEmpty()) {
for (Entity passenger : new ArrayList<>(this.passengers)) {
this.dismountEntity(passenger);
}
}
}
}
117 changes: 117 additions & 0 deletions src/main/java/maru/PmChair.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package maru;

import cn.nukkit.Player;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockStairs;
import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;
import cn.nukkit.entity.Entity;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.player.PlayerInteractEvent;
import cn.nukkit.event.player.PlayerQuitEvent;
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.utils.Config;

import java.io.File;
import java.util.*;

public class PmChair extends PluginBase implements Listener {

private final Map<Long, Long> doubleTap = new HashMap<>();
private final Set<String> disabled = new HashSet<>();
private Map<String, Object> messages;

private static final int m_version = 2;

@Override
public void onEnable() {
loadMessage();
Entity.registerEntity("Chair", ChairEntity.class);
getServer().getPluginManager().registerEvents(this, this);
}

private void loadMessage() {
saveResource("messages.yml");
messages = new Config(new File(getDataFolder(), "messages.yml"), Config.YAML).getAll();
if ((int) messages.get("m_version") < m_version) {
saveResource("messages.yml", true);
messages = new Config(new File(getDataFolder(), "messages.yml"), Config.YAML).getAll();
}
}

private String getTranslation(String m) {
return (String) messages.get(m);
}

@EventHandler
public void onTouch(PlayerInteractEvent event) {
Player player = event.getPlayer();

if (player.riding != null ||
player.isSneaking() ||
event.getAction() != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK ||
disabled.contains(player.getName())) {
return;
}

Block block = event.getBlock();
if (block instanceof BlockStairs) {
if (block.y > player.y + 2 || block.y < player.y - 2) return;
if (block.distanceSquared(player) > 100) return;
if ((block.getDamage() & 4) != 0 || block.up().isSolid()) return;

long playerId = player.getId();
Long last = doubleTap.get(playerId);
if (last == null) {
doubleTap.put(playerId, System.currentTimeMillis());
player.sendPopup(getTranslation("touch-stairs-popup"));
return;
}

if (System.currentTimeMillis() - last < 500) {
Entity minecart = Entity.createEntity("Chair", block.add(0.5, 0, 0.5));
player.setPosition(minecart);
minecart.mountEntity(player);
minecart.spawnToAll();

doubleTap.remove(playerId);
} else {
doubleTap.put(playerId, System.currentTimeMillis());
player.sendPopup(getTranslation("touch-stairs-popup"));
}
}
}

@EventHandler
public void onQuit(PlayerQuitEvent event) {
doubleTap.remove(event.getPlayer().getId());
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equals("chair")) {
if (!(sender instanceof Player)) {
return true;
}

if (args.length == 0) {
return false;
}

if (args[0].equalsIgnoreCase("off")) {
disabled.add(sender.getName());
sender.sendMessage(getTranslation("command-disabled"));
} else if (args[0].equalsIgnoreCase("on")) {
disabled.remove(sender.getName());
sender.sendMessage(getTranslation("command-enabled"));
} else {
return false;
}

return true;
}

return false;
}
}
6 changes: 6 additions & 0 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
m_version: 2

touch-stairs-popup: Double tap to sit on the stairs

command-enabled: Double tap to sit on the stairs enabled
command-disabled: Double tap to sit on the stairs disabled
16 changes: 16 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: PmChair
main: maru.PmChair
author: maru, PetteriM1
version: "${pom.version}"
api: ["1.1.0"]

commands:
chair:
usage: "/chair <on|off>"
description: "Enable/disable chairs"
permission: "chair.toggle"

permissions:
chair.toggle:
default: true
description: "Enable/disable chairs"
Loading