Cuberite Forum
Bananaprotect [Craftbukkit Plugin] - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Requests (https://forum.cuberite.org/forum-3.html)
+--- Thread: Bananaprotect [Craftbukkit Plugin] (/thread-1620.html)

Pages: 1 2


Bananaprotect [Craftbukkit Plugin] - ambushed01 - 10-12-2014

Dear MCServer developers, here is my question.

Befor the changes in the Minecraft API we used to have Bananaprotect. A plugin wich put a username to block positions and lock the blocks only to that username. When you removed a block the protection get removed.

Instead off having a plugin that makes a full "Area" Protection wich is annoying with only decent ammount off players wich are making towns together but i dont want them to destroy each other their homes.

Maybe anyone off you guys know this plugin and is able to remake this for MCServer?

Thanks in advance,
Ambushed01


RE: Bananaprotect [Craftbukkit Plugin] - NiLSPACE - 10-12-2014

You mean I place a block and nobody is able to destroy that block?


RE: Bananaprotect [Craftbukkit Plugin] - ambushed01 - 10-12-2014

Yes exept the people who are added to your personal friends list. and Operator / Admin ofcourse


RE: Bananaprotect [Craftbukkit Plugin] - NiLSPACE - 10-12-2014

It should be doable. The biggest problem would be the storage. Simply a table with all the data would use too much RAM eventualy. SQLite seems like the best option.


RE: Bananaprotect [Craftbukkit Plugin] - ambushed01 - 10-12-2014

Bananaprotect always used SQLite Smile


RE: Bananaprotect [Craftbukkit Plugin] - NiLSPACE - 10-12-2014

I'm not really familiar with SQLite. I used it once for a rewrite of my Login plugin but I dropped development.


RE: Bananaprotect [Craftbukkit Plugin] - ThuGie - 10-12-2014

well i would then just cover a house in dirt.. then they would no longer be able to access it..


RE: Bananaprotect [Craftbukkit Plugin] - xoft - 10-12-2014

This is a great plugin idea! Finally we have something for if a reasonably seasoned developer joins us and wants to do a plugin - if they know SQL, they can do this really easily.


RE: Bananaprotect [Craftbukkit Plugin] - xoft - 10-12-2014

Just the name is bad, it doesn't say much about what the plugin does.


RE: Bananaprotect [Craftbukkit Plugin] - ThuGie - 10-12-2014

I think i still have a lua plugin for this, for a minecraft classic :p.
Long long ago i made it cause i got tired of people.
Though make sure there is a way so they can always get back to the house..

Like i said you build a house, i cant destroy it, i put dirt around it. you cant access your house anymore.

Looked it up quickly and it seems it was python.
Code:
#Made by ThuGie
#This plugin has been made to provide a basic extra antiGrief system
#Make sure the zone plugin is enabled since it uses the zone plugin to punish griefers.
#If a griefer tries to destroy a zoned building he gets a point does he do it again another and again a ban.
#It starts with a 1 week ban after a week and the users tries it again it increases a week each time he tries it.
from core.pluginmanager import PluginBase, Hooks, PluginManager
from core.packet import PacketWriter
from core.constants import *
from core.console import *

class antiGriefingPlugin(PluginBase):
    griefDB = "GrieferDBPlugin"
    ZoneKey = "Zones"

    def OnLoad(self):
        self.PluginMgr.RegisterHook(self, self.OnAttemptPlaceBlock, Hooks.ON_ATTEMPT_PLACE_BLOCK)

    def OnAttemptPlaceBlock(self, pWorld, pPlayer, BlockValue, x, y, z):
            Zones = self.GetWorldZones(pWorld)

            if Zones is None:
                return True
            for pZone in Zones:
                if pZone.Check(pPlayer, x, y, z) == False:
                    grieferPoints = int(pPlayer.GetPermanentPluginData(antiGriefingPlugin.griefDB) or 0)
                    grieferPoints +=1
                    pPlayer.SetPermanentPluginData(antiGriefingPlugin.griefDB,grieferPoints)
                    if grieferPoints % 7:
                        pPlayer.SendMessage("&4[AntiGrief] &cThis is strike %d/7 watch out!" % (grieferPoints % 7))
                    else:
                        Console.Out("AntiGrief", "Marked \"%s\" as griefer" % (pPlayer.GetName()))
                        pPlayer.ServerControl.SetRank("AntiGrief", pPlayer.GetName(), "Griefer")
                        pPlayer.ServerControl.SendChatMessage("", "&4[AntiGrief] " + pPlayer.GetName() + " &chas been marked as a griefer!", NormalStart = False)
                return True

    def GetWorldZones(self, pWorld):
        return None if not pWorld.HasDataStoreEntry(antiGriefingPlugin.ZoneKey) else pWorld.GetDataStoreEntry(antiGriefingPlugin.ZoneKey)

Useless but oh well, back in the day it helped me a ton!

Edit:Err. sorry it seems to be the wrong plugin this is not the one i was talking about.

Edit2:
I think its this one
Code:
#Made by ThuGie
from core.pluginmanager import PluginBase, Hooks, PluginManager
from core.commandhandler import CommandObject
from core.world import MetaDataKey
from core.constants import *
from core.console import *

import sqlite3 as dbapi
import os.path
import shutil
import time
from datetime import timedelta

class blocklogPlugin(PluginBase):
    Instance = None
    def OnLoad(self):
        blocklogPlugin.Instance = self
        if os.path.exists("Worlds/BlockLog") == False:
            os.mkdir("Worlds/BlockLog")
        self.DBConnection = dbapi.connect("Worlds/BlockLog/beta.db", timeout = 0.1)
        self.DBConnection.text_factory = str
        self.DBCursor = self.DBConnection.cursor()
        try:
            Result = self.DBCursor.execute("SELECT * FROM sqlite_master where name='Blocklog' and type='table'")
        except dbapi.OperationalError:
            raise WorldLoadFailedException
        if Result.fetchone() is None:
            self.DBCursor.execute("CREATE TABLE Blocklog (Offset INTEGER NOT NULL,Username TEXT,Time INTEGER,OldValue INTEGER,World TEXT)")
            self.DBCursor.execute("CREATE INDEX Lookup ON Blocklog (Offset,OldValue,Time)")
            self.DBCursor.execute("CREATE INDEX Deletion ON Blocklog (Username,World)")
            self.DBConnection.commit()
        self.PluginMgr.RegisterHook(self, self.onPlace, Hooks.ON_ATTEMPT_PLACE_BLOCK)
        self.AddCommand("undogrief", undoCmd, 'admin', 'Undo griefing!', '', 1)

    def onPlace(self, pWorld, pPlayer, BlockValue, x, y, z):
        Offset = pWorld._CalculateOffset(x,y,z)
        BlockValue = ord(pWorld.Blocks[Offset])
        try:
            self.DBConnection.execute("INSERT INTO Blocklog (Offset,Username,Time,OldValue,World) VALUES (%d,'%s',%d,%d,'%s')" % (int(Offset), pPlayer.GetName(),int(time.time() * 1000),int(BlockValue),pWorld.Name))
        except dbapi.OperationalError:
            Console.Out("blocklog","failed at adding into blocklog!")
        except dbapi.Error as e:
            print("An error occurred:", e.args[0])

        self.DBConnection.commit()
        return True

class undoCmd(CommandObject):
    def Run(self, pPlayer, Args, Message):
        if pPlayer.GetWorld().LogBlocks == False:
            pPlayer.SendMessage("&RBlock logging is not enabled!")
            return

        ReversePlayer = Args[0]
        pPlayer.SendMessage("&S%s actions are being reversed. This may take a few moments" % ReversePlayer)
        DBCursor = blocklogPlugin.Instance.DBCursor
        DBConnection = blocklogPlugin.Instance.DBConnection
        try:
            SQLResult = DBCursor.execute("SELECT Offset,OldValue,Time from Blocklog where Username = ? and World = ? ORDER BY Time DESC", (ReversePlayer,pPlayer.GetWorld().Name))
        except dbapi.OperationalError:
            Console.Debug("blocklog", "Failed query 1")
            return
        NumChanged = 0
        while True:
            Rows = SQLResult.fetchmany(10000)
            if len(Rows) == 0:
                break
            for Row in Rows:
                if len(Row) == 3:
                    try:
                        SQLResultb = DBCursor.execute("SELECT OldValue,Username,Offset,Time FROM Blocklog where Offset = ? and Time > ? and World = ? and Username <> ?", [Row[0],Row[2],pPlayer.GetWorld().Name,ReversePlayer])
                    except dbapi.OperationalError:
                        Console.Debug("blocklog", "Failed query 2")
                        return
                    except dbapi.Error as e:
                        print("An error occurred:", e.args[0])
                        return
                    Rowsb = SQLResultb.fetchmany(1)
                    if len(Rowsb) == 0:
                        x, y, z = pPlayer.GetWorld()._CalculateCoords(Row[0])
                        pPlayer.GetWorld().SetBlock(pPlayer, x, y, z, Row[1], ResendToClient = True)
                        NumChanged += 1
                    else:
                        for RowB in Rowsb:
                            pPlayer.SendMessage("UPDATE Blocklog SET OldValue = %s WHERE Username = %s and Offset = %s and Time = %s" % (RowB[0],RowB[1],RowB[2],RowB[3]))
                            DBCursor.execute("UPDATE Blocklog SET OldValue = ? WHERE Username = ? and Offset = ? and Time = ?", [Row[1],RowB[1],RowB[2],RowB[3]])
                            DBConnection.commit()
        Console.Out("test","Changed %d" % NumChanged)
        try:
            SQLResult3 = DBCursor.execute("DELETE FROM Blocklog WHERE Username = ? and World = ?", [ReversePlayer,pPlayer.GetWorld().Name])
        except dbapi.OperationalError:
            Console.Debug("blocklog", "Failed query 3")
            return
        DBConnection.commit()

It uses sql, perhaps it can be a simple example.